Skip to content

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

Closed

Description

@shujaatak

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

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 17, 2021
  2. DanTup commented on Oct 18, 2021

    @DanTup
    Member

    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.

  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Oct 18, 2021
  4. added this to the v3.28.0 milestone on Oct 18, 2021
  5. shujaatak commented on Oct 18, 2021

    @shujaatak
    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.

  6. DanTup commented on Oct 26, 2021

    @DanTup
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions