Skip to content

feat(language-service): add semantic tokens for templates - #60260

Closed
JannikLassahn wants to merge 1 commit into
angular:mainfrom
JannikLassahn:feature/semantic-tokens
Closed

JannikLassahn wants to merge 1 commit into
angular:mainfrom
JannikLassahn:feature/semantic-tokens

Conversation

@JannikLassahn

@JannikLassahn JannikLassahn commented Mar 7, 2025 •

Copy link
Copy Markdown
Contributor

Adds support for getEncodedSemanticClassifications to the language service. The service now classifies components in a template as the class type.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

The language service does not provide semantic tokens.

Issue Number: #60262

What is the new behavior?

The Angular language service now implements the getEncodedSemanticClassifications call, which in turn is needed on the language server/client side to provide the desired contextual syntax highlighting in the editor.

For now, the service only tries to highlight component tags by classifying them as classes (similiar to TSX highlighting done by TypeScript). To this extent the token types are the same as in the TypeScript language service to ensure this service keeps working as a strict superset.

For details about semantic tokens see the LSP protocol.

Does this PR introduce a breaking change?

  • Yes
  • No

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: language-service Issues related to Angular's VS Code language service labels Mar 7, 2025
@ngbot ngbot Bot added this to the Backlog milestone Mar 7, 2025
@JannikLassahn

Copy link
Copy Markdown
Contributor Author

Since this feature requires changes in vscode-ng-language-service, I prepared a fork feature/semantic-tokens to test this PR in an actual editor.

This is a screenshot from VSCode with semantic tokens enabled:
screenshot

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I was waiting for this to move from draft to ready for review but maybe the fact that it was created in draft mode wasn't noticed.

@JannikLassahn
JannikLassahn force-pushed the feature/semantic-tokens branch from 5d1775c to 74904fa Compare June 11, 2025 19:19
@angular-robot
angular-robot Bot requested a review from atscott June 11, 2025 19:19
@JannikLassahn
JannikLassahn marked this pull request as ready for review June 11, 2025 19:20
@JannikLassahn

Copy link
Copy Markdown
Contributor Author

Thanks for your review and kind words!
(I kept the draft because I wasn't quite sure myself whether functionality/code were sufficient)

@JannikLassahn
JannikLassahn force-pushed the feature/semantic-tokens branch from 74904fa to 564c1b5 Compare June 12, 2025 17:31
@thePunderWoman thePunderWoman added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Jun 24, 2025
Adds support for `getEncodedSemanticClassifications` to the language service.
The service now classifies components in a template as the `class` type.
@thePunderWoman

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit 20c1f99.

The changes were merged into the following branches: main

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants