dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

Missing keywords in code completion suggestions #57032

Closed bwilkerson closed 2 weeks ago

bwilkerson commented 2 weeks ago

Create a file containing the following (with the caret removed):

void f() => <String, int>{"": ^};

Place the cursor in the location of the caret and request completions. Lots of identifiers will be suggested, but none of the keywords that are valid at that location are suggested.

If you type part of a keyword and request completions at the end of the identifier

void f() => <String, int>{"": co^};

The same behavior occurs, which suggests that this isn't just a problem with recovery.

However, if you type the whole keyword

void f() => <String, int>{"": const^};

and request completions, then the keyword will be suggested.

FMorschel commented 2 weeks ago

Working on https://github.com/dart-lang/sdk/issues/56936 I noticed the keywords were showing up, there may be something else here (take a look at ~15s for const):

https://github.com/user-attachments/assets/a1b706e5-799d-4f61-9eb3-fe82012454ee

I can see if I find something later.

FMorschel commented 2 weeks ago

Here is my CL https://dart-review.googlesource.com/c/sdk/+/393940. I'm not 100% sure the implementation is what we'd expect but we can discuss it.