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

Unified Diff: pkg/analysis_server/test/services/completion/dart/local_constructor_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_constructor_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
index 64773f481daa639f073ff606a5f59eca05954c53..172d767b1fef9fc14b4bf169801431df746ce6b6 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_constructor_contributor_test.dart
@@ -61,333 +61,6 @@ class LocalConstructorContributorTest extends DartCompletionContributorTest {
return new LocalConstructorContributor();
}
- test_constructor_parameters_mixed_required_and_named() async {
- addTestSource('class A {A(x, {int y}) {^}}');
- await computeSuggestions();
- assertNotSuggested('x');
- assertNotSuggested('y');
- }
-
- test_constructor_parameters_mixed_required_and_positional() async {
- addTestSource('class A {A(x, [int y]) {^}}');
- await computeSuggestions();
- assertNotSuggested('x');
- assertNotSuggested('y');
- }
-
- test_constructor_parameters_named() async {
- addTestSource('class A {A({x, int y}) {^}}');
- await computeSuggestions();
- assertNotSuggested('x');
- assertNotSuggested('y');
- }
-
- test_constructor_parameters_positional() async {
- addTestSource('class A {A([x, int y]) {^}}');
- await computeSuggestions();
- assertNotSuggested('x');
- assertNotSuggested('y');
- }
-
- test_constructor_parameters_required() async {
- addTestSource('class A {A(x, int y) {^}}');
- await computeSuggestions();
- assertNotSuggested('x');
- assertNotSuggested('y');
- }
-
- test_enum() async {
- addTestSource('enum E { one, two } main() {^}');
- await computeSuggestions();
- assertNotSuggested('E');
- assertNotSuggested('one');
- assertNotSuggested('two');
- }
-
- test_enum_deprecated() async {
- addTestSource('@deprecated enum E { one, two } main() {^}');
- await computeSuggestions();
- assertNotSuggested('E');
- 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();
- assertNotSuggested('m');
- }
-
- test_function_parameters_mixed_required_and_positional() async {
- addTestSource('''
-void m(x, [int y]) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_function_parameters_named() async {
- addTestSource('''
-void m({x, int y}) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_function_parameters_none() async {
- addTestSource('''
-void m() {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_function_parameters_positional() async {
- addTestSource('''
-void m([x, int y]) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_function_parameters_required() async {
- addTestSource('''
-void m(x, int y) {}
-class B extends A {
- main() {^}
-}
-''');
- await computeSuggestions();
- assertNotSuggested('m');
- }
-
- test_ignore_symbol_being_completed() async {
- addTestSource('class MyClass { } main(MC^) { }');
- await computeSuggestions();
- assertNotSuggested('MyClass');
- assertNotSuggested('MC');
- }
-
- test_inDartDoc_reference1() async {
- addTestSource('''
-/// The [^
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertNotSuggested('main');
- }
-
- test_inDartDoc_reference2() async {
- addTestSource('''
-/// The [m^
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertNotSuggested('main');
- }
-
- test_inDartDoc_reference3() async {
- addTestSource('''
-/// The [^]
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertNotSuggested('main');
- }
-
- test_inDartDoc_reference4() async {
- addTestSource('''
-/// The [m^]
-main(aaa, bbb) {}''');
- await computeSuggestions();
- assertNotSuggested('main');
- }
-
- 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();
- CompletionSuggestion suggestion;
-
- suggestion = assertSuggestConstructor('A', elemOffset: -1);
- expect(suggestion.element.parameters, '()');
- expect(suggestion.element.returnType, 'A');
- expect(suggestion.declaringType, 'A');
- expect(suggestion.parameterNames, hasLength(0));
- expect(suggestion.requiredParameterCount, 0);
- expect(suggestion.hasNamedParameters, false);
-
- suggestion = assertSuggestConstructor('B');
- expect(suggestion.element.parameters, '(int x, [String boo])');
- expect(suggestion.element.returnType, 'B');
- expect(suggestion.declaringType, 'B');
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'x');
- expect(suggestion.parameterTypes[0], 'int');
- expect(suggestion.parameterNames[1], 'boo');
- expect(suggestion.parameterTypes[1], 'String');
- expect(suggestion.requiredParameterCount, 1);
- expect(suggestion.hasNamedParameters, false);
-
- suggestion = assertSuggestConstructor('C.bar');
- expect(suggestion.element.parameters, '({dynamic boo: \'hoo\', int z: 0})');
- expect(suggestion.element.returnType, 'C');
- expect(suggestion.declaringType, 'C');
- expect(suggestion.parameterNames, hasLength(2));
- expect(suggestion.parameterNames[0], 'boo');
- expect(suggestion.parameterTypes[0], 'dynamic');
- expect(suggestion.parameterNames[1], 'z');
- expect(suggestion.parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 0);
- expect(suggestion.hasNamedParameters, true);
- }
-
- 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();
- assertNotSuggested('m');
- }
-
- test_prioritization() async {
- addTestSource('main() {var ab; var _ab; ^}');
- await computeSuggestions();
- assertNotSuggested('ab');
- assertNotSuggested('_ab');
- }
-
- test_prioritization_private() async {
- addTestSource('main() {var ab; var _ab; _^}');
- await computeSuggestions();
- assertNotSuggested('ab');
- assertNotSuggested('_ab');
- }
-
- test_prioritization_public() async {
- addTestSource('main() {var ab; var _ab; a^}');
- await computeSuggestions();
- assertNotSuggested('ab');
- assertNotSuggested('_ab');
- }
-
- test_shadowed_name() async {
- addTestSource('var a; class A { var a; m() { ^ } }');
- await computeSuggestions();
- assertNotSuggested('a');
- }
-
test_ArgumentList() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addSource(
@@ -1946,6 +1619,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();
+ assertNotSuggested('x');
+ assertNotSuggested('y');
+ }
+
+ test_constructor_parameters_mixed_required_and_positional() async {
+ addTestSource('class A {A(x, [int y]) {^}}');
+ await computeSuggestions();
+ assertNotSuggested('x');
+ assertNotSuggested('y');
+ }
+
+ test_constructor_parameters_named() async {
+ addTestSource('class A {A({x, int y}) {^}}');
+ await computeSuggestions();
+ assertNotSuggested('x');
+ assertNotSuggested('y');
+ }
+
+ test_constructor_parameters_positional() async {
+ addTestSource('class A {A([x, int y]) {^}}');
+ await computeSuggestions();
+ assertNotSuggested('x');
+ assertNotSuggested('y');
+ }
+
+ test_constructor_parameters_required() async {
+ addTestSource('class A {A(x, int y) {^}}');
+ await computeSuggestions();
+ assertNotSuggested('x');
+ assertNotSuggested('y');
+ }
+
test_ConstructorName_importedClass() async {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
@@ -2078,6 +1786,22 @@ class A {a(blat: ^) { }}''');
assertNotSuggested('bar');
}
+ test_enum() async {
+ addTestSource('enum E { one, two } main() {^}');
+ await computeSuggestions();
+ assertNotSuggested('E');
+ assertNotSuggested('one');
+ assertNotSuggested('two');
+ }
+
+ test_enum_deprecated() async {
+ addTestSource('@deprecated enum E { one, two } main() {^}');
+ await computeSuggestions();
+ assertNotSuggested('E');
+ assertNotSuggested('one');
+ assertNotSuggested('two');
+ }
+
test_ExpressionStatement_identifier() async {
// SimpleIdentifier ExpressionStatement Block
addSource(
@@ -2287,18 +2011,84 @@ class A {a(^) { }}''');
assertNotSuggested('index');
}
- test_ForStatement_updaters_prefix_expression() async {
- // SimpleIdentifier PrefixExpression ForStatement
+ 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);
+ assertNotSuggested('index');
+ assertNotSuggested('main');
+ assertNotSuggested('bar');
+ }
+
+ test_function_parameters_mixed_required_and_named() async {
+ addTestSource('''
+void m(x, {int y}) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_function_parameters_mixed_required_and_positional() async {
+ addTestSource('''
+void m(x, [int y]) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_function_parameters_named() async {
+ addTestSource('''
+void m({x, int y}) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_function_parameters_none() async {
+ addTestSource('''
+void m() {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
+ test_function_parameters_positional() async {
addTestSource('''
-void bar() { }
-main() {for (int index = 0; index < 10; ++i^)}''');
+void m([x, int y]) {}
+class B extends A {
+ main() {^}
+}
+''');
await computeSuggestions();
+ assertNotSuggested('m');
+ }
- expect(replacementOffset, completionOffset - 1);
- expect(replacementLength, 1);
- assertNotSuggested('index');
- assertNotSuggested('main');
- assertNotSuggested('bar');
+ test_function_parameters_required() async {
+ addTestSource('''
+void m(x, int y) {}
+class B extends A {
+ main() {^}
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
}
test_FunctionDeclaration_returnType_afterComment() async {
@@ -2473,6 +2263,13 @@ main() {var a; if (a.^) something}''');
assertNotSuggested('==');
}
+ test_ignore_symbol_being_completed() async {
+ addTestSource('class MyClass { } main(MC^) { }');
+ await computeSuggestions();
+ assertNotSuggested('MyClass');
+ assertNotSuggested('MC');
+ }
+
test_ImportDirective_dart() async {
// SimpleStringLiteral ImportDirective
addTestSource('''
@@ -2483,6 +2280,38 @@ main() {}''');
assertNoSuggestions();
}
+ test_inDartDoc_reference1() async {
+ addTestSource('''
+/// The [^
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertNotSuggested('main');
+ }
+
+ test_inDartDoc_reference2() async {
+ addTestSource('''
+/// The [m^
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertNotSuggested('main');
+ }
+
+ test_inDartDoc_reference3() async {
+ addTestSource('''
+/// The [^]
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertNotSuggested('main');
+ }
+
+ test_inDartDoc_reference4() async {
+ addTestSource('''
+/// The [m^]
+main(aaa, bbb) {}''');
+ await computeSuggestions();
+ assertNotSuggested('main');
+ }
+
test_IndexExpression() async {
// ExpressionStatement Block
addSource(
@@ -2533,6 +2362,48 @@ 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();
+ CompletionSuggestion suggestion;
+
+ suggestion = assertSuggestConstructor('A', elemOffset: -1);
+ expect(suggestion.element.parameters, '()');
+ expect(suggestion.element.returnType, 'A');
+ expect(suggestion.declaringType, 'A');
+ expect(suggestion.parameterNames, hasLength(0));
+ expect(suggestion.requiredParameterCount, 0);
+ expect(suggestion.hasNamedParameters, false);
+
+ suggestion = assertSuggestConstructor('B');
+ expect(suggestion.element.parameters, '(int x, [String boo])');
+ expect(suggestion.element.returnType, 'B');
+ expect(suggestion.declaringType, 'B');
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'x');
+ expect(suggestion.parameterTypes[0], 'int');
+ expect(suggestion.parameterNames[1], 'boo');
+ expect(suggestion.parameterTypes[1], 'String');
+ expect(suggestion.requiredParameterCount, 1);
+ expect(suggestion.hasNamedParameters, false);
+
+ suggestion = assertSuggestConstructor('C.bar');
+ expect(suggestion.element.parameters, '({dynamic boo: \'hoo\', int z: 0})');
+ expect(suggestion.element.returnType, 'C');
+ expect(suggestion.declaringType, 'C');
+ expect(suggestion.parameterNames, hasLength(2));
+ expect(suggestion.parameterNames[0], 'boo');
+ expect(suggestion.parameterTypes[0], 'dynamic');
+ expect(suggestion.parameterNames[1], 'z');
+ expect(suggestion.parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 0);
+ expect(suggestion.hasNamedParameters, true);
+ }
+
test_InstanceCreationExpression_imported() async {
// SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
addSource(
@@ -2811,6 +2682,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(
@@ -2890,6 +2769,84 @@ foo = {7:T^};''');
assertNotSuggested('T2');
}
+ 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;}');
@@ -3147,6 +3104,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();
@@ -3159,6 +3131,15 @@ class X{}''');
assertNotSuggested('A');
}
+ test_overrides() async {
+ addTestSource('''
+class A {m() {}}
+class B extends A {m() {^}}
+''');
+ await computeSuggestions();
+ assertNotSuggested('m');
+ }
+
test_parameterName_excludeTypes() async {
addTestSource('m(int ^) {}');
await computeSuggestions();
@@ -3595,14 +3576,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;}');
@@ -3619,6 +3592,27 @@ class X {foo(){A^.bar}}''');
assertNotSuggested('length');
}
+ test_prioritization() async {
+ addTestSource('main() {var ab; var _ab; ^}');
+ await computeSuggestions();
+ assertNotSuggested('ab');
+ assertNotSuggested('_ab');
+ }
+
+ test_prioritization_private() async {
+ addTestSource('main() {var ab; var _ab; _^}');
+ await computeSuggestions();
+ assertNotSuggested('ab');
+ assertNotSuggested('_ab');
+ }
+
+ test_prioritization_public() async {
+ addTestSource('main() {var ab; var _ab; a^}');
+ await computeSuggestions();
+ assertNotSuggested('ab');
+ assertNotSuggested('_ab');
+ }
+
test_PropertyAccess_expression() async {
// SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement
addTestSource('class A {a() {"hello".to^String().length}}');
@@ -3665,6 +3659,12 @@ class X {foo(){A^.bar}}''');
assertNotSuggested('==');
}
+ test_shadowed_name() async {
+ addTestSource('var a; class A { var a; m() { ^ } }');
+ await computeSuggestions();
+ assertNotSuggested('a');
+ }
+
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