| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library test.services.completion.util; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | |
| 10 show Element, ElementKind; | |
| 11 import 'package:analysis_server/plugin/protocol/protocol.dart' | |
| 12 hide Element, ElementKind; | |
| 13 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | |
| 14 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | |
| 15 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; | |
| 16 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | |
| 17 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | |
| 18 import 'package:analysis_server/src/services/completion/imported_reference_contr
ibutor.dart'; | |
| 19 import 'package:analysis_server/src/services/index/index.dart'; | |
| 20 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | |
| 21 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | |
| 22 import 'package:analyzer/dart/element/element.dart'; | |
| 23 import 'package:analyzer/src/generated/ast.dart'; | |
| 24 import 'package:analyzer/src/generated/engine.dart'; | |
| 25 import 'package:analyzer/src/generated/source.dart'; | |
| 26 import 'package:unittest/unittest.dart'; | |
| 27 | |
| 28 import '../../abstract_context.dart'; | |
| 29 | |
| 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | |
| 31 String c1 = s1.completion.toLowerCase(); | |
| 32 String c2 = s2.completion.toLowerCase(); | |
| 33 return c1.compareTo(c2); | |
| 34 } | |
| 35 | |
| 36 abstract class AbstractCompletionTest extends AbstractContextTest { | |
| 37 Index index; | |
| 38 SearchEngineImpl searchEngine; | |
| 39 DartCompletionContributor contributor; | |
| 40 String testFile = '/completionTest.dart'; | |
| 41 Source testSource; | |
| 42 CompilationUnit testUnit; | |
| 43 int completionOffset; | |
| 44 AstNode completionNode; | |
| 45 bool computeFastResult; | |
| 46 DartCompletionRequest request; | |
| 47 DartCompletionCache cache; | |
| 48 DartCompletionManager _completionManager; | |
| 49 | |
| 50 void addResolvedUnit(String file, String code) { | |
| 51 Source source = addSource(file, code); | |
| 52 CompilationUnit unit = resolveLibraryUnit(source); | |
| 53 index.index(context, unit); | |
| 54 } | |
| 55 | |
| 56 void addTestSource(String content) { | |
| 57 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); | |
| 58 completionOffset = content.indexOf('^'); | |
| 59 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | |
| 60 int nextOffset = content.indexOf('^', completionOffset + 1); | |
| 61 expect(nextOffset, equals(-1), reason: 'too many ^'); | |
| 62 content = content.substring(0, completionOffset) + | |
| 63 content.substring(completionOffset + 1); | |
| 64 testSource = addSource(testFile, content); | |
| 65 cache = new DartCompletionCache(context, testSource); | |
| 66 request = new DartCompletionRequest( | |
| 67 context, provider, searchEngine, testSource, completionOffset, cache); | |
| 68 } | |
| 69 | |
| 70 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { | |
| 71 expect(suggestion.parameterNames, isNull); | |
| 72 expect(suggestion.parameterTypes, isNull); | |
| 73 expect(suggestion.requiredParameterCount, isNull); | |
| 74 expect(suggestion.hasNamedParameters, isNull); | |
| 75 } | |
| 76 | |
| 77 void assertHasParameterInfo(CompletionSuggestion suggestion) { | |
| 78 expect(suggestion.parameterNames, isNotNull); | |
| 79 expect(suggestion.parameterTypes, isNotNull); | |
| 80 expect(suggestion.parameterNames.length, suggestion.parameterTypes.length); | |
| 81 expect(suggestion.requiredParameterCount, | |
| 82 lessThanOrEqualTo(suggestion.parameterNames.length)); | |
| 83 expect(suggestion.hasNamedParameters, isNotNull); | |
| 84 } | |
| 85 | |
| 86 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { | |
| 87 if (kind == null) { | |
| 88 if (request.suggestions.length > 0) { | |
| 89 failedCompletion('Expected no suggestions', request.suggestions); | |
| 90 } | |
| 91 return; | |
| 92 } | |
| 93 CompletionSuggestion suggestion = request.suggestions.firstWhere( | |
| 94 (CompletionSuggestion cs) => cs.kind == kind, | |
| 95 orElse: () => null); | |
| 96 if (suggestion != null) { | |
| 97 failedCompletion('did not expect completion: $completion\n $suggestion'); | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 CompletionSuggestion assertNotSuggested(String completion) { | |
| 102 CompletionSuggestion suggestion = request.suggestions.firstWhere( | |
| 103 (CompletionSuggestion cs) => cs.completion == completion, | |
| 104 orElse: () => null); | |
| 105 if (suggestion != null) { | |
| 106 failedCompletion('did not expect completion: $completion\n $suggestion'); | |
| 107 } | |
| 108 return null; | |
| 109 } | |
| 110 | |
| 111 CompletionSuggestion assertSuggest(String completion, | |
| 112 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, | |
| 113 int relevance: DART_RELEVANCE_DEFAULT, | |
| 114 String importUri, | |
| 115 protocol.ElementKind elemKind: null, | |
| 116 bool isDeprecated: false, | |
| 117 bool isPotential: false, | |
| 118 String elemFile, | |
| 119 int elemOffset}) { | |
| 120 CompletionSuggestion cs = | |
| 121 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); | |
| 122 if (cs == null) { | |
| 123 failedCompletion( | |
| 124 'expected $completion $csKind $elemKind', request.suggestions); | |
| 125 } | |
| 126 expect(cs.kind, equals(csKind)); | |
| 127 if (isDeprecated) { | |
| 128 expect(cs.relevance, equals(DART_RELEVANCE_LOW)); | |
| 129 } else { | |
| 130 expect(cs.relevance, equals(relevance)); | |
| 131 } | |
| 132 expect(cs.importUri, importUri); | |
| 133 expect(cs.selectionOffset, equals(completion.length)); | |
| 134 expect(cs.selectionLength, equals(0)); | |
| 135 expect(cs.isDeprecated, equals(isDeprecated)); | |
| 136 expect(cs.isPotential, equals(isPotential)); | |
| 137 if (cs.element != null) { | |
| 138 expect(cs.element.location, isNotNull); | |
| 139 expect(cs.element.location.file, isNotNull); | |
| 140 expect(cs.element.location.offset, isNotNull); | |
| 141 expect(cs.element.location.length, isNotNull); | |
| 142 expect(cs.element.location.startColumn, isNotNull); | |
| 143 expect(cs.element.location.startLine, isNotNull); | |
| 144 } | |
| 145 if (elemFile != null) { | |
| 146 expect(cs.element.location.file, elemFile); | |
| 147 } | |
| 148 if (elemOffset != null) { | |
| 149 expect(cs.element.location.offset, elemOffset); | |
| 150 } | |
| 151 return cs; | |
| 152 } | |
| 153 | |
| 154 CompletionSuggestion assertSuggestClass(String name, | |
| 155 {int relevance: DART_RELEVANCE_DEFAULT, | |
| 156 String importUri, | |
| 157 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 158 bool isDeprecated: false, | |
| 159 String elemFile, | |
| 160 int elemOffset}) { | |
| 161 CompletionSuggestion cs = assertSuggest(name, | |
| 162 csKind: kind, | |
| 163 relevance: relevance, | |
| 164 importUri: importUri, | |
| 165 isDeprecated: isDeprecated, | |
| 166 elemFile: elemFile, | |
| 167 elemOffset: elemOffset); | |
| 168 protocol.Element element = cs.element; | |
| 169 expect(element, isNotNull); | |
| 170 expect(element.kind, equals(protocol.ElementKind.CLASS)); | |
| 171 expect(element.name, equals(name)); | |
| 172 expect(element.parameters, isNull); | |
| 173 expect(element.returnType, isNull); | |
| 174 assertHasNoParameterInfo(cs); | |
| 175 return cs; | |
| 176 } | |
| 177 | |
| 178 CompletionSuggestion assertSuggestClassTypeAlias(String name, | |
| 179 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 180 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 181 CompletionSuggestion cs = | |
| 182 assertSuggest(name, csKind: kind, relevance: relevance); | |
| 183 protocol.Element element = cs.element; | |
| 184 expect(element, isNotNull); | |
| 185 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); | |
| 186 expect(element.name, equals(name)); | |
| 187 expect(element.parameters, isNull); | |
| 188 expect(element.returnType, isNull); | |
| 189 assertHasNoParameterInfo(cs); | |
| 190 return cs; | |
| 191 } | |
| 192 | |
| 193 CompletionSuggestion assertSuggestConstructor(String name, | |
| 194 {int relevance: DART_RELEVANCE_DEFAULT, | |
| 195 String importUri, | |
| 196 int elemOffset}) { | |
| 197 CompletionSuggestion cs = assertSuggest(name, | |
| 198 relevance: relevance, importUri: importUri, elemOffset: elemOffset); | |
| 199 protocol.Element element = cs.element; | |
| 200 expect(element, isNotNull); | |
| 201 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); | |
| 202 int index = name.indexOf('.'); | |
| 203 expect(element.name, index >= 0 ? name.substring(index + 1) : ''); | |
| 204 return cs; | |
| 205 } | |
| 206 | |
| 207 CompletionSuggestion assertSuggestField(String name, String type, | |
| 208 {int relevance: DART_RELEVANCE_DEFAULT, | |
| 209 String importUri, | |
| 210 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 211 bool isDeprecated: false}) { | |
| 212 CompletionSuggestion cs = assertSuggest(name, | |
| 213 csKind: kind, | |
| 214 relevance: relevance, | |
| 215 importUri: importUri, | |
| 216 elemKind: protocol.ElementKind.FIELD, | |
| 217 isDeprecated: isDeprecated); | |
| 218 // The returnType represents the type of a field | |
| 219 expect(cs.returnType, type != null ? type : 'dynamic'); | |
| 220 protocol.Element element = cs.element; | |
| 221 expect(element, isNotNull); | |
| 222 expect(element.kind, equals(protocol.ElementKind.FIELD)); | |
| 223 expect(element.name, equals(name)); | |
| 224 expect(element.parameters, isNull); | |
| 225 // The returnType represents the type of a field | |
| 226 expect(element.returnType, type != null ? type : 'dynamic'); | |
| 227 assertHasNoParameterInfo(cs); | |
| 228 return cs; | |
| 229 } | |
| 230 | |
| 231 CompletionSuggestion assertSuggestFunction(String name, String returnType, | |
| 232 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 233 bool deprecated: false, | |
| 234 int relevance: DART_RELEVANCE_DEFAULT, | |
| 235 String importUri}) { | |
| 236 CompletionSuggestion cs = assertSuggest(name, | |
| 237 csKind: kind, | |
| 238 relevance: relevance, | |
| 239 importUri: importUri, | |
| 240 isDeprecated: deprecated); | |
| 241 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 242 protocol.Element element = cs.element; | |
| 243 expect(element, isNotNull); | |
| 244 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); | |
| 245 expect(element.name, equals(name)); | |
| 246 expect(element.isDeprecated, equals(deprecated)); | |
| 247 String param = element.parameters; | |
| 248 expect(param, isNotNull); | |
| 249 expect(param[0], equals('(')); | |
| 250 expect(param[param.length - 1], equals(')')); | |
| 251 expect(element.returnType, | |
| 252 equals(returnType != null ? returnType : 'dynamic')); | |
| 253 assertHasParameterInfo(cs); | |
| 254 return cs; | |
| 255 } | |
| 256 | |
| 257 CompletionSuggestion assertSuggestFunctionTypeAlias( | |
| 258 String name, String returnType, bool isDeprecated, | |
| 259 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 260 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION, | |
| 261 String importUri]) { | |
| 262 CompletionSuggestion cs = assertSuggest(name, | |
| 263 csKind: kind, | |
| 264 relevance: relevance, | |
| 265 importUri: importUri, | |
| 266 isDeprecated: isDeprecated); | |
| 267 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 268 protocol.Element element = cs.element; | |
| 269 expect(element, isNotNull); | |
| 270 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS)); | |
| 271 expect(element.name, equals(name)); | |
| 272 expect(element.isDeprecated, equals(isDeprecated)); | |
| 273 // TODO (danrubel) Determine why params are null | |
| 274 // String param = element.parameters; | |
| 275 // expect(param, isNotNull); | |
| 276 // expect(param[0], equals('(')); | |
| 277 // expect(param[param.length - 1], equals(')')); | |
| 278 expect(element.returnType, | |
| 279 equals(returnType != null ? returnType : 'dynamic')); | |
| 280 // TODO (danrubel) Determine why param info is missing | |
| 281 // assertHasParameterInfo(cs); | |
| 282 return cs; | |
| 283 } | |
| 284 | |
| 285 CompletionSuggestion assertSuggestGetter(String name, String returnType, | |
| 286 {int relevance: DART_RELEVANCE_DEFAULT, | |
| 287 String importUri, | |
| 288 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 289 bool isDeprecated: false}) { | |
| 290 CompletionSuggestion cs = assertSuggest(name, | |
| 291 csKind: kind, | |
| 292 relevance: relevance, | |
| 293 importUri: importUri, | |
| 294 elemKind: protocol.ElementKind.GETTER, | |
| 295 isDeprecated: isDeprecated); | |
| 296 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 297 protocol.Element element = cs.element; | |
| 298 expect(element, isNotNull); | |
| 299 expect(element.kind, equals(protocol.ElementKind.GETTER)); | |
| 300 expect(element.name, equals(name)); | |
| 301 expect(element.parameters, isNull); | |
| 302 expect(element.returnType, | |
| 303 equals(returnType != null ? returnType : 'dynamic')); | |
| 304 assertHasNoParameterInfo(cs); | |
| 305 return cs; | |
| 306 } | |
| 307 | |
| 308 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, | |
| 309 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 310 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 311 // Library prefix should only be suggested by ImportedReferenceContributor | |
| 312 return assertNotSuggested(prefix); | |
| 313 } | |
| 314 | |
| 315 CompletionSuggestion assertSuggestMethod( | |
| 316 String name, String declaringType, String returnType, | |
| 317 {int relevance: DART_RELEVANCE_DEFAULT, | |
| 318 String importUri, | |
| 319 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 320 bool isDeprecated: false}) { | |
| 321 CompletionSuggestion cs = assertSuggest(name, | |
| 322 csKind: kind, | |
| 323 relevance: relevance, | |
| 324 importUri: importUri, | |
| 325 isDeprecated: isDeprecated); | |
| 326 expect(cs.declaringType, equals(declaringType)); | |
| 327 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 328 protocol.Element element = cs.element; | |
| 329 expect(element, isNotNull); | |
| 330 expect(element.kind, equals(protocol.ElementKind.METHOD)); | |
| 331 expect(element.name, equals(name)); | |
| 332 String param = element.parameters; | |
| 333 expect(param, isNotNull); | |
| 334 expect(param[0], equals('(')); | |
| 335 expect(param[param.length - 1], equals(')')); | |
| 336 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | |
| 337 assertHasParameterInfo(cs); | |
| 338 return cs; | |
| 339 } | |
| 340 | |
| 341 CompletionSuggestion assertSuggestParameter(String name, String returnType, | |
| 342 {int relevance: DART_RELEVANCE_PARAMETER}) { | |
| 343 return assertNotSuggested(name); | |
| 344 } | |
| 345 | |
| 346 CompletionSuggestion assertSuggestSetter(String name, | |
| 347 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 348 String importUri, | |
| 349 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 350 CompletionSuggestion cs = assertSuggest(name, | |
| 351 csKind: kind, | |
| 352 relevance: relevance, | |
| 353 importUri: importUri, | |
| 354 elemKind: protocol.ElementKind.SETTER); | |
| 355 protocol.Element element = cs.element; | |
| 356 expect(element, isNotNull); | |
| 357 expect(element.kind, equals(protocol.ElementKind.SETTER)); | |
| 358 expect(element.name, equals(name)); | |
| 359 // TODO (danrubel) assert setter param | |
| 360 //expect(element.parameters, isNull); | |
| 361 // TODO (danrubel) it would be better if this was always null | |
| 362 if (element.returnType != null) { | |
| 363 expect(element.returnType, 'dynamic'); | |
| 364 } | |
| 365 assertHasNoParameterInfo(cs); | |
| 366 return cs; | |
| 367 } | |
| 368 | |
| 369 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, | |
| 370 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 371 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION, | |
| 372 String importUri]) { | |
| 373 CompletionSuggestion cs = assertSuggest(name, | |
| 374 csKind: kind, relevance: relevance, importUri: importUri); | |
| 375 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 376 protocol.Element element = cs.element; | |
| 377 expect(element, isNotNull); | |
| 378 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); | |
| 379 expect(element.name, equals(name)); | |
| 380 expect(element.parameters, isNull); | |
| 381 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | |
| 382 assertHasNoParameterInfo(cs); | |
| 383 return cs; | |
| 384 } | |
| 385 | |
| 386 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, | |
| 387 [int relevance = DART_RELEVANCE_DEFAULT]) { | |
| 388 if (contributor is ImportedReferenceContributor) { | |
| 389 assertSuggestGetter(name, returnType); | |
| 390 assertSuggestSetter(name); | |
| 391 } else { | |
| 392 assertNotSuggested(name); | |
| 393 } | |
| 394 } | |
| 395 | |
| 396 bool computeFast() { | |
| 397 expect(computeFastResult, isNull); | |
| 398 _completionManager = new DartCompletionManager(context, searchEngine, | |
| 399 testSource, cache, [contributor], [], new CommonUsageSorter({})); | |
| 400 var result = | |
| 401 _completionManager.computeFast(request, new CompletionPerformance()); | |
| 402 expect(request.replacementOffset, isNotNull); | |
| 403 expect(request.replacementLength, isNotNull); | |
| 404 computeFastResult = result.isEmpty; | |
| 405 return computeFastResult; | |
| 406 } | |
| 407 | |
| 408 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | |
| 409 if (computeFastResult == null) { | |
| 410 computeFast(); | |
| 411 } | |
| 412 if (computeFastResult) { | |
| 413 assertFunction(true); | |
| 414 return new Future.value(true); | |
| 415 } else { | |
| 416 resolve(fullAnalysis); | |
| 417 return contributor.computeFull(request).then(assertFunction); | |
| 418 } | |
| 419 } | |
| 420 | |
| 421 void failedCompletion(String message, | |
| 422 [Iterable<CompletionSuggestion> completions]) { | |
| 423 StringBuffer sb = new StringBuffer(message); | |
| 424 if (completions != null) { | |
| 425 sb.write('\n found'); | |
| 426 completions.toList() | |
| 427 ..sort(suggestionComparator) | |
| 428 ..forEach((CompletionSuggestion suggestion) { | |
| 429 sb.write('\n ${suggestion.completion} -> $suggestion'); | |
| 430 }); | |
| 431 } | |
| 432 if (completionNode != null) { | |
| 433 sb.write('\n in'); | |
| 434 AstNode node = completionNode; | |
| 435 while (node != null) { | |
| 436 sb.write('\n ${node.runtimeType}'); | |
| 437 node = node.parent; | |
| 438 } | |
| 439 } | |
| 440 fail(sb.toString()); | |
| 441 } | |
| 442 | |
| 443 CompletionSuggestion getSuggest( | |
| 444 {String completion: null, | |
| 445 CompletionSuggestionKind csKind: null, | |
| 446 protocol.ElementKind elemKind: null}) { | |
| 447 CompletionSuggestion cs; | |
| 448 request.suggestions.forEach((CompletionSuggestion s) { | |
| 449 if (completion != null && completion != s.completion) { | |
| 450 return; | |
| 451 } | |
| 452 if (csKind != null && csKind != s.kind) { | |
| 453 return; | |
| 454 } | |
| 455 if (elemKind != null) { | |
| 456 protocol.Element element = s.element; | |
| 457 if (element == null || elemKind != element.kind) { | |
| 458 return; | |
| 459 } | |
| 460 } | |
| 461 if (cs == null) { | |
| 462 cs = s; | |
| 463 } else { | |
| 464 failedCompletion('expected exactly one $cs', | |
| 465 request.suggestions.where((s) => s.completion == completion)); | |
| 466 } | |
| 467 }); | |
| 468 return cs; | |
| 469 } | |
| 470 | |
| 471 void resolve(bool fullAnalysis) { | |
| 472 // Index SDK | |
| 473 for (Source librarySource in context.librarySources) { | |
| 474 CompilationUnit unit = | |
| 475 context.getResolvedCompilationUnit2(librarySource, librarySource); | |
| 476 if (unit != null) { | |
| 477 index.index(context, unit); | |
| 478 } | |
| 479 } | |
| 480 | |
| 481 var result = context.performAnalysisTask(); | |
| 482 bool resolved = false; | |
| 483 while (result.hasMoreWork) { | |
| 484 // Update the index | |
| 485 result.changeNotices.forEach((ChangeNotice notice) { | |
| 486 CompilationUnit unit = notice.resolvedDartUnit; | |
| 487 if (unit != null) { | |
| 488 index.index(context, unit); | |
| 489 } | |
| 490 }); | |
| 491 | |
| 492 // If the unit has been resolved, then finish the completion | |
| 493 List<Source> libSourceList = context.getLibrariesContaining(testSource); | |
| 494 if (libSourceList.length > 0) { | |
| 495 LibraryElement library = context.getLibraryElement(libSourceList[0]); | |
| 496 if (library != null) { | |
| 497 CompilationUnit unit = | |
| 498 context.getResolvedCompilationUnit(testSource, library); | |
| 499 if (unit != null) { | |
| 500 request.unit = unit; | |
| 501 request.target = | |
| 502 new CompletionTarget.forOffset(unit, completionOffset); | |
| 503 resolved = true; | |
| 504 if (!fullAnalysis) { | |
| 505 break; | |
| 506 } | |
| 507 } | |
| 508 } | |
| 509 } | |
| 510 | |
| 511 result = context.performAnalysisTask(); | |
| 512 } | |
| 513 if (!resolved) { | |
| 514 fail('expected unit to be resolved'); | |
| 515 } | |
| 516 } | |
| 517 | |
| 518 @override | |
| 519 void setUp() { | |
| 520 super.setUp(); | |
| 521 index = createLocalMemoryIndex(); | |
| 522 searchEngine = new SearchEngineImpl(index); | |
| 523 setUpContributor(); | |
| 524 } | |
| 525 | |
| 526 void setUpContributor(); | |
| 527 } | |
| 528 | |
| 529 /** | |
| 530 * Common tests for `ImportedTypeContributorTest`, `InvocationContributorTest`, | |
| 531 * and `LocalContributorTest`. | |
| 532 */ | |
| 533 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { | |
| 534 /** | |
| 535 * Assert that the ImportedReferenceContributor uses cached results | |
| 536 * to produce identical suggestions to the original set of suggestions. | |
| 537 */ | |
| 538 void assertCachedCompute(_) { | |
| 539 // Subclasses override | |
| 540 } | |
| 541 | |
| 542 CompletionSuggestion assertSuggestEnum(String completion, | |
| 543 {bool isDeprecated: false}) { | |
| 544 CompletionSuggestion suggestion = | |
| 545 assertSuggest(completion, isDeprecated: isDeprecated); | |
| 546 expect(suggestion.isDeprecated, isDeprecated); | |
| 547 expect(suggestion.element.kind, protocol.ElementKind.ENUM); | |
| 548 return suggestion; | |
| 549 } | |
| 550 | |
| 551 CompletionSuggestion assertSuggestEnumConst(String completion, | |
| 552 {bool isDeprecated: false}) { | |
| 553 CompletionSuggestion suggestion = | |
| 554 assertSuggest(completion, isDeprecated: isDeprecated); | |
| 555 expect(suggestion.isDeprecated, isDeprecated); | |
| 556 expect(suggestion.element.kind, protocol.ElementKind.ENUM_CONSTANT); | |
| 557 return suggestion; | |
| 558 } | |
| 559 | |
| 560 CompletionSuggestion assertSuggestImportedClass(String name, | |
| 561 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 562 int relevance: DART_RELEVANCE_DEFAULT, | |
| 563 String importUri, | |
| 564 String elemFile}) { | |
| 565 return assertNotSuggested(name); | |
| 566 } | |
| 567 | |
| 568 CompletionSuggestion assertSuggestImportedConstructor(String name, | |
| 569 {int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { | |
| 570 return assertNotSuggested(name); | |
| 571 } | |
| 572 | |
| 573 CompletionSuggestion assertSuggestImportedField(String name, String type, | |
| 574 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { | |
| 575 return assertNotSuggested(name); | |
| 576 } | |
| 577 | |
| 578 CompletionSuggestion assertSuggestImportedFunction( | |
| 579 String name, String returnType, | |
| 580 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 581 bool deprecated: false, | |
| 582 int relevance: DART_RELEVANCE_DEFAULT, | |
| 583 String importUri}) { | |
| 584 return assertNotSuggested(name); | |
| 585 } | |
| 586 | |
| 587 CompletionSuggestion assertSuggestImportedFunctionTypeAlias( | |
| 588 String name, String returnType, | |
| 589 [bool isDeprecated = false, | |
| 590 int relevance = DART_RELEVANCE_DEFAULT, | |
| 591 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 592 return assertNotSuggested(name); | |
| 593 } | |
| 594 | |
| 595 CompletionSuggestion assertSuggestImportedGetter( | |
| 596 String name, String returnType, | |
| 597 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { | |
| 598 return assertNotSuggested(name); | |
| 599 } | |
| 600 | |
| 601 CompletionSuggestion assertSuggestImportedMethod( | |
| 602 String name, String declaringType, String returnType, | |
| 603 {int relevance: DART_RELEVANCE_INHERITED_METHOD}) { | |
| 604 return assertNotSuggested(name); | |
| 605 } | |
| 606 | |
| 607 CompletionSuggestion assertSuggestImportedSetter(String name, | |
| 608 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { | |
| 609 return assertNotSuggested(name); | |
| 610 } | |
| 611 | |
| 612 CompletionSuggestion assertSuggestImportedTopLevelVar( | |
| 613 String name, String returnType, | |
| 614 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 615 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION, | |
| 616 String importUri]) { | |
| 617 return assertNotSuggested(name); | |
| 618 } | |
| 619 | |
| 620 CompletionSuggestion assertSuggestInvocationClass(String name, | |
| 621 [int relevance = DART_RELEVANCE_DEFAULT]) { | |
| 622 return assertNotSuggested(name); | |
| 623 } | |
| 624 | |
| 625 CompletionSuggestion assertSuggestInvocationField(String name, String type, | |
| 626 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | |
| 627 return assertNotSuggested(name); | |
| 628 } | |
| 629 | |
| 630 CompletionSuggestion assertSuggestInvocationGetter( | |
| 631 String name, String returnType, | |
| 632 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | |
| 633 return assertNotSuggested(name); | |
| 634 } | |
| 635 | |
| 636 CompletionSuggestion assertSuggestInvocationMethod( | |
| 637 String name, String declaringType, String returnType, | |
| 638 {int relevance: DART_RELEVANCE_DEFAULT}) { | |
| 639 return assertNotSuggested(name); | |
| 640 } | |
| 641 | |
| 642 CompletionSuggestion assertSuggestInvocationSetter(String name, | |
| 643 [int relevance = DART_RELEVANCE_DEFAULT]) { | |
| 644 return assertNotSuggested(name); | |
| 645 } | |
| 646 | |
| 647 CompletionSuggestion assertSuggestInvocationTopLevelVar( | |
| 648 String name, String returnType, | |
| 649 [int relevance = DART_RELEVANCE_DEFAULT]) { | |
| 650 return assertNotSuggested(name); | |
| 651 } | |
| 652 | |
| 653 CompletionSuggestion assertSuggestLocalClass(String name, | |
| 654 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | |
| 655 int relevance: DART_RELEVANCE_DEFAULT, | |
| 656 bool isDeprecated: false, | |
| 657 String elemFile, | |
| 658 int elemOffset}) { | |
| 659 return assertNotSuggested(name); | |
| 660 } | |
| 661 | |
| 662 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, | |
| 663 {int relevance: DART_RELEVANCE_DEFAULT}) { | |
| 664 return assertNotSuggested(name); | |
| 665 } | |
| 666 | |
| 667 CompletionSuggestion assertSuggestLocalField(String name, String type, | |
| 668 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { | |
| 669 return assertNotSuggested(name); | |
| 670 } | |
| 671 | |
| 672 CompletionSuggestion assertSuggestLocalFunction( | |
| 673 String name, String returnType, | |
| 674 {bool deprecated: false, | |
| 675 int relevance: DART_RELEVANCE_LOCAL_FUNCTION, | |
| 676 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION}) { | |
| 677 return assertNotSuggested(name); | |
| 678 } | |
| 679 | |
| 680 CompletionSuggestion assertSuggestLocalFunctionTypeAlias( | |
| 681 String name, String returnType, | |
| 682 {bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) { | |
| 683 return assertNotSuggested(name); | |
| 684 } | |
| 685 | |
| 686 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, | |
| 687 {int relevance: DART_RELEVANCE_LOCAL_ACCESSOR, bool deprecated: false}) { | |
| 688 return assertNotSuggested(name); | |
| 689 } | |
| 690 | |
| 691 CompletionSuggestion assertSuggestLocalMethod( | |
| 692 String name, String declaringType, String returnType, | |
| 693 {int relevance: DART_RELEVANCE_LOCAL_METHOD, bool deprecated: false}) { | |
| 694 return assertNotSuggested(name); | |
| 695 } | |
| 696 | |
| 697 CompletionSuggestion assertSuggestLocalSetter(String name, | |
| 698 {int relevance: DART_RELEVANCE_LOCAL_ACCESSOR}) { | |
| 699 return assertNotSuggested(name); | |
| 700 } | |
| 701 | |
| 702 CompletionSuggestion assertSuggestLocalTopLevelVar( | |
| 703 String name, String returnType, | |
| 704 {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE}) { | |
| 705 return assertNotSuggested(name); | |
| 706 } | |
| 707 | |
| 708 CompletionSuggestion assertSuggestLocalVariable( | |
| 709 String name, String returnType, | |
| 710 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { | |
| 711 return assertNotSuggested(name); | |
| 712 } | |
| 713 | |
| 714 CompletionSuggestion assertSuggestNonLocalClass(String name, | |
| 715 [int relevance = DART_RELEVANCE_DEFAULT, | |
| 716 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 717 return assertSuggestImportedClass(name, relevance: relevance, kind: kind); | |
| 718 } | |
| 719 | |
| 720 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | |
| 721 return super | |
| 722 .computeFull(assertFunction, fullAnalysis: fullAnalysis) | |
| 723 .then(assertCachedCompute); | |
| 724 } | |
| 725 | |
| 726 test_ArgumentList() { | |
| 727 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 728 addSource( | |
| 729 '/libA.dart', | |
| 730 ''' | |
| 731 library A; | |
| 732 bool hasLength(int expected) { } | |
| 733 void baz() { }'''); | |
| 734 addTestSource(''' | |
| 735 import '/libA.dart'; | |
| 736 class B { } | |
| 737 String bar() => true; | |
| 738 void main() {expect(^)}'''); | |
| 739 computeFast(); | |
| 740 return computeFull((bool result) { | |
| 741 expect(request.replacementOffset, completionOffset); | |
| 742 expect(request.replacementLength, 0); | |
| 743 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 744 assertSuggestLocalFunction('bar', 'String'); | |
| 745 assertSuggestImportedFunction('hasLength', 'bool'); | |
| 746 assertSuggestImportedFunction('identical', 'bool'); | |
| 747 assertSuggestLocalClass('B'); | |
| 748 assertSuggestImportedClass('Object'); | |
| 749 assertNotSuggested('main'); | |
| 750 assertNotSuggested('baz'); | |
| 751 assertNotSuggested('print'); | |
| 752 }); | |
| 753 } | |
| 754 | |
| 755 test_ArgumentList_imported_function() { | |
| 756 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 757 addSource( | |
| 758 '/libA.dart', | |
| 759 ''' | |
| 760 library A; | |
| 761 bool hasLength(int expected) { } | |
| 762 expect(arg) { } | |
| 763 void baz() { }'''); | |
| 764 addTestSource(''' | |
| 765 import '/libA.dart' | |
| 766 class B { } | |
| 767 String bar() => true; | |
| 768 void main() {expect(^)}'''); | |
| 769 computeFast(); | |
| 770 return computeFull((bool result) { | |
| 771 expect(request.replacementOffset, completionOffset); | |
| 772 expect(request.replacementLength, 0); | |
| 773 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 774 assertSuggestLocalFunction('bar', 'String'); | |
| 775 assertSuggestImportedFunction('hasLength', 'bool'); | |
| 776 assertSuggestImportedFunction('identical', 'bool'); | |
| 777 assertSuggestLocalClass('B'); | |
| 778 assertSuggestImportedClass('Object'); | |
| 779 assertNotSuggested('main'); | |
| 780 assertNotSuggested('baz'); | |
| 781 assertNotSuggested('print'); | |
| 782 }); | |
| 783 } | |
| 784 | |
| 785 test_ArgumentList_InstanceCreationExpression_functionalArg() { | |
| 786 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 787 addSource( | |
| 788 '/libA.dart', | |
| 789 ''' | |
| 790 library A; | |
| 791 class A { A(f()) { } } | |
| 792 bool hasLength(int expected) { } | |
| 793 void baz() { }'''); | |
| 794 addTestSource(''' | |
| 795 import 'dart:async'; | |
| 796 import '/libA.dart'; | |
| 797 class B { } | |
| 798 String bar() => true; | |
| 799 void main() {new A(^)}'''); | |
| 800 computeFast(); | |
| 801 return computeFull((bool result) { | |
| 802 expect(request.replacementOffset, completionOffset); | |
| 803 expect(request.replacementLength, 0); | |
| 804 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 805 assertSuggestLocalFunction('bar', 'String', | |
| 806 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 807 assertSuggestImportedFunction('hasLength', 'bool', | |
| 808 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 809 assertSuggestImportedFunction('identical', 'bool', | |
| 810 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 811 assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER); | |
| 812 assertSuggestImportedClass('A', | |
| 813 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 814 assertSuggestImportedClass('Object', | |
| 815 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 816 assertNotSuggested('main'); | |
| 817 assertNotSuggested('baz'); | |
| 818 assertNotSuggested('print'); | |
| 819 }); | |
| 820 } | |
| 821 | |
| 822 test_ArgumentList_InstanceCreationExpression_typedefArg() { | |
| 823 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 824 addSource( | |
| 825 '/libA.dart', | |
| 826 ''' | |
| 827 library A; | |
| 828 typedef Funct(); | |
| 829 class A { A(Funct f) { } } | |
| 830 bool hasLength(int expected) { } | |
| 831 void baz() { }'''); | |
| 832 addTestSource(''' | |
| 833 import 'dart:async'; | |
| 834 import '/libA.dart'; | |
| 835 class B { } | |
| 836 String bar() => true; | |
| 837 void main() {new A(^)}'''); | |
| 838 computeFast(); | |
| 839 return computeFull((bool result) { | |
| 840 expect(request.replacementOffset, completionOffset); | |
| 841 expect(request.replacementLength, 0); | |
| 842 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 843 assertSuggestLocalFunction('bar', 'String', | |
| 844 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 845 assertSuggestImportedFunction('hasLength', 'bool', | |
| 846 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 847 assertSuggestImportedFunction('identical', 'bool', | |
| 848 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 849 assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER); | |
| 850 assertSuggestImportedClass('A', | |
| 851 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 852 assertSuggestImportedClass('Object', | |
| 853 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 854 assertNotSuggested('main'); | |
| 855 assertNotSuggested('baz'); | |
| 856 assertNotSuggested('print'); | |
| 857 }); | |
| 858 } | |
| 859 | |
| 860 test_ArgumentList_local_function() { | |
| 861 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 862 addSource( | |
| 863 '/libA.dart', | |
| 864 ''' | |
| 865 library A; | |
| 866 bool hasLength(int expected) { } | |
| 867 void baz() { }'''); | |
| 868 addTestSource(''' | |
| 869 import '/libA.dart' | |
| 870 expect(arg) { } | |
| 871 class B { } | |
| 872 String bar() => true; | |
| 873 void main() {expect(^)}'''); | |
| 874 computeFast(); | |
| 875 return computeFull((bool result) { | |
| 876 expect(request.replacementOffset, completionOffset); | |
| 877 expect(request.replacementLength, 0); | |
| 878 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 879 assertSuggestLocalFunction('bar', 'String'); | |
| 880 assertSuggestImportedFunction('hasLength', 'bool'); | |
| 881 assertSuggestImportedFunction('identical', 'bool'); | |
| 882 assertSuggestLocalClass('B'); | |
| 883 assertSuggestImportedClass('Object'); | |
| 884 assertNotSuggested('main'); | |
| 885 assertNotSuggested('baz'); | |
| 886 assertNotSuggested('print'); | |
| 887 }); | |
| 888 } | |
| 889 | |
| 890 test_ArgumentList_local_method() { | |
| 891 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 892 addSource( | |
| 893 '/libA.dart', | |
| 894 ''' | |
| 895 library A; | |
| 896 bool hasLength(int expected) { } | |
| 897 void baz() { }'''); | |
| 898 addTestSource(''' | |
| 899 import '/libA.dart' | |
| 900 class B { | |
| 901 expect(arg) { } | |
| 902 void foo() {expect(^)}} | |
| 903 String bar() => true;'''); | |
| 904 computeFast(); | |
| 905 return computeFull((bool result) { | |
| 906 expect(request.replacementOffset, completionOffset); | |
| 907 expect(request.replacementLength, 0); | |
| 908 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 909 assertSuggestLocalFunction('bar', 'String'); | |
| 910 assertSuggestImportedFunction('hasLength', 'bool'); | |
| 911 assertSuggestImportedFunction('identical', 'bool'); | |
| 912 assertSuggestLocalClass('B'); | |
| 913 assertSuggestImportedClass('Object'); | |
| 914 assertNotSuggested('main'); | |
| 915 assertNotSuggested('baz'); | |
| 916 assertNotSuggested('print'); | |
| 917 }); | |
| 918 } | |
| 919 | |
| 920 test_ArgumentList_MethodInvocation_functionalArg() { | |
| 921 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 922 addSource( | |
| 923 '/libA.dart', | |
| 924 ''' | |
| 925 library A; | |
| 926 class A { A(f()) { } } | |
| 927 bool hasLength(int expected) { } | |
| 928 void baz() { }'''); | |
| 929 addTestSource(''' | |
| 930 import 'dart:async'; | |
| 931 import '/libA.dart'; | |
| 932 class B { } | |
| 933 String bar(f()) => true; | |
| 934 void main() {bar(^);}'''); | |
| 935 computeFast(); | |
| 936 return computeFull((bool result) { | |
| 937 expect(request.replacementOffset, completionOffset); | |
| 938 expect(request.replacementLength, 0); | |
| 939 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 940 assertSuggestLocalFunction('bar', 'String', | |
| 941 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 942 assertSuggestImportedFunction('hasLength', 'bool', | |
| 943 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 944 assertSuggestImportedFunction('identical', 'bool', | |
| 945 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 946 assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER); | |
| 947 assertSuggestImportedClass('A', | |
| 948 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 949 assertSuggestImportedClass('Object', | |
| 950 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 951 assertNotSuggested('main'); | |
| 952 assertNotSuggested('baz'); | |
| 953 assertNotSuggested('print'); | |
| 954 }); | |
| 955 } | |
| 956 | |
| 957 test_ArgumentList_MethodInvocation_methodArg() { | |
| 958 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 959 addSource( | |
| 960 '/libA.dart', | |
| 961 ''' | |
| 962 library A; | |
| 963 class A { A(f()) { } } | |
| 964 bool hasLength(int expected) { } | |
| 965 void baz() { }'''); | |
| 966 addTestSource(''' | |
| 967 import 'dart:async'; | |
| 968 import '/libA.dart'; | |
| 969 class B { String bar(f()) => true; } | |
| 970 void main() {new B().bar(^);}'''); | |
| 971 computeFast(); | |
| 972 return computeFull((bool result) { | |
| 973 expect(request.replacementOffset, completionOffset); | |
| 974 expect(request.replacementLength, 0); | |
| 975 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); | |
| 976 assertSuggestImportedFunction('hasLength', 'bool', | |
| 977 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 978 assertSuggestImportedFunction('identical', 'bool', | |
| 979 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 980 assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER); | |
| 981 assertSuggestImportedClass('A', | |
| 982 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 983 assertSuggestImportedClass('Object', | |
| 984 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 985 assertNotSuggested('main'); | |
| 986 assertNotSuggested('baz'); | |
| 987 assertNotSuggested('print'); | |
| 988 }); | |
| 989 } | |
| 990 | |
| 991 test_ArgumentList_namedParam() { | |
| 992 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation | |
| 993 // ExpressionStatement | |
| 994 addSource( | |
| 995 '/libA.dart', | |
| 996 ''' | |
| 997 library A; | |
| 998 bool hasLength(int expected) { }'''); | |
| 999 addTestSource(''' | |
| 1000 import '/libA.dart' | |
| 1001 String bar() => true; | |
| 1002 void main() {expect(foo: ^)}'''); | |
| 1003 computeFast(); | |
| 1004 return computeFull((bool result) { | |
| 1005 expect(request.replacementOffset, completionOffset); | |
| 1006 expect(request.replacementLength, 0); | |
| 1007 assertSuggestLocalFunction('bar', 'String'); | |
| 1008 assertSuggestImportedFunction('hasLength', 'bool'); | |
| 1009 assertNotSuggested('main'); | |
| 1010 }); | |
| 1011 } | |
| 1012 | |
| 1013 test_AsExpression() { | |
| 1014 // SimpleIdentifier TypeName AsExpression | |
| 1015 addTestSource(''' | |
| 1016 class A {var b; X _c; foo() {var a; (a as ^).foo();}'''); | |
| 1017 computeFast(); | |
| 1018 return computeFull((bool result) { | |
| 1019 expect(request.replacementOffset, completionOffset); | |
| 1020 expect(request.replacementLength, 0); | |
| 1021 assertNotSuggested('b'); | |
| 1022 assertNotSuggested('_c'); | |
| 1023 assertSuggestImportedClass('Object'); | |
| 1024 assertSuggestLocalClass('A'); | |
| 1025 assertNotSuggested('=='); | |
| 1026 }); | |
| 1027 } | |
| 1028 | |
| 1029 test_AssignmentExpression_name() { | |
| 1030 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1031 // VariableDeclarationStatement Block | |
| 1032 addTestSource('class A {} main() {int a; int ^b = 1;}'); | |
| 1033 computeFast(); | |
| 1034 return computeFull((bool result) { | |
| 1035 assertNoSuggestions(); | |
| 1036 }); | |
| 1037 } | |
| 1038 | |
| 1039 test_AssignmentExpression_RHS() { | |
| 1040 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1041 // VariableDeclarationStatement Block | |
| 1042 addTestSource('class A {} main() {int a; int b = ^}'); | |
| 1043 computeFast(); | |
| 1044 return computeFull((bool result) { | |
| 1045 expect(request.replacementOffset, completionOffset); | |
| 1046 expect(request.replacementLength, 0); | |
| 1047 assertSuggestLocalVariable('a', 'int'); | |
| 1048 assertSuggestLocalFunction('main', null); | |
| 1049 assertSuggestLocalClass('A'); | |
| 1050 assertSuggestImportedClass('Object'); | |
| 1051 }); | |
| 1052 } | |
| 1053 | |
| 1054 test_AssignmentExpression_type() { | |
| 1055 // SimpleIdentifier TypeName VariableDeclarationList | |
| 1056 // VariableDeclarationStatement Block | |
| 1057 addTestSource(''' | |
| 1058 class A {} main() { | |
| 1059 int a; | |
| 1060 ^ b = 1;}'''); | |
| 1061 computeFast(); | |
| 1062 return computeFull((bool result) { | |
| 1063 expect(request.replacementOffset, completionOffset); | |
| 1064 expect(request.replacementLength, 0); | |
| 1065 assertSuggestLocalClass('A'); | |
| 1066 assertSuggestImportedClass('int'); | |
| 1067 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | |
| 1068 // the user may be either (1) entering a type for the assignment | |
| 1069 // or (2) starting a new statement. | |
| 1070 // Consider suggesting only types | |
| 1071 // if only spaces separates the 1st and 2nd identifiers. | |
| 1072 //assertNotSuggested('a'); | |
| 1073 //assertNotSuggested('main'); | |
| 1074 //assertNotSuggested('identical'); | |
| 1075 }); | |
| 1076 } | |
| 1077 | |
| 1078 test_AssignmentExpression_type_newline() { | |
| 1079 // SimpleIdentifier TypeName VariableDeclarationList | |
| 1080 // VariableDeclarationStatement Block | |
| 1081 addTestSource(''' | |
| 1082 class A {} main() { | |
| 1083 int a; | |
| 1084 ^ | |
| 1085 b = 1;}'''); | |
| 1086 computeFast(); | |
| 1087 return computeFull((bool result) { | |
| 1088 expect(request.replacementOffset, completionOffset); | |
| 1089 expect(request.replacementLength, 0); | |
| 1090 assertSuggestLocalClass('A'); | |
| 1091 assertSuggestImportedClass('int'); | |
| 1092 // Allow non-types preceding an identifier on LHS of assignment | |
| 1093 // if newline follows first identifier | |
| 1094 // because user is probably starting a new statement | |
| 1095 assertSuggestLocalVariable('a', 'int'); | |
| 1096 assertSuggestLocalFunction('main', null); | |
| 1097 assertSuggestImportedFunction('identical', 'bool'); | |
| 1098 }); | |
| 1099 } | |
| 1100 | |
| 1101 test_AssignmentExpression_type_partial() { | |
| 1102 // SimpleIdentifier TypeName VariableDeclarationList | |
| 1103 // VariableDeclarationStatement Block | |
| 1104 addTestSource(''' | |
| 1105 class A {} main() { | |
| 1106 int a; | |
| 1107 int^ b = 1;}'''); | |
| 1108 computeFast(); | |
| 1109 return computeFull((bool result) { | |
| 1110 expect(request.replacementOffset, completionOffset - 3); | |
| 1111 expect(request.replacementLength, 3); | |
| 1112 assertSuggestLocalClass('A'); | |
| 1113 assertSuggestImportedClass('int'); | |
| 1114 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | |
| 1115 // the user may be either (1) entering a type for the assignment | |
| 1116 // or (2) starting a new statement. | |
| 1117 // Consider suggesting only types | |
| 1118 // if only spaces separates the 1st and 2nd identifiers. | |
| 1119 //assertNotSuggested('a'); | |
| 1120 //assertNotSuggested('main'); | |
| 1121 //assertNotSuggested('identical'); | |
| 1122 }); | |
| 1123 } | |
| 1124 | |
| 1125 test_AssignmentExpression_type_partial_newline() { | |
| 1126 // SimpleIdentifier TypeName VariableDeclarationList | |
| 1127 // VariableDeclarationStatement Block | |
| 1128 addTestSource(''' | |
| 1129 class A {} main() { | |
| 1130 int a; | |
| 1131 i^ | |
| 1132 b = 1;}'''); | |
| 1133 computeFast(); | |
| 1134 return computeFull((bool result) { | |
| 1135 expect(request.replacementOffset, completionOffset - 1); | |
| 1136 expect(request.replacementLength, 1); | |
| 1137 assertSuggestLocalClass('A'); | |
| 1138 assertSuggestImportedClass('int'); | |
| 1139 // Allow non-types preceding an identifier on LHS of assignment | |
| 1140 // if newline follows first identifier | |
| 1141 // because user is probably starting a new statement | |
| 1142 assertSuggestLocalVariable('a', 'int'); | |
| 1143 assertSuggestLocalFunction('main', null); | |
| 1144 assertSuggestImportedFunction('identical', 'bool'); | |
| 1145 }); | |
| 1146 } | |
| 1147 | |
| 1148 test_AwaitExpression() { | |
| 1149 // SimpleIdentifier AwaitExpression ExpressionStatement | |
| 1150 addTestSource(''' | |
| 1151 class A {int x; int y() => 0;} | |
| 1152 main() async {A a; await ^}'''); | |
| 1153 computeFast(); | |
| 1154 return computeFull((bool result) { | |
| 1155 expect(request.replacementOffset, completionOffset); | |
| 1156 expect(request.replacementLength, 0); | |
| 1157 assertSuggestLocalVariable('a', 'A'); | |
| 1158 assertSuggestLocalFunction('main', null); | |
| 1159 assertSuggestLocalClass('A'); | |
| 1160 assertSuggestImportedClass('Object'); | |
| 1161 }); | |
| 1162 } | |
| 1163 | |
| 1164 test_BinaryExpression_LHS() { | |
| 1165 // SimpleIdentifier BinaryExpression VariableDeclaration | |
| 1166 // VariableDeclarationList VariableDeclarationStatement | |
| 1167 addTestSource('main() {int a = 1, b = ^ + 2;}'); | |
| 1168 computeFast(); | |
| 1169 return computeFull((bool result) { | |
| 1170 expect(request.replacementOffset, completionOffset); | |
| 1171 expect(request.replacementLength, 0); | |
| 1172 assertSuggestLocalVariable('a', 'int'); | |
| 1173 assertSuggestImportedClass('Object'); | |
| 1174 assertNotSuggested('b'); | |
| 1175 }); | |
| 1176 } | |
| 1177 | |
| 1178 test_BinaryExpression_RHS() { | |
| 1179 // SimpleIdentifier BinaryExpression VariableDeclaration | |
| 1180 // VariableDeclarationList VariableDeclarationStatement | |
| 1181 addTestSource('main() {int a = 1, b = 2 + ^;}'); | |
| 1182 computeFast(); | |
| 1183 return computeFull((bool result) { | |
| 1184 expect(request.replacementOffset, completionOffset); | |
| 1185 expect(request.replacementLength, 0); | |
| 1186 assertSuggestLocalVariable('a', 'int'); | |
| 1187 assertSuggestImportedClass('Object'); | |
| 1188 assertNotSuggested('b'); | |
| 1189 assertNotSuggested('=='); | |
| 1190 }); | |
| 1191 } | |
| 1192 | |
| 1193 test_Block() { | |
| 1194 // Block BlockFunctionBody MethodDeclaration | |
| 1195 addSource( | |
| 1196 '/testAB.dart', | |
| 1197 ''' | |
| 1198 export "dart:math" hide max; | |
| 1199 class A {int x;} | |
| 1200 @deprecated D1() {int x;} | |
| 1201 class _B {boo() { partBoo() {}} }'''); | |
| 1202 addSource( | |
| 1203 '/testCD.dart', | |
| 1204 ''' | |
| 1205 String T1; | |
| 1206 var _T2; | |
| 1207 class C { } | |
| 1208 class D { }'''); | |
| 1209 addSource( | |
| 1210 '/testEEF.dart', | |
| 1211 ''' | |
| 1212 class EE { } | |
| 1213 class F { }'''); | |
| 1214 addSource('/testG.dart', 'class G { }'); | |
| 1215 addSource( | |
| 1216 '/testH.dart', | |
| 1217 ''' | |
| 1218 class H { } | |
| 1219 int T3; | |
| 1220 var _T4;'''); // not imported | |
| 1221 addTestSource(''' | |
| 1222 import "/testAB.dart"; | |
| 1223 import "/testCD.dart" hide D; | |
| 1224 import "/testEEF.dart" show EE; | |
| 1225 import "/testG.dart" as g; | |
| 1226 int T5; | |
| 1227 var _T6; | |
| 1228 String get T7 => 'hello'; | |
| 1229 set T8(int value) { partT8() {} } | |
| 1230 Z D2() {int x;} | |
| 1231 class X { | |
| 1232 int get clog => 8; | |
| 1233 set blog(value) { } | |
| 1234 a() { | |
| 1235 var f; | |
| 1236 localF(int arg1) { } | |
| 1237 {var x;} | |
| 1238 ^ var r; | |
| 1239 } | |
| 1240 void b() { }} | |
| 1241 class Z { }'''); | |
| 1242 computeFast(); | |
| 1243 return computeFull((bool result) { | |
| 1244 expect(request.replacementOffset, completionOffset); | |
| 1245 expect(request.replacementLength, 0); | |
| 1246 | |
| 1247 assertSuggestLocalClass('X', elemFile: testFile); | |
| 1248 assertSuggestLocalClass('Z'); | |
| 1249 assertSuggestLocalMethod('a', 'X', null); | |
| 1250 assertSuggestLocalMethod('b', 'X', 'void'); | |
| 1251 assertSuggestLocalFunction('localF', null); | |
| 1252 assertSuggestLocalVariable('f', null); | |
| 1253 // Don't suggest locals out of scope | |
| 1254 assertNotSuggested('r'); | |
| 1255 assertNotSuggested('x'); | |
| 1256 assertNotSuggested('partT8'); | |
| 1257 | |
| 1258 assertSuggestImportedClass('A', elemFile: '/testAB.dart'); | |
| 1259 assertNotSuggested('_B'); | |
| 1260 assertSuggestImportedClass('C'); | |
| 1261 assertNotSuggested('partBoo'); | |
| 1262 // hidden element suggested as low relevance | |
| 1263 // but imported results are partially filtered | |
| 1264 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | |
| 1265 //assertSuggestImportedFunction( | |
| 1266 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | |
| 1267 assertSuggestLocalFunction('D2', 'Z'); | |
| 1268 assertSuggestImportedClass('EE'); | |
| 1269 // hidden element suggested as low relevance | |
| 1270 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | |
| 1271 // Suggested by LibraryPrefixContributor | |
| 1272 assertNotSuggested('g'); | |
| 1273 assertNotSuggested('G'); | |
| 1274 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | |
| 1275 assertSuggestImportedClass('Object'); | |
| 1276 assertSuggestImportedFunction('min', 'num'); | |
| 1277 //assertSuggestImportedFunction( | |
| 1278 // 'max', | |
| 1279 // 'num', | |
| 1280 // false, | |
| 1281 // COMPLETION_RELEVANCE_LOW); | |
| 1282 if (contributor is ImportedReferenceContributor) { | |
| 1283 // TODO(danrubel) should be top level var suggestion | |
| 1284 assertSuggestGetter('T1', 'String'); | |
| 1285 } | |
| 1286 assertNotSuggested('_T2'); | |
| 1287 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); | |
| 1288 assertNotSuggested('_T4'); | |
| 1289 assertSuggestLocalTopLevelVar('T5', 'int'); | |
| 1290 assertSuggestLocalTopLevelVar('_T6', null, | |
| 1291 relevance: DART_RELEVANCE_DEFAULT); | |
| 1292 assertNotSuggested('=='); | |
| 1293 assertSuggestLocalGetter('T7', 'String'); | |
| 1294 assertSuggestLocalSetter('T8'); | |
| 1295 assertSuggestLocalGetter('clog', 'int'); | |
| 1296 assertSuggestLocalSetter('blog'); | |
| 1297 // TODO (danrubel) suggest HtmlElement as low relevance | |
| 1298 assertNotSuggested('HtmlElement'); | |
| 1299 assertSuggestImportedClass('Uri'); | |
| 1300 assertNotSuggested('parseIPv6Address'); | |
| 1301 assertNotSuggested('parseHex'); | |
| 1302 }); | |
| 1303 } | |
| 1304 | |
| 1305 test_Block_final() { | |
| 1306 // Block BlockFunctionBody MethodDeclaration | |
| 1307 addSource( | |
| 1308 '/testAB.dart', | |
| 1309 ''' | |
| 1310 export "dart:math" hide max; | |
| 1311 class A {int x;} | |
| 1312 @deprecated D1() {int x;} | |
| 1313 class _B {boo() { partBoo() {}} }'''); | |
| 1314 addSource( | |
| 1315 '/testCD.dart', | |
| 1316 ''' | |
| 1317 String T1; | |
| 1318 var _T2; | |
| 1319 class C { } | |
| 1320 class D { }'''); | |
| 1321 addSource( | |
| 1322 '/testEEF.dart', | |
| 1323 ''' | |
| 1324 class EE { } | |
| 1325 class F { }'''); | |
| 1326 addSource('/testG.dart', 'class G { }'); | |
| 1327 addSource( | |
| 1328 '/testH.dart', | |
| 1329 ''' | |
| 1330 class H { } | |
| 1331 int T3; | |
| 1332 var _T4;'''); // not imported | |
| 1333 addTestSource(''' | |
| 1334 import "/testAB.dart"; | |
| 1335 import "/testCD.dart" hide D; | |
| 1336 import "/testEEF.dart" show EE; | |
| 1337 import "/testG.dart" as g; | |
| 1338 int T5; | |
| 1339 var _T6; | |
| 1340 String get T7 => 'hello'; | |
| 1341 set T8(int value) { partT8() {} } | |
| 1342 Z D2() {int x;} | |
| 1343 class X { | |
| 1344 int get clog => 8; | |
| 1345 set blog(value) { } | |
| 1346 a() { | |
| 1347 var f; | |
| 1348 localF(int arg1) { } | |
| 1349 {var x;} | |
| 1350 final ^ | |
| 1351 } | |
| 1352 void b() { }} | |
| 1353 class Z { }'''); | |
| 1354 computeFast(); | |
| 1355 return computeFull((bool result) { | |
| 1356 expect(request.replacementOffset, completionOffset); | |
| 1357 expect(request.replacementLength, 0); | |
| 1358 | |
| 1359 assertSuggestLocalClass('X'); | |
| 1360 assertSuggestLocalClass('Z'); | |
| 1361 assertNotSuggested('a'); | |
| 1362 assertNotSuggested('b'); | |
| 1363 assertNotSuggested('localF'); | |
| 1364 assertNotSuggested('f'); | |
| 1365 // Don't suggest locals out of scope | |
| 1366 assertNotSuggested('r'); | |
| 1367 assertNotSuggested('x'); | |
| 1368 assertNotSuggested('partT8'); | |
| 1369 | |
| 1370 assertSuggestImportedClass('A'); | |
| 1371 assertNotSuggested('_B'); | |
| 1372 assertSuggestImportedClass('C'); | |
| 1373 assertNotSuggested('partBoo'); | |
| 1374 // hidden element suggested as low relevance | |
| 1375 // but imported results are partially filtered | |
| 1376 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | |
| 1377 //assertSuggestImportedFunction( | |
| 1378 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | |
| 1379 assertNotSuggested('D2'); | |
| 1380 assertSuggestImportedClass('EE'); | |
| 1381 // hidden element suggested as low relevance | |
| 1382 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | |
| 1383 // Suggested by LibraryPrefixContributor | |
| 1384 assertNotSuggested('g'); | |
| 1385 assertNotSuggested('G'); | |
| 1386 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | |
| 1387 assertSuggestImportedClass('Object'); | |
| 1388 assertNotSuggested('min'); | |
| 1389 //assertSuggestImportedFunction( | |
| 1390 // 'max', | |
| 1391 // 'num', | |
| 1392 // false, | |
| 1393 // COMPLETION_RELEVANCE_LOW); | |
| 1394 assertNotSuggested('T1'); | |
| 1395 assertNotSuggested('_T2'); | |
| 1396 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); | |
| 1397 assertNotSuggested('_T4'); | |
| 1398 assertNotSuggested('T5'); | |
| 1399 assertNotSuggested('_T6'); | |
| 1400 assertNotSuggested('=='); | |
| 1401 assertNotSuggested('T7'); | |
| 1402 assertNotSuggested('T8'); | |
| 1403 assertNotSuggested('clog'); | |
| 1404 assertNotSuggested('blog'); | |
| 1405 // TODO (danrubel) suggest HtmlElement as low relevance | |
| 1406 assertNotSuggested('HtmlElement'); | |
| 1407 assertSuggestImportedClass('Uri'); | |
| 1408 assertNotSuggested('parseIPv6Address'); | |
| 1409 assertNotSuggested('parseHex'); | |
| 1410 }); | |
| 1411 } | |
| 1412 | |
| 1413 test_Block_final2() { | |
| 1414 addTestSource('main() {final S^ v;}'); | |
| 1415 computeFast(); | |
| 1416 return computeFull((bool result) { | |
| 1417 assertSuggestImportedClass('String'); | |
| 1418 }); | |
| 1419 } | |
| 1420 | |
| 1421 test_Block_final3() { | |
| 1422 addTestSource('main() {final ^ v;}'); | |
| 1423 computeFast(); | |
| 1424 return computeFull((bool result) { | |
| 1425 assertSuggestImportedClass('String'); | |
| 1426 }); | |
| 1427 } | |
| 1428 | |
| 1429 test_Block_final_final() { | |
| 1430 // Block BlockFunctionBody MethodDeclaration | |
| 1431 addSource( | |
| 1432 '/testAB.dart', | |
| 1433 ''' | |
| 1434 export "dart:math" hide max; | |
| 1435 class A {int x;} | |
| 1436 @deprecated D1() {int x;} | |
| 1437 class _B {boo() { partBoo() {}} }'''); | |
| 1438 addSource( | |
| 1439 '/testCD.dart', | |
| 1440 ''' | |
| 1441 String T1; | |
| 1442 var _T2; | |
| 1443 class C { } | |
| 1444 class D { }'''); | |
| 1445 addSource( | |
| 1446 '/testEEF.dart', | |
| 1447 ''' | |
| 1448 class EE { } | |
| 1449 class F { }'''); | |
| 1450 addSource('/testG.dart', 'class G { }'); | |
| 1451 addSource( | |
| 1452 '/testH.dart', | |
| 1453 ''' | |
| 1454 class H { } | |
| 1455 int T3; | |
| 1456 var _T4;'''); // not imported | |
| 1457 addTestSource(''' | |
| 1458 import "/testAB.dart"; | |
| 1459 import "/testCD.dart" hide D; | |
| 1460 import "/testEEF.dart" show EE; | |
| 1461 import "/testG.dart" as g; | |
| 1462 int T5; | |
| 1463 var _T6; | |
| 1464 String get T7 => 'hello'; | |
| 1465 set T8(int value) { partT8() {} } | |
| 1466 Z D2() {int x;} | |
| 1467 class X { | |
| 1468 int get clog => 8; | |
| 1469 set blog(value) { } | |
| 1470 a() { | |
| 1471 final ^ | |
| 1472 final var f; | |
| 1473 localF(int arg1) { } | |
| 1474 {var x;} | |
| 1475 } | |
| 1476 void b() { }} | |
| 1477 class Z { }'''); | |
| 1478 computeFast(); | |
| 1479 return computeFull((bool result) { | |
| 1480 expect(request.replacementOffset, completionOffset); | |
| 1481 expect(request.replacementLength, 0); | |
| 1482 | |
| 1483 assertSuggestLocalClass('X'); | |
| 1484 assertSuggestLocalClass('Z'); | |
| 1485 assertNotSuggested('a'); | |
| 1486 assertNotSuggested('b'); | |
| 1487 assertNotSuggested('localF'); | |
| 1488 assertNotSuggested('f'); | |
| 1489 // Don't suggest locals out of scope | |
| 1490 assertNotSuggested('r'); | |
| 1491 assertNotSuggested('x'); | |
| 1492 assertNotSuggested('partT8'); | |
| 1493 | |
| 1494 assertSuggestImportedClass('A'); | |
| 1495 assertNotSuggested('_B'); | |
| 1496 assertSuggestImportedClass('C'); | |
| 1497 assertNotSuggested('partBoo'); | |
| 1498 // hidden element suggested as low relevance | |
| 1499 // but imported results are partially filtered | |
| 1500 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | |
| 1501 //assertSuggestImportedFunction( | |
| 1502 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | |
| 1503 assertNotSuggested('D2'); | |
| 1504 assertSuggestImportedClass('EE'); | |
| 1505 // hidden element suggested as low relevance | |
| 1506 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | |
| 1507 // Suggested by LibraryPrefixContributor | |
| 1508 assertNotSuggested('g'); | |
| 1509 assertNotSuggested('G'); | |
| 1510 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | |
| 1511 assertSuggestImportedClass('Object'); | |
| 1512 assertNotSuggested('min'); | |
| 1513 //assertSuggestImportedFunction( | |
| 1514 // 'max', | |
| 1515 // 'num', | |
| 1516 // false, | |
| 1517 // COMPLETION_RELEVANCE_LOW); | |
| 1518 assertNotSuggested('T1'); | |
| 1519 assertNotSuggested('_T2'); | |
| 1520 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); | |
| 1521 assertNotSuggested('_T4'); | |
| 1522 assertNotSuggested('T5'); | |
| 1523 assertNotSuggested('_T6'); | |
| 1524 assertNotSuggested('=='); | |
| 1525 assertNotSuggested('T7'); | |
| 1526 assertNotSuggested('T8'); | |
| 1527 assertNotSuggested('clog'); | |
| 1528 assertNotSuggested('blog'); | |
| 1529 // TODO (danrubel) suggest HtmlElement as low relevance | |
| 1530 assertNotSuggested('HtmlElement'); | |
| 1531 assertSuggestImportedClass('Uri'); | |
| 1532 assertNotSuggested('parseIPv6Address'); | |
| 1533 assertNotSuggested('parseHex'); | |
| 1534 }); | |
| 1535 } | |
| 1536 | |
| 1537 test_Block_final_var() { | |
| 1538 // Block BlockFunctionBody MethodDeclaration | |
| 1539 addSource( | |
| 1540 '/testAB.dart', | |
| 1541 ''' | |
| 1542 export "dart:math" hide max; | |
| 1543 class A {int x;} | |
| 1544 @deprecated D1() {int x;} | |
| 1545 class _B {boo() { partBoo() {}} }'''); | |
| 1546 addSource( | |
| 1547 '/testCD.dart', | |
| 1548 ''' | |
| 1549 String T1; | |
| 1550 var _T2; | |
| 1551 class C { } | |
| 1552 class D { }'''); | |
| 1553 addSource( | |
| 1554 '/testEEF.dart', | |
| 1555 ''' | |
| 1556 class EE { } | |
| 1557 class F { }'''); | |
| 1558 addSource('/testG.dart', 'class G { }'); | |
| 1559 addSource( | |
| 1560 '/testH.dart', | |
| 1561 ''' | |
| 1562 class H { } | |
| 1563 int T3; | |
| 1564 var _T4;'''); // not imported | |
| 1565 addTestSource(''' | |
| 1566 import "/testAB.dart"; | |
| 1567 import "/testCD.dart" hide D; | |
| 1568 import "/testEEF.dart" show EE; | |
| 1569 import "/testG.dart" as g; | |
| 1570 int T5; | |
| 1571 var _T6; | |
| 1572 String get T7 => 'hello'; | |
| 1573 set T8(int value) { partT8() {} } | |
| 1574 Z D2() {int x;} | |
| 1575 class X { | |
| 1576 int get clog => 8; | |
| 1577 set blog(value) { } | |
| 1578 a() { | |
| 1579 final ^ | |
| 1580 var f; | |
| 1581 localF(int arg1) { } | |
| 1582 {var x;} | |
| 1583 } | |
| 1584 void b() { }} | |
| 1585 class Z { }'''); | |
| 1586 computeFast(); | |
| 1587 return computeFull((bool result) { | |
| 1588 expect(request.replacementOffset, completionOffset); | |
| 1589 expect(request.replacementLength, 0); | |
| 1590 | |
| 1591 assertSuggestLocalClass('X'); | |
| 1592 assertSuggestLocalClass('Z'); | |
| 1593 assertNotSuggested('a'); | |
| 1594 assertNotSuggested('b'); | |
| 1595 assertNotSuggested('localF'); | |
| 1596 assertNotSuggested('f'); | |
| 1597 // Don't suggest locals out of scope | |
| 1598 assertNotSuggested('r'); | |
| 1599 assertNotSuggested('x'); | |
| 1600 assertNotSuggested('partT8'); | |
| 1601 | |
| 1602 assertSuggestImportedClass('A'); | |
| 1603 assertNotSuggested('_B'); | |
| 1604 assertSuggestImportedClass('C'); | |
| 1605 assertNotSuggested('partBoo'); | |
| 1606 // hidden element suggested as low relevance | |
| 1607 // but imported results are partially filtered | |
| 1608 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); | |
| 1609 //assertSuggestImportedFunction( | |
| 1610 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); | |
| 1611 assertNotSuggested('D2'); | |
| 1612 assertSuggestImportedClass('EE'); | |
| 1613 // hidden element suggested as low relevance | |
| 1614 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | |
| 1615 // Suggested by LibraryPrefixContributor | |
| 1616 assertNotSuggested('g'); | |
| 1617 assertNotSuggested('G'); | |
| 1618 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | |
| 1619 assertSuggestImportedClass('Object'); | |
| 1620 assertNotSuggested('min'); | |
| 1621 //assertSuggestImportedFunction( | |
| 1622 // 'max', | |
| 1623 // 'num', | |
| 1624 // false, | |
| 1625 // COMPLETION_RELEVANCE_LOW); | |
| 1626 assertNotSuggested('T1'); | |
| 1627 assertNotSuggested('_T2'); | |
| 1628 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); | |
| 1629 assertNotSuggested('_T4'); | |
| 1630 assertNotSuggested('T5'); | |
| 1631 assertNotSuggested('_T6'); | |
| 1632 assertNotSuggested('=='); | |
| 1633 assertNotSuggested('T7'); | |
| 1634 assertNotSuggested('T8'); | |
| 1635 assertNotSuggested('clog'); | |
| 1636 assertNotSuggested('blog'); | |
| 1637 // TODO (danrubel) suggest HtmlElement as low relevance | |
| 1638 assertNotSuggested('HtmlElement'); | |
| 1639 assertSuggestImportedClass('Uri'); | |
| 1640 assertNotSuggested('parseIPv6Address'); | |
| 1641 assertNotSuggested('parseHex'); | |
| 1642 }); | |
| 1643 } | |
| 1644 | |
| 1645 test_Block_identifier_partial() { | |
| 1646 addSource( | |
| 1647 '/testAB.dart', | |
| 1648 ''' | |
| 1649 export "dart:math" hide max; | |
| 1650 class A {int x;} | |
| 1651 @deprecated D1() {int x;} | |
| 1652 class _B { }'''); | |
| 1653 addSource( | |
| 1654 '/testCD.dart', | |
| 1655 ''' | |
| 1656 String T1; | |
| 1657 var _T2; | |
| 1658 class C { } | |
| 1659 class D { }'''); | |
| 1660 addSource( | |
| 1661 '/testEEF.dart', | |
| 1662 ''' | |
| 1663 class EE { } | |
| 1664 class F { }'''); | |
| 1665 addSource('/testG.dart', 'class G { }'); | |
| 1666 addSource( | |
| 1667 '/testH.dart', | |
| 1668 ''' | |
| 1669 class H { } | |
| 1670 class D3 { } | |
| 1671 int T3; | |
| 1672 var _T4;'''); // not imported | |
| 1673 addTestSource(''' | |
| 1674 import "/testAB.dart"; | |
| 1675 import "/testCD.dart" hide D; | |
| 1676 import "/testEEF.dart" show EE; | |
| 1677 import "/testG.dart" as g; | |
| 1678 int T5; | |
| 1679 var _T6; | |
| 1680 Z D2() {int x;} | |
| 1681 class X {a() {var f; {var x;} D^ var r;} void b() { }} | |
| 1682 class Z { }'''); | |
| 1683 computeFast(); | |
| 1684 return computeFull((bool result) { | |
| 1685 expect(request.replacementOffset, completionOffset - 1); | |
| 1686 expect(request.replacementLength, 1); | |
| 1687 | |
| 1688 assertSuggestLocalClass('X'); | |
| 1689 assertSuggestLocalClass('Z'); | |
| 1690 assertSuggestLocalMethod('a', 'X', null); | |
| 1691 assertSuggestLocalMethod('b', 'X', 'void'); | |
| 1692 assertSuggestLocalVariable('f', null); | |
| 1693 // Don't suggest locals out of scope | |
| 1694 assertNotSuggested('r'); | |
| 1695 assertNotSuggested('x'); | |
| 1696 | |
| 1697 // imported elements are portially filtered | |
| 1698 //assertSuggestImportedClass('A'); | |
| 1699 assertNotSuggested('_B'); | |
| 1700 //assertSuggestImportedClass('C'); | |
| 1701 // hidden element suggested as low relevance | |
| 1702 assertSuggestImportedClass('D', | |
| 1703 relevance: DART_RELEVANCE_LOW, importUri: 'testCD.dart'); | |
| 1704 assertSuggestImportedFunction('D1', null, | |
| 1705 deprecated: true, relevance: DART_RELEVANCE_LOW); | |
| 1706 assertSuggestLocalFunction('D2', 'Z'); | |
| 1707 // unimported elements suggested with low relevance | |
| 1708 assertSuggestImportedClass('D3', | |
| 1709 relevance: DART_RELEVANCE_LOW, importUri: 'testH.dart'); | |
| 1710 //assertSuggestImportedClass('EE'); | |
| 1711 // hidden element suggested as low relevance | |
| 1712 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); | |
| 1713 //assertSuggestLibraryPrefix('g'); | |
| 1714 assertNotSuggested('G'); | |
| 1715 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); | |
| 1716 //assertSuggestImportedClass('Object'); | |
| 1717 //assertSuggestImportedFunction('min', 'num', false); | |
| 1718 //assertSuggestImportedFunction( | |
| 1719 // 'max', | |
| 1720 // 'num', | |
| 1721 // false, | |
| 1722 // COMPLETION_RELEVANCE_LOW); | |
| 1723 //assertSuggestTopLevelVarGetterSetter('T1', 'String'); | |
| 1724 assertNotSuggested('_T2'); | |
| 1725 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); | |
| 1726 assertNotSuggested('_T4'); | |
| 1727 //assertSuggestLocalTopLevelVar('T5', 'int'); | |
| 1728 //assertSuggestLocalTopLevelVar('_T6', null); | |
| 1729 assertNotSuggested('=='); | |
| 1730 // TODO (danrubel) suggest HtmlElement as low relevance | |
| 1731 assertNotSuggested('HtmlElement'); | |
| 1732 }); | |
| 1733 } | |
| 1734 | |
| 1735 test_Block_inherited_imported() { | |
| 1736 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | |
| 1737 addSource( | |
| 1738 '/testB.dart', | |
| 1739 ''' | |
| 1740 lib B; | |
| 1741 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; } | |
| 1742 class E extends F { var e1; e2() { } } | |
| 1743 class I { int i1; i2() { } } | |
| 1744 class M { var m1; int m2() { } }'''); | |
| 1745 addTestSource(''' | |
| 1746 import "/testB.dart"; | |
| 1747 class A extends E implements I with M {a() {^}}'''); | |
| 1748 computeFast(); | |
| 1749 return computeFull((bool result) { | |
| 1750 expect(request.replacementOffset, completionOffset); | |
| 1751 expect(request.replacementLength, 0); | |
| 1752 assertNotSuggested('e1'); | |
| 1753 assertNotSuggested('f1'); | |
| 1754 assertNotSuggested('i1'); | |
| 1755 assertNotSuggested('m1'); | |
| 1756 assertNotSuggested('f3'); | |
| 1757 assertNotSuggested('f4'); | |
| 1758 assertNotSuggested('e2'); | |
| 1759 assertNotSuggested('f2'); | |
| 1760 assertNotSuggested('i2'); | |
| 1761 assertNotSuggested('m2'); | |
| 1762 assertNotSuggested('=='); | |
| 1763 }); | |
| 1764 } | |
| 1765 | |
| 1766 test_Block_inherited_local() { | |
| 1767 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | |
| 1768 addTestSource(''' | |
| 1769 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } } | |
| 1770 class E extends F { var e1; e2() { } } | |
| 1771 class I { int i1; i2() { } } | |
| 1772 class M { var m1; int m2() { } } | |
| 1773 class A extends E implements I with M {a() {^}}'''); | |
| 1774 computeFast(); | |
| 1775 return computeFull((bool result) { | |
| 1776 expect(request.replacementOffset, completionOffset); | |
| 1777 expect(request.replacementLength, 0); | |
| 1778 assertSuggestLocalField('e1', null); | |
| 1779 assertSuggestLocalField('f1', null); | |
| 1780 assertSuggestLocalField('i1', 'int'); | |
| 1781 assertSuggestLocalField('m1', null); | |
| 1782 assertSuggestLocalGetter('f3', null); | |
| 1783 assertSuggestLocalSetter('f4'); | |
| 1784 assertSuggestLocalMethod('e2', 'E', null); | |
| 1785 assertSuggestLocalMethod('f2', 'F', null); | |
| 1786 assertSuggestLocalMethod('i2', 'I', null); | |
| 1787 assertSuggestLocalMethod('m2', 'M', 'int'); | |
| 1788 }); | |
| 1789 } | |
| 1790 | |
| 1791 test_Block_local_function() { | |
| 1792 addSource( | |
| 1793 '/testAB.dart', | |
| 1794 ''' | |
| 1795 export "dart:math" hide max; | |
| 1796 class A {int x;} | |
| 1797 @deprecated D1() {int x;} | |
| 1798 class _B {boo() { partBoo() {}} }'''); | |
| 1799 addSource( | |
| 1800 '/testCD.dart', | |
| 1801 ''' | |
| 1802 String T1; | |
| 1803 var _T2; | |
| 1804 class C { } | |
| 1805 class D { }'''); | |
| 1806 addSource( | |
| 1807 '/testEEF.dart', | |
| 1808 ''' | |
| 1809 class EE { } | |
| 1810 class F { }'''); | |
| 1811 addSource('/testG.dart', 'class G { }'); | |
| 1812 addSource( | |
| 1813 '/testH.dart', | |
| 1814 ''' | |
| 1815 class H { } | |
| 1816 int T3; | |
| 1817 var _T4;'''); // not imported | |
| 1818 addTestSource(''' | |
| 1819 import "/testAB.dart"; | |
| 1820 import "/testCD.dart" hide D; | |
| 1821 import "/testEEF.dart" show EE; | |
| 1822 import "/testG.dart" as g; | |
| 1823 int T5; | |
| 1824 var _T6; | |
| 1825 String get T7 => 'hello'; | |
| 1826 set T8(int value) { partT8() {} } | |
| 1827 Z D2() {int x;} | |
| 1828 class X { | |
| 1829 int get clog => 8; | |
| 1830 set blog(value) { } | |
| 1831 a() { | |
| 1832 var f; | |
| 1833 localF(int arg1) { } | |
| 1834 {var x;} | |
| 1835 p^ var r; | |
| 1836 } | |
| 1837 void b() { }} | |
| 1838 class Z { }'''); | |
| 1839 computeFast(); | |
| 1840 return computeFull((bool result) { | |
| 1841 expect(request.replacementOffset, completionOffset - 1); | |
| 1842 expect(request.replacementLength, 1); | |
| 1843 | |
| 1844 assertNotSuggested('partT8'); | |
| 1845 assertNotSuggested('partBoo'); | |
| 1846 assertNotSuggested('parseIPv6Address'); | |
| 1847 assertNotSuggested('parseHex'); | |
| 1848 }); | |
| 1849 } | |
| 1850 | |
| 1851 test_Block_unimported() { | |
| 1852 addPackageSource('myBar', 'bar.dart', 'class Foo2 { Foo2() { } }'); | |
| 1853 addSource( | |
| 1854 '/proj/testAB.dart', 'import "package:myBar/bar.dart"; class Foo { }'); | |
| 1855 testFile = '/proj/completionTest.dart'; | |
| 1856 addTestSource('class C {foo(){F^}}'); | |
| 1857 computeFast(); | |
| 1858 return computeFull((bool result) { | |
| 1859 expect(request.replacementOffset, completionOffset - 1); | |
| 1860 expect(request.replacementLength, 1); | |
| 1861 assertSuggestImportedClass('Foo', | |
| 1862 relevance: DART_RELEVANCE_LOW, importUri: 'testAB.dart'); | |
| 1863 // TODO(danrubel) implement | |
| 1864 assertSuggestImportedClass('Foo2', | |
| 1865 relevance: DART_RELEVANCE_LOW, importUri: 'package:myBar/bar.dart'); | |
| 1866 assertSuggestImportedClass('Future', | |
| 1867 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async'); | |
| 1868 }); | |
| 1869 } | |
| 1870 | |
| 1871 test_CascadeExpression_selector1() { | |
| 1872 // PropertyAccess CascadeExpression ExpressionStatement Block | |
| 1873 addSource( | |
| 1874 '/testB.dart', | |
| 1875 ''' | |
| 1876 class B { }'''); | |
| 1877 addTestSource(''' | |
| 1878 import "/testB.dart"; | |
| 1879 class A {var b; X _c;} | |
| 1880 class X{} | |
| 1881 // looks like a cascade to the parser | |
| 1882 // but the user is trying to get completions for a non-cascade | |
| 1883 main() {A a; a.^.z}'''); | |
| 1884 computeFast(); | |
| 1885 return computeFull((bool result) { | |
| 1886 expect(request.replacementOffset, completionOffset); | |
| 1887 expect(request.replacementLength, 0); | |
| 1888 assertSuggestInvocationField('b', null); | |
| 1889 assertSuggestInvocationField('_c', 'X'); | |
| 1890 assertNotSuggested('Object'); | |
| 1891 assertNotSuggested('A'); | |
| 1892 assertNotSuggested('B'); | |
| 1893 assertNotSuggested('X'); | |
| 1894 assertNotSuggested('z'); | |
| 1895 assertNotSuggested('=='); | |
| 1896 }); | |
| 1897 } | |
| 1898 | |
| 1899 test_CascadeExpression_selector2() { | |
| 1900 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement | |
| 1901 addSource( | |
| 1902 '/testB.dart', | |
| 1903 ''' | |
| 1904 class B { }'''); | |
| 1905 addTestSource(''' | |
| 1906 import "/testB.dart"; | |
| 1907 class A {var b; X _c;} | |
| 1908 class X{} | |
| 1909 main() {A a; a..^z}'''); | |
| 1910 computeFast(); | |
| 1911 return computeFull((bool result) { | |
| 1912 expect(request.replacementOffset, completionOffset); | |
| 1913 expect(request.replacementLength, 1); | |
| 1914 assertSuggestInvocationField('b', null); | |
| 1915 assertSuggestInvocationField('_c', 'X'); | |
| 1916 assertNotSuggested('Object'); | |
| 1917 assertNotSuggested('A'); | |
| 1918 assertNotSuggested('B'); | |
| 1919 assertNotSuggested('X'); | |
| 1920 assertNotSuggested('z'); | |
| 1921 assertNotSuggested('=='); | |
| 1922 }); | |
| 1923 } | |
| 1924 | |
| 1925 test_CascadeExpression_selector2_withTrailingReturn() { | |
| 1926 // PropertyAccess CascadeExpression ExpressionStatement Block | |
| 1927 addSource( | |
| 1928 '/testB.dart', | |
| 1929 ''' | |
| 1930 class B { }'''); | |
| 1931 addTestSource(''' | |
| 1932 import "/testB.dart"; | |
| 1933 class A {var b; X _c;} | |
| 1934 class X{} | |
| 1935 main() {A a; a..^ return}'''); | |
| 1936 computeFast(); | |
| 1937 return computeFull((bool result) { | |
| 1938 expect(request.replacementOffset, completionOffset); | |
| 1939 expect(request.replacementLength, 0); | |
| 1940 assertSuggestInvocationField('b', null); | |
| 1941 assertSuggestInvocationField('_c', 'X'); | |
| 1942 assertNotSuggested('Object'); | |
| 1943 assertNotSuggested('A'); | |
| 1944 assertNotSuggested('B'); | |
| 1945 assertNotSuggested('X'); | |
| 1946 assertNotSuggested('z'); | |
| 1947 assertNotSuggested('=='); | |
| 1948 }); | |
| 1949 } | |
| 1950 | |
| 1951 test_CascadeExpression_target() { | |
| 1952 // SimpleIdentifier CascadeExpression ExpressionStatement | |
| 1953 addTestSource(''' | |
| 1954 class A {var b; X _c;} | |
| 1955 class X{} | |
| 1956 main() {A a; a^..b}'''); | |
| 1957 computeFast(); | |
| 1958 return computeFull((bool result) { | |
| 1959 expect(request.replacementOffset, completionOffset - 1); | |
| 1960 expect(request.replacementLength, 1); | |
| 1961 assertNotSuggested('b'); | |
| 1962 assertNotSuggested('_c'); | |
| 1963 assertSuggestLocalVariable('a', 'A'); | |
| 1964 assertSuggestLocalClass('A'); | |
| 1965 assertSuggestLocalClass('X'); | |
| 1966 // top level results are partially filtered | |
| 1967 //assertSuggestImportedClass('Object'); | |
| 1968 assertNotSuggested('=='); | |
| 1969 }); | |
| 1970 } | |
| 1971 | |
| 1972 test_CatchClause_onType() { | |
| 1973 // TypeName CatchClause TryStatement | |
| 1974 addTestSource('class A {a() {try{var x;} on ^ {}}}'); | |
| 1975 computeFast(); | |
| 1976 return computeFull((bool result) { | |
| 1977 expect(request.replacementOffset, completionOffset); | |
| 1978 expect(request.replacementLength, 0); | |
| 1979 assertSuggestLocalClass('A'); | |
| 1980 assertSuggestImportedClass('Object'); | |
| 1981 assertNotSuggested('a'); | |
| 1982 assertNotSuggested('x'); | |
| 1983 }); | |
| 1984 } | |
| 1985 | |
| 1986 test_CatchClause_onType_noBrackets() { | |
| 1987 // TypeName CatchClause TryStatement | |
| 1988 addTestSource('class A {a() {try{var x;} on ^}}'); | |
| 1989 computeFast(); | |
| 1990 return computeFull((bool result) { | |
| 1991 expect(request.replacementOffset, completionOffset); | |
| 1992 expect(request.replacementLength, 0); | |
| 1993 assertSuggestLocalClass('A', elemOffset: 6); | |
| 1994 assertSuggestImportedClass('Object'); | |
| 1995 assertNotSuggested('x'); | |
| 1996 }); | |
| 1997 } | |
| 1998 | |
| 1999 test_CatchClause_typed() { | |
| 2000 // Block CatchClause TryStatement | |
| 2001 addTestSource('class A {a() {try{var x;} on E catch (e) {^}}}'); | |
| 2002 computeFast(); | |
| 2003 return computeFull((bool result) { | |
| 2004 expect(request.replacementOffset, completionOffset); | |
| 2005 expect(request.replacementLength, 0); | |
| 2006 assertSuggestParameter('e', 'E'); | |
| 2007 assertSuggestLocalMethod('a', 'A', null); | |
| 2008 assertSuggestImportedClass('Object'); | |
| 2009 assertNotSuggested('x'); | |
| 2010 }); | |
| 2011 } | |
| 2012 | |
| 2013 test_CatchClause_untyped() { | |
| 2014 // Block CatchClause TryStatement | |
| 2015 addTestSource('class A {a() {try{var x;} catch (e, s) {^}}}'); | |
| 2016 computeFast(); | |
| 2017 return computeFull((bool result) { | |
| 2018 expect(request.replacementOffset, completionOffset); | |
| 2019 expect(request.replacementLength, 0); | |
| 2020 assertSuggestParameter('e', null); | |
| 2021 assertSuggestParameter('s', 'StackTrace'); | |
| 2022 assertSuggestLocalMethod('a', 'A', null); | |
| 2023 assertSuggestImportedClass('Object'); | |
| 2024 assertNotSuggested('x'); | |
| 2025 }); | |
| 2026 } | |
| 2027 | |
| 2028 test_ClassDeclaration_body() { | |
| 2029 // ClassDeclaration CompilationUnit | |
| 2030 addSource( | |
| 2031 '/testB.dart', | |
| 2032 ''' | |
| 2033 class B { }'''); | |
| 2034 addTestSource(''' | |
| 2035 import "testB.dart" as x; | |
| 2036 @deprecated class A {^} | |
| 2037 class _B {} | |
| 2038 A T;'''); | |
| 2039 computeFast(); | |
| 2040 return computeFull((bool result) { | |
| 2041 expect(request.replacementOffset, completionOffset); | |
| 2042 expect(request.replacementLength, 0); | |
| 2043 CompletionSuggestion suggestionA = assertSuggestLocalClass('A', | |
| 2044 relevance: DART_RELEVANCE_LOW, isDeprecated: true); | |
| 2045 if (suggestionA != null) { | |
| 2046 expect(suggestionA.element.isDeprecated, isTrue); | |
| 2047 expect(suggestionA.element.isPrivate, isFalse); | |
| 2048 } | |
| 2049 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); | |
| 2050 if (suggestionB != null) { | |
| 2051 expect(suggestionB.element.isDeprecated, isFalse); | |
| 2052 expect(suggestionB.element.isPrivate, isTrue); | |
| 2053 } | |
| 2054 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); | |
| 2055 if (suggestionO != null) { | |
| 2056 expect(suggestionO.element.isDeprecated, isFalse); | |
| 2057 expect(suggestionO.element.isPrivate, isFalse); | |
| 2058 } | |
| 2059 assertNotSuggested('T'); | |
| 2060 // Suggested by LibraryPrefixContributor | |
| 2061 assertNotSuggested('x'); | |
| 2062 }); | |
| 2063 } | |
| 2064 | |
| 2065 test_ClassDeclaration_body_final() { | |
| 2066 // ClassDeclaration CompilationUnit | |
| 2067 addSource( | |
| 2068 '/testB.dart', | |
| 2069 ''' | |
| 2070 class B { }'''); | |
| 2071 addTestSource(''' | |
| 2072 import "testB.dart" as x; | |
| 2073 class A {final ^} | |
| 2074 class _B {} | |
| 2075 A T;'''); | |
| 2076 computeFast(); | |
| 2077 return computeFull((bool result) { | |
| 2078 expect(request.replacementOffset, completionOffset); | |
| 2079 expect(request.replacementLength, 0); | |
| 2080 assertSuggestLocalClass('A'); | |
| 2081 assertSuggestLocalClass('_B'); | |
| 2082 assertSuggestImportedClass('Object'); | |
| 2083 assertNotSuggested('T'); | |
| 2084 // Suggested by LibraryPrefixContributor | |
| 2085 assertNotSuggested('x'); | |
| 2086 }); | |
| 2087 } | |
| 2088 | |
| 2089 test_ClassDeclaration_body_final_field() { | |
| 2090 // ClassDeclaration CompilationUnit | |
| 2091 addSource( | |
| 2092 '/testB.dart', | |
| 2093 ''' | |
| 2094 class B { }'''); | |
| 2095 addTestSource(''' | |
| 2096 import "testB.dart" as x; | |
| 2097 class A {final ^ A(){}} | |
| 2098 class _B {} | |
| 2099 A T;'''); | |
| 2100 computeFast(); | |
| 2101 return computeFull((bool result) { | |
| 2102 expect(request.replacementOffset, completionOffset); | |
| 2103 expect(request.replacementLength, 0); | |
| 2104 assertSuggestLocalClass('A'); | |
| 2105 assertSuggestLocalClass('_B'); | |
| 2106 assertSuggestImportedClass('String'); | |
| 2107 assertNotSuggested('T'); | |
| 2108 // Suggested by LibraryPrefixContributor | |
| 2109 assertNotSuggested('x'); | |
| 2110 }); | |
| 2111 } | |
| 2112 | |
| 2113 test_ClassDeclaration_body_final_field2() { | |
| 2114 // ClassDeclaration CompilationUnit | |
| 2115 addSource( | |
| 2116 '/testB.dart', | |
| 2117 ''' | |
| 2118 class B { }'''); | |
| 2119 addTestSource(''' | |
| 2120 import "testB.dart" as Soo; | |
| 2121 class A {final S^ A();} | |
| 2122 class _B {} | |
| 2123 A Sew;'''); | |
| 2124 computeFast(); | |
| 2125 return computeFull((bool result) { | |
| 2126 expect(request.replacementOffset, completionOffset - 1); | |
| 2127 expect(request.replacementLength, 1); | |
| 2128 assertSuggestLocalClass('A'); | |
| 2129 assertSuggestLocalClass('_B'); | |
| 2130 assertSuggestImportedClass('String'); | |
| 2131 assertNotSuggested('Sew'); | |
| 2132 // Suggested by LibraryPrefixContributor | |
| 2133 assertNotSuggested('Soo'); | |
| 2134 }); | |
| 2135 } | |
| 2136 | |
| 2137 test_ClassDeclaration_body_final_final() { | |
| 2138 // ClassDeclaration CompilationUnit | |
| 2139 addSource( | |
| 2140 '/testB.dart', | |
| 2141 ''' | |
| 2142 class B { }'''); | |
| 2143 addTestSource(''' | |
| 2144 import "testB.dart" as x; | |
| 2145 class A {final ^ final foo;} | |
| 2146 class _B {} | |
| 2147 A T;'''); | |
| 2148 computeFast(); | |
| 2149 return computeFull((bool result) { | |
| 2150 expect(request.replacementOffset, completionOffset); | |
| 2151 expect(request.replacementLength, 0); | |
| 2152 assertSuggestLocalClass('A'); | |
| 2153 assertSuggestLocalClass('_B'); | |
| 2154 assertSuggestImportedClass('Object'); | |
| 2155 assertNotSuggested('T'); | |
| 2156 // Suggested by LibraryPrefixContributor | |
| 2157 assertNotSuggested('x'); | |
| 2158 }); | |
| 2159 } | |
| 2160 | |
| 2161 test_ClassDeclaration_body_final_var() { | |
| 2162 // ClassDeclaration CompilationUnit | |
| 2163 addSource( | |
| 2164 '/testB.dart', | |
| 2165 ''' | |
| 2166 class B { }'''); | |
| 2167 addTestSource(''' | |
| 2168 import "testB.dart" as x; | |
| 2169 class A {final ^ var foo;} | |
| 2170 class _B {} | |
| 2171 A T;'''); | |
| 2172 computeFast(); | |
| 2173 return computeFull((bool result) { | |
| 2174 expect(request.replacementOffset, completionOffset); | |
| 2175 expect(request.replacementLength, 0); | |
| 2176 assertSuggestLocalClass('A'); | |
| 2177 assertSuggestLocalClass('_B'); | |
| 2178 assertSuggestImportedClass('Object'); | |
| 2179 assertNotSuggested('T'); | |
| 2180 // Suggested by LibraryPrefixContributor | |
| 2181 assertNotSuggested('x'); | |
| 2182 }); | |
| 2183 } | |
| 2184 | |
| 2185 test_Combinator_hide() { | |
| 2186 // SimpleIdentifier HideCombinator ImportDirective | |
| 2187 addSource( | |
| 2188 '/testAB.dart', | |
| 2189 ''' | |
| 2190 library libAB; | |
| 2191 part '/partAB.dart'; | |
| 2192 class A { } | |
| 2193 class B { }'''); | |
| 2194 addSource( | |
| 2195 '/partAB.dart', | |
| 2196 ''' | |
| 2197 part of libAB; | |
| 2198 var T1; | |
| 2199 PB F1() => new PB(); | |
| 2200 class PB { }'''); | |
| 2201 addSource( | |
| 2202 '/testCD.dart', | |
| 2203 ''' | |
| 2204 class C { } | |
| 2205 class D { }'''); | |
| 2206 addTestSource(''' | |
| 2207 import "/testAB.dart" hide ^; | |
| 2208 import "/testCD.dart"; | |
| 2209 class X {}'''); | |
| 2210 computeFast(); | |
| 2211 return computeFull((bool result) { | |
| 2212 assertNoSuggestions(); | |
| 2213 }); | |
| 2214 } | |
| 2215 | |
| 2216 test_Combinator_show() { | |
| 2217 // SimpleIdentifier HideCombinator ImportDirective | |
| 2218 addSource( | |
| 2219 '/testAB.dart', | |
| 2220 ''' | |
| 2221 library libAB; | |
| 2222 part '/partAB.dart'; | |
| 2223 class A { } | |
| 2224 class B { }'''); | |
| 2225 addSource( | |
| 2226 '/partAB.dart', | |
| 2227 ''' | |
| 2228 part of libAB; | |
| 2229 var T1; | |
| 2230 PB F1() => new PB(); | |
| 2231 typedef PB2 F2(int blat); | |
| 2232 class Clz = Object with Object; | |
| 2233 class PB { }'''); | |
| 2234 addSource( | |
| 2235 '/testCD.dart', | |
| 2236 ''' | |
| 2237 class C { } | |
| 2238 class D { }'''); | |
| 2239 addTestSource(''' | |
| 2240 import "/testAB.dart" show ^; | |
| 2241 import "/testCD.dart"; | |
| 2242 class X {}'''); | |
| 2243 computeFast(); | |
| 2244 return computeFull((bool result) { | |
| 2245 assertNoSuggestions(); | |
| 2246 }); | |
| 2247 } | |
| 2248 | |
| 2249 test_ConditionalExpression_elseExpression() { | |
| 2250 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 2251 addSource( | |
| 2252 '/testA.dart', | |
| 2253 ''' | |
| 2254 int T1; | |
| 2255 F1() { } | |
| 2256 class A {int x;}'''); | |
| 2257 addTestSource(''' | |
| 2258 import "/testA.dart"; | |
| 2259 int T2; | |
| 2260 F2() { } | |
| 2261 class B {int x;} | |
| 2262 class C {foo(){var f; {var x;} return a ? T1 : T^}}'''); | |
| 2263 computeFast(); | |
| 2264 return computeFull((bool result) { | |
| 2265 // top level results are partially filtered based on first char | |
| 2266 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2267 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2268 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2269 }); | |
| 2270 } | |
| 2271 | |
| 2272 test_ConditionalExpression_elseExpression_empty() { | |
| 2273 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 2274 addSource( | |
| 2275 '/testA.dart', | |
| 2276 ''' | |
| 2277 int T1; | |
| 2278 F1() { } | |
| 2279 class A {int x;}'''); | |
| 2280 addTestSource(''' | |
| 2281 import "/testA.dart"; | |
| 2282 int T2; | |
| 2283 F2() { } | |
| 2284 class B {int x;} | |
| 2285 class C {foo(){var f; {var x;} return a ? T1 : ^}}'''); | |
| 2286 computeFast(); | |
| 2287 return computeFull((bool result) { | |
| 2288 assertNotSuggested('x'); | |
| 2289 assertSuggestLocalVariable('f', null); | |
| 2290 assertSuggestLocalMethod('foo', 'C', null); | |
| 2291 assertSuggestLocalClass('C'); | |
| 2292 assertSuggestLocalFunction('F2', null); | |
| 2293 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2294 assertSuggestImportedClass('A'); | |
| 2295 assertSuggestImportedFunction('F1', null); | |
| 2296 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2297 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2298 }); | |
| 2299 } | |
| 2300 | |
| 2301 test_ConditionalExpression_partial_thenExpression() { | |
| 2302 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 2303 addSource( | |
| 2304 '/testA.dart', | |
| 2305 ''' | |
| 2306 int T1; | |
| 2307 F1() { } | |
| 2308 class A {int x;}'''); | |
| 2309 addTestSource(''' | |
| 2310 import "/testA.dart"; | |
| 2311 int T2; | |
| 2312 F2() { } | |
| 2313 class B {int x;} | |
| 2314 class C {foo(){var f; {var x;} return a ? T^}}'''); | |
| 2315 computeFast(); | |
| 2316 return computeFull((bool result) { | |
| 2317 // top level results are partially filtered based on first char | |
| 2318 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2319 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2320 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2321 }); | |
| 2322 } | |
| 2323 | |
| 2324 test_ConditionalExpression_partial_thenExpression_empty() { | |
| 2325 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 2326 addSource( | |
| 2327 '/testA.dart', | |
| 2328 ''' | |
| 2329 int T1; | |
| 2330 F1() { } | |
| 2331 class A {int x;}'''); | |
| 2332 addTestSource(''' | |
| 2333 import "/testA.dart"; | |
| 2334 int T2; | |
| 2335 F2() { } | |
| 2336 class B {int x;} | |
| 2337 class C {foo(){var f; {var x;} return a ? ^}}'''); | |
| 2338 computeFast(); | |
| 2339 return computeFull((bool result) { | |
| 2340 assertNotSuggested('x'); | |
| 2341 assertSuggestLocalVariable('f', null); | |
| 2342 assertSuggestLocalMethod('foo', 'C', null); | |
| 2343 assertSuggestLocalClass('C'); | |
| 2344 assertSuggestLocalFunction('F2', null); | |
| 2345 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2346 assertSuggestImportedClass('A'); | |
| 2347 assertSuggestImportedFunction('F1', null); | |
| 2348 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2349 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2350 }); | |
| 2351 } | |
| 2352 | |
| 2353 test_ConditionalExpression_thenExpression() { | |
| 2354 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 2355 addSource( | |
| 2356 '/testA.dart', | |
| 2357 ''' | |
| 2358 int T1; | |
| 2359 F1() { } | |
| 2360 class A {int x;}'''); | |
| 2361 addTestSource(''' | |
| 2362 import "/testA.dart"; | |
| 2363 int T2; | |
| 2364 F2() { } | |
| 2365 class B {int x;} | |
| 2366 class C {foo(){var f; {var x;} return a ? T^ : c}}'''); | |
| 2367 computeFast(); | |
| 2368 return computeFull((bool result) { | |
| 2369 // top level results are partially filtered based on first char | |
| 2370 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2371 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2372 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2373 }); | |
| 2374 } | |
| 2375 | |
| 2376 test_ConstructorName_importedClass() { | |
| 2377 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 2378 // InstanceCreationExpression | |
| 2379 addSource( | |
| 2380 '/testB.dart', | |
| 2381 ''' | |
| 2382 lib B; | |
| 2383 int T1; | |
| 2384 F1() { } | |
| 2385 class X {X.c(); X._d(); z() {}}'''); | |
| 2386 addTestSource(''' | |
| 2387 import "/testB.dart"; | |
| 2388 var m; | |
| 2389 main() {new X.^}'''); | |
| 2390 computeFast(); | |
| 2391 return computeFull((bool result) { | |
| 2392 expect(request.replacementOffset, completionOffset); | |
| 2393 expect(request.replacementLength, 0); | |
| 2394 // Suggested by NamedConstructorContributor | |
| 2395 assertNotSuggested('c'); | |
| 2396 assertNotSuggested('F1'); | |
| 2397 assertNotSuggested('T1'); | |
| 2398 assertNotSuggested('_d'); | |
| 2399 assertNotSuggested('z'); | |
| 2400 assertNotSuggested('m'); | |
| 2401 }); | |
| 2402 } | |
| 2403 | |
| 2404 test_ConstructorName_importedFactory() { | |
| 2405 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 2406 // InstanceCreationExpression | |
| 2407 addSource( | |
| 2408 '/testB.dart', | |
| 2409 ''' | |
| 2410 lib B; | |
| 2411 int T1; | |
| 2412 F1() { } | |
| 2413 class X {factory X.c(); factory X._d(); z() {}}'''); | |
| 2414 addTestSource(''' | |
| 2415 import "/testB.dart"; | |
| 2416 var m; | |
| 2417 main() {new X.^}'''); | |
| 2418 computeFast(); | |
| 2419 return computeFull((bool result) { | |
| 2420 expect(request.replacementOffset, completionOffset); | |
| 2421 expect(request.replacementLength, 0); | |
| 2422 // Suggested by NamedConstructorContributor | |
| 2423 assertNotSuggested('c'); | |
| 2424 assertNotSuggested('F1'); | |
| 2425 assertNotSuggested('T1'); | |
| 2426 assertNotSuggested('_d'); | |
| 2427 assertNotSuggested('z'); | |
| 2428 assertNotSuggested('m'); | |
| 2429 }); | |
| 2430 } | |
| 2431 | |
| 2432 test_ConstructorName_importedFactory2() { | |
| 2433 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 2434 // InstanceCreationExpression | |
| 2435 addTestSource(''' | |
| 2436 main() {new String.fr^omCharCodes([]);}'''); | |
| 2437 computeFast(); | |
| 2438 return computeFull((bool result) { | |
| 2439 expect(request.replacementOffset, completionOffset - 2); | |
| 2440 expect(request.replacementLength, 13); | |
| 2441 // Suggested by NamedConstructorContributor | |
| 2442 assertNotSuggested('fromCharCodes'); | |
| 2443 assertNotSuggested('isEmpty'); | |
| 2444 assertNotSuggested('isNotEmpty'); | |
| 2445 assertNotSuggested('length'); | |
| 2446 assertNotSuggested('Object'); | |
| 2447 assertNotSuggested('String'); | |
| 2448 }); | |
| 2449 } | |
| 2450 | |
| 2451 test_ConstructorName_localClass() { | |
| 2452 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 2453 // InstanceCreationExpression | |
| 2454 addTestSource(''' | |
| 2455 int T1; | |
| 2456 F1() { } | |
| 2457 class X {X.c(); X._d(); z() {}} | |
| 2458 main() {new X.^}'''); | |
| 2459 computeFast(); | |
| 2460 return computeFull((bool result) { | |
| 2461 expect(request.replacementOffset, completionOffset); | |
| 2462 expect(request.replacementLength, 0); | |
| 2463 // Suggested by NamedConstructorContributor | |
| 2464 assertNotSuggested('c'); | |
| 2465 assertNotSuggested('_d'); | |
| 2466 assertNotSuggested('F1'); | |
| 2467 assertNotSuggested('T1'); | |
| 2468 assertNotSuggested('z'); | |
| 2469 assertNotSuggested('m'); | |
| 2470 }); | |
| 2471 } | |
| 2472 | |
| 2473 test_ConstructorName_localFactory() { | |
| 2474 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 2475 // InstanceCreationExpression | |
| 2476 addTestSource(''' | |
| 2477 int T1; | |
| 2478 F1() { } | |
| 2479 class X {factory X.c(); factory X._d(); z() {}} | |
| 2480 main() {new X.^}'''); | |
| 2481 computeFast(); | |
| 2482 return computeFull((bool result) { | |
| 2483 expect(request.replacementOffset, completionOffset); | |
| 2484 expect(request.replacementLength, 0); | |
| 2485 // Suggested by NamedConstructorContributor | |
| 2486 assertNotSuggested('c'); | |
| 2487 assertNotSuggested('_d'); | |
| 2488 assertNotSuggested('F1'); | |
| 2489 assertNotSuggested('T1'); | |
| 2490 assertNotSuggested('z'); | |
| 2491 assertNotSuggested('m'); | |
| 2492 }); | |
| 2493 } | |
| 2494 | |
| 2495 test_DefaultFormalParameter_named_expression() { | |
| 2496 // DefaultFormalParameter FormalParameterList MethodDeclaration | |
| 2497 addTestSource(''' | |
| 2498 foo() { } | |
| 2499 void bar() { } | |
| 2500 class A {a(blat: ^) { }}'''); | |
| 2501 computeFast(); | |
| 2502 return computeFull((bool result) { | |
| 2503 expect(request.replacementOffset, completionOffset); | |
| 2504 expect(request.replacementLength, 0); | |
| 2505 assertSuggestLocalFunction('foo', null); | |
| 2506 assertSuggestLocalMethod('a', 'A', null); | |
| 2507 assertSuggestLocalClass('A'); | |
| 2508 assertSuggestImportedClass('String'); | |
| 2509 assertSuggestImportedFunction('identical', 'bool'); | |
| 2510 assertNotSuggested('bar'); | |
| 2511 }); | |
| 2512 } | |
| 2513 | |
| 2514 test_ExpressionStatement_identifier() { | |
| 2515 // SimpleIdentifier ExpressionStatement Block | |
| 2516 addSource( | |
| 2517 '/testA.dart', | |
| 2518 ''' | |
| 2519 _B F1() { } | |
| 2520 class A {int x;} | |
| 2521 class _B { }'''); | |
| 2522 addTestSource(''' | |
| 2523 import "/testA.dart"; | |
| 2524 typedef int F2(int blat); | |
| 2525 class Clz = Object with Object; | |
| 2526 class C {foo(){^} void bar() {}}'''); | |
| 2527 computeFast(); | |
| 2528 return computeFull((bool result) { | |
| 2529 expect(request.replacementOffset, completionOffset); | |
| 2530 expect(request.replacementLength, 0); | |
| 2531 assertSuggestImportedClass('A'); | |
| 2532 assertSuggestImportedFunction('F1', '_B'); | |
| 2533 assertSuggestLocalClass('C'); | |
| 2534 assertSuggestLocalMethod('foo', 'C', null); | |
| 2535 assertSuggestLocalMethod('bar', 'C', 'void'); | |
| 2536 assertSuggestLocalFunctionTypeAlias('F2', 'int'); | |
| 2537 assertSuggestLocalClassTypeAlias('Clz'); | |
| 2538 assertSuggestLocalClass('C'); | |
| 2539 assertNotSuggested('x'); | |
| 2540 assertNotSuggested('_B'); | |
| 2541 }); | |
| 2542 } | |
| 2543 | |
| 2544 test_ExpressionStatement_name() { | |
| 2545 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | |
| 2546 addSource( | |
| 2547 '/testA.dart', | |
| 2548 ''' | |
| 2549 B T1; | |
| 2550 class B{}'''); | |
| 2551 addTestSource(''' | |
| 2552 import "/testA.dart"; | |
| 2553 class C {a() {C ^}}'''); | |
| 2554 computeFast(); | |
| 2555 return computeFull((bool result) { | |
| 2556 assertNoSuggestions(); | |
| 2557 }); | |
| 2558 } | |
| 2559 | |
| 2560 test_FieldDeclaration_name_typed() { | |
| 2561 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 2562 // FieldDeclaration | |
| 2563 addSource('/testA.dart', 'class A { }'); | |
| 2564 addTestSource(''' | |
| 2565 import "/testA.dart"; | |
| 2566 class C {A ^}'''); | |
| 2567 computeFast(); | |
| 2568 return computeFull((bool result) { | |
| 2569 assertNoSuggestions(); | |
| 2570 }); | |
| 2571 } | |
| 2572 | |
| 2573 test_FieldDeclaration_name_var() { | |
| 2574 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 2575 // FieldDeclaration | |
| 2576 addSource('/testA.dart', 'class A { }'); | |
| 2577 addTestSource(''' | |
| 2578 import "/testA.dart"; | |
| 2579 class C {var ^}'''); | |
| 2580 computeFast(); | |
| 2581 return computeFull((bool result) { | |
| 2582 assertNoSuggestions(); | |
| 2583 }); | |
| 2584 } | |
| 2585 | |
| 2586 test_FieldFormalParameter_in_non_constructor() { | |
| 2587 // SimpleIdentifer FieldFormalParameter FormalParameterList | |
| 2588 addTestSource('class A {B(this.^foo) {}}'); | |
| 2589 return computeFull((bool result) { | |
| 2590 expect(request.replacementOffset, completionOffset); | |
| 2591 expect(request.replacementLength, 3); | |
| 2592 assertNoSuggestions(); | |
| 2593 }); | |
| 2594 } | |
| 2595 | |
| 2596 test_ForEachStatement_body_typed() { | |
| 2597 // Block ForEachStatement | |
| 2598 addTestSource('main(args) {for (int foo in bar) {^}}'); | |
| 2599 computeFast(); | |
| 2600 return computeFull((bool result) { | |
| 2601 expect(request.replacementOffset, completionOffset); | |
| 2602 expect(request.replacementLength, 0); | |
| 2603 assertSuggestParameter('args', null); | |
| 2604 assertSuggestLocalVariable('foo', 'int'); | |
| 2605 assertSuggestImportedClass('Object'); | |
| 2606 }); | |
| 2607 } | |
| 2608 | |
| 2609 test_ForEachStatement_body_untyped() { | |
| 2610 // Block ForEachStatement | |
| 2611 addTestSource('main(args) {for (foo in bar) {^}}'); | |
| 2612 computeFast(); | |
| 2613 return computeFull((bool result) { | |
| 2614 expect(request.replacementOffset, completionOffset); | |
| 2615 expect(request.replacementLength, 0); | |
| 2616 assertSuggestParameter('args', null); | |
| 2617 assertSuggestLocalVariable('foo', null); | |
| 2618 assertSuggestImportedClass('Object'); | |
| 2619 }); | |
| 2620 } | |
| 2621 | |
| 2622 test_ForEachStatement_iterable() { | |
| 2623 // SimpleIdentifier ForEachStatement Block | |
| 2624 addTestSource('main(args) {for (int foo in ^) {}}'); | |
| 2625 computeFast(); | |
| 2626 return computeFull((bool result) { | |
| 2627 expect(request.replacementOffset, completionOffset); | |
| 2628 expect(request.replacementLength, 0); | |
| 2629 assertSuggestParameter('args', null); | |
| 2630 assertSuggestImportedClass('Object'); | |
| 2631 }); | |
| 2632 } | |
| 2633 | |
| 2634 test_ForEachStatement_loopVariable() { | |
| 2635 // SimpleIdentifier ForEachStatement Block | |
| 2636 addTestSource('main(args) {for (^ in args) {}}'); | |
| 2637 computeFast(); | |
| 2638 return computeFull((bool result) { | |
| 2639 expect(request.replacementOffset, completionOffset); | |
| 2640 expect(request.replacementLength, 0); | |
| 2641 assertNotSuggested('args'); | |
| 2642 assertSuggestImportedClass('String'); | |
| 2643 }); | |
| 2644 } | |
| 2645 | |
| 2646 test_ForEachStatement_loopVariable_type() { | |
| 2647 // SimpleIdentifier ForEachStatement Block | |
| 2648 addTestSource('main(args) {for (^ foo in args) {}}'); | |
| 2649 computeFast(); | |
| 2650 return computeFull((bool result) { | |
| 2651 expect(request.replacementOffset, completionOffset); | |
| 2652 expect(request.replacementLength, 0); | |
| 2653 assertNotSuggested('args'); | |
| 2654 assertNotSuggested('foo'); | |
| 2655 assertSuggestImportedClass('String'); | |
| 2656 }); | |
| 2657 } | |
| 2658 | |
| 2659 test_ForEachStatement_loopVariable_type2() { | |
| 2660 // DeclaredIdentifier ForEachStatement Block | |
| 2661 addTestSource('main(args) {for (S^ foo in args) {}}'); | |
| 2662 computeFast(); | |
| 2663 return computeFull((bool result) { | |
| 2664 expect(request.replacementOffset, completionOffset - 1); | |
| 2665 expect(request.replacementLength, 1); | |
| 2666 assertNotSuggested('args'); | |
| 2667 assertNotSuggested('foo'); | |
| 2668 assertSuggestImportedClass('String'); | |
| 2669 }); | |
| 2670 } | |
| 2671 | |
| 2672 test_FormalParameterList() { | |
| 2673 // FormalParameterList MethodDeclaration | |
| 2674 addTestSource(''' | |
| 2675 foo() { } | |
| 2676 void bar() { } | |
| 2677 class A {a(^) { }}'''); | |
| 2678 computeFast(); | |
| 2679 return computeFull((bool result) { | |
| 2680 expect(request.replacementOffset, completionOffset); | |
| 2681 expect(request.replacementLength, 0); | |
| 2682 assertNotSuggested('foo'); | |
| 2683 assertNotSuggested('a'); | |
| 2684 assertSuggestLocalClass('A'); | |
| 2685 assertSuggestImportedClass('String'); | |
| 2686 assertNotSuggested('identical'); | |
| 2687 assertNotSuggested('bar'); | |
| 2688 }); | |
| 2689 } | |
| 2690 | |
| 2691 test_ForStatement_body() { | |
| 2692 // Block ForStatement | |
| 2693 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); | |
| 2694 computeFast(); | |
| 2695 return computeFull((bool result) { | |
| 2696 expect(request.replacementOffset, completionOffset); | |
| 2697 expect(request.replacementLength, 0); | |
| 2698 assertSuggestLocalVariable('i', 'int'); | |
| 2699 assertSuggestImportedClass('Object'); | |
| 2700 }); | |
| 2701 } | |
| 2702 | |
| 2703 test_ForStatement_condition() { | |
| 2704 // SimpleIdentifier ForStatement | |
| 2705 addTestSource('main() {for (int index = 0; i^)}'); | |
| 2706 computeFast(); | |
| 2707 return computeFull((bool result) { | |
| 2708 expect(request.replacementOffset, completionOffset - 1); | |
| 2709 expect(request.replacementLength, 1); | |
| 2710 assertSuggestLocalVariable('index', 'int'); | |
| 2711 }); | |
| 2712 } | |
| 2713 | |
| 2714 test_ForStatement_initializer() { | |
| 2715 // SimpleIdentifier ForStatement | |
| 2716 addTestSource('main() {List a; for (^)}'); | |
| 2717 computeFast(); | |
| 2718 return computeFull((bool result) { | |
| 2719 expect(request.replacementOffset, completionOffset); | |
| 2720 expect(request.replacementLength, 0); | |
| 2721 assertSuggestLocalVariable('a', 'List'); | |
| 2722 assertSuggestImportedClass('Object'); | |
| 2723 assertSuggestImportedClass('int'); | |
| 2724 }); | |
| 2725 } | |
| 2726 | |
| 2727 test_ForStatement_updaters() { | |
| 2728 // SimpleIdentifier ForStatement | |
| 2729 addTestSource('main() {for (int index = 0; index < 10; i^)}'); | |
| 2730 computeFast(); | |
| 2731 return computeFull((bool result) { | |
| 2732 expect(request.replacementOffset, completionOffset - 1); | |
| 2733 expect(request.replacementLength, 1); | |
| 2734 assertSuggestLocalVariable('index', 'int'); | |
| 2735 }); | |
| 2736 } | |
| 2737 | |
| 2738 test_ForStatement_updaters_prefix_expression() { | |
| 2739 // SimpleIdentifier PrefixExpression ForStatement | |
| 2740 addTestSource(''' | |
| 2741 void bar() { } | |
| 2742 main() {for (int index = 0; index < 10; ++i^)}'''); | |
| 2743 computeFast(); | |
| 2744 return computeFull((bool result) { | |
| 2745 expect(request.replacementOffset, completionOffset - 1); | |
| 2746 expect(request.replacementLength, 1); | |
| 2747 assertSuggestLocalVariable('index', 'int'); | |
| 2748 assertSuggestLocalFunction('main', null); | |
| 2749 assertNotSuggested('bar'); | |
| 2750 }); | |
| 2751 } | |
| 2752 | |
| 2753 test_FunctionDeclaration_returnType_afterComment() { | |
| 2754 // ClassDeclaration CompilationUnit | |
| 2755 addSource( | |
| 2756 '/testA.dart', | |
| 2757 ''' | |
| 2758 int T1; | |
| 2759 F1() { } | |
| 2760 typedef D1(); | |
| 2761 class C1 {C1(this.x) { } int x;}'''); | |
| 2762 addTestSource(''' | |
| 2763 import "/testA.dart"; | |
| 2764 int T2; | |
| 2765 F2() { } | |
| 2766 typedef D2(); | |
| 2767 class C2 { } | |
| 2768 /* */ ^ zoo(z) { } String name;'''); | |
| 2769 computeFast(); | |
| 2770 return computeFull((bool result) { | |
| 2771 expect(request.replacementOffset, completionOffset); | |
| 2772 expect(request.replacementLength, 0); | |
| 2773 assertSuggestImportedClass('Object'); | |
| 2774 assertNotSuggested('T1'); | |
| 2775 assertNotSuggested('F1'); | |
| 2776 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 2777 assertSuggestImportedClass('C1'); | |
| 2778 assertNotSuggested('T2'); | |
| 2779 assertNotSuggested('F2'); | |
| 2780 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 2781 assertSuggestLocalClass('C2'); | |
| 2782 assertNotSuggested('name'); | |
| 2783 }); | |
| 2784 } | |
| 2785 | |
| 2786 test_FunctionDeclaration_returnType_afterComment2() { | |
| 2787 // FunctionDeclaration ClassDeclaration CompilationUnit | |
| 2788 addSource( | |
| 2789 '/testA.dart', | |
| 2790 ''' | |
| 2791 int T1; | |
| 2792 F1() { } | |
| 2793 typedef D1(); | |
| 2794 class C1 {C1(this.x) { } int x;}'''); | |
| 2795 addTestSource(''' | |
| 2796 import "/testA.dart"; | |
| 2797 int T2; | |
| 2798 F2() { } | |
| 2799 typedef D2(); | |
| 2800 class C2 { } | |
| 2801 /** */ ^ zoo(z) { } String name;'''); | |
| 2802 computeFast(); | |
| 2803 return computeFull((bool result) { | |
| 2804 expect(request.replacementOffset, completionOffset); | |
| 2805 expect(request.replacementLength, 0); | |
| 2806 assertSuggestImportedClass('Object'); | |
| 2807 assertNotSuggested('T1'); | |
| 2808 assertNotSuggested('F1'); | |
| 2809 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 2810 assertSuggestImportedClass('C1'); | |
| 2811 assertNotSuggested('T2'); | |
| 2812 assertNotSuggested('F2'); | |
| 2813 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 2814 assertSuggestLocalClass('C2'); | |
| 2815 assertNotSuggested('name'); | |
| 2816 }); | |
| 2817 } | |
| 2818 | |
| 2819 test_FunctionDeclaration_returnType_afterComment3() { | |
| 2820 // FunctionDeclaration ClassDeclaration CompilationUnit | |
| 2821 addSource( | |
| 2822 '/testA.dart', | |
| 2823 ''' | |
| 2824 int T1; | |
| 2825 F1() { } | |
| 2826 typedef D1(); | |
| 2827 class C1 {C1(this.x) { } int x;}'''); | |
| 2828 addTestSource(''' | |
| 2829 import "/testA.dart"; | |
| 2830 int T2; | |
| 2831 F2() { } | |
| 2832 typedef D2(); | |
| 2833 /// some dartdoc | |
| 2834 class C2 { } | |
| 2835 ^ zoo(z) { } String name;'''); | |
| 2836 computeFast(); | |
| 2837 return computeFull((bool result) { | |
| 2838 expect(request.replacementOffset, completionOffset); | |
| 2839 expect(request.replacementLength, 0); | |
| 2840 assertSuggestImportedClass('Object'); | |
| 2841 assertNotSuggested('T1'); | |
| 2842 assertNotSuggested('F1'); | |
| 2843 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 2844 assertSuggestImportedClass('C1'); | |
| 2845 assertNotSuggested('T2'); | |
| 2846 assertNotSuggested('F2'); | |
| 2847 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 2848 assertSuggestLocalClass('C2'); | |
| 2849 assertNotSuggested('name'); | |
| 2850 }); | |
| 2851 } | |
| 2852 | |
| 2853 test_FunctionExpression_body_function() { | |
| 2854 // Block BlockFunctionBody FunctionExpression | |
| 2855 addTestSource(''' | |
| 2856 void bar() { } | |
| 2857 String foo(List args) {x.then((R b) {^});}'''); | |
| 2858 computeFast(); | |
| 2859 return computeFull((bool result) { | |
| 2860 expect(request.replacementOffset, completionOffset); | |
| 2861 expect(request.replacementLength, 0); | |
| 2862 var f = assertSuggestLocalFunction('foo', 'String', deprecated: false); | |
| 2863 if (f != null) { | |
| 2864 expect(f.element.isPrivate, isFalse); | |
| 2865 } | |
| 2866 assertSuggestLocalFunction('bar', 'void'); | |
| 2867 assertSuggestParameter('args', 'List'); | |
| 2868 assertSuggestParameter('b', 'R'); | |
| 2869 assertSuggestImportedClass('Object'); | |
| 2870 }); | |
| 2871 } | |
| 2872 | |
| 2873 test_IfStatement() { | |
| 2874 // SimpleIdentifier IfStatement | |
| 2875 addTestSource(''' | |
| 2876 class A {var b; X _c; foo() {A a; if (true) ^}}'''); | |
| 2877 computeFast(); | |
| 2878 return computeFull((bool result) { | |
| 2879 expect(request.replacementOffset, completionOffset); | |
| 2880 expect(request.replacementLength, 0); | |
| 2881 assertSuggestLocalField('b', null); | |
| 2882 assertSuggestLocalField('_c', 'X'); | |
| 2883 assertSuggestImportedClass('Object'); | |
| 2884 assertSuggestLocalClass('A'); | |
| 2885 assertNotSuggested('=='); | |
| 2886 }); | |
| 2887 } | |
| 2888 | |
| 2889 test_IfStatement_condition() { | |
| 2890 // SimpleIdentifier IfStatement Block BlockFunctionBody | |
| 2891 addTestSource(''' | |
| 2892 class A {int x; int y() => 0;} | |
| 2893 main(){var a; if (^)}'''); | |
| 2894 computeFast(); | |
| 2895 return computeFull((bool result) { | |
| 2896 expect(request.replacementOffset, completionOffset); | |
| 2897 expect(request.replacementLength, 0); | |
| 2898 assertSuggestLocalVariable('a', null); | |
| 2899 assertSuggestLocalFunction('main', null); | |
| 2900 assertSuggestLocalClass('A'); | |
| 2901 assertSuggestImportedClass('Object'); | |
| 2902 }); | |
| 2903 } | |
| 2904 | |
| 2905 test_IfStatement_empty() { | |
| 2906 // SimpleIdentifier IfStatement | |
| 2907 addTestSource(''' | |
| 2908 class A {var b; X _c; foo() {A a; if (^) something}}'''); | |
| 2909 computeFast(); | |
| 2910 return computeFull((bool result) { | |
| 2911 expect(request.replacementOffset, completionOffset); | |
| 2912 expect(request.replacementLength, 0); | |
| 2913 assertSuggestLocalField('b', null); | |
| 2914 assertSuggestLocalField('_c', 'X'); | |
| 2915 assertSuggestImportedClass('Object'); | |
| 2916 assertSuggestLocalClass('A'); | |
| 2917 assertNotSuggested('=='); | |
| 2918 }); | |
| 2919 } | |
| 2920 | |
| 2921 test_IfStatement_invocation() { | |
| 2922 // SimpleIdentifier PrefixIdentifier IfStatement | |
| 2923 addTestSource(''' | |
| 2924 main() {var a; if (a.^) something}'''); | |
| 2925 computeFast(); | |
| 2926 return computeFull((bool result) { | |
| 2927 expect(request.replacementOffset, completionOffset); | |
| 2928 expect(request.replacementLength, 0); | |
| 2929 assertSuggestInvocationMethod('toString', 'Object', 'String'); | |
| 2930 assertNotSuggested('Object'); | |
| 2931 assertNotSuggested('A'); | |
| 2932 assertNotSuggested('=='); | |
| 2933 }); | |
| 2934 } | |
| 2935 | |
| 2936 test_ImportDirective_dart() { | |
| 2937 // SimpleStringLiteral ImportDirective | |
| 2938 addTestSource(''' | |
| 2939 import "dart^"; | |
| 2940 main() {}'''); | |
| 2941 computeFast(); | |
| 2942 return computeFull((bool result) { | |
| 2943 assertNoSuggestions(); | |
| 2944 }); | |
| 2945 } | |
| 2946 | |
| 2947 test_IndexExpression() { | |
| 2948 // ExpressionStatement Block | |
| 2949 addSource( | |
| 2950 '/testA.dart', | |
| 2951 ''' | |
| 2952 int T1; | |
| 2953 F1() { } | |
| 2954 class A {int x;}'''); | |
| 2955 addTestSource(''' | |
| 2956 import "/testA.dart"; | |
| 2957 int T2; | |
| 2958 F2() { } | |
| 2959 class B {int x;} | |
| 2960 class C {foo(){var f; {var x;} f[^]}}'''); | |
| 2961 computeFast(); | |
| 2962 return computeFull((bool result) { | |
| 2963 assertNotSuggested('x'); | |
| 2964 assertSuggestLocalVariable('f', null); | |
| 2965 assertSuggestLocalMethod('foo', 'C', null); | |
| 2966 assertSuggestLocalClass('C'); | |
| 2967 assertSuggestLocalFunction('F2', null); | |
| 2968 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2969 assertSuggestImportedClass('A'); | |
| 2970 assertSuggestImportedFunction('F1', null); | |
| 2971 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2972 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2973 }); | |
| 2974 } | |
| 2975 | |
| 2976 test_IndexExpression2() { | |
| 2977 // SimpleIdentifier IndexExpression ExpressionStatement Block | |
| 2978 addSource( | |
| 2979 '/testA.dart', | |
| 2980 ''' | |
| 2981 int T1; | |
| 2982 F1() { } | |
| 2983 class A {int x;}'''); | |
| 2984 addTestSource(''' | |
| 2985 import "/testA.dart"; | |
| 2986 int T2; | |
| 2987 F2() { } | |
| 2988 class B {int x;} | |
| 2989 class C {foo(){var f; {var x;} f[T^]}}'''); | |
| 2990 computeFast(); | |
| 2991 return computeFull((bool result) { | |
| 2992 // top level results are partially filtered based on first char | |
| 2993 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 2994 // TODO (danrubel) getter is being suggested instead of top level var | |
| 2995 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 2996 }); | |
| 2997 } | |
| 2998 | |
| 2999 test_InstanceCreationExpression_imported() { | |
| 3000 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 3001 addSource( | |
| 3002 '/testA.dart', | |
| 3003 ''' | |
| 3004 int T1; | |
| 3005 F1() { } | |
| 3006 class A {A(this.x) { } int x;}'''); | |
| 3007 addTestSource(''' | |
| 3008 import "/testA.dart"; | |
| 3009 import "dart:async"; | |
| 3010 int T2; | |
| 3011 F2() { } | |
| 3012 class B {B(this.x, [String boo]) { } int x;} | |
| 3013 class C {foo(){var f; {var x;} new ^}}'''); | |
| 3014 computeFast(); | |
| 3015 return computeFull((bool result) { | |
| 3016 expect(request.replacementOffset, completionOffset); | |
| 3017 expect(request.replacementLength, 0); | |
| 3018 assertSuggestImportedConstructor('Object'); | |
| 3019 assertSuggestImportedConstructor('Future'); | |
| 3020 assertSuggestImportedConstructor('A'); | |
| 3021 // Suggested by ConstructorContributor | |
| 3022 assertNotSuggested('B'); | |
| 3023 assertNotSuggested('C'); | |
| 3024 assertNotSuggested('f'); | |
| 3025 assertNotSuggested('x'); | |
| 3026 assertNotSuggested('foo'); | |
| 3027 assertNotSuggested('F1'); | |
| 3028 assertNotSuggested('F2'); | |
| 3029 assertNotSuggested('T1'); | |
| 3030 assertNotSuggested('T2'); | |
| 3031 }); | |
| 3032 } | |
| 3033 | |
| 3034 test_InstanceCreationExpression_unimported() { | |
| 3035 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 3036 addSource('/testAB.dart', 'class Foo { }'); | |
| 3037 addTestSource('class C {foo(){new F^}}'); | |
| 3038 computeFast(); | |
| 3039 return computeFull((bool result) { | |
| 3040 expect(request.replacementOffset, completionOffset - 1); | |
| 3041 expect(request.replacementLength, 1); | |
| 3042 assertSuggestImportedConstructor('Future', | |
| 3043 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async'); | |
| 3044 assertSuggestImportedConstructor('Foo', | |
| 3045 relevance: DART_RELEVANCE_LOW, importUri: 'testAB.dart'); | |
| 3046 }); | |
| 3047 } | |
| 3048 | |
| 3049 test_InterpolationExpression() { | |
| 3050 // SimpleIdentifier InterpolationExpression StringInterpolation | |
| 3051 addSource( | |
| 3052 '/testA.dart', | |
| 3053 ''' | |
| 3054 int T1; | |
| 3055 F1() { } | |
| 3056 typedef D1(); | |
| 3057 class C1 {C1(this.x) { } int x;}'''); | |
| 3058 addTestSource(''' | |
| 3059 import "/testA.dart"; | |
| 3060 int T2; | |
| 3061 F2() { } | |
| 3062 typedef D2(); | |
| 3063 class C2 { } | |
| 3064 main() {String name; print("hello \$^");}'''); | |
| 3065 computeFast(); | |
| 3066 return computeFull((bool result) { | |
| 3067 expect(request.replacementOffset, completionOffset); | |
| 3068 expect(request.replacementLength, 0); | |
| 3069 assertNotSuggested('Object'); | |
| 3070 // TODO(danrubel) should return top level var rather than getter | |
| 3071 if (contributor is ImportedReferenceContributor) { | |
| 3072 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 3073 assertSuggestGetter('T1', 'int'); | |
| 3074 } | |
| 3075 assertSuggestImportedFunction('F1', null); | |
| 3076 assertNotSuggested('D1'); | |
| 3077 assertNotSuggested('C1'); | |
| 3078 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 3079 assertSuggestLocalFunction('F2', null); | |
| 3080 assertNotSuggested('D2'); | |
| 3081 assertNotSuggested('C2'); | |
| 3082 assertSuggestLocalVariable('name', 'String'); | |
| 3083 }); | |
| 3084 } | |
| 3085 | |
| 3086 test_InterpolationExpression_block() { | |
| 3087 // SimpleIdentifier InterpolationExpression StringInterpolation | |
| 3088 addSource( | |
| 3089 '/testA.dart', | |
| 3090 ''' | |
| 3091 int T1; | |
| 3092 F1() { } | |
| 3093 typedef D1(); | |
| 3094 class C1 {C1(this.x) { } int x;}'''); | |
| 3095 addTestSource(''' | |
| 3096 import "/testA.dart"; | |
| 3097 int T2; | |
| 3098 F2() { } | |
| 3099 typedef D2(); | |
| 3100 class C2 { } | |
| 3101 main() {String name; print("hello \${^}");}'''); | |
| 3102 computeFast(); | |
| 3103 return computeFull((bool result) { | |
| 3104 expect(request.replacementOffset, completionOffset); | |
| 3105 expect(request.replacementLength, 0); | |
| 3106 assertSuggestImportedClass('Object'); | |
| 3107 // TODO(danrubel) should return top level var rather than getter | |
| 3108 if (contributor is ImportedReferenceContributor) { | |
| 3109 //assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 3110 assertSuggestGetter('T1', 'int'); | |
| 3111 } | |
| 3112 assertSuggestImportedFunction('F1', null); | |
| 3113 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3114 assertSuggestImportedClass('C1'); | |
| 3115 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 3116 assertSuggestLocalFunction('F2', null); | |
| 3117 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3118 assertSuggestLocalClass('C2'); | |
| 3119 assertSuggestLocalVariable('name', 'String'); | |
| 3120 }); | |
| 3121 } | |
| 3122 | |
| 3123 test_InterpolationExpression_block2() { | |
| 3124 // SimpleIdentifier InterpolationExpression StringInterpolation | |
| 3125 addTestSource('main() {String name; print("hello \${n^}");}'); | |
| 3126 computeFast(); | |
| 3127 return computeFull((bool result) { | |
| 3128 assertSuggestLocalVariable('name', 'String'); | |
| 3129 // top level results are partially filtered | |
| 3130 //assertSuggestImportedClass('Object'); | |
| 3131 }); | |
| 3132 } | |
| 3133 | |
| 3134 test_InterpolationExpression_prefix_selector() { | |
| 3135 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | |
| 3136 addTestSource('main() {String name; print("hello \${name.^}");}'); | |
| 3137 computeFast(); | |
| 3138 return computeFull((bool result) { | |
| 3139 expect(request.replacementOffset, completionOffset); | |
| 3140 expect(request.replacementLength, 0); | |
| 3141 assertSuggestInvocationGetter('length', 'int'); | |
| 3142 assertNotSuggested('name'); | |
| 3143 assertNotSuggested('Object'); | |
| 3144 assertNotSuggested('=='); | |
| 3145 }); | |
| 3146 } | |
| 3147 | |
| 3148 test_InterpolationExpression_prefix_selector2() { | |
| 3149 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | |
| 3150 addTestSource('main() {String name; print("hello \$name.^");}'); | |
| 3151 computeFast(); | |
| 3152 return computeFull((bool result) { | |
| 3153 assertNoSuggestions(); | |
| 3154 }); | |
| 3155 } | |
| 3156 | |
| 3157 test_InterpolationExpression_prefix_target() { | |
| 3158 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | |
| 3159 addTestSource('main() {String name; print("hello \${nam^e.length}");}'); | |
| 3160 computeFast(); | |
| 3161 return computeFull((bool result) { | |
| 3162 assertSuggestLocalVariable('name', 'String'); | |
| 3163 // top level results are partially filtered | |
| 3164 //assertSuggestImportedClass('Object'); | |
| 3165 assertNotSuggested('length'); | |
| 3166 }); | |
| 3167 } | |
| 3168 | |
| 3169 test_IsExpression() { | |
| 3170 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 3171 addSource( | |
| 3172 '/testB.dart', | |
| 3173 ''' | |
| 3174 lib B; | |
| 3175 foo() { } | |
| 3176 class X {X.c(); X._d(); z() {}}'''); | |
| 3177 addTestSource(''' | |
| 3178 import "/testB.dart"; | |
| 3179 class Y {Y.c(); Y._d(); z() {}} | |
| 3180 main() {var x; if (x is ^) { }}'''); | |
| 3181 computeFast(); | |
| 3182 return computeFull((bool result) { | |
| 3183 expect(request.replacementOffset, completionOffset); | |
| 3184 expect(request.replacementLength, 0); | |
| 3185 assertSuggestImportedClass('X'); | |
| 3186 assertSuggestLocalClass('Y'); | |
| 3187 assertNotSuggested('x'); | |
| 3188 assertNotSuggested('main'); | |
| 3189 assertNotSuggested('foo'); | |
| 3190 }); | |
| 3191 } | |
| 3192 | |
| 3193 test_IsExpression_target() { | |
| 3194 // IfStatement Block BlockFunctionBody | |
| 3195 addTestSource(''' | |
| 3196 foo() { } | |
| 3197 void bar() { } | |
| 3198 class A {int x; int y() => 0;} | |
| 3199 main(){var a; if (^ is A)}'''); | |
| 3200 computeFast(); | |
| 3201 return computeFull((bool result) { | |
| 3202 expect(request.replacementOffset, completionOffset); | |
| 3203 expect(request.replacementLength, 0); | |
| 3204 assertSuggestLocalVariable('a', null); | |
| 3205 assertSuggestLocalFunction('main', null); | |
| 3206 assertSuggestLocalFunction('foo', null); | |
| 3207 assertNotSuggested('bar'); | |
| 3208 assertSuggestLocalClass('A'); | |
| 3209 assertSuggestImportedClass('Object'); | |
| 3210 }); | |
| 3211 } | |
| 3212 | |
| 3213 test_IsExpression_type() { | |
| 3214 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 3215 addTestSource(''' | |
| 3216 class A {int x; int y() => 0;} | |
| 3217 main(){var a; if (a is ^)}'''); | |
| 3218 computeFast(); | |
| 3219 return computeFull((bool result) { | |
| 3220 expect(request.replacementOffset, completionOffset); | |
| 3221 expect(request.replacementLength, 0); | |
| 3222 assertNotSuggested('a'); | |
| 3223 assertNotSuggested('main'); | |
| 3224 assertSuggestLocalClass('A'); | |
| 3225 assertSuggestImportedClass('Object'); | |
| 3226 }); | |
| 3227 } | |
| 3228 | |
| 3229 test_IsExpression_type_partial() { | |
| 3230 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 3231 addTestSource(''' | |
| 3232 class A {int x; int y() => 0;} | |
| 3233 main(){var a; if (a is Obj^)}'''); | |
| 3234 computeFast(); | |
| 3235 return computeFull((bool result) { | |
| 3236 expect(request.replacementOffset, completionOffset - 3); | |
| 3237 expect(request.replacementLength, 3); | |
| 3238 assertNotSuggested('a'); | |
| 3239 assertNotSuggested('main'); | |
| 3240 assertSuggestLocalClass('A'); | |
| 3241 assertSuggestImportedClass('Object'); | |
| 3242 }); | |
| 3243 } | |
| 3244 | |
| 3245 test_keyword() { | |
| 3246 addSource( | |
| 3247 '/testB.dart', | |
| 3248 ''' | |
| 3249 lib B; | |
| 3250 int newT1; | |
| 3251 int T1; | |
| 3252 nowIsIt() { } | |
| 3253 class X {factory X.c(); factory X._d(); z() {}}'''); | |
| 3254 addTestSource(''' | |
| 3255 import "/testB.dart"; | |
| 3256 String newer() {} | |
| 3257 var m; | |
| 3258 main() {new^ X.c();}'''); | |
| 3259 computeFast(); | |
| 3260 return computeFull((bool result) { | |
| 3261 expect(request.replacementOffset, completionOffset - 3); | |
| 3262 expect(request.replacementLength, 3); | |
| 3263 assertNotSuggested('c'); | |
| 3264 assertNotSuggested('_d'); | |
| 3265 // Imported suggestion are filtered by 1st character | |
| 3266 assertSuggestImportedFunction('nowIsIt', null); | |
| 3267 assertNotSuggested('T1'); | |
| 3268 // TODO (danrubel) this really should be TopLevelVar not getter/setter | |
| 3269 if (contributor is ImportedReferenceContributor) { | |
| 3270 assertSuggestGetter('newT1', 'int'); | |
| 3271 } | |
| 3272 assertNotSuggested('z'); | |
| 3273 assertSuggestLocalTopLevelVar('m', 'dynamic'); | |
| 3274 assertSuggestLocalFunction('newer', 'String'); | |
| 3275 }); | |
| 3276 } | |
| 3277 | |
| 3278 test_Literal_list() { | |
| 3279 // ']' ListLiteral ArgumentList MethodInvocation | |
| 3280 addTestSource('main() {var Some; print([^]);}'); | |
| 3281 computeFast(); | |
| 3282 return computeFull((bool result) { | |
| 3283 assertSuggestLocalVariable('Some', null); | |
| 3284 assertSuggestImportedClass('String'); | |
| 3285 }); | |
| 3286 } | |
| 3287 | |
| 3288 test_Literal_list2() { | |
| 3289 // SimpleIdentifier ListLiteral ArgumentList MethodInvocation | |
| 3290 addTestSource('main() {var Some; print([S^]);}'); | |
| 3291 computeFast(); | |
| 3292 return computeFull((bool result) { | |
| 3293 assertSuggestLocalVariable('Some', null); | |
| 3294 assertSuggestImportedClass('String'); | |
| 3295 }); | |
| 3296 } | |
| 3297 | |
| 3298 test_Literal_string() { | |
| 3299 // SimpleStringLiteral ExpressionStatement Block | |
| 3300 addTestSource('class A {a() {"hel^lo"}}'); | |
| 3301 computeFast(); | |
| 3302 return computeFull((bool result) { | |
| 3303 assertNoSuggestions(); | |
| 3304 }); | |
| 3305 } | |
| 3306 | |
| 3307 test_localVariableDeclarationName() { | |
| 3308 addTestSource('main() {String m^}'); | |
| 3309 return computeFull((bool result) { | |
| 3310 assertNotSuggested('main'); | |
| 3311 assertNotSuggested('min'); | |
| 3312 }); | |
| 3313 } | |
| 3314 | |
| 3315 test_MapLiteralEntry() { | |
| 3316 // MapLiteralEntry MapLiteral VariableDeclaration | |
| 3317 addSource( | |
| 3318 '/testA.dart', | |
| 3319 ''' | |
| 3320 int T1; | |
| 3321 F1() { } | |
| 3322 typedef D1(); | |
| 3323 class C1 {C1(this.x) { } int x;}'''); | |
| 3324 addTestSource(''' | |
| 3325 import "/testA.dart"; | |
| 3326 int T2; | |
| 3327 F2() { } | |
| 3328 typedef D2(); | |
| 3329 class C2 { } | |
| 3330 foo = {^'''); | |
| 3331 computeFast(); | |
| 3332 return computeFull((bool result) { | |
| 3333 expect(request.replacementOffset, completionOffset); | |
| 3334 expect(request.replacementLength, 0); | |
| 3335 assertSuggestImportedClass('Object'); | |
| 3336 // TODO(danrubel) Should be top level variable | |
| 3337 if (contributor is ImportedReferenceContributor) { | |
| 3338 assertSuggestGetter('T1', 'int'); | |
| 3339 // assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 3340 } | |
| 3341 assertSuggestImportedFunction('F1', null); | |
| 3342 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3343 assertSuggestImportedClass('C1'); | |
| 3344 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 3345 assertSuggestLocalFunction('F2', null); | |
| 3346 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3347 assertSuggestLocalClass('C2'); | |
| 3348 }); | |
| 3349 } | |
| 3350 | |
| 3351 test_MapLiteralEntry1() { | |
| 3352 // MapLiteralEntry MapLiteral VariableDeclaration | |
| 3353 addSource( | |
| 3354 '/testA.dart', | |
| 3355 ''' | |
| 3356 int T1; | |
| 3357 F1() { } | |
| 3358 typedef D1(); | |
| 3359 class C1 {C1(this.x) { } int x;}'''); | |
| 3360 addTestSource(''' | |
| 3361 import "/testA.dart"; | |
| 3362 int T2; | |
| 3363 F2() { } | |
| 3364 typedef D2(); | |
| 3365 class C2 { } | |
| 3366 foo = {T^'''); | |
| 3367 computeFast(); | |
| 3368 return computeFull((bool result) { | |
| 3369 expect(request.replacementOffset, completionOffset - 1); | |
| 3370 expect(request.replacementLength, 1); | |
| 3371 // TODO(danrubel) Should be top level variable | |
| 3372 if (contributor is ImportedReferenceContributor) { | |
| 3373 assertSuggestGetter('T1', 'int'); | |
| 3374 // assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 3375 } | |
| 3376 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 3377 }); | |
| 3378 } | |
| 3379 | |
| 3380 test_MapLiteralEntry2() { | |
| 3381 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration | |
| 3382 addSource( | |
| 3383 '/testA.dart', | |
| 3384 ''' | |
| 3385 int T1; | |
| 3386 F1() { } | |
| 3387 typedef D1(); | |
| 3388 class C1 {C1(this.x) { } int x;}'''); | |
| 3389 addTestSource(''' | |
| 3390 import "/testA.dart"; | |
| 3391 int T2; | |
| 3392 F2() { } | |
| 3393 typedef D2(); | |
| 3394 class C2 { } | |
| 3395 foo = {7:T^};'''); | |
| 3396 computeFast(); | |
| 3397 return computeFull((bool result) { | |
| 3398 expect(request.replacementOffset, completionOffset - 1); | |
| 3399 expect(request.replacementLength, 1); | |
| 3400 // TODO(danrubel) Should be top level variable | |
| 3401 if (contributor is ImportedReferenceContributor) { | |
| 3402 assertSuggestGetter('T1', 'int'); | |
| 3403 // assertSuggestImportedTopLevelVar('T1', 'int'); | |
| 3404 } | |
| 3405 assertSuggestLocalTopLevelVar('T2', 'int'); | |
| 3406 }); | |
| 3407 } | |
| 3408 | |
| 3409 test_MethodDeclaration_body_getters() { | |
| 3410 // Block BlockFunctionBody MethodDeclaration | |
| 3411 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); | |
| 3412 computeFast(); | |
| 3413 return computeFull((bool result) { | |
| 3414 expect(request.replacementOffset, completionOffset); | |
| 3415 expect(request.replacementLength, 0); | |
| 3416 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | |
| 3417 if (methodA != null) { | |
| 3418 expect(methodA.element.isDeprecated, isFalse); | |
| 3419 expect(methodA.element.isPrivate, isFalse); | |
| 3420 } | |
| 3421 CompletionSuggestion getterF = assertSuggestLocalGetter('f', 'X', | |
| 3422 relevance: DART_RELEVANCE_LOW, deprecated: true); | |
| 3423 if (getterF != null) { | |
| 3424 expect(getterF.element.isDeprecated, isTrue); | |
| 3425 expect(getterF.element.isPrivate, isFalse); | |
| 3426 } | |
| 3427 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null, | |
| 3428 relevance: DART_RELEVANCE_DEFAULT); | |
| 3429 if (getterG != null) { | |
| 3430 expect(getterG.element.isDeprecated, isFalse); | |
| 3431 expect(getterG.element.isPrivate, isTrue); | |
| 3432 } | |
| 3433 }); | |
| 3434 } | |
| 3435 | |
| 3436 test_MethodDeclaration_body_static() { | |
| 3437 // Block BlockFunctionBody MethodDeclaration | |
| 3438 addSource( | |
| 3439 '/testC.dart', | |
| 3440 ''' | |
| 3441 class C { | |
| 3442 c1() {} | |
| 3443 var c2; | |
| 3444 static c3() {} | |
| 3445 static var c4;}'''); | |
| 3446 addTestSource(''' | |
| 3447 import "/testC.dart"; | |
| 3448 class B extends C { | |
| 3449 b1() {} | |
| 3450 var b2; | |
| 3451 static b3() {} | |
| 3452 static var b4;} | |
| 3453 class A extends B { | |
| 3454 a1() {} | |
| 3455 var a2; | |
| 3456 static a3() {} | |
| 3457 static var a4; | |
| 3458 static a() {^}}'''); | |
| 3459 computeFast(); | |
| 3460 return computeFull((bool result) { | |
| 3461 assertNotSuggested('a1'); | |
| 3462 assertNotSuggested('a2'); | |
| 3463 assertSuggestLocalMethod('a3', 'A', null); | |
| 3464 assertSuggestLocalField('a4', null); | |
| 3465 assertNotSuggested('b1'); | |
| 3466 assertNotSuggested('b2'); | |
| 3467 assertNotSuggested('b3'); | |
| 3468 assertNotSuggested('b4'); | |
| 3469 assertNotSuggested('c1'); | |
| 3470 assertNotSuggested('c2'); | |
| 3471 assertNotSuggested('c3'); | |
| 3472 assertNotSuggested('c4'); | |
| 3473 }); | |
| 3474 } | |
| 3475 | |
| 3476 test_MethodDeclaration_members() { | |
| 3477 // Block BlockFunctionBody MethodDeclaration | |
| 3478 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | |
| 3479 computeFast(); | |
| 3480 return computeFull((bool result) { | |
| 3481 expect(request.replacementOffset, completionOffset); | |
| 3482 expect(request.replacementLength, 0); | |
| 3483 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z', | |
| 3484 relevance: DART_RELEVANCE_DEFAULT); | |
| 3485 if (methodA != null) { | |
| 3486 expect(methodA.element.isDeprecated, isFalse); | |
| 3487 expect(methodA.element.isPrivate, isTrue); | |
| 3488 } | |
| 3489 CompletionSuggestion getterF = assertSuggestLocalField('f', 'X', | |
| 3490 relevance: DART_RELEVANCE_LOW, deprecated: true); | |
| 3491 if (getterF != null) { | |
| 3492 expect(getterF.element.isDeprecated, isTrue); | |
| 3493 expect(getterF.element.isPrivate, isFalse); | |
| 3494 expect(getterF.element.parameters, isNull); | |
| 3495 } | |
| 3496 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); | |
| 3497 if (getterG != null) { | |
| 3498 expect(getterG.element.isDeprecated, isFalse); | |
| 3499 expect(getterG.element.isPrivate, isTrue); | |
| 3500 expect(getterF.element.parameters, isNull); | |
| 3501 } | |
| 3502 assertSuggestImportedClass('bool'); | |
| 3503 }); | |
| 3504 } | |
| 3505 | |
| 3506 test_MethodDeclaration_parameters_named() { | |
| 3507 // Block BlockFunctionBody MethodDeclaration | |
| 3508 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); | |
| 3509 computeFast(); | |
| 3510 return computeFull((bool result) { | |
| 3511 expect(request.replacementOffset, completionOffset); | |
| 3512 expect(request.replacementLength, 0); | |
| 3513 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z', | |
| 3514 relevance: DART_RELEVANCE_LOW, deprecated: true); | |
| 3515 if (methodA != null) { | |
| 3516 expect(methodA.element.isDeprecated, isTrue); | |
| 3517 expect(methodA.element.isPrivate, isFalse); | |
| 3518 } | |
| 3519 assertSuggestParameter('x', 'X'); | |
| 3520 assertSuggestParameter('y', null); | |
| 3521 assertSuggestParameter('b', null); | |
| 3522 assertSuggestImportedClass('int'); | |
| 3523 assertNotSuggested('_'); | |
| 3524 }); | |
| 3525 } | |
| 3526 | |
| 3527 test_MethodDeclaration_parameters_positional() { | |
| 3528 // Block BlockFunctionBody MethodDeclaration | |
| 3529 addTestSource(''' | |
| 3530 foo() { } | |
| 3531 void bar() { } | |
| 3532 class A {Z a(X x, [int y=1]) {^}}'''); | |
| 3533 computeFast(); | |
| 3534 return computeFull((bool result) { | |
| 3535 expect(request.replacementOffset, completionOffset); | |
| 3536 expect(request.replacementLength, 0); | |
| 3537 assertSuggestLocalFunction('foo', null); | |
| 3538 assertSuggestLocalFunction('bar', 'void'); | |
| 3539 assertSuggestLocalMethod('a', 'A', 'Z'); | |
| 3540 assertSuggestParameter('x', 'X'); | |
| 3541 assertSuggestParameter('y', 'int'); | |
| 3542 assertSuggestImportedClass('String'); | |
| 3543 }); | |
| 3544 } | |
| 3545 | |
| 3546 test_MethodDeclaration_returnType() { | |
| 3547 // ClassDeclaration CompilationUnit | |
| 3548 addSource( | |
| 3549 '/testA.dart', | |
| 3550 ''' | |
| 3551 int T1; | |
| 3552 F1() { } | |
| 3553 typedef D1(); | |
| 3554 class C1 {C1(this.x) { } int x;}'''); | |
| 3555 addTestSource(''' | |
| 3556 import "/testA.dart"; | |
| 3557 int T2; | |
| 3558 F2() { } | |
| 3559 typedef D2(); | |
| 3560 class C2 {^ zoo(z) { } String name; }'''); | |
| 3561 computeFast(); | |
| 3562 return computeFull((bool result) { | |
| 3563 expect(request.replacementOffset, completionOffset); | |
| 3564 expect(request.replacementLength, 0); | |
| 3565 assertSuggestImportedClass('Object'); | |
| 3566 assertNotSuggested('T1'); | |
| 3567 assertNotSuggested('F1'); | |
| 3568 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3569 assertSuggestImportedClass('C1'); | |
| 3570 assertNotSuggested('T2'); | |
| 3571 assertNotSuggested('F2'); | |
| 3572 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3573 assertSuggestLocalClass('C2'); | |
| 3574 assertNotSuggested('name'); | |
| 3575 }); | |
| 3576 } | |
| 3577 | |
| 3578 test_MethodDeclaration_returnType_afterComment() { | |
| 3579 // ClassDeclaration CompilationUnit | |
| 3580 addSource( | |
| 3581 '/testA.dart', | |
| 3582 ''' | |
| 3583 int T1; | |
| 3584 F1() { } | |
| 3585 typedef D1(); | |
| 3586 class C1 {C1(this.x) { } int x;}'''); | |
| 3587 addTestSource(''' | |
| 3588 import "/testA.dart"; | |
| 3589 int T2; | |
| 3590 F2() { } | |
| 3591 typedef D2(); | |
| 3592 class C2 {/* */ ^ zoo(z) { } String name; }'''); | |
| 3593 computeFast(); | |
| 3594 return computeFull((bool result) { | |
| 3595 expect(request.replacementOffset, completionOffset); | |
| 3596 expect(request.replacementLength, 0); | |
| 3597 assertSuggestImportedClass('Object'); | |
| 3598 assertNotSuggested('T1'); | |
| 3599 assertNotSuggested('F1'); | |
| 3600 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3601 assertSuggestImportedClass('C1'); | |
| 3602 assertNotSuggested('T2'); | |
| 3603 assertNotSuggested('F2'); | |
| 3604 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3605 assertSuggestLocalClass('C2'); | |
| 3606 assertNotSuggested('name'); | |
| 3607 }); | |
| 3608 } | |
| 3609 | |
| 3610 test_MethodDeclaration_returnType_afterComment2() { | |
| 3611 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 3612 addSource( | |
| 3613 '/testA.dart', | |
| 3614 ''' | |
| 3615 int T1; | |
| 3616 F1() { } | |
| 3617 typedef D1(); | |
| 3618 class C1 {C1(this.x) { } int x;}'''); | |
| 3619 addTestSource(''' | |
| 3620 import "/testA.dart"; | |
| 3621 int T2; | |
| 3622 F2() { } | |
| 3623 typedef D2(); | |
| 3624 class C2 {/** */ ^ zoo(z) { } String name; }'''); | |
| 3625 computeFast(); | |
| 3626 return computeFull((bool result) { | |
| 3627 expect(request.replacementOffset, completionOffset); | |
| 3628 expect(request.replacementLength, 0); | |
| 3629 assertSuggestImportedClass('Object'); | |
| 3630 assertNotSuggested('T1'); | |
| 3631 assertNotSuggested('F1'); | |
| 3632 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3633 assertSuggestImportedClass('C1'); | |
| 3634 assertNotSuggested('T2'); | |
| 3635 assertNotSuggested('F2'); | |
| 3636 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3637 assertSuggestLocalClass('C2'); | |
| 3638 assertNotSuggested('name'); | |
| 3639 }); | |
| 3640 } | |
| 3641 | |
| 3642 test_MethodDeclaration_returnType_afterComment3() { | |
| 3643 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 3644 addSource( | |
| 3645 '/testA.dart', | |
| 3646 ''' | |
| 3647 int T1; | |
| 3648 F1() { } | |
| 3649 typedef D1(); | |
| 3650 class C1 {C1(this.x) { } int x;}'''); | |
| 3651 addTestSource(''' | |
| 3652 import "/testA.dart"; | |
| 3653 int T2; | |
| 3654 F2() { } | |
| 3655 typedef D2(); | |
| 3656 class C2 { | |
| 3657 /// some dartdoc | |
| 3658 ^ zoo(z) { } String name; }'''); | |
| 3659 computeFast(); | |
| 3660 return computeFull((bool result) { | |
| 3661 expect(request.replacementOffset, completionOffset); | |
| 3662 expect(request.replacementLength, 0); | |
| 3663 assertSuggestImportedClass('Object'); | |
| 3664 assertNotSuggested('T1'); | |
| 3665 assertNotSuggested('F1'); | |
| 3666 assertSuggestImportedFunctionTypeAlias('D1', null); | |
| 3667 assertSuggestImportedClass('C1'); | |
| 3668 assertNotSuggested('T2'); | |
| 3669 assertNotSuggested('F2'); | |
| 3670 assertSuggestLocalFunctionTypeAlias('D2', null); | |
| 3671 assertSuggestLocalClass('C2'); | |
| 3672 assertNotSuggested('name'); | |
| 3673 }); | |
| 3674 } | |
| 3675 | |
| 3676 test_MethodInvocation_no_semicolon() { | |
| 3677 // MethodInvocation ExpressionStatement Block | |
| 3678 addTestSource(''' | |
| 3679 main() { } | |
| 3680 class I {X get f => new A();get _g => new A();} | |
| 3681 class A implements I { | |
| 3682 var b; X _c; | |
| 3683 X get d => new A();get _e => new A(); | |
| 3684 // no semicolon between completion point and next statement | |
| 3685 set s1(I x) {} set _s2(I x) {x.^ m(null);} | |
| 3686 m(X x) {} I _n(X x) {}} | |
| 3687 class X{}'''); | |
| 3688 computeFast(); | |
| 3689 return computeFull((bool result) { | |
| 3690 expect(request.replacementOffset, completionOffset); | |
| 3691 expect(request.replacementLength, 0); | |
| 3692 assertSuggestInvocationGetter('f', 'X'); | |
| 3693 assertSuggestInvocationGetter('_g', null); | |
| 3694 assertNotSuggested('b'); | |
| 3695 assertNotSuggested('_c'); | |
| 3696 assertNotSuggested('d'); | |
| 3697 assertNotSuggested('_e'); | |
| 3698 assertNotSuggested('s1'); | |
| 3699 assertNotSuggested('_s2'); | |
| 3700 assertNotSuggested('m'); | |
| 3701 assertNotSuggested('_n'); | |
| 3702 assertNotSuggested('a'); | |
| 3703 assertNotSuggested('A'); | |
| 3704 assertNotSuggested('X'); | |
| 3705 assertNotSuggested('Object'); | |
| 3706 assertNotSuggested('=='); | |
| 3707 }); | |
| 3708 } | |
| 3709 | |
| 3710 test_new_instance() { | |
| 3711 addTestSource('import "dart:math"; class A {x() {new Random().^}}'); | |
| 3712 computeFast(); | |
| 3713 return computeFull((bool result) { | |
| 3714 assertSuggestInvocationMethod('nextBool', 'Random', 'bool'); | |
| 3715 assertSuggestInvocationMethod('nextDouble', 'Random', 'double'); | |
| 3716 assertSuggestInvocationMethod('nextInt', 'Random', 'int'); | |
| 3717 assertNotSuggested('Random'); | |
| 3718 assertNotSuggested('Object'); | |
| 3719 assertNotSuggested('A'); | |
| 3720 }); | |
| 3721 } | |
| 3722 | |
| 3723 test_parameterName_excludeTypes() { | |
| 3724 addTestSource('m(int ^) {}'); | |
| 3725 return computeFull((bool result) { | |
| 3726 assertNotSuggested('int'); | |
| 3727 assertNotSuggested('bool'); | |
| 3728 }); | |
| 3729 } | |
| 3730 | |
| 3731 test_partFile_TypeName() { | |
| 3732 // SimpleIdentifier TypeName ConstructorName | |
| 3733 addSource( | |
| 3734 '/testB.dart', | |
| 3735 ''' | |
| 3736 lib B; | |
| 3737 int T1; | |
| 3738 F1() { } | |
| 3739 class X {X.c(); X._d(); z() {}}'''); | |
| 3740 addSource( | |
| 3741 '/testA.dart', | |
| 3742 ''' | |
| 3743 library libA; | |
| 3744 import "/testB.dart"; | |
| 3745 part "$testFile"; | |
| 3746 class A { } | |
| 3747 var m;'''); | |
| 3748 addTestSource(''' | |
| 3749 part of libA; | |
| 3750 class B { factory B.bar(int x) => null; } | |
| 3751 main() {new ^}'''); | |
| 3752 computeFast(); | |
| 3753 return computeFull((bool result) { | |
| 3754 expect(request.replacementOffset, completionOffset); | |
| 3755 expect(request.replacementLength, 0); | |
| 3756 // Suggested by ConstructorContributor | |
| 3757 assertNotSuggested('B.bar'); | |
| 3758 assertSuggestImportedConstructor('Object'); | |
| 3759 assertSuggestImportedConstructor('X.c'); | |
| 3760 assertNotSuggested('X._d'); | |
| 3761 // Suggested by LocalLibraryContributor | |
| 3762 assertNotSuggested('A'); | |
| 3763 assertNotSuggested('F1'); | |
| 3764 assertNotSuggested('T1'); | |
| 3765 assertNotSuggested('_d'); | |
| 3766 assertNotSuggested('z'); | |
| 3767 assertNotSuggested('m'); | |
| 3768 }); | |
| 3769 } | |
| 3770 | |
| 3771 test_partFile_TypeName2() { | |
| 3772 // SimpleIdentifier TypeName ConstructorName | |
| 3773 addSource( | |
| 3774 '/testB.dart', | |
| 3775 ''' | |
| 3776 lib B; | |
| 3777 int T1; | |
| 3778 F1() { } | |
| 3779 class X {X.c(); X._d(); z() {}}'''); | |
| 3780 addSource( | |
| 3781 '/testA.dart', | |
| 3782 ''' | |
| 3783 part of libA; | |
| 3784 class B { }'''); | |
| 3785 addTestSource(''' | |
| 3786 library libA; | |
| 3787 import "/testB.dart"; | |
| 3788 part "/testA.dart"; | |
| 3789 class A { A({String boo: 'hoo'}) { } } | |
| 3790 main() {new ^} | |
| 3791 var m;'''); | |
| 3792 computeFast(); | |
| 3793 return computeFull((bool result) { | |
| 3794 expect(request.replacementOffset, completionOffset); | |
| 3795 expect(request.replacementLength, 0); | |
| 3796 // Suggested by ConstructorContributor | |
| 3797 assertNotSuggested('A'); | |
| 3798 assertSuggestImportedConstructor('Object'); | |
| 3799 assertSuggestImportedConstructor('X.c'); | |
| 3800 assertNotSuggested('X._d'); | |
| 3801 // Suggested by LocalLibraryContributor | |
| 3802 assertNotSuggested('B'); | |
| 3803 assertNotSuggested('F1'); | |
| 3804 assertNotSuggested('T1'); | |
| 3805 assertNotSuggested('_d'); | |
| 3806 assertNotSuggested('z'); | |
| 3807 assertNotSuggested('m'); | |
| 3808 }); | |
| 3809 } | |
| 3810 | |
| 3811 test_PrefixedIdentifier_class_const() { | |
| 3812 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block | |
| 3813 addSource( | |
| 3814 '/testB.dart', | |
| 3815 ''' | |
| 3816 lib B; | |
| 3817 class I { | |
| 3818 static const scI = 'boo'; | |
| 3819 X get f => new A(); | |
| 3820 get _g => new A();} | |
| 3821 class B implements I { | |
| 3822 static const int scB = 12; | |
| 3823 var b; X _c; | |
| 3824 X get d => new A();get _e => new A(); | |
| 3825 set s1(I x) {} set _s2(I x) {} | |
| 3826 m(X x) {} I _n(X x) {}} | |
| 3827 class X{}'''); | |
| 3828 addTestSource(''' | |
| 3829 import "/testB.dart"; | |
| 3830 class A extends B { | |
| 3831 static const String scA = 'foo'; | |
| 3832 w() { }} | |
| 3833 main() {A.^}'''); | |
| 3834 computeFast(); | |
| 3835 return computeFull((bool result) { | |
| 3836 expect(request.replacementOffset, completionOffset); | |
| 3837 expect(request.replacementLength, 0); | |
| 3838 // Suggested by StaticMemberContributor | |
| 3839 assertNotSuggested('scA'); | |
| 3840 assertNotSuggested('scB'); | |
| 3841 assertNotSuggested('scI'); | |
| 3842 assertNotSuggested('b'); | |
| 3843 assertNotSuggested('_c'); | |
| 3844 assertNotSuggested('d'); | |
| 3845 assertNotSuggested('_e'); | |
| 3846 assertNotSuggested('f'); | |
| 3847 assertNotSuggested('_g'); | |
| 3848 assertNotSuggested('s1'); | |
| 3849 assertNotSuggested('_s2'); | |
| 3850 assertNotSuggested('m'); | |
| 3851 assertNotSuggested('_n'); | |
| 3852 assertNotSuggested('a'); | |
| 3853 assertNotSuggested('A'); | |
| 3854 assertNotSuggested('X'); | |
| 3855 assertNotSuggested('w'); | |
| 3856 assertNotSuggested('Object'); | |
| 3857 assertNotSuggested('=='); | |
| 3858 }); | |
| 3859 } | |
| 3860 | |
| 3861 test_PrefixedIdentifier_class_imported() { | |
| 3862 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 3863 addSource( | |
| 3864 '/testB.dart', | |
| 3865 ''' | |
| 3866 lib B; | |
| 3867 class I {X get f => new A();get _g => new A();} | |
| 3868 class A implements I { | |
| 3869 static const int sc = 12; | |
| 3870 @deprecated var b; X _c; | |
| 3871 X get d => new A();get _e => new A(); | |
| 3872 set s1(I x) {} set _s2(I x) {} | |
| 3873 m(X x) {} I _n(X x) {}} | |
| 3874 class X{}'''); | |
| 3875 addTestSource(''' | |
| 3876 import "/testB.dart"; | |
| 3877 main() {A a; a.^}'''); | |
| 3878 computeFast(); | |
| 3879 return computeFull((bool result) { | |
| 3880 expect(request.replacementOffset, completionOffset); | |
| 3881 expect(request.replacementLength, 0); | |
| 3882 assertNotSuggested('sc'); | |
| 3883 assertSuggestInvocationField('b', null, isDeprecated: true); | |
| 3884 assertNotSuggested('_c'); | |
| 3885 assertSuggestInvocationGetter('d', 'X'); | |
| 3886 assertNotSuggested('_e'); | |
| 3887 assertSuggestInvocationGetter('f', 'X'); | |
| 3888 assertNotSuggested('_g'); | |
| 3889 assertSuggestInvocationSetter('s1'); | |
| 3890 assertNotSuggested('_s2'); | |
| 3891 assertSuggestInvocationMethod('m', 'A', null); | |
| 3892 assertNotSuggested('_n'); | |
| 3893 assertNotSuggested('a'); | |
| 3894 assertNotSuggested('A'); | |
| 3895 assertNotSuggested('X'); | |
| 3896 assertNotSuggested('Object'); | |
| 3897 assertNotSuggested('=='); | |
| 3898 }); | |
| 3899 } | |
| 3900 | |
| 3901 test_PrefixedIdentifier_class_local() { | |
| 3902 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 3903 addTestSource(''' | |
| 3904 main() {A a; a.^} | |
| 3905 class I {X get f => new A();get _g => new A();} | |
| 3906 class A implements I { | |
| 3907 static const int sc = 12; | |
| 3908 var b; X _c; | |
| 3909 X get d => new A();get _e => new A(); | |
| 3910 set s1(I x) {} set _s2(I x) {} | |
| 3911 m(X x) {} I _n(X x) {}} | |
| 3912 class X{}'''); | |
| 3913 computeFast(); | |
| 3914 return computeFull((bool result) { | |
| 3915 expect(request.replacementOffset, completionOffset); | |
| 3916 expect(request.replacementLength, 0); | |
| 3917 assertNotSuggested('sc'); | |
| 3918 assertSuggestInvocationField('b', null); | |
| 3919 assertSuggestInvocationField('_c', 'X'); | |
| 3920 assertSuggestInvocationGetter('d', 'X'); | |
| 3921 assertSuggestInvocationGetter('_e', null); | |
| 3922 assertSuggestInvocationGetter('f', 'X'); | |
| 3923 assertSuggestInvocationGetter('_g', null); | |
| 3924 assertSuggestInvocationSetter('s1'); | |
| 3925 assertSuggestInvocationSetter('_s2'); | |
| 3926 assertSuggestInvocationMethod('m', 'A', null); | |
| 3927 assertSuggestInvocationMethod('_n', 'A', 'I'); | |
| 3928 assertNotSuggested('a'); | |
| 3929 assertNotSuggested('A'); | |
| 3930 assertNotSuggested('X'); | |
| 3931 assertNotSuggested('Object'); | |
| 3932 assertNotSuggested('=='); | |
| 3933 }); | |
| 3934 } | |
| 3935 | |
| 3936 test_PrefixedIdentifier_getter() { | |
| 3937 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 3938 addTestSource('String get g => "one"; f() {g.^}'); | |
| 3939 computeFast(); | |
| 3940 return computeFull((bool result) { | |
| 3941 assertSuggestInvocationGetter('length', 'int'); | |
| 3942 }); | |
| 3943 } | |
| 3944 | |
| 3945 test_PrefixedIdentifier_library() { | |
| 3946 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 3947 addSource( | |
| 3948 '/testB.dart', | |
| 3949 ''' | |
| 3950 lib B; | |
| 3951 var T1; | |
| 3952 class X { } | |
| 3953 class Y { }'''); | |
| 3954 addTestSource(''' | |
| 3955 import "/testB.dart" as b; | |
| 3956 var T2; | |
| 3957 class A { } | |
| 3958 main() {b.^}'''); | |
| 3959 computeFast(); | |
| 3960 return computeFull((bool result) { | |
| 3961 expect(request.replacementOffset, completionOffset); | |
| 3962 expect(request.replacementLength, 0); | |
| 3963 // Suggested by LibraryMemberContributor | |
| 3964 assertNotSuggested('X'); | |
| 3965 assertNotSuggested('Y'); | |
| 3966 assertNotSuggested('T1'); | |
| 3967 assertNotSuggested('T2'); | |
| 3968 assertNotSuggested('Object'); | |
| 3969 assertNotSuggested('b'); | |
| 3970 assertNotSuggested('A'); | |
| 3971 assertNotSuggested('=='); | |
| 3972 }); | |
| 3973 } | |
| 3974 | |
| 3975 test_PrefixedIdentifier_library_typesOnly() { | |
| 3976 // SimpleIdentifier PrefixedIdentifier TypeName | |
| 3977 addSource( | |
| 3978 '/testB.dart', | |
| 3979 ''' | |
| 3980 lib B; | |
| 3981 var T1; | |
| 3982 class X { } | |
| 3983 class Y { }'''); | |
| 3984 addTestSource(''' | |
| 3985 import "/testB.dart" as b; | |
| 3986 var T2; | |
| 3987 class A { } | |
| 3988 foo(b.^ f) {}'''); | |
| 3989 computeFast(); | |
| 3990 return computeFull((bool result) { | |
| 3991 expect(request.replacementOffset, completionOffset); | |
| 3992 expect(request.replacementLength, 0); | |
| 3993 // Suggested by LibraryMemberContributor | |
| 3994 assertNotSuggested('X'); | |
| 3995 assertNotSuggested('Y'); | |
| 3996 assertNotSuggested('T1'); | |
| 3997 assertNotSuggested('T2'); | |
| 3998 assertNotSuggested('Object'); | |
| 3999 assertNotSuggested('b'); | |
| 4000 assertNotSuggested('A'); | |
| 4001 assertNotSuggested('=='); | |
| 4002 }); | |
| 4003 } | |
| 4004 | |
| 4005 test_PrefixedIdentifier_library_typesOnly2() { | |
| 4006 // SimpleIdentifier PrefixedIdentifier TypeName | |
| 4007 addSource( | |
| 4008 '/testB.dart', | |
| 4009 ''' | |
| 4010 lib B; | |
| 4011 var T1; | |
| 4012 class X { } | |
| 4013 class Y { }'''); | |
| 4014 addTestSource(''' | |
| 4015 import "/testB.dart" as b; | |
| 4016 var T2; | |
| 4017 class A { } | |
| 4018 foo(b.^) {}'''); | |
| 4019 computeFast(); | |
| 4020 return computeFull((bool result) { | |
| 4021 expect(request.replacementOffset, completionOffset); | |
| 4022 expect(request.replacementLength, 0); | |
| 4023 // Suggested by LibraryMemberContributor | |
| 4024 assertNotSuggested('X'); | |
| 4025 assertNotSuggested('Y'); | |
| 4026 assertNotSuggested('T1'); | |
| 4027 assertNotSuggested('T2'); | |
| 4028 assertNotSuggested('Object'); | |
| 4029 assertNotSuggested('b'); | |
| 4030 assertNotSuggested('A'); | |
| 4031 assertNotSuggested('=='); | |
| 4032 }); | |
| 4033 } | |
| 4034 | |
| 4035 test_PrefixedIdentifier_parameter() { | |
| 4036 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4037 addSource( | |
| 4038 '/testB.dart', | |
| 4039 ''' | |
| 4040 lib B; | |
| 4041 class _W {M y; var _z;} | |
| 4042 class X extends _W {} | |
| 4043 class M{}'''); | |
| 4044 addTestSource(''' | |
| 4045 import "/testB.dart"; | |
| 4046 foo(X x) {x.^}'''); | |
| 4047 computeFast(); | |
| 4048 return computeFull((bool result) { | |
| 4049 expect(request.replacementOffset, completionOffset); | |
| 4050 expect(request.replacementLength, 0); | |
| 4051 assertSuggestInvocationField('y', 'M'); | |
| 4052 assertNotSuggested('_z'); | |
| 4053 assertNotSuggested('=='); | |
| 4054 }); | |
| 4055 } | |
| 4056 | |
| 4057 test_PrefixedIdentifier_prefix() { | |
| 4058 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4059 addSource( | |
| 4060 '/testA.dart', | |
| 4061 ''' | |
| 4062 class A {static int bar = 10;} | |
| 4063 _B() {}'''); | |
| 4064 addTestSource(''' | |
| 4065 import "/testA.dart"; | |
| 4066 class X {foo(){A^.bar}}'''); | |
| 4067 computeFast(); | |
| 4068 return computeFull((bool result) { | |
| 4069 expect(request.replacementOffset, completionOffset - 1); | |
| 4070 expect(request.replacementLength, 1); | |
| 4071 assertSuggestImportedClass('A'); | |
| 4072 assertSuggestLocalClass('X'); | |
| 4073 assertSuggestLocalMethod('foo', 'X', null); | |
| 4074 assertNotSuggested('bar'); | |
| 4075 assertNotSuggested('_B'); | |
| 4076 }); | |
| 4077 } | |
| 4078 | |
| 4079 test_PrefixedIdentifier_propertyAccess() { | |
| 4080 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody | |
| 4081 addTestSource('class A {String x; int get foo {x.^}'); | |
| 4082 computeFast(); | |
| 4083 return computeFull((bool result) { | |
| 4084 expect(request.replacementOffset, completionOffset); | |
| 4085 expect(request.replacementLength, 0); | |
| 4086 assertSuggestInvocationGetter('isEmpty', 'bool'); | |
| 4087 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | |
| 4088 }); | |
| 4089 } | |
| 4090 | |
| 4091 test_PrefixedIdentifier_propertyAccess_newStmt() { | |
| 4092 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody | |
| 4093 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); | |
| 4094 computeFast(); | |
| 4095 return computeFull((bool result) { | |
| 4096 expect(request.replacementOffset, completionOffset); | |
| 4097 expect(request.replacementLength, 0); | |
| 4098 assertSuggestInvocationGetter('isEmpty', 'bool'); | |
| 4099 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | |
| 4100 }); | |
| 4101 } | |
| 4102 | |
| 4103 test_PrefixedIdentifier_trailingStmt_const() { | |
| 4104 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4105 addTestSource('const String g = "hello"; f() {g.^ int y = 0;}'); | |
| 4106 computeFast(); | |
| 4107 return computeFull((bool result) { | |
| 4108 assertSuggestInvocationGetter('length', 'int'); | |
| 4109 }); | |
| 4110 } | |
| 4111 | |
| 4112 test_PrefixedIdentifier_trailingStmt_field() { | |
| 4113 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4114 addTestSource('class A {String g; f() {g.^ int y = 0;}}'); | |
| 4115 computeFast(); | |
| 4116 return computeFull((bool result) { | |
| 4117 assertSuggestInvocationGetter('length', 'int'); | |
| 4118 }); | |
| 4119 } | |
| 4120 | |
| 4121 test_PrefixedIdentifier_trailingStmt_function() { | |
| 4122 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4123 addTestSource('String g() => "one"; f() {g.^ int y = 0;}'); | |
| 4124 computeFast(); | |
| 4125 return computeFull((bool result) { | |
| 4126 assertSuggestInvocationGetter('length', 'int'); | |
| 4127 }); | |
| 4128 } | |
| 4129 | |
| 4130 test_PrefixedIdentifier_trailingStmt_functionTypeAlias() { | |
| 4131 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4132 addTestSource('typedef String g(); f() {g.^ int y = 0;}'); | |
| 4133 computeFast(); | |
| 4134 return computeFull((bool result) { | |
| 4135 assertSuggestInvocationGetter('length', 'int'); | |
| 4136 }); | |
| 4137 } | |
| 4138 | |
| 4139 test_PrefixedIdentifier_trailingStmt_getter() { | |
| 4140 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4141 addTestSource('String get g => "one"; f() {g.^ int y = 0;}'); | |
| 4142 computeFast(); | |
| 4143 return computeFull((bool result) { | |
| 4144 assertSuggestInvocationGetter('length', 'int'); | |
| 4145 }); | |
| 4146 } | |
| 4147 | |
| 4148 test_PrefixedIdentifier_trailingStmt_local_typed() { | |
| 4149 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4150 addTestSource('f() {String g; g.^ int y = 0;}'); | |
| 4151 computeFast(); | |
| 4152 return computeFull((bool result) { | |
| 4153 assertSuggestInvocationGetter('length', 'int'); | |
| 4154 }); | |
| 4155 } | |
| 4156 | |
| 4157 test_PrefixedIdentifier_trailingStmt_local_untyped() { | |
| 4158 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4159 addTestSource('f() {var g = "hello"; g.^ int y = 0;}'); | |
| 4160 computeFast(); | |
| 4161 return computeFull((bool result) { | |
| 4162 assertSuggestInvocationGetter('length', 'int'); | |
| 4163 }); | |
| 4164 } | |
| 4165 | |
| 4166 test_PrefixedIdentifier_trailingStmt_method() { | |
| 4167 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4168 addTestSource('class A {String g() {}; f() {g.^ int y = 0;}}'); | |
| 4169 computeFast(); | |
| 4170 return computeFull((bool result) { | |
| 4171 assertSuggestInvocationGetter('length', 'int'); | |
| 4172 }); | |
| 4173 } | |
| 4174 | |
| 4175 test_PrefixedIdentifier_trailingStmt_param() { | |
| 4176 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4177 addTestSource('class A {f(String g) {g.^ int y = 0;}}'); | |
| 4178 computeFast(); | |
| 4179 return computeFull((bool result) { | |
| 4180 assertSuggestInvocationGetter('length', 'int'); | |
| 4181 }); | |
| 4182 } | |
| 4183 | |
| 4184 test_PrefixedIdentifier_trailingStmt_param2() { | |
| 4185 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4186 addTestSource('f(String g) {g.^ int y = 0;}'); | |
| 4187 computeFast(); | |
| 4188 return computeFull((bool result) { | |
| 4189 assertSuggestInvocationGetter('length', 'int'); | |
| 4190 }); | |
| 4191 } | |
| 4192 | |
| 4193 test_PrefixedIdentifier_trailingStmt_topLevelVar() { | |
| 4194 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 4195 addTestSource('String g; f() {g.^ int y = 0;}'); | |
| 4196 computeFast(); | |
| 4197 return computeFull((bool result) { | |
| 4198 assertSuggestInvocationGetter('length', 'int'); | |
| 4199 }); | |
| 4200 } | |
| 4201 | |
| 4202 test_PropertyAccess_expression() { | |
| 4203 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | |
| 4204 addTestSource('class A {a() {"hello".to^String().length}}'); | |
| 4205 computeFast(); | |
| 4206 return computeFull((bool result) { | |
| 4207 expect(request.replacementOffset, completionOffset - 2); | |
| 4208 expect(request.replacementLength, 8); | |
| 4209 assertSuggestInvocationGetter('length', 'int'); | |
| 4210 assertNotSuggested('A'); | |
| 4211 assertNotSuggested('a'); | |
| 4212 assertNotSuggested('Object'); | |
| 4213 assertNotSuggested('=='); | |
| 4214 }); | |
| 4215 } | |
| 4216 | |
| 4217 test_PropertyAccess_noTarget() { | |
| 4218 // SimpleIdentifier PropertyAccess ExpressionStatement | |
| 4219 addSource('/testAB.dart', 'class Foo { }'); | |
| 4220 addTestSource('class C {foo(){.^}}'); | |
| 4221 computeFast(); | |
| 4222 return computeFull((bool result) { | |
| 4223 assertNoSuggestions(); | |
| 4224 }); | |
| 4225 } | |
| 4226 | |
| 4227 test_PropertyAccess_noTarget2() { | |
| 4228 // SimpleIdentifier PropertyAccess ExpressionStatement | |
| 4229 addSource('/testAB.dart', 'class Foo { }'); | |
| 4230 addTestSource('main() {.^}'); | |
| 4231 computeFast(); | |
| 4232 return computeFull((bool result) { | |
| 4233 assertNoSuggestions(); | |
| 4234 }); | |
| 4235 } | |
| 4236 | |
| 4237 test_PropertyAccess_selector() { | |
| 4238 // SimpleIdentifier PropertyAccess ExpressionStatement Block | |
| 4239 addTestSource('class A {a() {"hello".length.^}}'); | |
| 4240 computeFast(); | |
| 4241 return computeFull((bool result) { | |
| 4242 expect(request.replacementOffset, completionOffset); | |
| 4243 expect(request.replacementLength, 0); | |
| 4244 assertSuggestInvocationGetter('isEven', 'bool'); | |
| 4245 assertNotSuggested('A'); | |
| 4246 assertNotSuggested('a'); | |
| 4247 assertNotSuggested('Object'); | |
| 4248 assertNotSuggested('=='); | |
| 4249 }); | |
| 4250 } | |
| 4251 | |
| 4252 test_SwitchStatement_c() { | |
| 4253 // SwitchStatement Block BlockFunctionBody MethodDeclaration | |
| 4254 addTestSource('class A {String g(int x) {switch(x) {c^}}}'); | |
| 4255 computeFast(); | |
| 4256 return computeFull((bool result) { | |
| 4257 assertNoSuggestions(); | |
| 4258 }); | |
| 4259 } | |
| 4260 | |
| 4261 test_SwitchStatement_case() { | |
| 4262 // SwitchStatement Block BlockFunctionBody MethodDeclaration | |
| 4263 addTestSource('class A {String g(int x) {var t; switch(x) {case 0: ^}}}'); | |
| 4264 computeFast(); | |
| 4265 return computeFull((bool result) { | |
| 4266 assertSuggestLocalClass('A'); | |
| 4267 assertSuggestLocalMethod('g', 'A', 'String'); | |
| 4268 assertSuggestLocalVariable('t', null); | |
| 4269 assertSuggestImportedClass('String'); | |
| 4270 }); | |
| 4271 } | |
| 4272 | |
| 4273 test_SwitchStatement_empty() { | |
| 4274 // SwitchStatement Block BlockFunctionBody MethodDeclaration | |
| 4275 addTestSource('class A {String g(int x) {switch(x) {^}}}'); | |
| 4276 computeFast(); | |
| 4277 return computeFull((bool result) { | |
| 4278 assertNoSuggestions(); | |
| 4279 }); | |
| 4280 } | |
| 4281 | |
| 4282 test_ThisExpression_block() { | |
| 4283 // MethodInvocation ExpressionStatement Block | |
| 4284 addTestSource(''' | |
| 4285 main() { } | |
| 4286 class I {X get f => new A();get _g => new A();} | |
| 4287 class A implements I { | |
| 4288 A() {} | |
| 4289 A.z() {} | |
| 4290 var b; X _c; | |
| 4291 X get d => new A();get _e => new A(); | |
| 4292 // no semicolon between completion point and next statement | |
| 4293 set s1(I x) {} set _s2(I x) {this.^ m(null);} | |
| 4294 m(X x) {} I _n(X x) {}} | |
| 4295 class X{}'''); | |
| 4296 computeFast(); | |
| 4297 return computeFull((bool result) { | |
| 4298 expect(request.replacementOffset, completionOffset); | |
| 4299 expect(request.replacementLength, 0); | |
| 4300 assertSuggestInvocationField('b', null); | |
| 4301 assertSuggestInvocationField('_c', 'X'); | |
| 4302 assertSuggestInvocationGetter('d', 'X'); | |
| 4303 assertSuggestInvocationGetter('_e', null); | |
| 4304 assertSuggestInvocationGetter('f', 'X'); | |
| 4305 assertSuggestInvocationGetter('_g', null); | |
| 4306 assertSuggestInvocationMethod('m', 'A', null); | |
| 4307 assertSuggestInvocationMethod('_n', 'A', 'I'); | |
| 4308 assertSuggestInvocationSetter('s1'); | |
| 4309 assertSuggestInvocationSetter('_s2'); | |
| 4310 assertNotSuggested('z'); | |
| 4311 assertNotSuggested('I'); | |
| 4312 assertNotSuggested('A'); | |
| 4313 assertNotSuggested('X'); | |
| 4314 assertNotSuggested('Object'); | |
| 4315 assertNotSuggested('=='); | |
| 4316 }); | |
| 4317 } | |
| 4318 | |
| 4319 test_ThisExpression_constructor() { | |
| 4320 // MethodInvocation ExpressionStatement Block | |
| 4321 addTestSource(''' | |
| 4322 main() { } | |
| 4323 class I {X get f => new A();get _g => new A();} | |
| 4324 class A implements I { | |
| 4325 A() {this.^} | |
| 4326 A.z() {} | |
| 4327 var b; X _c; | |
| 4328 X get d => new A();get _e => new A(); | |
| 4329 // no semicolon between completion point and next statement | |
| 4330 set s1(I x) {} set _s2(I x) {m(null);} | |
| 4331 m(X x) {} I _n(X x) {}} | |
| 4332 class X{}'''); | |
| 4333 computeFast(); | |
| 4334 return computeFull((bool result) { | |
| 4335 expect(request.replacementOffset, completionOffset); | |
| 4336 expect(request.replacementLength, 0); | |
| 4337 assertSuggestInvocationField('b', null); | |
| 4338 assertSuggestInvocationField('_c', 'X'); | |
| 4339 assertSuggestInvocationGetter('d', 'X'); | |
| 4340 assertSuggestInvocationGetter('_e', null); | |
| 4341 assertSuggestInvocationGetter('f', 'X'); | |
| 4342 assertSuggestInvocationGetter('_g', null); | |
| 4343 assertSuggestInvocationMethod('m', 'A', null); | |
| 4344 assertSuggestInvocationMethod('_n', 'A', 'I'); | |
| 4345 assertSuggestInvocationSetter('s1'); | |
| 4346 assertSuggestInvocationSetter('_s2'); | |
| 4347 assertNotSuggested('z'); | |
| 4348 assertNotSuggested('I'); | |
| 4349 assertNotSuggested('A'); | |
| 4350 assertNotSuggested('X'); | |
| 4351 assertNotSuggested('Object'); | |
| 4352 assertNotSuggested('=='); | |
| 4353 }); | |
| 4354 } | |
| 4355 | |
| 4356 test_ThisExpression_constructor_param() { | |
| 4357 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 4358 addTestSource(''' | |
| 4359 main() { } | |
| 4360 class I {X get f => new A();get _g => new A();} | |
| 4361 class A implements I { | |
| 4362 A(this.^) {} | |
| 4363 A.z() {} | |
| 4364 var b; X _c; static sb; | |
| 4365 X get d => new A();get _e => new A(); | |
| 4366 // no semicolon between completion point and next statement | |
| 4367 set s1(I x) {} set _s2(I x) {m(null);} | |
| 4368 m(X x) {} I _n(X x) {}} | |
| 4369 class X{}'''); | |
| 4370 computeFast(); | |
| 4371 return computeFull((bool result) { | |
| 4372 expect(request.replacementOffset, completionOffset); | |
| 4373 expect(request.replacementLength, 0); | |
| 4374 // Contributed by FieldFormalConstructorContributor | |
| 4375 assertNotSuggested('b'); | |
| 4376 assertNotSuggested('_c'); | |
| 4377 assertNotSuggested('sb'); | |
| 4378 assertNotSuggested('d'); | |
| 4379 assertNotSuggested('_e'); | |
| 4380 assertNotSuggested('f'); | |
| 4381 assertNotSuggested('_g'); | |
| 4382 assertNotSuggested('m'); | |
| 4383 assertNotSuggested('_n'); | |
| 4384 assertNotSuggested('s1'); | |
| 4385 assertNotSuggested('_s2'); | |
| 4386 assertNotSuggested('z'); | |
| 4387 assertNotSuggested('I'); | |
| 4388 assertNotSuggested('A'); | |
| 4389 assertNotSuggested('X'); | |
| 4390 assertNotSuggested('Object'); | |
| 4391 assertNotSuggested('=='); | |
| 4392 }); | |
| 4393 } | |
| 4394 | |
| 4395 test_ThisExpression_constructor_param2() { | |
| 4396 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 4397 addTestSource(''' | |
| 4398 main() { } | |
| 4399 class I {X get f => new A();get _g => new A();} | |
| 4400 class A implements I { | |
| 4401 A(this.b^) {} | |
| 4402 A.z() {} | |
| 4403 var b; X _c; | |
| 4404 X get d => new A();get _e => new A(); | |
| 4405 // no semicolon between completion point and next statement | |
| 4406 set s1(I x) {} set _s2(I x) {m(null);} | |
| 4407 m(X x) {} I _n(X x) {}} | |
| 4408 class X{}'''); | |
| 4409 computeFast(); | |
| 4410 return computeFull((bool result) { | |
| 4411 expect(request.replacementOffset, completionOffset - 1); | |
| 4412 expect(request.replacementLength, 1); | |
| 4413 // Contributed by FieldFormalConstructorContributor | |
| 4414 assertNotSuggested('b'); | |
| 4415 assertNotSuggested('_c'); | |
| 4416 assertNotSuggested('d'); | |
| 4417 assertNotSuggested('_e'); | |
| 4418 assertNotSuggested('f'); | |
| 4419 assertNotSuggested('_g'); | |
| 4420 assertNotSuggested('m'); | |
| 4421 assertNotSuggested('_n'); | |
| 4422 assertNotSuggested('s1'); | |
| 4423 assertNotSuggested('_s2'); | |
| 4424 assertNotSuggested('z'); | |
| 4425 assertNotSuggested('I'); | |
| 4426 assertNotSuggested('A'); | |
| 4427 assertNotSuggested('X'); | |
| 4428 assertNotSuggested('Object'); | |
| 4429 assertNotSuggested('=='); | |
| 4430 }); | |
| 4431 } | |
| 4432 | |
| 4433 test_ThisExpression_constructor_param3() { | |
| 4434 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 4435 addTestSource(''' | |
| 4436 main() { } | |
| 4437 class I {X get f => new A();get _g => new A();} | |
| 4438 class A implements I { | |
| 4439 A(this.^b) {} | |
| 4440 A.z() {} | |
| 4441 var b; X _c; | |
| 4442 X get d => new A();get _e => new A(); | |
| 4443 // no semicolon between completion point and next statement | |
| 4444 set s1(I x) {} set _s2(I x) {m(null);} | |
| 4445 m(X x) {} I _n(X x) {}} | |
| 4446 class X{}'''); | |
| 4447 computeFast(); | |
| 4448 return computeFull((bool result) { | |
| 4449 expect(request.replacementOffset, completionOffset); | |
| 4450 expect(request.replacementLength, 1); | |
| 4451 // Contributed by FieldFormalConstructorContributor | |
| 4452 assertNotSuggested('b'); | |
| 4453 assertNotSuggested('_c'); | |
| 4454 assertNotSuggested('d'); | |
| 4455 assertNotSuggested('_e'); | |
| 4456 assertNotSuggested('f'); | |
| 4457 assertNotSuggested('_g'); | |
| 4458 assertNotSuggested('m'); | |
| 4459 assertNotSuggested('_n'); | |
| 4460 assertNotSuggested('s1'); | |
| 4461 assertNotSuggested('_s2'); | |
| 4462 assertNotSuggested('z'); | |
| 4463 assertNotSuggested('I'); | |
| 4464 assertNotSuggested('A'); | |
| 4465 assertNotSuggested('X'); | |
| 4466 assertNotSuggested('Object'); | |
| 4467 assertNotSuggested('=='); | |
| 4468 }); | |
| 4469 } | |
| 4470 | |
| 4471 test_ThisExpression_constructor_param4() { | |
| 4472 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 4473 addTestSource(''' | |
| 4474 main() { } | |
| 4475 class I {X get f => new A();get _g => new A();} | |
| 4476 class A implements I { | |
| 4477 A(this.b, this.^) {} | |
| 4478 A.z() {} | |
| 4479 var b; X _c; | |
| 4480 X get d => new A();get _e => new A(); | |
| 4481 // no semicolon between completion point and next statement | |
| 4482 set s1(I x) {} set _s2(I x) {m(null);} | |
| 4483 m(X x) {} I _n(X x) {}} | |
| 4484 class X{}'''); | |
| 4485 computeFast(); | |
| 4486 return computeFull((bool result) { | |
| 4487 expect(request.replacementOffset, completionOffset); | |
| 4488 expect(request.replacementLength, 0); | |
| 4489 assertNotSuggested('b'); | |
| 4490 // Contributed by FieldFormalConstructorContributor | |
| 4491 assertNotSuggested('_c'); | |
| 4492 assertNotSuggested('d'); | |
| 4493 assertNotSuggested('_e'); | |
| 4494 assertNotSuggested('f'); | |
| 4495 assertNotSuggested('_g'); | |
| 4496 assertNotSuggested('m'); | |
| 4497 assertNotSuggested('_n'); | |
| 4498 assertNotSuggested('s1'); | |
| 4499 assertNotSuggested('_s2'); | |
| 4500 assertNotSuggested('z'); | |
| 4501 assertNotSuggested('I'); | |
| 4502 assertNotSuggested('A'); | |
| 4503 assertNotSuggested('X'); | |
| 4504 assertNotSuggested('Object'); | |
| 4505 assertNotSuggested('=='); | |
| 4506 }); | |
| 4507 } | |
| 4508 | |
| 4509 test_TopLevelVariableDeclaration_typed_name() { | |
| 4510 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 4511 // TopLevelVariableDeclaration | |
| 4512 addTestSource('class A {} B ^'); | |
| 4513 computeFast(); | |
| 4514 return computeFull((bool result) { | |
| 4515 assertNoSuggestions(); | |
| 4516 }); | |
| 4517 } | |
| 4518 | |
| 4519 test_TopLevelVariableDeclaration_untyped_name() { | |
| 4520 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 4521 // TopLevelVariableDeclaration | |
| 4522 addTestSource('class A {} var ^'); | |
| 4523 computeFast(); | |
| 4524 return computeFull((bool result) { | |
| 4525 assertNoSuggestions(); | |
| 4526 }); | |
| 4527 } | |
| 4528 | |
| 4529 test_TypeArgumentList() { | |
| 4530 // SimpleIdentifier BinaryExpression ExpressionStatement | |
| 4531 addSource( | |
| 4532 '/testA.dart', | |
| 4533 ''' | |
| 4534 class C1 {int x;} | |
| 4535 F1() => 0; | |
| 4536 typedef String T1(int blat);'''); | |
| 4537 addTestSource(''' | |
| 4538 import "/testA.dart";' | |
| 4539 class C2 {int x;} | |
| 4540 F2() => 0; | |
| 4541 typedef int T2(int blat); | |
| 4542 class C<E> {} | |
| 4543 main() { C<^> c; }'''); | |
| 4544 computeFast(); | |
| 4545 return computeFull((bool result) { | |
| 4546 expect(request.replacementOffset, completionOffset); | |
| 4547 expect(request.replacementLength, 0); | |
| 4548 assertSuggestImportedClass('Object'); | |
| 4549 assertSuggestImportedClass('C1'); | |
| 4550 assertSuggestImportedFunctionTypeAlias('T1', 'String'); | |
| 4551 assertSuggestLocalClass('C2'); | |
| 4552 assertSuggestLocalFunctionTypeAlias('T2', 'int'); | |
| 4553 assertNotSuggested('F1'); | |
| 4554 assertNotSuggested('F2'); | |
| 4555 }); | |
| 4556 } | |
| 4557 | |
| 4558 test_TypeArgumentList2() { | |
| 4559 // TypeName TypeArgumentList TypeName | |
| 4560 addSource( | |
| 4561 '/testA.dart', | |
| 4562 ''' | |
| 4563 class C1 {int x;} | |
| 4564 F1() => 0; | |
| 4565 typedef String T1(int blat);'''); | |
| 4566 addTestSource(''' | |
| 4567 import "/testA.dart";' | |
| 4568 class C2 {int x;} | |
| 4569 F2() => 0; | |
| 4570 typedef int T2(int blat); | |
| 4571 class C<E> {} | |
| 4572 main() { C<C^> c; }'''); | |
| 4573 computeFast(); | |
| 4574 return computeFull((bool result) { | |
| 4575 expect(request.replacementOffset, completionOffset - 1); | |
| 4576 expect(request.replacementLength, 1); | |
| 4577 assertSuggestImportedClass('C1'); | |
| 4578 assertSuggestLocalClass('C2'); | |
| 4579 }); | |
| 4580 } | |
| 4581 | |
| 4582 test_VariableDeclaration_name() { | |
| 4583 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 4584 // VariableDeclarationStatement Block | |
| 4585 addSource( | |
| 4586 '/testB.dart', | |
| 4587 ''' | |
| 4588 lib B; | |
| 4589 foo() { } | |
| 4590 class _B { } | |
| 4591 class X {X.c(); X._d(); z() {}}'''); | |
| 4592 addTestSource(''' | |
| 4593 import "/testB.dart"; | |
| 4594 class Y {Y.c(); Y._d(); z() {}} | |
| 4595 main() {var ^}'''); | |
| 4596 computeFast(); | |
| 4597 return computeFull((bool result) { | |
| 4598 assertNoSuggestions(); | |
| 4599 }); | |
| 4600 } | |
| 4601 | |
| 4602 test_VariableDeclarationList_final() { | |
| 4603 // VariableDeclarationList VariableDeclarationStatement Block | |
| 4604 addTestSource('main() {final ^} class C { }'); | |
| 4605 computeFast(); | |
| 4606 return computeFull((bool result) { | |
| 4607 assertSuggestImportedClass('Object'); | |
| 4608 assertSuggestLocalClass('C'); | |
| 4609 assertNotSuggested('=='); | |
| 4610 }); | |
| 4611 } | |
| 4612 | |
| 4613 test_VariableDeclarationStatement_RHS() { | |
| 4614 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 4615 // VariableDeclarationStatement | |
| 4616 addSource( | |
| 4617 '/testB.dart', | |
| 4618 ''' | |
| 4619 lib B; | |
| 4620 foo() { } | |
| 4621 class _B { } | |
| 4622 class X {X.c(); X._d(); z() {}}'''); | |
| 4623 addTestSource(''' | |
| 4624 import "/testB.dart"; | |
| 4625 class Y {Y.c(); Y._d(); z() {}} | |
| 4626 class C {bar(){var f; {var x;} var e = ^}}'''); | |
| 4627 computeFast(); | |
| 4628 return computeFull((bool result) { | |
| 4629 expect(request.replacementOffset, completionOffset); | |
| 4630 expect(request.replacementLength, 0); | |
| 4631 assertSuggestImportedClass('X'); | |
| 4632 assertNotSuggested('_B'); | |
| 4633 assertSuggestLocalClass('Y'); | |
| 4634 assertSuggestLocalClass('C'); | |
| 4635 assertSuggestLocalVariable('f', null); | |
| 4636 assertNotSuggested('x'); | |
| 4637 assertNotSuggested('e'); | |
| 4638 }); | |
| 4639 } | |
| 4640 | |
| 4641 test_VariableDeclarationStatement_RHS_missing_semicolon() { | |
| 4642 // VariableDeclaration VariableDeclarationList | |
| 4643 // VariableDeclarationStatement | |
| 4644 addSource( | |
| 4645 '/testB.dart', | |
| 4646 ''' | |
| 4647 lib B; | |
| 4648 foo1() { } | |
| 4649 void bar1() { } | |
| 4650 class _B { } | |
| 4651 class X {X.c(); X._d(); z() {}}'''); | |
| 4652 addTestSource(''' | |
| 4653 import "/testB.dart"; | |
| 4654 foo2() { } | |
| 4655 void bar2() { } | |
| 4656 class Y {Y.c(); Y._d(); z() {}} | |
| 4657 class C {bar(){var f; {var x;} var e = ^ var g}}'''); | |
| 4658 computeFast(); | |
| 4659 return computeFull((bool result) { | |
| 4660 expect(request.replacementOffset, completionOffset); | |
| 4661 expect(request.replacementLength, 0); | |
| 4662 assertSuggestImportedClass('X'); | |
| 4663 assertSuggestImportedFunction('foo1', null); | |
| 4664 assertNotSuggested('bar1'); | |
| 4665 assertSuggestLocalFunction('foo2', null); | |
| 4666 assertNotSuggested('bar2'); | |
| 4667 assertNotSuggested('_B'); | |
| 4668 assertSuggestLocalClass('Y'); | |
| 4669 assertSuggestLocalClass('C'); | |
| 4670 assertSuggestLocalVariable('f', null); | |
| 4671 assertNotSuggested('x'); | |
| 4672 assertNotSuggested('e'); | |
| 4673 }); | |
| 4674 } | |
| 4675 } | |
| OLD | NEW |