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

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

Closed
shujaatak opened this issue Oct 18, 2021 · 6 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 18, 2021

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.

@DanTup
Copy link
Member

DanTup commented Oct 19, 2021

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?

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Oct 19, 2021
@shujaatak
Copy link
Author

shujaatak commented Oct 19, 2021

@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

@shujaatak
Copy link
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!

@DanTup
Copy link
Member

DanTup commented 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
Copy link
Member

DanTup commented 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:

"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.

@DanTup DanTup added this to the v3.28.0 milestone Oct 25, 2021
@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 and removed awaiting info Requires more information from the customer to progress labels Oct 25, 2021
@DanTup
Copy link
Member

DanTup commented 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).

@DanTup DanTup 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 Oct 25, 2021
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Oct 25, 2021
…notations

Fixes Dart-Code/Dart-Code#3621.

Change-Id: Idf0cfb7f8a0b2a8b4f1ed269f125f6743fa19471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
@DanTup DanTup closed this as completed Oct 26, 2021
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