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.23k stars 1.58k forks source link

Code completion for methods should not call the method but just reference it #40703

Open vogella opened 4 years ago

vogella commented 4 years ago

Code completion results in an error in the following case:

RaisedButton( onPressed: [CODE COMPLETION HERE] child: Text("Press me"), )

void doIt() {}

If I select doIt from the proposals I end up with:

RaisedButton( onPressed: doIt() child: Text("Press me"), ),

while it should be:

RaisedButton( onPressed: doIt child: Text("Press me"), ),

bwilkerson commented 4 years ago

@pq

vogella commented 4 years ago

I see this error relatively often in your Flutter development training sessions for new Flutter developers.

pq commented 4 years ago

Interestingly, it looks like we are not suggesting function references in completions at all.

image

Notice that foo() is an invocation and not the reference.

I suspect we really want either:

  1. both foo and foo(), with foo ranked higher, or
  2. just foo, with foo() filtered out since it's return type (int) is not compatible with the expected function

/fyi @bwilkerson

bwilkerson commented 4 years ago

... it looks like we are not suggesting function references in completions at all.

I could believe that.

I'll offer another proposal, which is to propose both and then use type information for the ranking.

srawlins commented 1 year ago

I'll offer another proposal, which is to propose both and then use type information for the ranking.

💯 this.