| Index: pkg/analysis_server/test/services/completion/completion_test_util.dart
|
| diff --git a/pkg/analysis_server/test/services/completion/completion_test_util.dart b/pkg/analysis_server/test/services/completion/completion_test_util.dart
|
| index e2af4d81fa83b3384eb3d230bb081bbd16e2a3ee..58f0005c004b32c0d73df4db5e524a16791aa03f 100644
|
| --- a/pkg/analysis_server/test/services/completion/completion_test_util.dart
|
| +++ b/pkg/analysis_server/test/services/completion/completion_test_util.dart
|
| @@ -42,7 +42,7 @@ abstract class AbstractCompletionTest extends AbstractContextTest {
|
| CompilationUnit testUnit;
|
| int completionOffset;
|
| AstNode completionNode;
|
| - bool _computeFastCalled = false;
|
| + bool computeFastResult;
|
| DartCompletionRequest request;
|
| DartCompletionCache cache;
|
| DartCompletionManager _completionManager;
|
| @@ -382,21 +382,27 @@ abstract class AbstractCompletionTest extends AbstractContextTest {
|
| }
|
|
|
| bool computeFast() {
|
| - _computeFastCalled = true;
|
| + expect(computeFastResult, isNull);
|
| _completionManager = new DartCompletionManager(context, searchEngine,
|
| testSource, cache, [contributor], new CommonUsageComputer({}));
|
| var result = _completionManager.computeFast(request);
|
| expect(request.replacementOffset, isNotNull);
|
| expect(request.replacementLength, isNotNull);
|
| - return result.isEmpty;
|
| + computeFastResult = result.isEmpty;
|
| + return computeFastResult;
|
| }
|
|
|
| Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
|
| - if (!_computeFastCalled) {
|
| - expect(computeFast(), isFalse);
|
| + if (computeFastResult == null) {
|
| + computeFast();
|
| + }
|
| + if (computeFastResult) {
|
| + assertFunction(true);
|
| + return new Future.value(true);
|
| + } else {
|
| + resolve(fullAnalysis);
|
| + return contributor.computeFull(request).then(assertFunction);
|
| }
|
| - resolve(fullAnalysis);
|
| - return contributor.computeFull(request).then(assertFunction);
|
| }
|
|
|
| void failedCompletion(String message,
|
| @@ -3624,6 +3630,161 @@ abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest {
|
| });
|
| }
|
|
|
| + test_ThisExpression_constructor_param() {
|
| + // SimpleIdentifier FieldFormalParameter FormalParameterList
|
| + addTestSource('''
|
| + main() { }
|
| + class I {X get f => new A();get _g => new A();}
|
| + class A implements I {
|
| + A(this.^) {}
|
| + A.z() {}
|
| + var b; X _c;
|
| + X get d => new A();get _e => new A();
|
| + // no semicolon between completion point and next statement
|
| + set s1(I x) {} set _s2(I x) {m(null);}
|
| + m(X x) {} I _n(X x) {}}
|
| + class X{}''');
|
| + computeFast();
|
| + return computeFull((bool result) {
|
| + expect(request.replacementOffset, completionOffset);
|
| + expect(request.replacementLength, 0);
|
| + assertSuggestInvocationField('b', null,
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertSuggestInvocationField('_c', 'X',
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertNotSuggested('d');
|
| + assertNotSuggested('_e');
|
| + assertNotSuggested('f');
|
| + assertNotSuggested('_g');
|
| + assertNotSuggested('m');
|
| + assertNotSuggested('_n');
|
| + assertNotSuggested('s1');
|
| + assertNotSuggested('_s2');
|
| + assertNotSuggested('z');
|
| + assertNotSuggested('I');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('==');
|
| + });
|
| + }
|
| +
|
| + test_ThisExpression_constructor_param2() {
|
| + // SimpleIdentifier FieldFormalParameter FormalParameterList
|
| + addTestSource('''
|
| + main() { }
|
| + class I {X get f => new A();get _g => new A();}
|
| + class A implements I {
|
| + A(this.b^) {}
|
| + A.z() {}
|
| + var b; X _c;
|
| + X get d => new A();get _e => new A();
|
| + // no semicolon between completion point and next statement
|
| + set s1(I x) {} set _s2(I x) {m(null);}
|
| + m(X x) {} I _n(X x) {}}
|
| + class X{}''');
|
| + computeFast();
|
| + return computeFull((bool result) {
|
| + expect(request.replacementOffset, completionOffset - 1);
|
| + expect(request.replacementLength, 1);
|
| + assertSuggestInvocationField('b', null,
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertSuggestInvocationField('_c', 'X',
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertNotSuggested('d');
|
| + assertNotSuggested('_e');
|
| + assertNotSuggested('f');
|
| + assertNotSuggested('_g');
|
| + assertNotSuggested('m');
|
| + assertNotSuggested('_n');
|
| + assertNotSuggested('s1');
|
| + assertNotSuggested('_s2');
|
| + assertNotSuggested('z');
|
| + assertNotSuggested('I');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('==');
|
| + });
|
| + }
|
| +
|
| + test_ThisExpression_constructor_param3() {
|
| + // SimpleIdentifier FieldFormalParameter FormalParameterList
|
| + addTestSource('''
|
| + main() { }
|
| + class I {X get f => new A();get _g => new A();}
|
| + class A implements I {
|
| + A(this.^b) {}
|
| + A.z() {}
|
| + var b; X _c;
|
| + X get d => new A();get _e => new A();
|
| + // no semicolon between completion point and next statement
|
| + set s1(I x) {} set _s2(I x) {m(null);}
|
| + m(X x) {} I _n(X x) {}}
|
| + class X{}''');
|
| + computeFast();
|
| + return computeFull((bool result) {
|
| + expect(request.replacementOffset, completionOffset);
|
| + expect(request.replacementLength, 1);
|
| + assertSuggestInvocationField('b', null,
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertSuggestInvocationField('_c', 'X',
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertNotSuggested('d');
|
| + assertNotSuggested('_e');
|
| + assertNotSuggested('f');
|
| + assertNotSuggested('_g');
|
| + assertNotSuggested('m');
|
| + assertNotSuggested('_n');
|
| + assertNotSuggested('s1');
|
| + assertNotSuggested('_s2');
|
| + assertNotSuggested('z');
|
| + assertNotSuggested('I');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('==');
|
| + });
|
| + }
|
| +
|
| + test_ThisExpression_constructor_param4() {
|
| + // SimpleIdentifier FieldFormalParameter FormalParameterList
|
| + addTestSource('''
|
| + main() { }
|
| + class I {X get f => new A();get _g => new A();}
|
| + class A implements I {
|
| + A(this.b, this.^) {}
|
| + A.z() {}
|
| + var b; X _c;
|
| + X get d => new A();get _e => new A();
|
| + // no semicolon between completion point and next statement
|
| + set s1(I x) {} set _s2(I x) {m(null);}
|
| + m(X x) {} I _n(X x) {}}
|
| + class X{}''');
|
| + computeFast();
|
| + return computeFull((bool result) {
|
| + expect(request.replacementOffset, completionOffset);
|
| + expect(request.replacementLength, 0);
|
| + assertNotSuggested('b');
|
| + assertSuggestInvocationField('_c', 'X',
|
| + relevance: DART_RELEVANCE_LOCAL_FIELD);
|
| + assertNotSuggested('d');
|
| + assertNotSuggested('_e');
|
| + assertNotSuggested('f');
|
| + assertNotSuggested('_g');
|
| + assertNotSuggested('m');
|
| + assertNotSuggested('_n');
|
| + assertNotSuggested('s1');
|
| + assertNotSuggested('_s2');
|
| + assertNotSuggested('z');
|
| + assertNotSuggested('I');
|
| + assertNotSuggested('A');
|
| + assertNotSuggested('X');
|
| + assertNotSuggested('Object');
|
| + assertNotSuggested('==');
|
| + });
|
| + }
|
| +
|
| test_TopLevelVariableDeclaration_typed_name() {
|
| // SimpleIdentifier VariableDeclaration VariableDeclarationList
|
| // TopLevelVariableDeclaration
|
|
|