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

SemanticTokensModifier: Add unused token modifier #604

Open
kjeremy opened this issue Apr 1, 2020 · 9 comments
Open

SemanticTokensModifier: Add unused token modifier #604

kjeremy opened this issue Apr 1, 2020 · 9 comments
Labels
depends on VS Code feature-request Request for new features or functionality
Milestone

Comments

@kjeremy
Copy link
Contributor

kjeremy commented Apr 1, 2020

I was thinking today how one might implement "grey out unreachable code" and I think we could do it with semantic tokens. Furthermore it's a pretty common operation spanning many languages. As such I think a modifier for "unused" or "unreachable" should be added to the protocol for consistency across languages.

@Gama11
Copy link
Contributor

Gama11 commented Apr 1, 2020

The LSP already supports this via DiagnosticTag.Unnecessary. See also microsoft/vscode#92157.

@dbaeumer
Copy link
Member

dbaeumer commented Apr 1, 2020

@aeschli what it your take on this. I actually do think we should support unused / unreachable code in semantics as well.

@dbaeumer dbaeumer added this to the 3.16 milestone Apr 1, 2020
@aeschli
Copy link
Contributor

aeschli commented Apr 1, 2020

If you want to just mark a single token e.g identifier of a variable or parameter declaration as unused, yes, having a unused modifier is feasible.
If you want to mark a whole range as unreachable, then semantic tokens are not the right thing to use. We don't allow overlapping ranges.
From your description it sounds that it's range of unused code...

@kjeremy
Copy link
Contributor Author

kjeremy commented Apr 1, 2020

Yes I was originally thinking a whole range which is why I proposed "unreachable" but agree that if we are to mark single tokens (and I think that's entirely reasonable and desired) as unused then there should be an "unused" modifier.

@dbaeumer
Copy link
Member

dbaeumer commented May 6, 2020

@aeschli any take of adding the modifier?

@aeschli
Copy link
Contributor

aeschli commented May 7, 2020

I created microsoft/vscode#97063 to collect proposals for new standard token types/modifiers.

@aeschli aeschli changed the title SemanticTokensModifier: Add unused/unreachable SemanticTokensModifier: Add unused token modifier May 7, 2020
@dbaeumer
Copy link
Member

dbaeumer commented May 7, 2020

Thanks @aeschli

@dbaeumer
Copy link
Member

Lets wait for the outcome in VS Code.

@dbaeumer dbaeumer modified the milestones: 3.16, On Deck Jun 23, 2020
@starball5
Copy link

Related on Stack Overflow: How can I disable problem underlines for unused code with the Rust Analyzer VS Code extension and instead highlight it gray?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
depends on VS Code feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants