-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[wildcards] Semantic Highlighting - consider styling wildcards #56567
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
Comments
Thanks Konstantin! |
For LSP, we can add a 'modifier' to a highlight range and users can choose whether or not to color the range differently based on the modifiers. IntelliJ is a little harder because we'd have to add a new value to the protocol in order to pass the information across. I can remember what happens if the user hasn't set a highlight for one of the provided values, so we might want to investigate that. |
Starting w/ VS Code sounds like a great idea. I'll look into it. Thanks, Brian. |
/fyi @DanTup for thoughts. |
See: #56567 Change-Id: I0abf861903e440f3bc6162e671c71d134786e8d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382280 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
For VS Code/LSP I think it would be good to have semantic token modifiers on them for users to style them. I'm not yet sure if I'd prefer them greyed or not, but if we apply a modifier it'd be easy to try both out for a while and if we decide in future we want some default styling, we can add that in Dart-Code (by applying a style for the modifier). There are two ways we usually apply custom modifiers/types for highlighting - one is if there is an existing specific sdk/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart Lines 27 to 30 in 56230ca
Otherwise, if the token type is the same as for other things and the custom modifier should be applied to only a subset, we can include it in the highlight computer: sdk/pkg/analysis_server/lib/src/computer/computer_highlights.dart Lines 226 to 233 in 56230ca
I don't know which of these is best - it may depend on how IntelliJ will be handled. If for now we want to leave IntelliJ as-is, the second option probably makes sense (and we can always simplify it if we switch to a different |
I don't see any @jwren For thoughts about IntelliJ. |
Yep, that's what I had in mind too. The two options above are both still valid - if we had |
@pq is this something you're looking at? If not, I'm happy to add it. |
Thanks for the nudge! I'm not actively looking at it and wouldn't have real time to throw at it until after the summit so it's up for grabs. |
I started looking at this and have a new custom modifier "wildcard" applied to variable declarations that are wildcards. However while writing tests I found that existing wildcard assignments like: f() {
int a;
(_, a) = (1, 2);
} Do not actually produce any highlights/semantic tokens for the Any opinions? |
Hmmmm, in principle I guess I would like consistent highlighting here but I'm not sure how involved fixing that would be (and if assigning a token is a desirable approach). |
Yeah, this one is interesting. The The inconsistency of not highlighting it bothers me, but I can't think of a good alternative at the moment. |
The |
The current options I can come up with are:
I feel like the top two options are probably the better ones but I'm interested in others opinions (or other suggestions!). |
I don't think treating a |
I believe that's option 2. That would be the least invasive change, and I'd be fine with it. I'd also be fine with option 1, but it requires more work from users that like the current behavior. |
Ok, I'll go with 2. It at gets things consistent and we can always change in future if we have better ideas. Thanks! |
Consider highlighting wildcards specially (see discussion).
@scheglov: as someone who enjoys semantic highlighting, I'd be especially curious to get your perspective. Would this be valuable? Too much noise? Too difficult to discern?
The text was updated successfully, but these errors were encountered: