Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 cache = new DartCompletionCache(context, testSource); | 64 cache = new DartCompletionCache(context, testSource); |
| 65 request = new DartCompletionRequest( | 65 request = new DartCompletionRequest( |
| 66 context, | 66 context, |
| 67 searchEngine, | 67 searchEngine, |
| 68 testSource, | 68 testSource, |
| 69 completionOffset, | 69 completionOffset, |
| 70 cache, | 70 cache, |
| 71 new CompletionPerformance()); | 71 new CompletionPerformance()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { | |
| 75 expect(suggestion.parameterNames, isNull); | |
| 76 expect(suggestion.parameterTypes, isNull); | |
| 77 expect(suggestion.requiredParameterCount, isNull); | |
| 78 expect(suggestion.hasNamedParameters, isNull); | |
| 79 } | |
| 80 | |
| 74 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { | 81 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { |
| 75 if (kind == null) { | 82 if (kind == null) { |
| 76 if (request.suggestions.length > 0) { | 83 if (request.suggestions.length > 0) { |
| 77 failedCompletion('Expected no suggestions', request.suggestions); | 84 failedCompletion('Expected no suggestions', request.suggestions); |
| 78 } | 85 } |
| 79 return; | 86 return; |
| 80 } | 87 } |
| 81 CompletionSuggestion suggestion = request.suggestions.firstWhere( | 88 CompletionSuggestion suggestion = request.suggestions.firstWhere( |
| 82 (CompletionSuggestion cs) => cs.kind == kind, | 89 (CompletionSuggestion cs) => cs.kind == kind, |
| 83 orElse: () => null); | 90 orElse: () => null); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 expect(element, isNotNull); | 213 expect(element, isNotNull); |
| 207 expect(element.kind, equals(protocol.ElementKind.FIELD)); | 214 expect(element.kind, equals(protocol.ElementKind.FIELD)); |
| 208 expect(element.name, equals(name)); | 215 expect(element.name, equals(name)); |
| 209 expect(element.parameters, isNull); | 216 expect(element.parameters, isNull); |
| 210 // The returnType represents the type of a field | 217 // The returnType represents the type of a field |
| 211 expect(element.returnType, type != null ? type : 'dynamic'); | 218 expect(element.returnType, type != null ? type : 'dynamic'); |
| 212 return cs; | 219 return cs; |
| 213 } | 220 } |
| 214 | 221 |
| 215 CompletionSuggestion assertSuggestFunction(String name, String returnType, | 222 CompletionSuggestion assertSuggestFunction(String name, String returnType, |
| 216 bool isDeprecated, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 223 [bool isDeprecated = false, int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 217 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 224 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 218 CompletionSuggestion cs = assertSuggest( | 225 CompletionSuggestion cs = assertSuggest( |
| 219 name, | 226 name, |
| 220 csKind: kind, | 227 csKind: kind, |
| 221 relevance: relevance, | 228 relevance: relevance, |
| 222 isDeprecated: isDeprecated); | 229 isDeprecated: isDeprecated); |
| 223 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 230 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 224 protocol.Element element = cs.element; | 231 protocol.Element element = cs.element; |
| 225 expect(element, isNotNull); | 232 expect(element, isNotNull); |
| 226 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); | 233 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 assertNotSuggested('HtmlElement'); | 1298 assertNotSuggested('HtmlElement'); |
| 1292 }); | 1299 }); |
| 1293 } | 1300 } |
| 1294 | 1301 |
| 1295 test_Block_inherited_imported() { | 1302 test_Block_inherited_imported() { |
| 1296 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | 1303 // Block BlockFunctionBody MethodDeclaration ClassDeclaration |
| 1297 addSource('/testB.dart', ''' | 1304 addSource('/testB.dart', ''' |
| 1298 lib B; | 1305 lib B; |
| 1299 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } | 1306 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } |
| 1300 class E extends F { var e1; e2() { } } | 1307 class E extends F { var e1; e2() { } } |
| 1301 class I { int i1; i2() { } get e1; } | 1308 class I { int i1; i2() { } } |
|
Paul Berry
2015/01/13 00:02:47
I'm curious why this getter was removed.
danrubel
2015/01/13 14:19:59
Oops. Forgot to add a comment about that. Done.
| |
| 1302 class M { var m1; int m2() { } }'''); | 1309 class M { var m1; int m2() { } }'''); |
| 1303 addTestSource(''' | 1310 addTestSource(''' |
| 1304 import "/testB.dart"; | 1311 import "/testB.dart"; |
| 1305 class A extends E implements I with M {a() {^}}'''); | 1312 class A extends E implements I with M {a() {^}}'''); |
| 1306 computeFast(); | 1313 computeFast(); |
| 1307 return computeFull((bool result) { | 1314 return computeFull((bool result) { |
| 1308 assertSuggestImportedField('e1', null); | 1315 assertSuggestImportedField('e1', null); |
| 1309 assertSuggestImportedField('f1', null); | 1316 assertSuggestImportedField('f1', null); |
| 1310 assertSuggestImportedField('i1', 'int'); | 1317 assertSuggestImportedField('i1', 'int'); |
| 1311 assertSuggestImportedField('m1', null); | 1318 assertSuggestImportedField('m1', null); |
| 1312 assertSuggestImportedGetter('f3', null); | 1319 assertSuggestImportedGetter('f3', null); |
| 1313 assertSuggestImportedSetter('f4'); | 1320 assertSuggestImportedSetter('f4'); |
| 1314 //TODO (danrubel) include declared type in suggestion | 1321 assertSuggestImportedMethod('e2', 'E', null); |
| 1315 assertSuggestImportedMethod('e2', null, null); | 1322 assertSuggestImportedMethod('f2', 'F', null); |
| 1316 assertSuggestImportedMethod('f2', null, null); | 1323 assertSuggestImportedMethod('i2', 'I', null); |
| 1317 assertSuggestImportedMethod('i2', null, null); | |
| 1318 //assertSuggestImportedMethod('m2', null, null); | 1324 //assertSuggestImportedMethod('m2', null, null); |
| 1319 assertNotSuggested('=='); | 1325 assertNotSuggested('=='); |
| 1320 }); | 1326 }); |
| 1321 } | 1327 } |
| 1322 | 1328 |
| 1323 test_Block_inherited_local() { | 1329 test_Block_inherited_local() { |
| 1324 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | 1330 // Block BlockFunctionBody MethodDeclaration ClassDeclaration |
| 1325 addTestSource(''' | 1331 addTestSource(''' |
| 1326 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } | 1332 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } |
| 1327 class E extends F { var e1; e2() { } } | 1333 class E extends F { var e1; e2() { } } |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2571 assertNotSuggested('bar2'); | 2577 assertNotSuggested('bar2'); |
| 2572 assertNotSuggested('_B'); | 2578 assertNotSuggested('_B'); |
| 2573 assertSuggestLocalClass('Y'); | 2579 assertSuggestLocalClass('Y'); |
| 2574 assertSuggestLocalClass('C'); | 2580 assertSuggestLocalClass('C'); |
| 2575 assertSuggestLocalVariable('f', null); | 2581 assertSuggestLocalVariable('f', null); |
| 2576 assertNotSuggested('x'); | 2582 assertNotSuggested('x'); |
| 2577 assertNotSuggested('e'); | 2583 assertNotSuggested('e'); |
| 2578 }); | 2584 }); |
| 2579 } | 2585 } |
| 2580 } | 2586 } |
| OLD | NEW |