You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include "required" parameters in LSP's completeFunctionCalls completions #1960
class Blah {
final stob;
Blah({@required this.stob});
}
When I type 'Bl' intellisense suggests 'Blah(...)'. When selecting this item it writes Blah() in my code file. Would it be a nice feature to supply my property names where the constructor uses named parameters? So I think it would be nice if it wrote the following in my code file.
Blah(
stob:
)
For me it would be especially useful where the parameter is decorated with the @required metadata because then the named parameter must be defined. It would just save some keystrokes I guess but it would be nice. Many thanks :-)
This would be nice, however I think it would be a bit awkward to use unless we also put tab stops next to each one:
Blah(
arg1: {$1},
arg2: {$2},
arg13 {$3},
);${0}
However, VS Code doesn't handle this well because you get stuck in snippet-mode when you're in each of the tab stops, and in Flutter it's very common to want to write multiline functions as arguments (see microsoft/vscode#43270). For ex, imagine you wanted to write:
arg2: () {
// Handle key press
}
When you press <tab> to indent that code, it would jump to the next tabstop (arg3) which would be frustrating.
We do do something similar for non-named arguments already, but that has the issue described above (see #1173 (comment)) so I'd like to get rid of it when I can (which is probably when commit characters work better).
(I think it's a valid request to do better here though, so I'll keep this open in case a way to do it well comes up.. it'll likely need some analysis server work to get us the right info, but that might be simpler if we move to LSP).
Alternatively a quickfix for "Add all required arguments". Right now there are quickfixes for every individual required arguments, but that's kind of annoying for functions that have a lot of arguments.
@jacoplane that sounds like a reasonable request too. The quick fixes come from the analyzer SDK, so this it would need to be implemented there - would you mind filing an issue at https://github.com/dart-lang/sdk requesting that and post a link back here for people to 👍 ? Thanks!
This is mostly the same as #2823 which is now implemented. When using the LSP preview (and an upcoming SDK release - since that change only landed yesterday), the dart.completeFunctionCalls setting will insert parens and positional args.
However, it doesn't do required parameters, so I'll re-purpose this to support them (note: it's possible we'll only support real required params using the new required keyword rather than the @required annotation).
changed the title [-]When intellisense suggests the creation of a new class or a function call can it provide the named parameters?[/-][+]Include "required" parameters in LSP's completeFunctionCalls completions[/+]on Nov 12, 2020
Activity
DanTup commentedon Sep 3, 2019
This would be nice, however I think it would be a bit awkward to use unless we also put tab stops next to each one:
However, VS Code doesn't handle this well because you get stuck in snippet-mode when you're in each of the tab stops, and in Flutter it's very common to want to write multiline functions as arguments (see microsoft/vscode#43270). For ex, imagine you wanted to write:
When you press
<tab>to indent that code, it would jump to the next tabstop (arg3) which would be frustrating.We do do something similar for non-named arguments already, but that has the issue described above (see #1173 (comment)) so I'd like to get rid of it when I can (which is probably when commit characters work better).
DanTup commentedon Sep 3, 2019
(I think it's a valid request to do better here though, so I'll keep this open in case a way to do it well comes up.. it'll likely need some analysis server work to get us the right info, but that might be simpler if we move to LSP).
atreeon commentedon Sep 3, 2019
ok great, thank you. I shall keep watching :-)
jacoplane commentedon Oct 10, 2019
Alternatively a quickfix for "Add all required arguments". Right now there are quickfixes for every individual required arguments, but that's kind of annoying for functions that have a lot of arguments.

DanTup commentedon Oct 14, 2019
@jacoplane that sounds like a reasonable request too. The quick fixes come from the analyzer SDK, so this it would need to be implemented there - would you mind filing an issue at https://github.com/dart-lang/sdk requesting that and post a link back here for people to 👍 ? Thanks!
jacoplane commentedon Oct 14, 2019
@DanTup I've opened an issue there: dart-lang/sdk#38876
DanTup commentedon Nov 12, 2020
This is mostly the same as #2823 which is now implemented. When using the LSP preview (and an upcoming SDK release - since that change only landed yesterday), the
dart.completeFunctionCallssetting will insert parens and positional args.However, it doesn't do
requiredparameters, so I'll re-purpose this to support them (note: it's possible we'll only support realrequiredparams using the newrequiredkeyword rather than the@requiredannotation).[-]When intellisense suggests the creation of a new class or a function call can it provide the named parameters?[/-][+]Include "required" parameters in LSP's completeFunctionCalls completions[/+]DanTup commentedon Dec 8, 2020
Fix out for review https://dart-review.googlesource.com/c/sdk/+/174802.
DanTup commentedon Dec 9, 2020
Fixed by dart-lang/sdk@0fa6674.