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

Add different semantic token type for class' properties and method's or normal variables #3618

Closed
shujaatak opened this issue Oct 17, 2021 · 3 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Milestone

Comments

@shujaatak
Copy link

shujaatak commented Oct 17, 2021

Problem
I'm always frustrated to see that the semantic token type for both class properties and local variables in class methods are set as variable and hence highlighted with the same color! (I have modified the color, see the below details section)

image

In VS Code, I enabled Developer: Inspect Editors Tokens and Scopes to compare the semantic token type and modifiers for both class properties and variables but unfortunately they are same so one can't set distinct colors for them to easily differentiate them.

Because of the same semantic token type as variable, one can't customize a class property's declaration color using the following:

"property.declaration:dart":{ // bug or missing feature: doesn't work!
    "bold": true,
    "foreground": "#ff0000",  // For property declaration
},  

Solution I'd like
Please set the semantic token type for class properties as property
and set the semantic token type for normal variables as variable.

More details
I added the following to settings.json to highlight variables with this #bc5fd3 color:

"variable.declaration:dart":{
    "bold": true,
    "foreground": "#bc5fd3",  // For variable declaration
}, 

But it highlights the properties of the classes with the same color too!

image

@DanTup
Copy link
Member

DanTup commented Oct 18, 2021

This was done deliberately, though I now think it was incorrect.

Getters and setters are currently categories as property, with fields (as in your example) categorised as variable. This seemed to make sense, however looking at the VS Code docs it says property should also be used for fields/member variables:

property - For identifiers that declare or reference a member property, member field, or member variable.

@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Oct 18, 2021
@DanTup DanTup added this to the v3.28.0 milestone Oct 18, 2021
@shujaatak
Copy link
Author

@DanTup Can you please have a look at this #3621 and it would be so kind of you if you please add it to the v3.28.0 milestone.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Oct 25, 2021
…s fields

Fixes Dart-Code/Dart-Code#3618.

Change-Id: I53b219dde6aeaaf64ac1b1a702b41c838c2b7819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Oct 26, 2021

This is fixed in dart-lang/sdk@fa5f6fc. Since it's in the language server, it'll require a future SDK release not a VS Code extension release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Projects
None yet
Development

No branches or pull requests

2 participants