-
Notifications
You must be signed in to change notification settings - Fork 767
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
Add semantic token modifiers to callable variables. #5841
Comments
If my understanding is correct, today's semantic token provider generates tokens based on semantic categories only, not on type information. What you're proposing would require the token provider to perform full type analysis of every identifier at every point in the code flow since the type of an identifier can change based on narrowing, assignments, etc. It also means that the color of an identifier might now vary from one place in the code flow to the next. And it would require you to decide what to do with types that involve unions between, for example, a callable type and a non-callable type. |
how we will implement or how much perf cost it will have, we need to dig in but before that, we probably want to see how many people will upvote this. |
I briefly looked, and we get decls for all identifiers (basically names), but we only get the type of the decl, not at each specific position, which will cause us to do the narrowing and other things Eric mentioned above. So, if we do it based on the declared type, there won't be any extra cost. However, if we want it to be precise and correct at each position where identifiers are used, there will be extra performance cost. That said, since the semantic token provider and checker (the one that produces diagnostics) will share the same cache, and since the checker will call getType on every identifier anyway, in reality, the overall cost should be the same. It would be just a matter of who does it first and gets the blame. For the same variable/parameter being colored differently if we decide to do it per each position, since we just mark the token with extra data and people who want it need to opt in, it might be okay? But I am not here to draw conclusions but to provide more context so people can discuss with more information in hand. |
This is related to #5612 |
This issue has been fixed in prerelease version 2025.1.100, which we've just released. You can find the changelog here: CHANGELOG.md |
@oskarkk, thanks for catching this. #5111 is unrelated to this issue. I'll reopen it. |
this is related to #5785
basically, user could have something like this
func: Callable[...] = ...
it is a variable, but it can be used like
function
also, user could have something like this
here
func
is a variable again but it can be used likefunction
we could add
semantic token modifier
to these variables so users who want to distinguish them can useeditor.semanticTokenColorCustomizations
to do so.The text was updated successfully, but these errors were encountered: