Skip to content

[LSP] Fix semantic tokens overlap bug#58620

Merged
allisonchou merged 3 commits intodotnet:release/dev17.1from
allisonchou:FixSemanticTokensOverlap
Jan 6, 2022
Merged

[LSP] Fix semantic tokens overlap bug#58620
allisonchou merged 3 commits intodotnet:release/dev17.1from
allisonchou:FixSemanticTokensOverlap

Conversation

@allisonchou
Copy link
Copy Markdown
Contributor

I inadvertently introduced a bug in #58238, in which we sometimes return both semantic and syntactic classifications for the same TextSpan. In reality, if there is a semantic classification, it should override the syntactic classification for any matching TextSpan unless the syntactic classification is a modifier (e.g. static).

This bug introduced was caught via an assert failure in Razor and is currently breaking semantic tokens on their end.

The existing LSP semantic tokens tests were previously partially incorrect. They have been updated this PR and now have the correct expected results, which should help catch this problem in the future.

@allisonchou allisonchou requested a review from a team as a code owner January 5, 2022 02:00
@ghost ghost added the Area-IDE label Jan 5, 2022
@allisonchou allisonchou changed the base branch from main to release/dev17.1 January 5, 2022 02:01
@allisonchou allisonchou requested review from a team as code owners January 5, 2022 02:01
@allisonchou allisonchou requested a review from a team January 5, 2022 02:01
@allisonchou allisonchou changed the base branch from release/dev17.1 to main January 5, 2022 02:02
@allisonchou
Copy link
Copy Markdown
Contributor Author

@jinujoseph for M2 approval

classifiedSpans.AddRange(spans);

// The spans returned to us may include some empty spans, which we don't care about.
var nonEmptySpans = spans.Where(s => !s.TextSpan.IsEmpty);
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.

What is the use case for empty spans that are classified?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't seem to reproduce it anymore, but there was a file where somehow an empty span was being produced as part of a classification. Razor breaks with empty spans (via a failed assert), so I thought it'd be good to just include this here as a precaution. Empty spans are also unnecessary to return in the LSP case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This actually seems to be a bug in AdjustSpans - for now I filed #58658 to track, but it shouldn't block this PR.

@allisonchou allisonchou merged commit 361f618 into dotnet:release/dev17.1 Jan 6, 2022
@allisonchou allisonchou deleted the FixSemanticTokensOverlap branch January 6, 2022 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants