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

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

Issue 1834423002: Sort the files in analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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
Index: pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index e5d854dc5c711da85aef003ccc7dd270bbb049b6..a9389c09ff440860be1bc6e2d98153c480026c13 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -61,335 +61,6 @@ class LocalReferenceContributorTest extends DartCompletionContributorTest {
return new LocalReferenceContributor();
}
- test_constructor_parameters_mixed_required_and_named() async {
- addTestSource('class A {A(x, {int y}) {^}}');
- await computeSuggestions();
- assertSuggestParameter('x', null);
- assertSuggestParameter('y', 'int');
- }
-
- test_constructor_parameters_mixed_required_and_positional() async {
- addTestSource('class A {A(x, [int y]) {^}}');
- await computeSuggestions();
- assertSuggestParameter('x', null);
- assertSuggestParameter('y', 'int');
- }
-
- test_constructor_parameters_named() async {
- addTestSource('class A {A({x, int y}) {^}}');
- await computeSuggestions();
- assertSuggestParameter('x', null);
- assertSuggestParameter('y', 'int');
- }
-
- test_constructor_parameters_positional() async {
- addTestSource('class A {A([x, int y]) {^}}');
- await computeSuggestions();
- assertSuggestParameter('x', null);
- assertSuggestParameter('y', 'int');
- }
-
- test_constructor_parameters_required() async {
- addTestSource('class A {A(x, int y) {^}}');
- await computeSuggestions();
- assertSuggestParameter('x', null);
- assertSuggestParameter('y', 'int');
- }
-
- test_enum() async {
- addTestSource('enum E { one, two } main() {^}');
- await computeSuggestions();
- assertSuggestEnum('E');
- assertNotSuggested('one');
- assertNotSuggested('two');
- }
-
- test_enum_deprecated() async {
- addTestSource('@deprecated enum E { one, two } main() {^}');
- await computeSuggestions();
- assertSuggestEnum('E', isDeprecated: true);
- assertNotSuggested('one');
- assertNotSuggested('two');
- }
-
- test_function_parameters_mixed_required_and_named() async {
- addTestSource('''
-void m(x, {int y}) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'y');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 1);
- expect(suggestion.hasNamedParameters, true);
- }
-
- test_function_parameters_mixed_required_and_positional() async {
- addTestSource('''
-void m(x, [int y]) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'y');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 1);
- expect(suggestion.hasNamedParameters, false);
- }
-
- test_function_parameters_named() async {
- addTestSource('''
-void m({x, int y}) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'y');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 0);
- expect(suggestion.hasNamedParameters, true);
- }
-
- test_function_parameters_none() async {
- addTestSource('''
-void m() {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, isEmpty);
- expect(suggestion.parameterTypes, isEmpty);
- expect(suggestion.requiredParameterCount, 0);
- expect(suggestion.hasNamedParameters, false);
- }
-
- test_function_parameters_positional() async {
- addTestSource('''
-void m([x, int y]) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'y');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 0);
- expect(suggestion.hasNamedParameters, false);
- }
-
- test_function_parameters_required() async {
- addTestSource('''
-void m(x, int y) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'y');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 2);
- expect(suggestion.hasNamedParameters, false);
- }
-
- test_ignore_symbol_being_completed() async {
- addTestSource('class MyClass { } main(MC^) { }');
- await computeSuggestions();
- assertSuggestClass('MyClass');
- assertNotSuggested('MC');
- }
-
- test_inDartDoc_reference3() async {
- addTestSource('''
-/// The [^]
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertSuggestFunction('main', null,
- kind: CompletionSuggestionKind.IDENTIFIER,
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- }
-
- test_inDartDoc_reference4() async {
- addTestSource('''
-/// The [m^]
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertSuggestFunction('main', null,
- kind: CompletionSuggestionKind.IDENTIFIER,
- relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- }
-
- test_InstanceCreationExpression() async {
- addTestSource('''
-class A {foo(){var f; {var x;}}}
-class B {B(this.x, [String boo]) { } int x;}
-class C {C.bar({boo: 'hoo', int z: 0}) { } }
-main() {new ^ String x = "hello";}''');
- await computeSuggestions();
- // Suggested by LocalConstructorContributor
- assertNoSuggestions();
- }
-
- test_method_parameters_mixed_required_and_named() async {
- addTestSource('''
-class A {
- void m(x, {int y}) {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_method_parameters_mixed_required_and_positional() async {
- addTestSource('''
-class A {
- void m(x, [int y]) {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_method_parameters_named() async {
- addTestSource('''
-class A {
- void m({x, int y}) {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_method_parameters_none() async {
- addTestSource('''
-class A {
- void m() {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_method_parameters_positional() async {
- addTestSource('''
-class A {
- void m([x, int y]) {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_method_parameters_required() async {
- addTestSource('''
-class A {
- void m(x, int y) {}
-}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_missing_params_constructor() async {
- addTestSource('class C1{C1{} main(){C^}}');
- await computeSuggestions();
- }
-
- test_missing_params_function() async {
- addTestSource('int f1{} main(){f^}');
- await computeSuggestions();
- }
-
- test_missing_params_method() async {
- addTestSource('class C1{int f1{} main(){f^}}');
- await computeSuggestions();
- }
-
- test_overrides() async {
- addTestSource('''
-class A {m() {}}
-class B extends A {m() {^}}
-''');
- await computeSuggestions();
- assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD);
- }
-
- test_prioritization() async {
- addTestSource('main() {var ab; var _ab; ^}');
- await computeSuggestions();
- assertSuggestLocalVariable('ab', null);
- assertSuggestLocalVariable('_ab', null, relevance: DART_RELEVANCE_DEFAULT);
- }
-
- test_prioritization_private() async {
- addTestSource('main() {var ab; var _ab; _^}');
- await computeSuggestions();
- assertSuggestLocalVariable('ab', null);
- assertSuggestLocalVariable('_ab', null);
- }
-
- test_prioritization_public() async {
- addTestSource('main() {var ab; var _ab; a^}');
- await computeSuggestions();
- assertSuggestLocalVariable('ab', null);
- assertSuggestLocalVariable('_ab', null, relevance: DART_RELEVANCE_DEFAULT);
- }
-
- test_shadowed_name() async {
- addTestSource('var a; class A { var a; m() { ^ } }');
- await computeSuggestions();
- assertSuggestField('a', null, relevance: DART_RELEVANCE_LOCAL_FIELD);
- }
-
test_ArgumentList() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addSource(
@@ -2003,6 +1674,41 @@ class C {foo(){var f; {var x;} return a ? T^ : c}}''');
//assertNotSuggested('T1');
}
+ test_constructor_parameters_mixed_required_and_named() async {
+ addTestSource('class A {A(x, {int y}) {^}}');
+ await computeSuggestions();
+ assertSuggestParameter('x', null);
+ assertSuggestParameter('y', 'int');
+ }
+
+ test_constructor_parameters_mixed_required_and_positional() async {
+ addTestSource('class A {A(x, [int y]) {^}}');
+ await computeSuggestions();
+ assertSuggestParameter('x', null);
+ assertSuggestParameter('y', 'int');
+ }
+
+ test_constructor_parameters_named() async {
+ addTestSource('class A {A({x, int y}) {^}}');
+ await computeSuggestions();
+ assertSuggestParameter('x', null);
+ assertSuggestParameter('y', 'int');
+ }
+
+ test_constructor_parameters_positional() async {
+ addTestSource('class A {A([x, int y]) {^}}');
+ await computeSuggestions();
+ assertSuggestParameter('x', null);
+ assertSuggestParameter('y', 'int');
+ }
+
+ test_constructor_parameters_required() async {
+ addTestSource('class A {A(x, int y) {^}}');
+ await computeSuggestions();
+ assertSuggestParameter('x', null);
+ assertSuggestParameter('y', 'int');
+ }
+
test_ConstructorName_importedClass() async {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
@@ -2136,6 +1842,22 @@ class A {a(blat: ^) { }}''');
assertNotSuggested('bar');
}
+ test_enum() async {
+ addTestSource('enum E { one, two } main() {^}');
+ await computeSuggestions();
+ assertSuggestEnum('E');
+ assertNotSuggested('one');
+ assertNotSuggested('two');
+ }
+
+ test_enum_deprecated() async {
+ addTestSource('@deprecated enum E { one, two } main() {^}');
+ await computeSuggestions();
+ assertSuggestEnum('E', isDeprecated: true);
+ assertNotSuggested('one');
+ assertNotSuggested('two');
+ }
+
test_ExpressionStatement_identifier() async {
// SimpleIdentifier ExpressionStatement Block
addSource(
@@ -2216,6 +1938,39 @@ class C {foo(){^} void bar() {}}''');
assertNoSuggestions();
}
+ test_ForEachStatement() async {
+ // SimpleIdentifier ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in ^)}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
+ test_ForEachStatement2() async {
+ // SimpleIdentifier ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in i^)}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset - 1);
+ expect(replacementLength, 1);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
+ test_ForEachStatement3() async {
+ // SimpleIdentifier ParenthesizedExpression ForEachStatement
+ addTestSource('main() {List<int> values; for (int index in (i^))}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset - 1);
+ expect(replacementLength, 1);
+ assertSuggestLocalVariable('values', 'List');
+ assertNotSuggested('index');
+ }
+
test_ForEachStatement_body_typed() async {
// Block ForEachStatement
addTestSource('main(args) {for (int foo in bar) {^}}');
@@ -2304,95 +2059,173 @@ class A {a(^) { }}''');
assertNotSuggested('bar');
}
- test_ForEachStatement() async {
- // SimpleIdentifier ForEachStatement
- addTestSource('main() {List<int> values; for (int index in ^)}');
+ test_ForStatement_body() async {
+ // Block ForStatement
+ addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestLocalVariable('values', 'List');
- assertNotSuggested('index');
- }
-
- test_ForEachStatement2() async {
- // SimpleIdentifier ForEachStatement
- addTestSource('main() {List<int> values; for (int index in i^)}');
- await computeSuggestions();
-
- expect(replacementOffset, completionOffset - 1);
- expect(replacementLength, 1);
- assertSuggestLocalVariable('values', 'List');
- assertNotSuggested('index');
+ assertSuggestLocalVariable('i', 'int');
+ assertNotSuggested('Object');
}
- test_ForEachStatement3() async {
- // SimpleIdentifier ParenthesizedExpression ForEachStatement
- addTestSource('main() {List<int> values; for (int index in (i^))}');
+ test_ForStatement_condition() async {
+ // SimpleIdentifier ForStatement
+ addTestSource('main() {for (int index = 0; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
- assertSuggestLocalVariable('values', 'List');
- assertNotSuggested('index');
+ assertSuggestLocalVariable('index', 'int');
}
- test_ForStatement_body() async {
- // Block ForStatement
- addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
+ test_ForStatement_initializer() async {
+ // SimpleIdentifier ForStatement
+ addTestSource('main() {List a; for (^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestLocalVariable('i', 'int');
+ assertSuggestLocalVariable('a', 'List');
assertNotSuggested('Object');
+ assertNotSuggested('int');
}
- test_ForStatement_condition() async {
+ test_ForStatement_updaters() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; i^)}');
+ addTestSource('main() {for (int index = 0; index < 10; i^)}');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset - 1);
+ expect(replacementLength, 1);
+ assertSuggestLocalVariable('index', 'int');
+ }
+
+ test_ForStatement_updaters_prefix_expression() async {
+ // SimpleIdentifier PrefixExpression ForStatement
+ addTestSource('''
+void bar() { }
+main() {for (int index = 0; index < 10; ++i^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
assertSuggestLocalVariable('index', 'int');
+ assertSuggestFunction('main', null,
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ assertNotSuggested('bar');
+ }
+
+ test_function_parameters_mixed_required_and_named() async {
+ addTestSource('''
+void m(x, {int y}) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'y');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 1);
+ expect(suggestion.hasNamedParameters, true);
+ }
+
+ test_function_parameters_mixed_required_and_positional() async {
+ addTestSource('''
+void m(x, [int y]) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'y');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 1);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
+ test_function_parameters_named() async {
+ addTestSource('''
+void m({x, int y}) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'y');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 0);
+ expect(suggestion.hasNamedParameters, true);
}
- test_ForStatement_initializer() async {
- // SimpleIdentifier ForStatement
- addTestSource('main() {List a; for (^)}');
+ test_function_parameters_none() async {
+ addTestSource('''
+void m() {}
+class B extends A {
+ main() {^}
+}
+''');
await computeSuggestions();
-
- expect(replacementOffset, completionOffset);
- expect(replacementLength, 0);
- assertSuggestLocalVariable('a', 'List');
- assertNotSuggested('Object');
- assertNotSuggested('int');
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ expect(suggestion.parameterNames, isEmpty);
+ expect(suggestion.parameterTypes, isEmpty);
+ expect(suggestion.requiredParameterCount, 0);
+ expect(suggestion.hasNamedParameters, false);
}
- test_ForStatement_updaters() async {
- // SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; index < 10; i^)}');
+ test_function_parameters_positional() async {
+ addTestSource('''
+void m([x, int y]) {}
+class B extends A {
+ main() {^}
+}
+''');
await computeSuggestions();
-
- expect(replacementOffset, completionOffset - 1);
- expect(replacementLength, 1);
- assertSuggestLocalVariable('index', 'int');
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'y');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 0);
+ expect(suggestion.hasNamedParameters, false);
}
- test_ForStatement_updaters_prefix_expression() async {
- // SimpleIdentifier PrefixExpression ForStatement
+ test_function_parameters_required() async {
addTestSource('''
-void bar() { }
-main() {for (int index = 0; index < 10; ++i^)}''');
+void m(x, int y) {}
+class B extends A {
+ main() {^}
+}
+''');
await computeSuggestions();
-
- expect(replacementOffset, completionOffset - 1);
- expect(replacementLength, 1);
- assertSuggestLocalVariable('index', 'int');
- assertSuggestFunction('main', null,
+ CompletionSuggestion suggestion = assertSuggestFunction('m', 'void',
relevance: DART_RELEVANCE_LOCAL_FUNCTION);
- assertNotSuggested('bar');
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'y');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 2);
+ expect(suggestion.hasNamedParameters, false);
}
test_FunctionDeclaration_returnType_afterComment() async {
@@ -2588,6 +2421,13 @@ main() {var a; if (a.^) something}''');
assertNotSuggested('==');
}
+ test_ignore_symbol_being_completed() async {
+ addTestSource('class MyClass { } main(MC^) { }');
+ await computeSuggestions();
+ assertSuggestClass('MyClass');
+ assertNotSuggested('MC');
+ }
+
test_ImportDirective_dart() async {
// SimpleStringLiteral ImportDirective
addTestSource('''
@@ -2598,6 +2438,26 @@ main() {}''');
assertNoSuggestions();
}
+ test_inDartDoc_reference3() async {
+ addTestSource('''
+/// The [^]
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertSuggestFunction('main', null,
+ kind: CompletionSuggestionKind.IDENTIFIER,
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ }
+
+ test_inDartDoc_reference4() async {
+ addTestSource('''
+/// The [m^]
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertSuggestFunction('main', null,
+ kind: CompletionSuggestionKind.IDENTIFIER,
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ }
+
test_IndexExpression() async {
// ExpressionStatement Block
addSource(
@@ -2651,6 +2511,17 @@ class C {foo(){var f; {var x;} f[T^]}}''');
//assertNotSuggested('T1');
}
+ test_InstanceCreationExpression() async {
+ addTestSource('''
+class A {foo(){var f; {var x;}}}
+class B {B(this.x, [String boo]) { } int x;}
+class C {C.bar({boo: 'hoo', int z: 0}) { } }
+main() {new ^ String x = "hello";}''');
+ await computeSuggestions();
+ // Suggested by LocalConstructorContributor
+ assertNoSuggestions();
+ }
+
test_InstanceCreationExpression_imported() async {
// SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
addSource(
@@ -2936,6 +2807,14 @@ main() {new^ X.c();}''');
assertNoSuggestions();
}
+ test_localVariableDeclarationName() async {
+ addTestSource('main() {String m^}');
+ await computeSuggestions();
+
+ assertNotSuggested('main');
+ assertNotSuggested('min');
+ }
+
test_MapLiteralEntry() async {
// MapLiteralEntry MapLiteral VariableDeclaration
addSource(
@@ -3018,6 +2897,84 @@ foo = {7:T^};''');
relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE);
}
+ test_method_parameters_mixed_required_and_named() async {
+ addTestSource('''
+class A {
+ void m(x, {int y}) {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_method_parameters_mixed_required_and_positional() async {
+ addTestSource('''
+class A {
+ void m(x, [int y]) {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_method_parameters_named() async {
+ addTestSource('''
+class A {
+ void m({x, int y}) {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_method_parameters_none() async {
+ addTestSource('''
+class A {
+ void m() {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_method_parameters_positional() async {
+ addTestSource('''
+class A {
+ void m([x, int y]) {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_method_parameters_required() async {
+ addTestSource('''
+class A {
+ void m(x, int y) {}
+}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
test_MethodDeclaration_body_getters() async {
// Block BlockFunctionBody MethodDeclaration
addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}');
@@ -3347,6 +3304,21 @@ class X{}''');
assertNotSuggested('==');
}
+ test_missing_params_constructor() async {
+ addTestSource('class C1{C1{} main(){C^}}');
+ await computeSuggestions();
+ }
+
+ test_missing_params_function() async {
+ addTestSource('int f1{} main(){f^}');
+ await computeSuggestions();
+ }
+
+ test_missing_params_method() async {
+ addTestSource('class C1{int f1{} main(){f^}}');
+ await computeSuggestions();
+ }
+
test_new_instance() async {
addTestSource('import "dart:math"; class A {x() {new Random().^}}');
await computeSuggestions();
@@ -3359,6 +3331,15 @@ class X{}''');
assertNotSuggested('A');
}
+ test_overrides() async {
+ addTestSource('''
+class A {m() {}}
+class B extends A {m() {^}}
+''');
+ await computeSuggestions();
+ assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD);
+ }
+
test_parameterName_excludeTypes() async {
addTestSource('m(int ^) {}');
await computeSuggestions();
@@ -3798,14 +3779,6 @@ class X {foo(){A^.bar}}''');
assertNotSuggested('length');
}
- test_localVariableDeclarationName() async {
- addTestSource('main() {String m^}');
- await computeSuggestions();
-
- assertNotSuggested('main');
- assertNotSuggested('min');
- }
-
test_PrefixedIdentifier_trailingStmt_param2() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('f(String g) {g.^ int y = 0;}');
@@ -3822,6 +3795,27 @@ class X {foo(){A^.bar}}''');
assertNotSuggested('length');
}
+ test_prioritization() async {
+ addTestSource('main() {var ab; var _ab; ^}');
+ await computeSuggestions();
+ assertSuggestLocalVariable('ab', null);
+ assertSuggestLocalVariable('_ab', null, relevance: DART_RELEVANCE_DEFAULT);
+ }
+
+ test_prioritization_private() async {
+ addTestSource('main() {var ab; var _ab; _^}');
+ await computeSuggestions();
+ assertSuggestLocalVariable('ab', null);
+ assertSuggestLocalVariable('_ab', null);
+ }
+
+ test_prioritization_public() async {
+ addTestSource('main() {var ab; var _ab; a^}');
+ await computeSuggestions();
+ assertSuggestLocalVariable('ab', null);
+ assertSuggestLocalVariable('_ab', null, relevance: DART_RELEVANCE_DEFAULT);
+ }
+
test_PropertyAccess_expression() async {
// SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement
addTestSource('class A {a() {"hello".to^String().length}}');
@@ -3868,6 +3862,12 @@ class X {foo(){A^.bar}}''');
assertNotSuggested('==');
}
+ test_shadowed_name() async {
+ addTestSource('var a; class A { var a; m() { ^ } }');
+ await computeSuggestions();
+ assertSuggestField('a', null, relevance: DART_RELEVANCE_LOCAL_FIELD);
+ }
+
test_SwitchStatement_c() async {
// SwitchStatement Block BlockFunctionBody MethodDeclaration
addTestSource('class A {String g(int x) {switch(x) {c^}}}');

Powered by Google App Engine
This is Rietveld 408576698