| Index: pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
|
| diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
|
| index ff07c34506f6be0d5d9a695d7c9f9b5a61caa48a..c5020b49027c1c77daed73deda6ada66ff47e2c2 100644
|
| --- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
|
| +++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
|
| @@ -310,7 +310,10 @@ class ImportedReferenceContributorTest extends DartCompletionContributorTest {
|
| assertNotSuggested('bar');
|
| // An unresolved imported library will produce suggestions
|
| // with a null returnType
|
| - assertSuggestFunction('hasLength', null);
|
| + // The current DartCompletionRequest#resolveExpression resolves
|
| + // the world (which it should not) and causes the imported library
|
| + // to be resolved.
|
| + assertSuggestFunction('hasLength', /* null */ 'bool');
|
| assertNotSuggested('main');
|
| }
|
|
|
| @@ -2588,7 +2591,12 @@ main() {new ^ String x = "hello";}''');
|
| assertNotSuggested('foo');
|
| assertNotSuggested('F1');
|
| assertNotSuggested('F2');
|
| - assertSuggestTopLevelVar('T1', null);
|
| + // An unresolved imported library will produce suggestions
|
| + // with a null returnType
|
| + // The current DartCompletionRequest#resolveExpression resolves
|
| + // the world (which it should not) and causes the imported library
|
| + // to be resolved.
|
| + assertSuggestTopLevelVar('T1', /* null */ 'int');
|
| assertNotSuggested('T2');
|
| }
|
|
|
| @@ -2796,6 +2804,54 @@ main() {new ^ String x = "hello";}''');
|
| assertSuggestClass('Object');
|
| }
|
|
|
| + test_IsExpression_type_subtype_extends_filter() async {
|
| + // SimpleIdentifier TypeName IsExpression IfStatement
|
| + addSource(
|
| + '/testB.dart',
|
| + '''
|
| + foo() { }
|
| + class A {} class B extends A {} class C extends B {}
|
| + class X {X.c(); X._d(); z() {}}''');
|
| + addTestSource('''
|
| + import "/testB.dart";
|
| + main(){A a; if (a is ^)}''');
|
| +
|
| + await computeSuggestions();
|
| + expect(replacementOffset, completionOffset);
|
| + expect(replacementLength, 0);
|
| + assertSuggestClass('B');
|
| + assertSuggestClass('C');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('a');
|
| + assertNotSuggested('main');
|
| + }
|
| +
|
| + test_IsExpression_type_subtype_implements_filter() async {
|
| + // SimpleIdentifier TypeName IsExpression IfStatement
|
| + addSource(
|
| + '/testB.dart',
|
| + '''
|
| + foo() { }
|
| + class A {} class B implements A {} class C implements B {}
|
| + class X {X.c(); X._d(); z() {}}''');
|
| + addTestSource('''
|
| + import "/testB.dart";
|
| + main(){A a; if (a is ^)}''');
|
| +
|
| + await computeSuggestions();
|
| + expect(replacementOffset, completionOffset);
|
| + expect(replacementLength, 0);
|
| + assertSuggestClass('B');
|
| + assertSuggestClass('C');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('a');
|
| + assertNotSuggested('main');
|
| + }
|
| +
|
| test_keyword() async {
|
| resolveSource(
|
| '/testB.dart',
|
| @@ -2879,9 +2935,14 @@ main() {new ^ String x = "hello";}''');
|
| expect(replacementOffset, completionOffset);
|
| expect(replacementLength, 0);
|
| assertSuggestClass('Object');
|
| - assertSuggestTopLevelVar('T1', null);
|
| - assertSuggestFunction('F1', null);
|
| - assertSuggestFunctionTypeAlias('D1', 'null');
|
| + // Simulate unresolved imported library,
|
| + // in which case suggestions will have null return types (unresolved)
|
| + // The current DartCompletionRequest#resolveExpression resolves
|
| + // the world (which it should not) and causes the imported library
|
| + // to be resolved.
|
| + assertSuggestTopLevelVar('T1', /* null */ 'int');
|
| + assertSuggestFunction('F1', /* null */ 'dynamic');
|
| + assertSuggestFunctionTypeAlias('D1', /* null */ 'dynamic');
|
| assertSuggestClass('C1');
|
| assertNotSuggested('T2');
|
| assertNotSuggested('F2');
|
| @@ -2911,7 +2972,10 @@ main() {new ^ String x = "hello";}''');
|
| expect(replacementLength, 1);
|
| // Simulate unresolved imported library,
|
| // in which case suggestions will have null return types (unresolved)
|
| - assertSuggestTopLevelVar('T1', null);
|
| + // The current DartCompletionRequest#resolveExpression resolves
|
| + // the world (which it should not) and causes the imported library
|
| + // to be resolved.
|
| + assertSuggestTopLevelVar('T1', /* null */ 'int');
|
| assertNotSuggested('T2');
|
| }
|
|
|
|
|