| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 486 bool computeFast() { | 486 bool computeFast() { |
| 487 _computeFastCalled = true; | 487 _computeFastCalled = true; |
| 488 _completionManager = new DartCompletionManager( | 488 _completionManager = new DartCompletionManager( |
| 489 context, | 489 context, |
| 490 searchEngine, | 490 searchEngine, |
| 491 testSource, | 491 testSource, |
| 492 cache, | 492 cache, |
| 493 [computer]); | 493 [computer]); |
| 494 var result = _completionManager.computeFast(request); | 494 var result = _completionManager.computeFast(request); |
| 495 if (request.replacementOffset == null) { | 495 expect(request.replacementOffset, isNotNull); |
| 496 fail('expected non null'); | 496 expect(request.replacementLength, isNotNull); |
| 497 } | |
| 498 return result.isEmpty; | 497 return result.isEmpty; |
| 499 } | 498 } |
| 500 | 499 |
| 501 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | 500 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { |
| 502 if (!_computeFastCalled) { | 501 if (!_computeFastCalled) { |
| 503 expect(computeFast(), isFalse); | 502 expect(computeFast(), isFalse); |
| 504 } | 503 } |
| 505 | 504 |
| 506 // Index SDK | 505 // Index SDK |
| 507 for (Source librarySource in context.librarySources) { | 506 for (Source librarySource in context.librarySources) { |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 return computeFull((bool result) { | 2129 return computeFull((bool result) { |
| 2131 expect(request.replacementOffset, completionOffset - 3); | 2130 expect(request.replacementOffset, completionOffset - 3); |
| 2132 expect(request.replacementLength, 3); | 2131 expect(request.replacementLength, 3); |
| 2133 assertNotSuggested('a'); | 2132 assertNotSuggested('a'); |
| 2134 assertNotSuggested('main'); | 2133 assertNotSuggested('main'); |
| 2135 assertSuggestLocalClass('A'); | 2134 assertSuggestLocalClass('A'); |
| 2136 assertSuggestImportedClass('Object'); | 2135 assertSuggestImportedClass('Object'); |
| 2137 }); | 2136 }); |
| 2138 } | 2137 } |
| 2139 | 2138 |
| 2139 test_keyword() { |
| 2140 addSource('/testB.dart', ''' |
| 2141 lib B; |
| 2142 int newT1; |
| 2143 int T1; |
| 2144 nowIsIt() { } |
| 2145 class X {factory X.c(); factory X._d(); z() {}}'''); |
| 2146 addTestSource(''' |
| 2147 import "/testB.dart"; |
| 2148 String newer() {} |
| 2149 var m; |
| 2150 main() {new^ X.c();}'''); |
| 2151 computeFast(); |
| 2152 return computeFull((bool result) { |
| 2153 expect(request.replacementOffset, completionOffset - 3); |
| 2154 expect(request.replacementLength, 3); |
| 2155 assertNotSuggested('c'); |
| 2156 assertNotSuggested('_d'); |
| 2157 // Imported suggestion are filtered by 1st character |
| 2158 assertSuggestImportedFunction('nowIsIt', null); |
| 2159 assertNotSuggested('T1'); |
| 2160 // TODO (danrubel) this really should be TopLevelVar not getter/setter |
| 2161 assertSuggestTopLevelVarGetterSetter('newT1', 'int'); |
| 2162 assertNotSuggested('z'); |
| 2163 assertSuggestLocalTopLevelVar('m', 'dynamic'); |
| 2164 assertSuggestLocalFunction('newer', 'String'); |
| 2165 }); |
| 2166 } |
| 2167 |
| 2140 test_Literal_string() { | 2168 test_Literal_string() { |
| 2141 // SimpleStringLiteral ExpressionStatement Block | 2169 // SimpleStringLiteral ExpressionStatement Block |
| 2142 addTestSource('class A {a() {"hel^lo"}}'); | 2170 addTestSource('class A {a() {"hel^lo"}}'); |
| 2143 computeFast(); | 2171 computeFast(); |
| 2144 return computeFull((bool result) { | 2172 return computeFull((bool result) { |
| 2145 assertNoSuggestions(); | 2173 assertNoSuggestions(); |
| 2146 }); | 2174 }); |
| 2147 } | 2175 } |
| 2148 | 2176 |
| 2149 test_MethodDeclaration_body_getters() { | 2177 test_MethodDeclaration_body_getters() { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 assertNotSuggested('bar2'); | 2784 assertNotSuggested('bar2'); |
| 2757 assertNotSuggested('_B'); | 2785 assertNotSuggested('_B'); |
| 2758 assertSuggestLocalClass('Y'); | 2786 assertSuggestLocalClass('Y'); |
| 2759 assertSuggestLocalClass('C'); | 2787 assertSuggestLocalClass('C'); |
| 2760 assertSuggestLocalVariable('f', null); | 2788 assertSuggestLocalVariable('f', null); |
| 2761 assertNotSuggested('x'); | 2789 assertNotSuggested('x'); |
| 2762 assertNotSuggested('e'); | 2790 assertNotSuggested('e'); |
| 2763 }); | 2791 }); |
| 2764 } | 2792 } |
| 2765 } | 2793 } |
| OLD | NEW |