Skip to content
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

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

sailingKieler
Copy link
Contributor

@sailingKieler sailingKieler commented Feb 19, 2025

  • 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'

The actual bug fix is this the addition of the following line, everything else is just polishing:

this.recentNonImmediateIndents.length = 0;

@sailingKieler sailingKieler added the bug Something isn't working label Feb 19, 2025
@sailingKieler sailingKieler added this to the v3.4.0 milestone Feb 19, 2025
@@ -171,6 +171,11 @@
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/packages/vscode-uri/lib/**/*.js",
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 😐

Copy link
Contributor

@JohannesMeierSE JohannesMeierSE left a 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', () => {
Copy link
Contributor

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', () => {
Copy link
Contributor

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

Copy link
Contributor Author

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\'', () => {
Copy link
Contributor

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!

…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'
@sailingKieler sailingKieler merged commit fa8371b into main Feb 20, 2025
5 checks passed
@sailingKieler sailingKieler deleted the cs/expandToNode-bug branch February 20, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants