Dart-code: Invalid syntax highlightning for methods named "get" or "set"

Created on 27 Aug 2020  ·  3Comments  ·  Source: Dart-Code/Dart-Code

The built-in identifiers get and set are blue when used in property declarations.

The problem is that they are blue also if they are used as normal method names, The expected behavior is that they have the same color as other normal methods.

This cosmetic issue is now more visible as the latest official Firestore plugin introduced renamed methods Query.get() and DocumentReference.set(). Also other popular plugin get_it uses a method named get.

in editor is bug

All 3 comments

This is a limitation of how we currently do syntax highlighting. The plan is to switch to proper semantic highlighting as part of the LSP migration. There's an issue open about this (which by coincidence I was just working on!) at https://github.com/Dart-Code/Dart-Code/issues/2202

It's not complete yet (the LSP spec has not been finalised), but I just tested with get and set and they are coloured the same as methods when they're methods, and keywords when they're keywords:

Screenshot 2020-08-27 at 15 34 30

I'll close this as a dupe, but you can subscribe to #2202 for updates on when it ships (though it will require both a Dart-Code and an SDK update since the LSP server lives in the SDK).

Thanks!

Fixed by https://github.com/dart-lang/sdk/commit/cb2ede57b7c91fb61c0cb05971cc1823faee2086.

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

semantic_tokens

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgb1380 picture rgb1380  ·  3Comments

FeimiSzy picture FeimiSzy  ·  4Comments

Matt-Gleich picture Matt-Gleich  ·  4Comments

mccadi picture mccadi  ·  3Comments

ifredom picture ifredom  ·  3Comments