-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring: Define Blocktypes solely in Code #445
Conversation
libs/language-server/src/stdlib/builtin-blocktypes/TextRangeSelector.jv
Outdated
Show resolved
Hide resolved
ea637aa
to
a1f5ffe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started this PR today and ran into some dead ends. Especially expressing the validation logic in Jayvee itself is not there yet.. Any ideas how to approach it @rhazn ?
You can find the specific code snippets when looking at the jv
blocktype definitions where I left a TODO, I marked two exemplary ones as conversation.
libs/language-server/src/stdlib/builtin-blocktypes/TableTransformer.jv
Outdated
Show resolved
Hide resolved
libs/language-server/src/stdlib/builtin-blocktypes/RowDeleter.jv
Outdated
Show resolved
Hide resolved
); | ||
it('should provide matching block executors for builtin block types', async () => { | ||
useStdExtension(); | ||
(await getAllBuiltinBlocktypes()).forEach( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I wasn't able to pull that out so that each blocktype has its own test case. Issue is the asynchronous nature of loading the builtin blocktypes. Requires some further digging I guess.
The function getAllBuildinBlocktypes
might be a good candidate to pull out and add as util functionality to the interpreter-lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled out function to model-util
.
libs/interpreter-lib/src/validation-checks/runtime-parameter-literal.ts
Outdated
Show resolved
Hide resolved
const outputPort = blocktypeDefinition.outputs[0]; | ||
assert(outputPort !== undefined); | ||
this.outputType = getIOType(outputPort); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design decision: I did not extract docs here since that would require the JayveeServices
to be injected. However, we don't have it available at all places where we construct this class. Would be too big of a refactoring, so I chose to leave that out and extract the docs from comments in the docs generator instead. Might influence the hovering support of Jayvee.
@@ -15,21 +24,90 @@ interface BlockDocs { | |||
examples?: ExampleDoc[]; | |||
} | |||
|
|||
export abstract class BlockMetaInformation extends MetaInformation { | |||
export class BlockMetaInformation extends MetaInformation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class basically became an AST wrapper (like Valuetype and others). I did not move it yet as I'd like to have the MetaInformation
stuff cohesively in one place. Would move them as soon as we did the same for Constraints
.
libs/language-server/src/lib/services/jayvee-documentation-provider.ts
Outdated
Show resolved
Hide resolved
:::info | ||
This mechanism is currently under construction! We are moving from a code-first approach (using typescript classes to generate the Jayvee model of the blocktype) to a model-first approach (parsing the Jayvee model of the blocktype and creating ast wrappers). | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use these info boxes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 48b883c
return; | ||
} | ||
if (BlockMetaInformation.canBeWrapped(blocktypeDefinition)) { | ||
allBuiltinBlocktypes.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: duplicate blocktype definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 7d98ae4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pair reviewed in meeting.
25a5cca
to
57ee14d
Compare
This PR removes the need for
language extensions
- the execution extensions are not touched. Therfore, theBlockMetaInformation
becomes more of a wrapper class for the AST elements.This will also resolve #435 as soon as we do the same for constraints.
Next steps
Constraints
.execution
to thelanguage-server
to allow their usage for blocktype properties.