-
Notifications
You must be signed in to change notification settings - Fork 75
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
langium generate: fixed a hidden bug in 'node-processor.ts' of Langium's 'generate' facility #1814
Conversation
.vscode/launch.json
Outdated
@@ -171,6 +171,11 @@ | |||
"args": ["run", "${relativeFile}"], | |||
"smartStep": true, | |||
"console": "integratedTerminal", | |||
"sourceMaps": true, | |||
"outFiles": [ | |||
"${workspaceFolder}/packages/vscode-uri/lib/**/*.js", |
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 don't have a package called packages/vscode-uri
in our repo.
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.
Damn, True. It's supposed to be node_modules
🙈, but I think I'll just drop that line.
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 kept the line, and made it work.
I however dropped the line mentioning langium
, as it doesn't bring any benefit.
That's most likely due to Vitest/Vite (executed via launch config) that one the fly translates the executed test module implemented in TS and all transitively referenced ones. However, it messes up the sourcemaps, or I wasn't able to configure it correctly.
Running the test via the Vitest VSCode extension works nicely in this regard 😐
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 reviewed the changes in the generator: Thanks @sailingKieler for fixing this bug!
@@ -832,9 +832,47 @@ describe('Multiple nested substitution templates', () => { | |||
generated text! | |||
`); | |||
}); | |||
|
|||
test('Nested substitution of with indented nested template starting with an _undefined_ line', () => { |
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 test case reflects the critical case, nice!
); | ||
}); | ||
|
||
test('Nested substitution of with indented nested template starting with an _empty string_ line', () => { |
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 case already worked before
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.
True. It's good to have it still, especially in contrast to the above one.
@@ -172,6 +172,22 @@ describe('indentation', () => { | |||
expect(process(comp, '\t')).toBe(`No indent${EOL}\tIndent {${EOL}\t}${EOL}`); | |||
}); | |||
|
|||
test('should indent nested template starting with a new line with \'ifNotEmpty\', with \'indentImmediately: false\'', () => { |
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 test case targets the critical bug, thanks!
1df3bcf
to
29c57ff
Compare
…m's 'generate' facility * added some test cases * extended 'Vitest: Run Selected File' launch config * brought config of the Vitest VSCode extension closer to the Vitest setup in 'vite.config.mts'
29c57ff
to
4ca343f
Compare
The actual bug fix is this the addition of the following line, everything else is just polishing:
langium/packages/langium/src/generate/node-processor.ts
Line 97 in 1df3bcf