mirror of
https://github.com/dart-lang/sdk
synced 2024-10-07 08:50:47 +00:00
Suggest named arguments anywhere when named_arguments_anywhere.
Change-Id: I1aefd0c7f4c4e140e5505a2b91a65a8c3b1e449a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222080 Reviewed-by: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
parent
76bfec126d
commit
0d98f6ab5d
|
@ -7,6 +7,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
|
|||
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
|
||||
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
|
||||
import 'package:analysis_server/src/utilities/flutter.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
|
@ -100,7 +101,9 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
if (_isEditingNamedArgLabel() ||
|
||||
_isAppendingToArgList() ||
|
||||
_isAddingLabelToPositional()) {
|
||||
if (requiredCount == 0 || requiredCount < _argCount()) {
|
||||
if (request.featureSet.isEnabled(Feature.named_arguments_anywhere) ||
|
||||
requiredCount == 0 ||
|
||||
requiredCount < _argCount()) {
|
||||
// If there's a replacement range that starts at the caret, it will be
|
||||
// for an identifier that is not the named label and therefore it should
|
||||
// not be replaced.
|
||||
|
|
|
@ -172,6 +172,15 @@ class A { const A({int one, String two: 'defaultValue'}); }
|
|||
assertSuggestArgumentsAndTypes(namedArgumentsWithTypes: {'one': 'int'});
|
||||
}
|
||||
|
||||
Future<void> test_Annotation_local_constructor_named_param_12() async {
|
||||
addTestSource('''
|
||||
class A { const A(int one, int two, int three, {int four, String five:
|
||||
'defaultValue'}); }
|
||||
@A(1, ^, 3) main() { }''');
|
||||
await computeSuggestions();
|
||||
assertSuggestions(['four: ', 'five: ']);
|
||||
}
|
||||
|
||||
Future<void> test_Annotation_local_constructor_named_param_2() async {
|
||||
addTestSource('''
|
||||
class A { const A({int one, String two: 'defaultValue'}); }
|
||||
|
@ -239,6 +248,7 @@ class A { const A({int one, String two: 'defaultValue'}); }
|
|||
|
||||
Future<void> test_Annotation_local_constructor_named_param_negative() async {
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
class A { const A(int one, int two, int three, {int four, String five:
|
||||
'defaultValue'}); }
|
||||
@A(1, ^, 3) main() { }''');
|
||||
|
@ -660,6 +670,7 @@ foo({String children}) {}
|
|||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
void baz() { }''');
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
import 'a.dart'
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -676,6 +687,7 @@ foo({String children}) {}
|
|||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
void baz() { }''');
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
import 'a.dart'
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -692,6 +704,7 @@ foo({String children}) {}
|
|||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
void baz() { }''');
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
import 'a.dart'
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -708,6 +721,7 @@ foo({String children}) {}
|
|||
expect(String arg1, int arg2, {bool arg3}) { }
|
||||
void baz() { }''');
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
import 'a.dart'
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -987,6 +1001,7 @@ main() { new A(^);}''');
|
|||
Future<void> test_ArgumentList_local_function_3a() async {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
expect(arg1, int arg2, {bool arg3}) { }
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -998,6 +1013,7 @@ main() { new A(^);}''');
|
|||
Future<void> test_ArgumentList_local_function_3b() async {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
expect(arg1, int arg2, {bool arg3}) { }
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -1009,6 +1025,7 @@ main() { new A(^);}''');
|
|||
Future<void> test_ArgumentList_local_function_3c() async {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
expect(arg1, int arg2, {bool arg3}) { }
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
@ -1020,6 +1037,7 @@ main() { new A(^);}''');
|
|||
Future<void> test_ArgumentList_local_function_3d() async {
|
||||
// ArgumentList MethodInvocation ExpressionStatement Block
|
||||
addTestSource('''
|
||||
// @dart = 2.15
|
||||
expect(arg1, int arg2, {bool arg3}) { }
|
||||
class B { }
|
||||
String bar() => true;
|
||||
|
|
Loading…
Reference in a new issue