-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Semantic tokens: add module name support and improve performance and accuracy by traversing the hieAst along with source code #3958
Conversation
This looks like it's still a work in progress? |
WIP, I decicded to do the module name split in here as well. |
Looks like we could also do |
The issue with parens is actually kind of tricky. Consider the following cases:
My feeling is that 1 should be highlighted with the whole thing as a function, since the parens are "part of" the syntax there (like the backticks in I think maybe we're already getting sort of the right thing? I was confused why we were getting the parens in the span for In this case I almost think that the cleanest thing to do would be to just add an (overlapping) token for the |
2, 4 won't happen, |
Okay, so the parentheses are only included in the span if it's an operator section. That seems fine. The question is whether we should highlight the parens when it's an operator section. |
Having overlapping is the ideal situation. But we need to consider the fall back situation with no overlapping now. Since most lsp client does not support it yet. |
Before we support overlapping tokens. The following might be a good idea: |
But if we drop the parens for operator sections around qualified names, we should do it for normal operator sections like |
yes this is what I have in mind too. |
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Internal.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Query.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/SemanticConfig.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Utils.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Utils.hs
Outdated
Show resolved
Hide resolved
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Utils.hs
Outdated
Show resolved
Hide resolved
@wz1000 Thank you for your detailed reviews. Many good advices, I have made some adjustments to the code. |
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Tokenize.hs
Outdated
Show resolved
Hide resolved
another thing, though this doesn't have to be addressed in this MR and could be a follow up - now that we are traversing the entire document in order, do we still need to accumulate results into a |
plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Tokenize.hs
Outdated
Show resolved
Hide resolved
Good point, I'll take a look some time later if there is optimization space we can do on this. |
One thing I am not sure about would be wether the mappings of range change would change the range ordering. |
you mean the |
Yes, thanx for clearing this out! |
A follow up of #3958 , we have added a tokenizor to walk the hieAst along with the file rope, it means we no longer need to do the detour of storing temperal result as Map Range (Set identifier), instead we can optimize by fusing most of the logic into tokenizer and return [(Range, HsSemanticTokenType)] directly.
fix #3957
Things have been done:
Name
toIdentifier
in the implementation and addModuleName
to theHsSemanticTokenType
` `
and()
, and split out qualified names. e.g.`Preclude.length`
toPreclude.
length