| Index: pkg/analysis_server/test/services/completion/imported_computer_test.dart
|
| diff --git a/pkg/analysis_server/test/services/completion/imported_computer_test.dart b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
|
| index a1216a90e0929ed08a866bbc8ad8c42d63f5302b..56d574875b2ce80fd78eb864af427ff5c40fa111 100644
|
| --- a/pkg/analysis_server/test/services/completion/imported_computer_test.dart
|
| +++ b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
|
| @@ -6,9 +6,9 @@ library test.services.completion.toplevel;
|
|
|
| import 'package:analysis_server/src/protocol.dart';
|
| import 'package:analysis_server/src/services/completion/imported_computer.dart';
|
| -import '../../reflective_tests.dart';
|
| import 'package:unittest/unittest.dart';
|
|
|
| +import '../../reflective_tests.dart';
|
| import 'completion_test_util.dart';
|
|
|
| main() {
|
| @@ -25,194 +25,274 @@ class ImportedTypeComputerTest extends AbstractCompletionTest {
|
| computer = new ImportedComputer();
|
| }
|
|
|
| - test_class() {
|
| - addSource('/testA.dart', 'class A {int x;} class _B { }');
|
| - addTestSource('import "/testA.dart"; class C {foo(){^}}');
|
| - return computeFull().then((_) {
|
| + test_Block_class() {
|
| + // Block BlockFunctionBody MethodDeclaration ClassDeclaration
|
| + addSource('/testAB.dart', '''
|
| + class A {int x;}
|
| + class _B { }''');
|
| + addSource('/testCD.dart', '''
|
| + class C { }
|
| + class D { }''');
|
| + addSource('/testEEF.dart', '''
|
| + class EE { }
|
| + class F { }''');
|
| + addSource('/testG.dart', 'class G { }');
|
| + addSource('/testH.dart', 'class H { }'); // not imported
|
| + addTestSource('''
|
| + import "/testAB.dart";
|
| + import "/testCD.dart" hide D;
|
| + import "/testEEF.dart" show EE;
|
| + import "/testG.dart" as g;
|
| + class X {foo(){^}}''');
|
| + // pass true for full analysis to pick up unimported source
|
| + return computeFull(true).then((_) {
|
| assertSuggestClass('A');
|
| assertNotSuggested('x');
|
| assertNotSuggested('_B');
|
| + assertSuggestClass('C');
|
| + assertNotSuggested('D');
|
| + assertSuggestClass('EE');
|
| + assertNotSuggested('F');
|
| + // Don't suggest library prefix as it is suggested by local computer
|
| + // TODO (danrubel) modify so that imported_computer handles
|
| + // all aspects of import statement
|
| + assertNotSuggested('g');
|
| + assertNotSuggested('G');
|
| + assertSuggestClass('H', CompletionRelevance.LOW);
|
| // Should not suggest compilation unit elements
|
| // which are returned by the LocalComputer
|
| - assertNotSuggested('C');
|
| + assertNotSuggested('X');
|
| + assertSuggestClass('Object');
|
| + // TODO (danrubel) suggest HtmlElement as low relevance
|
| + assertNotSuggested('HtmlElement');
|
| });
|
| }
|
|
|
| - test_function() {
|
| - addSource('/testA.dart', '@deprecated A() {int x;} _B() {}');
|
| - addTestSource('import "/testA.dart"; class C {foo(){^}}');
|
| + test_Block_function() {
|
| + addSource('/testA.dart', '''
|
| + export "dart:math" hide sin;
|
| + @deprecated A() {int x;}
|
| + _B() {}''');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class X {foo(){^}}''');
|
| return computeFull().then((_) {
|
| assertSuggestFunction('A', null, true);
|
| assertNotSuggested('x');
|
| assertNotSuggested('_B');
|
| + // TODO (danrubel) should suggest exported elements from imported lib
|
| + //assertSuggestFunction('cos', 'num', false);
|
| + assertNotSuggested('cos');
|
| + assertNotSuggested('sin');
|
| // Should not suggest compilation unit elements
|
| // which are returned by the LocalComputer
|
| - assertNotSuggested('C');
|
| + assertNotSuggested('X');
|
| });
|
| }
|
|
|
| - test_class_importHide() {
|
| - addSource('/testA.dart', 'class A { } class B { }');
|
| - addTestSource('import "/testA.dart" hide ^; class C {}');
|
| - return computeFull().then((_) {
|
| - assertSuggestClass('A');
|
| - assertSuggestClass('B');
|
| - assertNotSuggested('Object');
|
| + test_Block_topLevelVar() {
|
| + // Block BlockFunctionBody MethodDeclaration
|
| + addSource('/testA.dart', '''
|
| + String T1;
|
| + var _T2;''');
|
| + addSource('/testB.dart', /* not imported */ '''
|
| + int T3;
|
| + var _T4;''');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {foo(){^}}''');
|
| + // pass true for full analysis to pick up unimported source
|
| + return computeFull(true).then((_) {
|
| + assertSuggestTopLevelVar('T1', 'String');
|
| + assertNotSuggested('_T2');
|
| + assertSuggestTopLevelVar('T3', 'int', CompletionRelevance.LOW);
|
| + assertNotSuggested('_T4');
|
| });
|
| }
|
|
|
| - test_class_importShow() {
|
| - addSource('/testA.dart', 'class A { } class B { }');
|
| - addTestSource('import "/testA.dart" show ^; class C {}');
|
| + test_ExpressionStatement_class() {
|
| + // SimpleIdentifier ExpressionStatement Block
|
| + addSource('/testA.dart', '''
|
| + class A {int x;}
|
| + class _B { }''');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {foo(){O^}}''');
|
| return computeFull().then((_) {
|
| - // only suggest elements listed in show combinator
|
| assertSuggestClass('A');
|
| - assertSuggestClass('B');
|
| - assertNotSuggested('Object');
|
| + assertNotSuggested('x');
|
| + assertNotSuggested('_B');
|
| + // Should not suggest compilation unit elements
|
| + // which are returned by the LocalComputer
|
| + assertNotSuggested('C');
|
| });
|
| }
|
|
|
| - test_class_importShowWithPart() {
|
| - addSource('/testB.dart', 'part of libA; class B { }');
|
| - addSource('/testA.dart', 'part "/testB.dart"; class A { }');
|
| - addTestSource('import "/testA.dart" show ^; class C {}');
|
| + test_ExpressionStatement_name() {
|
| + // ExpressionStatement Block BlockFunctionBody MethodDeclaration
|
| + addSource('/testA.dart', '''
|
| + B T1;
|
| + class B{}''');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {a() {C ^}}''');
|
| return computeFull().then((_) {
|
| - // only suggest elements listed in show combinator
|
| - assertSuggestClass('A');
|
| - assertSuggestClass('B');
|
| - assertNotSuggested('Object');
|
| + assertNotSuggested('T1');
|
| });
|
| }
|
|
|
| - test_class_importedWithHide() {
|
| - addSource('/testA.dart', 'class A { } class B { }');
|
| - addTestSource('import "/testA.dart" hide B; class C {foo(){^}}');
|
| + test_FieldDeclaration_name() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // FieldDeclaration
|
| + addSource('/testA.dart', 'class A { }');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {A ^}''');
|
| return computeFull().then((_) {
|
| - // exclude elements listed in hide combinator
|
| - assertSuggestClass('A');
|
| - assertNotSuggested('B');
|
| - assertSuggestClass('Object');
|
| + assertNotSuggested('A');
|
| });
|
| }
|
|
|
| - test_class_importedWithPrefix() {
|
| + test_FieldDeclaration_name_varType() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // FieldDeclaration
|
| addSource('/testA.dart', 'class A { }');
|
| - addTestSource('import "/testA.dart" as foo; class C {foo(){^}}');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {var ^}''');
|
| return computeFull().then((_) {
|
| - // do not suggest types imported with prefix
|
| assertNotSuggested('A');
|
| - // do not suggest prefix as it is suggested by LocalComputer
|
| - assertNotSuggested('foo');
|
| });
|
| }
|
|
|
| - test_class_importedWithShow() {
|
| - addSource('/testA.dart', 'class A { } class B { }');
|
| - addTestSource('import "/testA.dart" show A; class C {foo(){^}}');
|
| + test_HideCombinator_class() {
|
| + // SimpleIdentifier HideCombinator ImportDirective
|
| + addSource('/testAB.dart', '''
|
| + library libAB;
|
| + part '/partAB.dart';
|
| + class A { }
|
| + class B { }''');
|
| + addSource('/partAB.dart', '''
|
| + part of libAB;
|
| + class PB { }''');
|
| + addSource('/testCD.dart', '''
|
| + class C { }
|
| + class D { }''');
|
| + addTestSource('''
|
| + import "/testAB.dart" hide ^;
|
| + import "/testCD.dart";
|
| + class X {}''');
|
| return computeFull().then((_) {
|
| - // only suggest elements listed in show combinator
|
| assertSuggestClass('A');
|
| - assertNotSuggested('B');
|
| - assertSuggestClass('Object');
|
| - });
|
| - }
|
| -
|
| - test_class_notImported() {
|
| - addSource('/testA.dart', 'class A {int x;} class _B { }');
|
| - addTestSource('class C {foo(){^}}');
|
| - return computeFull(true).then((_) {
|
| - assertSuggestClass('A', CompletionRelevance.LOW);
|
| - assertNotSuggested('x');
|
| - assertNotSuggested('_B');
|
| - });
|
| - }
|
| -
|
| - test_dartCore() {
|
| - addTestSource('class C {foo(){^}}');
|
| - return computeFull().then((_) {
|
| - assertSuggestClass('Object');
|
| - assertNotSuggested('HtmlElement');
|
| + assertSuggestClass('B');
|
| + assertSuggestClass('PB');
|
| + assertNotSuggested('C');
|
| + assertNotSuggested('D');
|
| + assertNotSuggested('Object');
|
| });
|
| }
|
|
|
| - test_dartHtml() {
|
| - addTestSource('import "dart:html"; class C {foo(){^}}');
|
| + test_ImportDirective_dart() {
|
| + // SimpleStringLiteral ImportDirective
|
| + addTestSource('''
|
| + import "dart^";
|
| + main() {}''');
|
| return computeFull().then((_) {
|
| - assertSuggestClass('Object');
|
| - assertSuggestClass('HtmlElement');
|
| + assertNotSuggested('Object');
|
| });
|
| }
|
|
|
| - test_field_name() {
|
| - addSource('/testA.dart', 'class A { }');
|
| - addTestSource('import "/testA.dart"; class C {A ^}');
|
| + test_ShowCombinator_class() {
|
| + // SimpleIdentifier ShowCombinator ImportDirective
|
| + addSource('/testAB.dart', '''
|
| + class A { }
|
| + class B { }''');
|
| + addSource('/testCD.dart', '''
|
| + class C { }
|
| + class D { }''');
|
| + addTestSource('''
|
| + import "/testAB.dart" show ^;
|
| + import "/testCD.dart";
|
| + class X {}''');
|
| return computeFull().then((_) {
|
| - assertNotSuggested('A');
|
| + assertSuggestClass('A');
|
| + assertSuggestClass('B');
|
| + assertNotSuggested('C');
|
| + assertNotSuggested('D');
|
| + assertNotSuggested('Object');
|
| });
|
| }
|
|
|
| - test_field_name2() {
|
| - addSource('/testA.dart', 'class A { }');
|
| - addTestSource('import "/testA.dart"; class C {var ^}');
|
| + test_TopLevelVariableDeclaration_name() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // TopLevelVariableDeclaration
|
| + addSource('/testA.dart', 'class B { };');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {} B ^''');
|
| return computeFull().then((_) {
|
| - assertNotSuggested('A');
|
| + assertNotSuggested('B');
|
| });
|
| }
|
|
|
| - test_local_name() {
|
| - addSource('/testA.dart', 'B T1; class B{}');
|
| - addTestSource('import "/testA.dart"; class C {a() {C ^}}');
|
| + test_TopLevelVariableDeclaration_name_untyped() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // TopLevelVariableDeclaration
|
| + addSource('/testA.dart', 'class B { };');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {} var ^''');
|
| return computeFull().then((_) {
|
| - assertNotSuggested('T1');
|
| + assertNotSuggested('B');
|
| });
|
| }
|
|
|
| - test_local_name2() {
|
| + test_VariableDeclaration_name() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // VariableDeclarationStatement Block
|
| addSource('/testA.dart', 'var T1;');
|
| - addTestSource('import "/testA.dart"; class C {a() {var ^}}');
|
| - return computeFull().then((_) {
|
| - assertNotSuggested('T1');
|
| - });
|
| - }
|
| -
|
| - test_import_dart() {
|
| - addTestSource('import "dart^"; main() {}');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {a() {var ^}}''');
|
| return computeFull().then((_) {
|
| assertNotSuggested('T1');
|
| });
|
| }
|
|
|
| - test_topLevelVar() {
|
| - addSource('/testA.dart', 'String T1; var _T2;');
|
| - addTestSource('import "/testA.dart"; class C {foo(){^}}');
|
| - return computeFull().then((_) {
|
| - assertSuggestTopLevelVar('T1', 'String');
|
| - assertNotSuggested('_T2');
|
| - });
|
| - }
|
| -
|
| - test_topLevelVar_name() {
|
| - addSource('/testA.dart', 'class B { };');
|
| - addTestSource('import "/testA.dart"; class C {} B ^');
|
| + // TODO (danrubel) implement
|
| + xtest_InstanceCreationExpression() {
|
| + // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
|
| + addSource('/testA.dart', '''
|
| + class A {int x;}
|
| + B() { }''');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {foo(){new ^}}''');
|
| return computeFull().then((_) {
|
| + assertSuggestClass('A');
|
| + assertNotSuggested('x');
|
| assertNotSuggested('B');
|
| + // Should not suggest compilation unit elements
|
| + // which are returned by the LocalComputer
|
| + assertNotSuggested('C');
|
| });
|
| }
|
|
|
| - test_topLevelVar_name2() {
|
| - addSource('/testA.dart', 'class B { };');
|
| - addTestSource('import "/testA.dart"; class C {} var ^');
|
| + // TODO (danrubel) implement
|
| + xtest_VariableDeclarationStatement_RHS() {
|
| + // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| + // VariableDeclarationStatement
|
| + addSource('/testA.dart', 'class A {int x;} class _B { }');
|
| + addTestSource('''
|
| + import "/testA.dart";
|
| + class C {foo(){var e = ^}}''');
|
| return computeFull().then((_) {
|
| - assertNotSuggested('B');
|
| - });
|
| - }
|
| -
|
| - test_topLevelVar_notImported() {
|
| - addSource('/testA.dart', 'var T1; var _T2;');
|
| - addTestSource('class C {foo(){^}}');
|
| - return computeFull(true).then((_) {
|
| - assertSuggestTopLevelVar('T1', null, CompletionRelevance.LOW);
|
| - assertNotSuggested('_T2');
|
| + assertSuggestClass('A');
|
| + assertNotSuggested('x');
|
| + assertNotSuggested('_B');
|
| + // Should not suggest compilation unit elements
|
| + // which are returned by the LocalComputer
|
| + assertNotSuggested('C');
|
| });
|
| }
|
| }
|
|
|