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

improvement: Make fallback semantic tokens readonly #5067

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

jkciesluk
Copy link
Member

When we can't match any node with scalameta ident token, we make it either class or variable, if it starts with upper or lower case. Now this variable will have readonly modifier, since it's rarely mutable (e.g. self types, wildcard imports).

Solves #5052

@jkciesluk
Copy link
Member Author

I've changed SemanticHighlightLspSuite and SemanticHighlightBench to SemanticTokensLspSuite and SemanticTokensBench, because other files about semantic tokens are named like that.

@jkciesluk jkciesluk force-pushed the sem-def-ro branch 3 times, most recently from 8875d8d to b9ecd94 Compare March 21, 2023 09:24
@jkciesluk jkciesluk requested a review from tgodzik March 29, 2023 09:50
val tokenModifier: Int =
tokenType match {
case _ if tokenType == getTypeId(SemanticTokenTypes.Variable) =>
1 << getModifierId(SemanticTokenModifiers.Readonly)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add readonly only in the fallback?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for cases when token isn't an ident, but it becomes variable. For now, the only case for that is underscore, which is almost always readonly.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM! Though you need to rebase first.

@jkciesluk jkciesluk force-pushed the sem-def-ro branch 2 times, most recently from c9dac0b to 1c7aea8 Compare April 3, 2023 10:17
When we can't match any node with scalameta ident token, we make it either `class` or `variable`, if it starts with upper or lower case.
Now this `variable` will have `readonly` modifier, since it's rarely mutable (e.g. self types, wildcard imports).
@jkciesluk jkciesluk merged commit 9b120ac into scalameta:main Apr 4, 2023
@jkciesluk jkciesluk deleted the sem-def-ro branch April 4, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants