You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support coloring the identifier part of an annotation the same as the annotation @ marker #3621
I'm always frustrated to see that while the semantic token type for annotations should be annotation but :
The semantic token type for annotations override and required is currently set as property.
The semantic token type for annotation Deprecated is currently set as class.
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.
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 annotationmodifier to the rest of the expression so its colour can be overridden separately?
@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.
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!
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.
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:
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).
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
Activity
DanTup commentedon Oct 19, 2021
Currently annotations are coloured according to the type of annotation. Eg. if you call a constructor, it will colour as such:
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
annotationmodifier to the rest of the expression so its colour can be overridden separately?shujaatak commentedon Oct 19, 2021
@DanTup Basically I think the annotation identifiers like override, Deprecated etc. should be assigned a
semantic token typeasannotationand the thetypeof the annotation should be assigned asmodifier, 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.shujaatak commentedon Oct 19, 2021
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 typeforoverrideis set aspropertywhile that forDeprecatedis set asclass!DanTup commentedon Oct 25, 2021
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.
DanTup commentedon Oct 25, 2021
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:
Which looks like the following:
Note: Only the identifier part is covered, so nested expressions/identifiers will be colour normally.
DanTup commentedon Oct 25, 2021
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).
[-]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[/+][analysis_server] Add "annotation" modifier to identifiers used as an…