mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Completion. Issue 40588. Support for function typed functions invoked.
Bug: https://github.com/dart-lang/sdk/issues/40588 Change-Id: Ifc4ff940e5a519dab982f5ab771fe95277c3ae94 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356480 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
f30da31b21
commit
da488fdb78
2 changed files with 36 additions and 15 deletions
|
@ -229,8 +229,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
|||
var (:positionalArgumentCount, :usedNames) =
|
||||
node.argumentContext(argumentIndex);
|
||||
|
||||
var element = node.invokedElement;
|
||||
var parameters = element.getParameters();
|
||||
var parameters = node.invokedFormalParameters;
|
||||
if (parameters != null) {
|
||||
var positionalParameterCount = 0;
|
||||
var availableNamedParameters = <ParameterElement>[];
|
||||
|
@ -1542,14 +1541,14 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
|
|||
if (argumentList is! ArgumentList) {
|
||||
return;
|
||||
}
|
||||
var element = argumentList.invokedElement;
|
||||
if (element is ExecutableElement) {
|
||||
|
||||
var parameters = argumentList.invokedFormalParameters;
|
||||
if (parameters != null) {
|
||||
var (positionalArgumentCount: _, :usedNames) =
|
||||
argumentList.argumentContext(-1);
|
||||
usedNames.remove(node.name.label.name);
|
||||
|
||||
var appendColon = node.name.colon.isSynthetic;
|
||||
var parameters = element.parameters;
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
var parameter = parameters[i];
|
||||
if (parameter.isNamed) {
|
||||
|
@ -3052,6 +3051,23 @@ extension on ArgumentList {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<ParameterElement>? get invokedFormalParameters {
|
||||
var result = invokedElement?.getParameters();
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (parent) {
|
||||
case FunctionExpressionInvocation invocation:
|
||||
var functionType = invocation.function.staticType;
|
||||
if (functionType is FunctionType) {
|
||||
return functionType.parameters;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns a record whose fields indicate the number of positional arguments
|
||||
/// before the argument at the [argumentIndex], and the names of named
|
||||
/// parameters that are already in use.
|
||||
|
|
|
@ -930,20 +930,25 @@ var v = f$arguments;
|
|||
|
||||
await computeAndCheck('''
|
||||
$languageVersionLine
|
||||
class A {
|
||||
A$parameters;
|
||||
void foo(void Function$parameters f) {
|
||||
f$arguments;
|
||||
}
|
||||
class B extends A {
|
||||
B() : super$arguments;
|
||||
}
|
||||
''', ' (super constructor invocation)');
|
||||
''', ' (invocation, function typed formal parameter)');
|
||||
|
||||
await computeAndCheck('''
|
||||
$languageVersionLine
|
||||
class A {
|
||||
A$parameters;
|
||||
A.named() : this$arguments;
|
||||
void foo() {
|
||||
void Function$parameters f; // not initialized
|
||||
f$arguments;
|
||||
}
|
||||
''', ' (this constructor invocation)');
|
||||
''', ' (invocation, function typed local variable)');
|
||||
|
||||
await computeAndCheck('''
|
||||
$languageVersionLine
|
||||
void Function$parameters foo() => throw 0;
|
||||
void f() {
|
||||
foo()$arguments;
|
||||
}
|
||||
''', ' (invocation, function typed expression)');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue