Skip to content

Support coloring the identifier part of an annotation the same as the annotation @ marker #3621

Closed

Description

@shujaatak

Problem

I'm always frustrated to see that while the semantic token type for annotations should be annotation but :

  1. The semantic token type for annotations override and required is currently set as property.
  2. The semantic token type for annotation Deprecated is currently set as class.

image
image

Due to the above problem one can't assign distinct colors to properties and annotations.

Solution I'd like

Please set the semantic token type as annotation for all annotations including but not limited to Deprecated, override and required .

According to official docs , any class can be transformed into an annotation, as long as they provide a const constructor and since annotations are prefixed by @ so they are easy to be recognized and assigned the semantic token type as annotation.

Activity

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

    @DanTup
    Member

    Currently annotations are coloured according to the type of annotation. Eg. if you call a constructor, it will colour as such:

    @FooClass(a,b,c)
    

    Semantic Tokens does not allow overlapping tokens, so we can't have annotation span the whole string without losing the ability to highlight the rest of the annotation according to its type.

    Perhaps a reasonable fix would be to add an annotation modifier to the rest of the expression so its colour can be overridden separately?

  3. added
    awaiting infoRequires more information from the customer to progress
    on Oct 19, 2021
  4. shujaatak commented on Oct 19, 2021

    @shujaatak
    Author

    @DanTup Basically I think the annotation identifiers like override, Deprecated etc. should be assigned a semantic token type as annotation and the the type of the annotation should be assigned as modifier, for example, class etc. In my opinion, the rest of the expression is not that much important to color code as annotation or something so it can be kept as it as.

    image

  5. shujaatak commented on Oct 19, 2021

    @shujaatak
    Author

    Basically I like to differentiate Annotations from Classes, Properties, etc. using color codes but currently there is no way to differentiate because currently the semantic token type for override is set as property while that for Deprecated is set as class!

  6. DanTup commented on Oct 25, 2021

    @DanTup
    Member

    I understand your preference and it was actually also my preference initially, however after some discussion I came around to this being most consistent with the goal of semantic tokens and how we've handled some of the other tokens.

    Adding a modifier will still allow you to colour them the same if you wish, but they'll be different by default.

  7. DanTup commented on Oct 25, 2021

    @DanTup
    Member

    I've a change open to add a modifier here:

    https://dart-review.googlesource.com/c/sdk/+/217940/

    This allows you to customise how the identifier part of the annotation looks (either to be the same as the annotation marker/parens or separately) like this:

    "editor.semanticTokenColorCustomizations": {
    	"rules": {
    		"annotation": "#00ff00",
    		"*.annotation": "#00ff00",
    	},
    },
    

    Which looks like the following:

    Screenshot 2021-10-25 at 15 42 31

    Note: Only the identifier part is covered, so nested expressions/identifiers will be colour normally.

  8. added this to the v3.28.0 milestone on Oct 25, 2021
  9. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    and removed
    awaiting infoRequires more information from the customer to progress
    on Oct 25, 2021
  10. DanTup commented on Oct 25, 2021

    @DanTup
    Member

    Note: Since the tokens come from the language server, if/when merged, it will require an SDK update before it shows up in VS Code (not a VS Code extension update).

  11. changed the title [-]Set the `semantic token type` for `override` as `annotation` instead of `property`[/-] [+]Support coloring the identifier part of an annotation the same as the annotation @ marker[/+] on Oct 25, 2021
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