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

When completing a named function argument, can we include the boilerplate for the function signature? #25267

Closed
sethladd opened this issue Dec 15, 2015 · 7 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-flutter devexp-completion Issues with the analysis server's code completion feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sethladd
Copy link
Contributor

I'm trying to setup a FlatButton. I know it takes something like onPressed. I write new FlatButton() and then code complete inside the parens. I scroll to find onPressed (yay!) and hit enter.

Expected: add onPressed: () { }

Actual: onPressed:

That is, please fill in the function signature (which, in this case, is VoidCallback) when completing a named parameter that is a function.

I tried to code complete after the : but all I found was:

screen shot 2015-12-15 at 2 05 56 pm

I had to go to the docs to find out what onPressed expected. I was hoping I could learn that through code completion.

@sethladd sethladd added devexp-completion Issues with the analysis server's code completion feature customer-flutter labels Dec 15, 2015
@floitschG floitschG added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 16, 2015
@sethladd
Copy link
Contributor Author

Another example that I just ran into:

new List.genCODE COMPLETE HERE

Actual: new List.generate(length, generator)

Hoped/expected: new List.generate(length, (int index) => null)

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@bwilkerson
Copy link
Member

If we do this at all, we should provide both options for completion:

onPressed: () => null
onPressed:

I hate having to select text that was added for me and remove / replace it when it's wrong, and I often want to pass in a tear-off in cases like these. If we do this then we ought to also allow completion (to something like () => null) after the colon.

Of course, if we complete named parameter values we also need to complete positional parameter values that way.

@skybrian
Copy link

After autocomplete to "onPressed:", if you type "(" perhaps it should autocomplete to the parameter list for the callback function?

@danrubel danrubel removed their assignment Jan 6, 2020
@pq
Copy link
Member

pq commented Jan 16, 2020

Lambda completion is implemented w/ e0c178b.

@pq pq closed this as completed Jan 16, 2020
@greglittlefield-wf
Copy link
Contributor

This is awesome to see! Is there a reason why this functionality is limited to named arguments, and not positional arguments, though?

I would love to see this for functions like Iterable.map/.where that take a single function argument.

@pq
Copy link
Member

pq commented Jan 17, 2020

@greglittlefield-wf: working on it, but I see it wasn't tracked. Added here: #40202.

Thanks for the feedback!

@greglittlefield-wf
Copy link
Contributor

Awesome, I'm so excited!! 😃 Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-flutter devexp-completion Issues with the analysis server's code completion feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

8 participants