Skip to content

Feature Request: Turn Of Code Highlights for Classes unkown to Dart. #2241

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

Closed
digitalwert-developer opened this issue Jan 30, 2020 · 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

@digitalwert-developer
Copy link

digitalwert-developer commented Jan 30, 2020

Since some Flutter and Dart Classnames can become quite Long I would like to request, that Classes which are not implemented won't be highlighted as Classes any longer.
This would make it easier to spot typos ( I type mostly faster than autocomplete reacts)
and to avoid wrong conclusions like following example:

class Baa{
};
class Foo<T  extends Baa> {
}
...
 var  myfoo = new Foo<Baar>() 

Why does Foo<T> doesnt accept my Baa class as a Type did i do something wrong in the template?
While the while problem lies in me writing Baar instead ..

So it would be nice to only highlight Words starting with a Capital Letter as Classes if they can be identified. Would that be possible? :)

@DanTup
Copy link
Member

DanTup commented Jan 30, 2020

This isn't currently possible, as the highlighting is done with TextMate grammars and has no access to type info. There's an open PR to move to server-based highlighting when VS Code finalises the API, however I'm not sure if the server highlights differentiate between resolved/unresolved classes either. If not, maybe using the new API we could use the diagnostics (errors) to apply additional colouring rules? I'll have to do some testing.

@DanTup DanTup added this to the v3.9.0 milestone Jan 30, 2020
@DanTup DanTup added in editor Relates to code editing or language features is enhancement labels Jan 30, 2020
@DanTup DanTup modified the milestones: v3.9.0, On Deck Mar 11, 2020
@DanTup DanTup modified the milestones: On Deck, Backlog Jul 2, 2020
@DanTup DanTup added the in lsp/analysis server Something to be fixed in the Dart analysis server label Aug 25, 2020
@DanTup DanTup modified the milestones: On Deck, v3.18.0 Dec 10, 2020
@DanTup
Copy link
Member

DanTup commented Dec 15, 2020

This will be achievable with the semantic token work in dart-lang/sdk@cb2ede5.

In order to get the fix you'll need Dart-Code v3.18.0 (a preview release should be available later today/tomorrow), be using LSP Preview, and have a Dart SDK from after yesterday (the most recent nightly works, and of course the next releases of Dart/Flutter SDKs will include this).

With all this active, you'll be able to override the colours supplied by the textMate grammar (for example here I've set classes that come from the grammar as red), and the Semantic Tokens will then be layered over the top (and re-color known classes as classes):

Screenshot 2020-12-15 at 12 22 31

(probably you'd just want a slightly faded colour or something though, rather than red).

Note: The overridden colour will be used for all types until semantic tokens are available, so when you first open a file you'd see them all like that, and then they'd be updated once the token data arrived.

@DanTup DanTup closed this as completed Dec 15, 2020
@DanTup
Copy link
Member

DanTup commented Dec 22, 2020

Due to some last minute issues, support for LSP 3.16 (which supports semantic tokens) won't be included in v3.18, but hopefully the next release after that.

@DanTup DanTup modified the milestones: v3.18.0, v3.19.0 Dec 22, 2020
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