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

"Fix" LSP semantic token modifiers #68744

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

davidwengier
Copy link
Contributor

For purley selfish reasons, I'm trying to add support to VS for semantic token modifiers, and noticed that Roslyns legend was a bit wrong (you weren't returning the "Reassigned Variable" modifier in the legend, but are returning it in the semantic token range LSP request). Additionally, Razors legend is wrong too, so exposing the fixed one so we can reuse it fixes that too.

Sneak peak!
image

@davidwengier davidwengier requested a review from a team as a code owner June 23, 2023 06:58
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 23, 2023
@davidwengier davidwengier changed the title Add reassigned variable token modifier, and allow Razor to use same "Fix" LSP semantic token modifiers Jun 23, 2023
@davidwengier
Copy link
Contributor Author

davidwengier commented Jun 23, 2023

Also, noticed in the code that converts classifications to semantic tokens that Roslyn will only ever apply one token modifier to a span. Is that intentional? Or a side-effect of the fact that the current two are mutually exclusive?

@CyrusNajmabadi do you remember?

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

Also, noticed in the code that converts classifications to semantic tokens that Roslyn will only ever apply one token modifier to a span. Is that intentional? Or a side-effect of the fact that the current two are mutually exclusive?

I'm guessing we just never implemented it because we only returned one at the time (think this predates the existence of the reassigned variable modifier).

The spec supports multiple, we'd just have to do the work to do the proper encoding for it.

{
// This must be in the same order as SemanticTokens.TokenModifiers, but skip the "None" item
SemanticTokenModifiers.Static,
nameof(SemanticTokens.TokenModifiers.ReassignedVariable)
Copy link
Member

Choose a reason for hiding this comment

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

why nameof for reassignedvariable but not the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Static is coming from the LSP protocol DLL, as its part of the standard set. I could change it to nameof(SemanticTokens.TokenModifiers.Static) for consistency, but ReassignedVariable can't come from anywhere else, as its entirely a Roslyn construct. Between Roslyn, Razor and VS, I don't think anyone actually implements this part of the spec properly (or nobody knows how it should be implemented - myself included!)

@davidwengier davidwengier merged commit 575bc42 into dotnet:main Jun 28, 2023
@davidwengier davidwengier deleted the TokenModifiers branch June 28, 2023 02:27
@ghost ghost added this to the Next milestone Jun 28, 2023
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants