Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart

Issue 1806113002: Fix in code completion for named parameters in constructor, method and function invocations, https:… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: comments from danrubel Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index 679a8791a6ef01168cd71b997fc3e43b3bf04176..e7f4feacd5b4271669e7ce164a0f1c9e84290fa1 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -79,6 +79,20 @@ class ArgListContributorTest extends DartCompletionContributorTest {
/**
* Assert that the specified suggestions are the only suggestions.
*/
+ void assertSuggestions(List<String> suggestions) {
+ List<CompletionSuggestion> expected = new List<CompletionSuggestion>();
+ for (String suggestion in suggestions) {
+ expected.add(assertSuggest('$suggestion',
+ csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
+ relevance: DART_RELEVANCE_NAMED_PARAMETER));
+ }
+ assertNoOtherSuggestions(expected);
+ }
+
+ /**
+ * Assert that the specified named argument suggestions are the only
+ * suggestions.
+ */
void assertSuggestArguments({List<String> namedArguments}) {
List<CompletionSuggestion> expected = new List<CompletionSuggestion>();
for (String name in namedArguments) {
@@ -94,6 +108,15 @@ class ArgListContributorTest extends DartCompletionContributorTest {
return new ArgListContributor();
}
+ test_Annotation_local_constructor_named_param_negative() async {
+ addTestSource('''
+class A { const A(int one, int two, int three, {int four, String five:
+ 'defaultValue'}); }
+@A(1, ^, 3) main() { }''');
+ await computeSuggestions();
+ assertNoSuggestions();
+ }
+
test_Annotation_local_constructor_named_param() async {
addTestSource('''
class A { const A({int one, String two: 'defaultValue'}); }
@@ -102,6 +125,86 @@ class A { const A({int one, String two: 'defaultValue'}); }
assertSuggestArguments(namedArguments: ['one', 'two']);
}
+ test_Annotation_local_constructor_named_param_2() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(^ two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestions(['one: ,']);
+ }
+
+ test_Annotation_local_constructor_named_param_3() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(^two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestions(['one: ,']);
+ }
+
+ test_Annotation_local_constructor_named_param_4() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(^, two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestArguments(namedArguments: ['one']);
+ }
+
+ test_Annotation_local_constructor_named_param_5() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(^ , two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestArguments(namedArguments: ['one']);
+ }
+
+ test_Annotation_local_constructor_named_param_6() async {
+ addTestSource('''
+class A { const A(int zero, {int one, String two: 'defaultValue'}); }
+@A(0, ^, two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestArguments(namedArguments: ['one']);
+ }
+
+ test_Annotation_local_constructor_named_param_7() async {
+ addTestSource('''
+class A { const A(int zero, {int one, String two: 'defaultValue'}); }
+@A(0, ^ two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestions(['one: ,']);
+ }
+
+ test_Annotation_local_constructor_named_param_8() async {
+ addTestSource('''
+class A { const A(int zero, {int one, String two: 'defaultValue'}); }
+@A(0, ^two: '2') main() { }''');
+ await computeSuggestions();
+ assertSuggestions(['one: ,']);
+ }
+
+ fail_test_Annotation_local_constructor_named_param_9() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(two: '2'^) main() { }''');
+ await computeSuggestions();
+ assertSuggestions([', one: ']);
+ }
+
+ fail_test_Annotation_local_constructor_named_param_10() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(two: '2' ^) main() { }''');
+ await computeSuggestions();
+ assertSuggestions([', one: ']);
+ }
+
+ test_Annotation_local_constructor_named_param_11() async {
+ addTestSource('''
+class A { const A({int one, String two: 'defaultValue'}); }
+@A(two: '2', ^) main() { }''');
+ await computeSuggestions();
+ assertSuggestArguments(namedArguments: ['one']);
+ }
+
test_Annotation_imported_constructor_named_param() async {
addSource(
'/libA.dart',
@@ -317,7 +420,7 @@ library libA; class A { const A({int one, String two: 'defaultValue'}); }''');
//
addTestSource('main() { int.parse("16", ^r: 16);}');
await computeSuggestions();
- assertSuggestArguments(namedArguments: ['radix', 'onError']);
+ assertSuggestions(['radix: ,', 'onError: ,']);
}
test_ArgumentList_imported_function_named_param_label3() async {
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698