Skip to content

Disregard semantic classification tokens from <template> portions of .gts files #873

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

Merged
merged 3 commits into from
Apr 1, 2025

Conversation

machty
Copy link
Contributor

@machty machty commented Apr 1, 2025

Closes #835

The solution here is to classify the spans/mappings for the generated TS representing code within <template> regions as shouldHightlight=false. This tells volar to NOT reverse-source-map the classification tokens generated by vanilla TS when parsing the generated TS representation of .gts files.

This has the desired effect of preserving the tokens for the outer TS regions of the .gts file while ignoring the tokens for the templates. It may be desirable at some point in the future to see see how the default classifications for the template portion can be "fixed", but I don't have a sense for how difficult this might be. I suspect the reason the default classifications looking "wrong" is due to some of the constructs used for getting the type-checking aspect of Glint working correctly, e.g. in some cases we might use something like __glintDSL.resolve('fooBar') to represent {{this.fooBar}} (this is not totally accurate, just an example); this might work really well for the purposes of generating useful diagnostics that can be source-mapped back to .gts, but when doing semantic classification, TS will classify this as a string argument to a function when really it's a simple property lookup on this.

@machty machty changed the title Tweak / fix semantic classifications used for semantic highlighting Disregard semantic classification tokens from <template> portions of .gts files Apr 1, 2025
@machty machty merged commit 502de14 into main Apr 1, 2025
2 checks passed
@machty machty deleted the disable-semantic branch April 1, 2025 18:09
@github-actions github-actions bot mentioned this pull request Apr 1, 2025
@NullVoxPopuli NullVoxPopuli added the enhancement New feature or request label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Glint v2] Syntax highlighting looks broken in gts file
2 participants