Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(968)

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_test_util.dart

Issue 1290743003: reformat and 2 new tests for #23501 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2
Paul Berry 2015/08/12 17:00:59 Unintentional extra newline.
danrubel 2015/08/26 14:03:57 Removed
2 // for details. All rights reserved. Use of this source code is governed by a 3 // 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 // BSD-style license that can be found in the LICENSE file.
4 5
5 library test.services.completion.util; 6 library test.services.completion.util;
6 7
7 import 'dart:async'; 8 import 'dart:async';
8 9
9 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/protocol.dart' as protocol 11 import 'package:analysis_server/src/protocol.dart' as protocol
11 show Element, ElementKind; 12 show Element, ElementKind;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 89 }
89 90
90 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { 91 void assertNoSuggestions({CompletionSuggestionKind kind: null}) {
91 if (kind == null) { 92 if (kind == null) {
92 if (request.suggestions.length > 0) { 93 if (request.suggestions.length > 0) {
93 failedCompletion('Expected no suggestions', request.suggestions); 94 failedCompletion('Expected no suggestions', request.suggestions);
94 } 95 }
95 return; 96 return;
96 } 97 }
97 CompletionSuggestion suggestion = request.suggestions.firstWhere( 98 CompletionSuggestion suggestion = request.suggestions.firstWhere(
98 (CompletionSuggestion cs) => cs.kind == kind, orElse: () => null); 99 (CompletionSuggestion cs) => cs.kind == kind,
100 orElse: () => null);
99 if (suggestion != null) { 101 if (suggestion != null) {
100 failedCompletion('did not expect completion: $completion\n $suggestion'); 102 failedCompletion('did not expect completion: $completion\n $suggestion');
101 } 103 }
102 } 104 }
103 105
104 CompletionSuggestion assertNotSuggested(String completion) { 106 CompletionSuggestion assertNotSuggested(String completion) {
105 CompletionSuggestion suggestion = request.suggestions.firstWhere( 107 CompletionSuggestion suggestion = request.suggestions.firstWhere(
106 (CompletionSuggestion cs) => cs.completion == completion, 108 (CompletionSuggestion cs) => cs.completion == completion,
107 orElse: () => null); 109 orElse: () => null);
108 if (suggestion != null) { 110 if (suggestion != null) {
109 failedCompletion('did not expect completion: $completion\n $suggestion'); 111 failedCompletion('did not expect completion: $completion\n $suggestion');
110 } 112 }
111 return null; 113 return null;
112 } 114 }
113 115
114 CompletionSuggestion assertSuggest(String completion, 116 CompletionSuggestion assertSuggest(String completion,
115 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, 117 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION,
116 int relevance: DART_RELEVANCE_DEFAULT, String importUri, 118 int relevance: DART_RELEVANCE_DEFAULT,
117 protocol.ElementKind elemKind: null, bool isDeprecated: false, 119 String importUri,
118 bool isPotential: false, String elemFile, int elemOffset}) { 120 protocol.ElementKind elemKind: null,
121 bool isDeprecated: false,
122 bool isPotential: false,
123 String elemFile,
124 int elemOffset}) {
119 CompletionSuggestion cs = 125 CompletionSuggestion cs =
120 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); 126 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind);
121 if (cs == null) { 127 if (cs == null) {
122 failedCompletion( 128 failedCompletion(
123 'expected $completion $csKind $elemKind', request.suggestions); 129 'expected $completion $csKind $elemKind', request.suggestions);
124 } 130 }
125 expect(cs.kind, equals(csKind)); 131 expect(cs.kind, equals(csKind));
126 if (isDeprecated) { 132 if (isDeprecated) {
127 expect(cs.relevance, equals(DART_RELEVANCE_LOW)); 133 expect(cs.relevance, equals(DART_RELEVANCE_LOW));
128 } else { 134 } else {
(...skipping 15 matching lines...) Expand all
144 if (elemFile != null) { 150 if (elemFile != null) {
145 expect(cs.element.location.file, elemFile); 151 expect(cs.element.location.file, elemFile);
146 } 152 }
147 if (elemOffset != null) { 153 if (elemOffset != null) {
148 expect(cs.element.location.offset, elemOffset); 154 expect(cs.element.location.offset, elemOffset);
149 } 155 }
150 return cs; 156 return cs;
151 } 157 }
152 158
153 CompletionSuggestion assertSuggestClass(String name, 159 CompletionSuggestion assertSuggestClass(String name,
154 {int relevance: DART_RELEVANCE_DEFAULT, String importUri, 160 {int relevance: DART_RELEVANCE_DEFAULT,
161 String importUri,
155 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 162 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
156 bool isDeprecated: false, String elemFile, int elemOffset}) { 163 bool isDeprecated: false,
164 String elemFile,
165 int elemOffset}) {
157 CompletionSuggestion cs = assertSuggest(name, 166 CompletionSuggestion cs = assertSuggest(name,
158 csKind: kind, 167 csKind: kind,
159 relevance: relevance, 168 relevance: relevance,
160 importUri: importUri, 169 importUri: importUri,
161 isDeprecated: isDeprecated, 170 isDeprecated: isDeprecated,
162 elemFile: elemFile, 171 elemFile: elemFile,
163 elemOffset: elemOffset); 172 elemOffset: elemOffset);
164 protocol.Element element = cs.element; 173 protocol.Element element = cs.element;
165 expect(element, isNotNull); 174 expect(element, isNotNull);
166 expect(element.kind, equals(protocol.ElementKind.CLASS)); 175 expect(element.kind, equals(protocol.ElementKind.CLASS));
(...skipping 13 matching lines...) Expand all
180 expect(element, isNotNull); 189 expect(element, isNotNull);
181 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); 190 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS));
182 expect(element.name, equals(name)); 191 expect(element.name, equals(name));
183 expect(element.parameters, isNull); 192 expect(element.parameters, isNull);
184 expect(element.returnType, isNull); 193 expect(element.returnType, isNull);
185 assertHasNoParameterInfo(cs); 194 assertHasNoParameterInfo(cs);
186 return cs; 195 return cs;
187 } 196 }
188 197
189 CompletionSuggestion assertSuggestConstructor(String name, 198 CompletionSuggestion assertSuggestConstructor(String name,
190 {int relevance: DART_RELEVANCE_DEFAULT, String importUri, 199 {int relevance: DART_RELEVANCE_DEFAULT,
200 String importUri,
191 int elemOffset}) { 201 int elemOffset}) {
192 CompletionSuggestion cs = assertSuggest(name, 202 CompletionSuggestion cs = assertSuggest(name,
193 relevance: relevance, importUri: importUri, elemOffset: elemOffset); 203 relevance: relevance, importUri: importUri, elemOffset: elemOffset);
194 protocol.Element element = cs.element; 204 protocol.Element element = cs.element;
195 expect(element, isNotNull); 205 expect(element, isNotNull);
196 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); 206 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
197 int index = name.indexOf('.'); 207 int index = name.indexOf('.');
198 expect(element.name, index >= 0 ? name.substring(index + 1) : ''); 208 expect(element.name, index >= 0 ? name.substring(index + 1) : '');
199 return cs; 209 return cs;
200 } 210 }
201 211
202 CompletionSuggestion assertSuggestField(String name, String type, 212 CompletionSuggestion assertSuggestField(String name, String type,
203 {int relevance: DART_RELEVANCE_DEFAULT, String importUri, 213 {int relevance: DART_RELEVANCE_DEFAULT,
214 String importUri,
204 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 215 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
205 bool isDeprecated: false}) { 216 bool isDeprecated: false}) {
206 CompletionSuggestion cs = assertSuggest(name, 217 CompletionSuggestion cs = assertSuggest(name,
207 csKind: kind, 218 csKind: kind,
208 relevance: relevance, 219 relevance: relevance,
209 importUri: importUri, 220 importUri: importUri,
210 elemKind: protocol.ElementKind.FIELD, 221 elemKind: protocol.ElementKind.FIELD,
211 isDeprecated: isDeprecated); 222 isDeprecated: isDeprecated);
212 // The returnType represents the type of a field 223 // The returnType represents the type of a field
213 expect(cs.returnType, type != null ? type : 'dynamic'); 224 expect(cs.returnType, type != null ? type : 'dynamic');
214 protocol.Element element = cs.element; 225 protocol.Element element = cs.element;
215 expect(element, isNotNull); 226 expect(element, isNotNull);
216 expect(element.kind, equals(protocol.ElementKind.FIELD)); 227 expect(element.kind, equals(protocol.ElementKind.FIELD));
217 expect(element.name, equals(name)); 228 expect(element.name, equals(name));
218 expect(element.parameters, isNull); 229 expect(element.parameters, isNull);
219 // The returnType represents the type of a field 230 // The returnType represents the type of a field
220 expect(element.returnType, type != null ? type : 'dynamic'); 231 expect(element.returnType, type != null ? type : 'dynamic');
221 assertHasNoParameterInfo(cs); 232 assertHasNoParameterInfo(cs);
222 return cs; 233 return cs;
223 } 234 }
224 235
225 CompletionSuggestion assertSuggestFunction(String name, String returnType, 236 CompletionSuggestion assertSuggestFunction(String name, String returnType,
226 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 237 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
227 bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT, 238 bool deprecated: false,
239 int relevance: DART_RELEVANCE_DEFAULT,
228 String importUri}) { 240 String importUri}) {
229 CompletionSuggestion cs = assertSuggest(name, 241 CompletionSuggestion cs = assertSuggest(name,
230 csKind: kind, 242 csKind: kind,
231 relevance: relevance, 243 relevance: relevance,
232 importUri: importUri, 244 importUri: importUri,
233 isDeprecated: deprecated); 245 isDeprecated: deprecated);
234 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 246 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
235 protocol.Element element = cs.element; 247 protocol.Element element = cs.element;
236 expect(element, isNotNull); 248 expect(element, isNotNull);
237 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); 249 expect(element.kind, equals(protocol.ElementKind.FUNCTION));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // expect(param[0], equals('(')); 281 // expect(param[0], equals('('));
270 // expect(param[param.length - 1], equals(')')); 282 // expect(param[param.length - 1], equals(')'));
271 expect(element.returnType, 283 expect(element.returnType,
272 equals(returnType != null ? returnType : 'dynamic')); 284 equals(returnType != null ? returnType : 'dynamic'));
273 // TODO (danrubel) Determine why param info is missing 285 // TODO (danrubel) Determine why param info is missing
274 // assertHasParameterInfo(cs); 286 // assertHasParameterInfo(cs);
275 return cs; 287 return cs;
276 } 288 }
277 289
278 CompletionSuggestion assertSuggestGetter(String name, String returnType, 290 CompletionSuggestion assertSuggestGetter(String name, String returnType,
279 {int relevance: DART_RELEVANCE_DEFAULT, String importUri, 291 {int relevance: DART_RELEVANCE_DEFAULT,
292 String importUri,
280 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 293 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
281 bool isDeprecated: false}) { 294 bool isDeprecated: false}) {
282 CompletionSuggestion cs = assertSuggest(name, 295 CompletionSuggestion cs = assertSuggest(name,
283 csKind: kind, 296 csKind: kind,
284 relevance: relevance, 297 relevance: relevance,
285 importUri: importUri, 298 importUri: importUri,
286 elemKind: protocol.ElementKind.GETTER, 299 elemKind: protocol.ElementKind.GETTER,
287 isDeprecated: isDeprecated); 300 isDeprecated: isDeprecated);
288 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 301 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
289 protocol.Element element = cs.element; 302 protocol.Element element = cs.element;
(...skipping 26 matching lines...) Expand all
316 329
317 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, 330 CompletionSuggestion assertSuggestLibraryPrefix(String prefix,
318 [int relevance = DART_RELEVANCE_DEFAULT, 331 [int relevance = DART_RELEVANCE_DEFAULT,
319 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 332 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
320 // Library prefix should only be suggested by ImportedReferenceContributor 333 // Library prefix should only be suggested by ImportedReferenceContributor
321 return assertNotSuggested(prefix); 334 return assertNotSuggested(prefix);
322 } 335 }
323 336
324 CompletionSuggestion assertSuggestMethod( 337 CompletionSuggestion assertSuggestMethod(
325 String name, String declaringType, String returnType, 338 String name, String declaringType, String returnType,
326 {int relevance: DART_RELEVANCE_DEFAULT, String importUri, 339 {int relevance: DART_RELEVANCE_DEFAULT,
340 String importUri,
327 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 341 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
328 bool isDeprecated: false}) { 342 bool isDeprecated: false}) {
329 CompletionSuggestion cs = assertSuggest(name, 343 CompletionSuggestion cs = assertSuggest(name,
330 csKind: kind, 344 csKind: kind,
331 relevance: relevance, 345 relevance: relevance,
332 importUri: importUri, 346 importUri: importUri,
333 isDeprecated: isDeprecated); 347 isDeprecated: isDeprecated);
334 expect(cs.declaringType, equals(declaringType)); 348 expect(cs.declaringType, equals(declaringType));
335 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 349 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
336 protocol.Element element = cs.element; 350 protocol.Element element = cs.element;
337 expect(element, isNotNull); 351 expect(element, isNotNull);
338 expect(element.kind, equals(protocol.ElementKind.METHOD)); 352 expect(element.kind, equals(protocol.ElementKind.METHOD));
339 expect(element.name, equals(name)); 353 expect(element.name, equals(name));
340 String param = element.parameters; 354 String param = element.parameters;
341 expect(param, isNotNull); 355 expect(param, isNotNull);
342 expect(param[0], equals('(')); 356 expect(param[0], equals('('));
343 expect(param[param.length - 1], equals(')')); 357 expect(param[param.length - 1], equals(')'));
344 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 358 expect(element.returnType, returnType != null ? returnType : 'dynamic');
345 assertHasParameterInfo(cs); 359 assertHasParameterInfo(cs);
346 return cs; 360 return cs;
347 } 361 }
348 362
349 CompletionSuggestion assertSuggestNamedConstructor( 363 CompletionSuggestion assertSuggestNamedConstructor(
350 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT, 364 String name, String returnType,
365 [int relevance = DART_RELEVANCE_DEFAULT,
351 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 366 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
352 if (contributor is PrefixedElementContributor) { 367 if (contributor is PrefixedElementContributor) {
353 CompletionSuggestion cs = 368 CompletionSuggestion cs =
354 assertSuggest(name, csKind: kind, relevance: relevance); 369 assertSuggest(name, csKind: kind, relevance: relevance);
355 protocol.Element element = cs.element; 370 protocol.Element element = cs.element;
356 expect(element, isNotNull); 371 expect(element, isNotNull);
357 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); 372 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
358 expect(element.name, equals(name)); 373 expect(element.name, equals(name));
359 String param = element.parameters; 374 String param = element.parameters;
360 expect(param, isNotNull); 375 expect(param, isNotNull);
361 expect(param[0], equals('(')); 376 expect(param[0], equals('('));
362 expect(param[param.length - 1], equals(')')); 377 expect(param[param.length - 1], equals(')'));
363 expect(element.returnType, equals(returnType)); 378 expect(element.returnType, equals(returnType));
364 assertHasParameterInfo(cs); 379 assertHasParameterInfo(cs);
365 return cs; 380 return cs;
366 } else { 381 } else {
367 return assertNotSuggested(name); 382 return assertNotSuggested(name);
368 } 383 }
369 } 384 }
370 385
371 CompletionSuggestion assertSuggestParameter(String name, String returnType, 386 CompletionSuggestion assertSuggestParameter(String name, String returnType,
372 {int relevance: DART_RELEVANCE_PARAMETER}) { 387 {int relevance: DART_RELEVANCE_PARAMETER}) {
373 return assertNotSuggested(name); 388 return assertNotSuggested(name);
374 } 389 }
375 390
376 CompletionSuggestion assertSuggestSetter(String name, 391 CompletionSuggestion assertSuggestSetter(String name,
377 [int relevance = DART_RELEVANCE_DEFAULT, String importUri, 392 [int relevance = DART_RELEVANCE_DEFAULT,
393 String importUri,
378 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 394 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
379 CompletionSuggestion cs = assertSuggest(name, 395 CompletionSuggestion cs = assertSuggest(name,
380 csKind: kind, 396 csKind: kind,
381 relevance: relevance, 397 relevance: relevance,
382 importUri: importUri, 398 importUri: importUri,
383 elemKind: protocol.ElementKind.SETTER); 399 elemKind: protocol.ElementKind.SETTER);
384 protocol.Element element = cs.element; 400 protocol.Element element = cs.element;
385 expect(element, isNotNull); 401 expect(element, isNotNull);
386 expect(element.kind, equals(protocol.ElementKind.SETTER)); 402 expect(element.kind, equals(protocol.ElementKind.SETTER));
387 expect(element.name, equals(name)); 403 expect(element.name, equals(name));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 sb.write('\n in'); 478 sb.write('\n in');
463 AstNode node = completionNode; 479 AstNode node = completionNode;
464 while (node != null) { 480 while (node != null) {
465 sb.write('\n ${node.runtimeType}'); 481 sb.write('\n ${node.runtimeType}');
466 node = node.parent; 482 node = node.parent;
467 } 483 }
468 } 484 }
469 fail(sb.toString()); 485 fail(sb.toString());
470 } 486 }
471 487
472 CompletionSuggestion getSuggest({String completion: null, 488 CompletionSuggestion getSuggest(
489 {String completion: null,
473 CompletionSuggestionKind csKind: null, 490 CompletionSuggestionKind csKind: null,
474 protocol.ElementKind elemKind: null}) { 491 protocol.ElementKind elemKind: null}) {
475 CompletionSuggestion cs; 492 CompletionSuggestion cs;
476 request.suggestions.forEach((CompletionSuggestion s) { 493 request.suggestions.forEach((CompletionSuggestion s) {
477 if (completion != null && completion != s.completion) { 494 if (completion != null && completion != s.completion) {
478 return; 495 return;
479 } 496 }
480 if (csKind != null && csKind != s.kind) { 497 if (csKind != null && csKind != s.kind) {
481 return; 498 return;
482 } 499 }
483 if (elemKind != null) { 500 if (elemKind != null) {
484 protocol.Element element = s.element; 501 protocol.Element element = s.element;
485 if (element == null || elemKind != element.kind) { 502 if (element == null || elemKind != element.kind) {
486 return; 503 return;
487 } 504 }
488 } 505 }
489 if (cs == null) { 506 if (cs == null) {
490 cs = s; 507 cs = s;
491 } else { 508 } else {
492 failedCompletion('expected exactly one $cs', 509 failedCompletion('expected exactly one $cs',
493 request.suggestions.where((s) => s.completion == completion)); 510 request.suggestions.where((s) => s.completion == completion));
494 } 511 }
495 }); 512 });
496 return cs; 513 return cs;
497 } 514 }
498 515
499 void resolve(bool fullAnalysis) { 516 void resolve(bool fullAnalysis) {
500
501 // Index SDK 517 // Index SDK
502 for (Source librarySource in context.librarySources) { 518 for (Source librarySource in context.librarySources) {
503 CompilationUnit unit = 519 CompilationUnit unit =
504 context.getResolvedCompilationUnit2(librarySource, librarySource); 520 context.getResolvedCompilationUnit2(librarySource, librarySource);
505 if (unit != null) { 521 if (unit != null) {
506 index.indexUnit(context, unit); 522 index.indexUnit(context, unit);
507 } 523 }
508 } 524 }
509 525
510 var result = context.performAnalysisTask(); 526 var result = context.performAnalysisTask();
511 bool resolved = false; 527 bool resolved = false;
512 while (result.hasMoreWork) { 528 while (result.hasMoreWork) {
513
514 // Update the index 529 // Update the index
515 result.changeNotices.forEach((ChangeNotice notice) { 530 result.changeNotices.forEach((ChangeNotice notice) {
516 CompilationUnit unit = notice.resolvedDartUnit; 531 CompilationUnit unit = notice.resolvedDartUnit;
517 if (unit != null) { 532 if (unit != null) {
518 index.indexUnit(context, unit); 533 index.indexUnit(context, unit);
519 } 534 }
520 }); 535 });
521 536
522 // If the unit has been resolved, then finish the completion 537 // If the unit has been resolved, then finish the completion
523 List<Source> libSourceList = context.getLibrariesContaining(testSource); 538 List<Source> libSourceList = context.getLibrariesContaining(testSource);
(...skipping 30 matching lines...) Expand all
554 } 569 }
555 570
556 void setUpContributor(); 571 void setUpContributor();
557 } 572 }
558 573
559 /** 574 /**
560 * Common tests for `ImportedTypeContributorTest`, `InvocationContributorTest`, 575 * Common tests for `ImportedTypeContributorTest`, `InvocationContributorTest`,
561 * and `LocalContributorTest`. 576 * and `LocalContributorTest`.
562 */ 577 */
563 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { 578 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest {
564
565 /** 579 /**
566 * Assert that the ImportedReferenceContributor uses cached results 580 * Assert that the ImportedReferenceContributor uses cached results
567 * to produce identical suggestions to the original set of suggestions. 581 * to produce identical suggestions to the original set of suggestions.
568 */ 582 */
569 void assertCachedCompute(_) { 583 void assertCachedCompute(_) {
570 // Subclasses override 584 // Subclasses override
571 } 585 }
572 586
573 CompletionSuggestion assertSuggestEnum(String completion, 587 CompletionSuggestion assertSuggestEnum(String completion,
574 {bool isDeprecated: false}) { 588 {bool isDeprecated: false}) {
575 CompletionSuggestion suggestion = 589 CompletionSuggestion suggestion =
576 assertSuggest(completion, isDeprecated: isDeprecated); 590 assertSuggest(completion, isDeprecated: isDeprecated);
577 expect(suggestion.isDeprecated, isDeprecated); 591 expect(suggestion.isDeprecated, isDeprecated);
578 expect(suggestion.element.kind, protocol.ElementKind.ENUM); 592 expect(suggestion.element.kind, protocol.ElementKind.ENUM);
579 return suggestion; 593 return suggestion;
580 } 594 }
581 595
582 CompletionSuggestion assertSuggestEnumConst(String completion, 596 CompletionSuggestion assertSuggestEnumConst(String completion,
583 {bool isDeprecated: false}) { 597 {bool isDeprecated: false}) {
584 CompletionSuggestion suggestion = 598 CompletionSuggestion suggestion =
585 assertSuggest(completion, isDeprecated: isDeprecated); 599 assertSuggest(completion, isDeprecated: isDeprecated);
586 expect(suggestion.isDeprecated, isDeprecated); 600 expect(suggestion.isDeprecated, isDeprecated);
587 expect(suggestion.element.kind, protocol.ElementKind.ENUM_CONSTANT); 601 expect(suggestion.element.kind, protocol.ElementKind.ENUM_CONSTANT);
588 return suggestion; 602 return suggestion;
589 } 603 }
590 604
591 CompletionSuggestion assertSuggestImportedClass(String name, 605 CompletionSuggestion assertSuggestImportedClass(String name,
592 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 606 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
593 int relevance: DART_RELEVANCE_DEFAULT, String importUri, 607 int relevance: DART_RELEVANCE_DEFAULT,
608 String importUri,
594 String elemFile}) { 609 String elemFile}) {
595 return assertNotSuggested(name); 610 return assertNotSuggested(name);
596 } 611 }
597 612
598 CompletionSuggestion assertSuggestImportedConstructor(String name, 613 CompletionSuggestion assertSuggestImportedConstructor(String name,
599 {int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { 614 {int relevance: DART_RELEVANCE_DEFAULT, String importUri}) {
600 return assertNotSuggested(name); 615 return assertNotSuggested(name);
601 } 616 }
602 617
603 CompletionSuggestion assertSuggestImportedField(String name, String type, 618 CompletionSuggestion assertSuggestImportedField(String name, String type,
604 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { 619 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) {
605 return assertNotSuggested(name); 620 return assertNotSuggested(name);
606 } 621 }
607 622
608 CompletionSuggestion assertSuggestImportedFunction( 623 CompletionSuggestion assertSuggestImportedFunction(
609 String name, String returnType, 624 String name, String returnType,
610 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 625 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
611 bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT, 626 bool deprecated: false,
627 int relevance: DART_RELEVANCE_DEFAULT,
612 String importUri}) { 628 String importUri}) {
613 return assertNotSuggested(name); 629 return assertNotSuggested(name);
614 } 630 }
615 631
616 CompletionSuggestion assertSuggestImportedFunctionTypeAlias( 632 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(
617 String name, String returnType, [bool isDeprecated = false, 633 String name, String returnType,
634 [bool isDeprecated = false,
618 int relevance = DART_RELEVANCE_DEFAULT, 635 int relevance = DART_RELEVANCE_DEFAULT,
619 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 636 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
620 return assertNotSuggested(name); 637 return assertNotSuggested(name);
621 } 638 }
622 639
623 CompletionSuggestion assertSuggestImportedGetter( 640 CompletionSuggestion assertSuggestImportedGetter(
624 String name, String returnType, 641 String name, String returnType,
625 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { 642 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {
626 return assertNotSuggested(name); 643 return assertNotSuggested(name);
627 } 644 }
628 645
629 CompletionSuggestion assertSuggestImportedMethod( 646 CompletionSuggestion assertSuggestImportedMethod(
630 String name, String declaringType, String returnType, 647 String name, String declaringType, String returnType,
631 {int relevance: DART_RELEVANCE_INHERITED_METHOD}) { 648 {int relevance: DART_RELEVANCE_INHERITED_METHOD}) {
632 return assertNotSuggested(name); 649 return assertNotSuggested(name);
633 } 650 }
634 651
635 CompletionSuggestion assertSuggestImportedSetter(String name, 652 CompletionSuggestion assertSuggestImportedSetter(String name,
636 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { 653 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {
637 return assertNotSuggested(name); 654 return assertNotSuggested(name);
638 } 655 }
639 656
640 CompletionSuggestion assertSuggestImportedTopLevelVar( 657 CompletionSuggestion assertSuggestImportedTopLevelVar(
641 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT, 658 String name, String returnType,
659 [int relevance = DART_RELEVANCE_DEFAULT,
642 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION, 660 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
643 String importUri]) { 661 String importUri]) {
644 return assertNotSuggested(name); 662 return assertNotSuggested(name);
645 } 663 }
646 664
647 CompletionSuggestion assertSuggestInvocationClass(String name, 665 CompletionSuggestion assertSuggestInvocationClass(String name,
648 [int relevance = DART_RELEVANCE_DEFAULT]) { 666 [int relevance = DART_RELEVANCE_DEFAULT]) {
649 if (contributor is PrefixedElementContributor) { 667 if (contributor is PrefixedElementContributor) {
650 return assertSuggestClass(name, relevance: relevance); 668 return assertSuggestClass(name, relevance: relevance);
651 } else { 669 } else {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 [int relevance = DART_RELEVANCE_DEFAULT]) { 712 [int relevance = DART_RELEVANCE_DEFAULT]) {
695 if (contributor is PrefixedElementContributor) { 713 if (contributor is PrefixedElementContributor) {
696 return assertSuggestTopLevelVar(name, returnType, relevance); 714 return assertSuggestTopLevelVar(name, returnType, relevance);
697 } else { 715 } else {
698 return assertNotSuggested(name); 716 return assertNotSuggested(name);
699 } 717 }
700 } 718 }
701 719
702 CompletionSuggestion assertSuggestLocalClass(String name, 720 CompletionSuggestion assertSuggestLocalClass(String name,
703 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 721 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
704 int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false, 722 int relevance: DART_RELEVANCE_DEFAULT,
705 String elemFile, int elemOffset}) { 723 bool isDeprecated: false,
724 String elemFile,
725 int elemOffset}) {
706 return assertNotSuggested(name); 726 return assertNotSuggested(name);
707 } 727 }
708 728
709 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, 729 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
710 {int relevance: DART_RELEVANCE_DEFAULT}) { 730 {int relevance: DART_RELEVANCE_DEFAULT}) {
711 return assertNotSuggested(name); 731 return assertNotSuggested(name);
712 } 732 }
713 733
714 CompletionSuggestion assertSuggestLocalConstructor(String name, 734 CompletionSuggestion assertSuggestLocalConstructor(String name,
715 {int elemOffset}) { 735 {int elemOffset}) {
716 return assertNotSuggested(name); 736 return assertNotSuggested(name);
717 } 737 }
718 738
719 CompletionSuggestion assertSuggestLocalField(String name, String type, 739 CompletionSuggestion assertSuggestLocalField(String name, String type,
720 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { 740 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) {
721 return assertNotSuggested(name); 741 return assertNotSuggested(name);
722 } 742 }
723 743
724 CompletionSuggestion assertSuggestLocalFunction( 744 CompletionSuggestion assertSuggestLocalFunction(
725 String name, String returnType, {bool deprecated: false, 745 String name, String returnType,
746 {bool deprecated: false,
726 int relevance: DART_RELEVANCE_LOCAL_FUNCTION, 747 int relevance: DART_RELEVANCE_LOCAL_FUNCTION,
727 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION}) { 748 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION}) {
728 return assertNotSuggested(name); 749 return assertNotSuggested(name);
729 } 750 }
730 751
731 CompletionSuggestion assertSuggestLocalFunctionTypeAlias( 752 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(
732 String name, String returnType, 753 String name, String returnType,
733 {bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) { 754 {bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) {
734 return assertNotSuggested(name); 755 return assertNotSuggested(name);
735 } 756 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 } 790 }
770 791
771 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { 792 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
772 return super 793 return super
773 .computeFull(assertFunction, fullAnalysis: fullAnalysis) 794 .computeFull(assertFunction, fullAnalysis: fullAnalysis)
774 .then(assertCachedCompute); 795 .then(assertCachedCompute);
775 } 796 }
776 797
777 test_ArgumentList() { 798 test_ArgumentList() {
778 // ArgumentList MethodInvocation ExpressionStatement Block 799 // ArgumentList MethodInvocation ExpressionStatement Block
779 addSource('/libA.dart', ''' 800 addSource(
801 '/libA.dart',
802 '''
780 library A; 803 library A;
781 bool hasLength(int expected) { } 804 bool hasLength(int expected) { }
782 void baz() { }'''); 805 void baz() { }''');
783 addTestSource(''' 806 addTestSource('''
784 import '/libA.dart'; 807 import '/libA.dart';
785 class B { } 808 class B { }
786 String bar() => true; 809 String bar() => true;
787 void main() {expect(^)}'''); 810 void main() {expect(^)}''');
788 computeFast(); 811 computeFast();
789 return computeFull((bool result) { 812 return computeFull((bool result) {
790 expect(request.replacementOffset, completionOffset); 813 expect(request.replacementOffset, completionOffset);
791 expect(request.replacementLength, 0); 814 expect(request.replacementLength, 0);
792 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 815 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
793 assertSuggestLocalFunction('bar', 'String'); 816 assertSuggestLocalFunction('bar', 'String');
794 assertSuggestImportedFunction('hasLength', 'bool'); 817 assertSuggestImportedFunction('hasLength', 'bool');
795 assertSuggestImportedFunction('identical', 'bool'); 818 assertSuggestImportedFunction('identical', 'bool');
796 assertSuggestLocalClass('B'); 819 assertSuggestLocalClass('B');
797 assertSuggestImportedClass('Object'); 820 assertSuggestImportedClass('Object');
798 assertNotSuggested('main'); 821 assertNotSuggested('main');
799 assertNotSuggested('baz'); 822 assertNotSuggested('baz');
800 assertNotSuggested('print'); 823 assertNotSuggested('print');
801 }); 824 });
802 } 825 }
803 826
804 test_ArgumentList_imported_function() { 827 test_ArgumentList_imported_function() {
805 // ArgumentList MethodInvocation ExpressionStatement Block 828 // ArgumentList MethodInvocation ExpressionStatement Block
806 addSource('/libA.dart', ''' 829 addSource(
830 '/libA.dart',
831 '''
807 library A; 832 library A;
808 bool hasLength(int expected) { } 833 bool hasLength(int expected) { }
809 expect(arg) { } 834 expect(arg) { }
810 void baz() { }'''); 835 void baz() { }''');
811 addTestSource(''' 836 addTestSource('''
812 import '/libA.dart' 837 import '/libA.dart'
813 class B { } 838 class B { }
814 String bar() => true; 839 String bar() => true;
815 void main() {expect(^)}'''); 840 void main() {expect(^)}''');
816 computeFast(); 841 computeFast();
817 return computeFull((bool result) { 842 return computeFull((bool result) {
818 expect(request.replacementOffset, completionOffset); 843 expect(request.replacementOffset, completionOffset);
819 expect(request.replacementLength, 0); 844 expect(request.replacementLength, 0);
820 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 845 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
821 assertSuggestLocalFunction('bar', 'String'); 846 assertSuggestLocalFunction('bar', 'String');
822 assertSuggestImportedFunction('hasLength', 'bool'); 847 assertSuggestImportedFunction('hasLength', 'bool');
823 assertSuggestImportedFunction('identical', 'bool'); 848 assertSuggestImportedFunction('identical', 'bool');
824 assertSuggestLocalClass('B'); 849 assertSuggestLocalClass('B');
825 assertSuggestImportedClass('Object'); 850 assertSuggestImportedClass('Object');
826 assertNotSuggested('main'); 851 assertNotSuggested('main');
827 assertNotSuggested('baz'); 852 assertNotSuggested('baz');
828 assertNotSuggested('print'); 853 assertNotSuggested('print');
829 }); 854 });
830 } 855 }
831 856
832 test_ArgumentList_InstanceCreationExpression_functionalArg() { 857 test_ArgumentList_InstanceCreationExpression_functionalArg() {
833 // ArgumentList InstanceCreationExpression ExpressionStatement Block 858 // ArgumentList InstanceCreationExpression ExpressionStatement Block
834 addSource('/libA.dart', ''' 859 addSource(
860 '/libA.dart',
861 '''
835 library A; 862 library A;
836 class A { A(f()) { } } 863 class A { A(f()) { } }
837 bool hasLength(int expected) { } 864 bool hasLength(int expected) { }
838 void baz() { }'''); 865 void baz() { }''');
839 addTestSource(''' 866 addTestSource('''
840 import 'dart:async'; 867 import 'dart:async';
841 import '/libA.dart'; 868 import '/libA.dart';
842 class B { } 869 class B { }
843 String bar() => true; 870 String bar() => true;
844 void main() {new A(^)}'''); 871 void main() {new A(^)}''');
(...skipping 14 matching lines...) Expand all
859 assertSuggestImportedClass('Object', 886 assertSuggestImportedClass('Object',
860 kind: CompletionSuggestionKind.IDENTIFIER); 887 kind: CompletionSuggestionKind.IDENTIFIER);
861 assertNotSuggested('main'); 888 assertNotSuggested('main');
862 assertNotSuggested('baz'); 889 assertNotSuggested('baz');
863 assertNotSuggested('print'); 890 assertNotSuggested('print');
864 }); 891 });
865 } 892 }
866 893
867 test_ArgumentList_InstanceCreationExpression_typedefArg() { 894 test_ArgumentList_InstanceCreationExpression_typedefArg() {
868 // ArgumentList InstanceCreationExpression ExpressionStatement Block 895 // ArgumentList InstanceCreationExpression ExpressionStatement Block
869 addSource('/libA.dart', ''' 896 addSource(
897 '/libA.dart',
898 '''
870 library A; 899 library A;
871 typedef Funct(); 900 typedef Funct();
872 class A { A(Funct f) { } } 901 class A { A(Funct f) { } }
873 bool hasLength(int expected) { } 902 bool hasLength(int expected) { }
874 void baz() { }'''); 903 void baz() { }''');
875 addTestSource(''' 904 addTestSource('''
876 import 'dart:async'; 905 import 'dart:async';
877 import '/libA.dart'; 906 import '/libA.dart';
878 class B { } 907 class B { }
879 String bar() => true; 908 String bar() => true;
(...skipping 15 matching lines...) Expand all
895 assertSuggestImportedClass('Object', 924 assertSuggestImportedClass('Object',
896 kind: CompletionSuggestionKind.IDENTIFIER); 925 kind: CompletionSuggestionKind.IDENTIFIER);
897 assertNotSuggested('main'); 926 assertNotSuggested('main');
898 assertNotSuggested('baz'); 927 assertNotSuggested('baz');
899 assertNotSuggested('print'); 928 assertNotSuggested('print');
900 }); 929 });
901 } 930 }
902 931
903 test_ArgumentList_local_function() { 932 test_ArgumentList_local_function() {
904 // ArgumentList MethodInvocation ExpressionStatement Block 933 // ArgumentList MethodInvocation ExpressionStatement Block
905 addSource('/libA.dart', ''' 934 addSource(
935 '/libA.dart',
936 '''
906 library A; 937 library A;
907 bool hasLength(int expected) { } 938 bool hasLength(int expected) { }
908 void baz() { }'''); 939 void baz() { }''');
909 addTestSource(''' 940 addTestSource('''
910 import '/libA.dart' 941 import '/libA.dart'
911 expect(arg) { } 942 expect(arg) { }
912 class B { } 943 class B { }
913 String bar() => true; 944 String bar() => true;
914 void main() {expect(^)}'''); 945 void main() {expect(^)}''');
915 computeFast(); 946 computeFast();
916 return computeFull((bool result) { 947 return computeFull((bool result) {
917 expect(request.replacementOffset, completionOffset); 948 expect(request.replacementOffset, completionOffset);
918 expect(request.replacementLength, 0); 949 expect(request.replacementLength, 0);
919 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 950 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
920 assertSuggestLocalFunction('bar', 'String'); 951 assertSuggestLocalFunction('bar', 'String');
921 assertSuggestImportedFunction('hasLength', 'bool'); 952 assertSuggestImportedFunction('hasLength', 'bool');
922 assertSuggestImportedFunction('identical', 'bool'); 953 assertSuggestImportedFunction('identical', 'bool');
923 assertSuggestLocalClass('B'); 954 assertSuggestLocalClass('B');
924 assertSuggestImportedClass('Object'); 955 assertSuggestImportedClass('Object');
925 assertNotSuggested('main'); 956 assertNotSuggested('main');
926 assertNotSuggested('baz'); 957 assertNotSuggested('baz');
927 assertNotSuggested('print'); 958 assertNotSuggested('print');
928 }); 959 });
929 } 960 }
930 961
931 test_ArgumentList_local_method() { 962 test_ArgumentList_local_method() {
932 // ArgumentList MethodInvocation ExpressionStatement Block 963 // ArgumentList MethodInvocation ExpressionStatement Block
933 addSource('/libA.dart', ''' 964 addSource(
965 '/libA.dart',
966 '''
934 library A; 967 library A;
935 bool hasLength(int expected) { } 968 bool hasLength(int expected) { }
936 void baz() { }'''); 969 void baz() { }''');
937 addTestSource(''' 970 addTestSource('''
938 import '/libA.dart' 971 import '/libA.dart'
939 class B { 972 class B {
940 expect(arg) { } 973 expect(arg) { }
941 void foo() {expect(^)}} 974 void foo() {expect(^)}}
942 String bar() => true;'''); 975 String bar() => true;''');
943 computeFast(); 976 computeFast();
944 return computeFull((bool result) { 977 return computeFull((bool result) {
945 expect(request.replacementOffset, completionOffset); 978 expect(request.replacementOffset, completionOffset);
946 expect(request.replacementLength, 0); 979 expect(request.replacementLength, 0);
947 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 980 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
948 assertSuggestLocalFunction('bar', 'String'); 981 assertSuggestLocalFunction('bar', 'String');
949 assertSuggestImportedFunction('hasLength', 'bool'); 982 assertSuggestImportedFunction('hasLength', 'bool');
950 assertSuggestImportedFunction('identical', 'bool'); 983 assertSuggestImportedFunction('identical', 'bool');
951 assertSuggestLocalClass('B'); 984 assertSuggestLocalClass('B');
952 assertSuggestImportedClass('Object'); 985 assertSuggestImportedClass('Object');
953 assertNotSuggested('main'); 986 assertNotSuggested('main');
954 assertNotSuggested('baz'); 987 assertNotSuggested('baz');
955 assertNotSuggested('print'); 988 assertNotSuggested('print');
956 }); 989 });
957 } 990 }
958 991
959 test_ArgumentList_MethodInvocation_functionalArg() { 992 test_ArgumentList_MethodInvocation_functionalArg() {
960 // ArgumentList MethodInvocation ExpressionStatement Block 993 // ArgumentList MethodInvocation ExpressionStatement Block
961 addSource('/libA.dart', ''' 994 addSource(
995 '/libA.dart',
996 '''
962 library A; 997 library A;
963 class A { A(f()) { } } 998 class A { A(f()) { } }
964 bool hasLength(int expected) { } 999 bool hasLength(int expected) { }
965 void baz() { }'''); 1000 void baz() { }''');
966 addTestSource(''' 1001 addTestSource('''
967 import 'dart:async'; 1002 import 'dart:async';
968 import '/libA.dart'; 1003 import '/libA.dart';
969 class B { } 1004 class B { }
970 String bar(f()) => true; 1005 String bar(f()) => true;
971 void main() {bar(^);}'''); 1006 void main() {bar(^);}''');
(...skipping 14 matching lines...) Expand all
986 assertSuggestImportedClass('Object', 1021 assertSuggestImportedClass('Object',
987 kind: CompletionSuggestionKind.IDENTIFIER); 1022 kind: CompletionSuggestionKind.IDENTIFIER);
988 assertNotSuggested('main'); 1023 assertNotSuggested('main');
989 assertNotSuggested('baz'); 1024 assertNotSuggested('baz');
990 assertNotSuggested('print'); 1025 assertNotSuggested('print');
991 }); 1026 });
992 } 1027 }
993 1028
994 test_ArgumentList_MethodInvocation_methodArg() { 1029 test_ArgumentList_MethodInvocation_methodArg() {
995 // ArgumentList MethodInvocation ExpressionStatement Block 1030 // ArgumentList MethodInvocation ExpressionStatement Block
996 addSource('/libA.dart', ''' 1031 addSource(
1032 '/libA.dart',
1033 '''
997 library A; 1034 library A;
998 class A { A(f()) { } } 1035 class A { A(f()) { } }
999 bool hasLength(int expected) { } 1036 bool hasLength(int expected) { }
1000 void baz() { }'''); 1037 void baz() { }''');
1001 addTestSource(''' 1038 addTestSource('''
1002 import 'dart:async'; 1039 import 'dart:async';
1003 import '/libA.dart'; 1040 import '/libA.dart';
1004 class B { String bar(f()) => true; } 1041 class B { String bar(f()) => true; }
1005 void main() {new B().bar(^);}'''); 1042 void main() {new B().bar(^);}''');
1006 computeFast(); 1043 computeFast();
(...skipping 12 matching lines...) Expand all
1019 kind: CompletionSuggestionKind.IDENTIFIER); 1056 kind: CompletionSuggestionKind.IDENTIFIER);
1020 assertNotSuggested('main'); 1057 assertNotSuggested('main');
1021 assertNotSuggested('baz'); 1058 assertNotSuggested('baz');
1022 assertNotSuggested('print'); 1059 assertNotSuggested('print');
1023 }); 1060 });
1024 } 1061 }
1025 1062
1026 test_ArgumentList_namedParam() { 1063 test_ArgumentList_namedParam() {
1027 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation 1064 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation
1028 // ExpressionStatement 1065 // ExpressionStatement
1029 addSource('/libA.dart', ''' 1066 addSource(
1067 '/libA.dart',
1068 '''
1030 library A; 1069 library A;
1031 bool hasLength(int expected) { }'''); 1070 bool hasLength(int expected) { }''');
1032 addTestSource(''' 1071 addTestSource('''
1033 import '/libA.dart' 1072 import '/libA.dart'
1034 String bar() => true; 1073 String bar() => true;
1035 void main() {expect(foo: ^)}'''); 1074 void main() {expect(foo: ^)}''');
1036 computeFast(); 1075 computeFast();
1037 return computeFull((bool result) { 1076 return computeFull((bool result) {
1038 expect(request.replacementOffset, completionOffset); 1077 expect(request.replacementOffset, completionOffset);
1039 expect(request.replacementLength, 0); 1078 expect(request.replacementLength, 0);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 expect(request.replacementLength, 0); 1257 expect(request.replacementLength, 0);
1219 assertSuggestLocalVariable('a', 'int'); 1258 assertSuggestLocalVariable('a', 'int');
1220 assertSuggestImportedClass('Object'); 1259 assertSuggestImportedClass('Object');
1221 assertNotSuggested('b'); 1260 assertNotSuggested('b');
1222 assertNotSuggested('=='); 1261 assertNotSuggested('==');
1223 }); 1262 });
1224 } 1263 }
1225 1264
1226 test_Block() { 1265 test_Block() {
1227 // Block BlockFunctionBody MethodDeclaration 1266 // Block BlockFunctionBody MethodDeclaration
1228 addSource('/testAB.dart', ''' 1267 addSource(
1268 '/testAB.dart',
1269 '''
1229 export "dart:math" hide max; 1270 export "dart:math" hide max;
1230 class A {int x;} 1271 class A {int x;}
1231 @deprecated D1() {int x;} 1272 @deprecated D1() {int x;}
1232 class _B {boo() { partBoo() {}} }'''); 1273 class _B {boo() { partBoo() {}} }''');
1233 addSource('/testCD.dart', ''' 1274 addSource(
1275 '/testCD.dart',
1276 '''
1234 String T1; 1277 String T1;
1235 var _T2; 1278 var _T2;
1236 class C { } 1279 class C { }
1237 class D { }'''); 1280 class D { }''');
1238 addSource('/testEEF.dart', ''' 1281 addSource(
1282 '/testEEF.dart',
1283 '''
1239 class EE { } 1284 class EE { }
1240 class F { }'''); 1285 class F { }''');
1241 addSource('/testG.dart', 'class G { }'); 1286 addSource('/testG.dart', 'class G { }');
1242 addSource('/testH.dart', ''' 1287 addSource(
1288 '/testH.dart',
1289 '''
1243 class H { } 1290 class H { }
1244 int T3; 1291 int T3;
1245 var _T4;'''); // not imported 1292 var _T4;'''); // not imported
1246 addTestSource(''' 1293 addTestSource('''
1247 import "/testAB.dart"; 1294 import "/testAB.dart";
1248 import "/testCD.dart" hide D; 1295 import "/testCD.dart" hide D;
1249 import "/testEEF.dart" show EE; 1296 import "/testEEF.dart" show EE;
1250 import "/testG.dart" as g; 1297 import "/testG.dart" as g;
1251 int T5; 1298 int T5;
1252 var _T6; 1299 var _T6;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 // TODO (danrubel) suggest HtmlElement as low relevance 1367 // TODO (danrubel) suggest HtmlElement as low relevance
1321 assertNotSuggested('HtmlElement'); 1368 assertNotSuggested('HtmlElement');
1322 assertSuggestImportedClass('Uri'); 1369 assertSuggestImportedClass('Uri');
1323 assertNotSuggested('parseIPv6Address'); 1370 assertNotSuggested('parseIPv6Address');
1324 assertNotSuggested('parseHex'); 1371 assertNotSuggested('parseHex');
1325 }); 1372 });
1326 } 1373 }
1327 1374
1328 test_Block_final() { 1375 test_Block_final() {
1329 // Block BlockFunctionBody MethodDeclaration 1376 // Block BlockFunctionBody MethodDeclaration
1330 addSource('/testAB.dart', ''' 1377 addSource(
1378 '/testAB.dart',
1379 '''
1331 export "dart:math" hide max; 1380 export "dart:math" hide max;
1332 class A {int x;} 1381 class A {int x;}
1333 @deprecated D1() {int x;} 1382 @deprecated D1() {int x;}
1334 class _B {boo() { partBoo() {}} }'''); 1383 class _B {boo() { partBoo() {}} }''');
1335 addSource('/testCD.dart', ''' 1384 addSource(
1385 '/testCD.dart',
1386 '''
1336 String T1; 1387 String T1;
1337 var _T2; 1388 var _T2;
1338 class C { } 1389 class C { }
1339 class D { }'''); 1390 class D { }''');
1340 addSource('/testEEF.dart', ''' 1391 addSource(
1392 '/testEEF.dart',
1393 '''
1341 class EE { } 1394 class EE { }
1342 class F { }'''); 1395 class F { }''');
1343 addSource('/testG.dart', 'class G { }'); 1396 addSource('/testG.dart', 'class G { }');
1344 addSource('/testH.dart', ''' 1397 addSource(
1398 '/testH.dart',
1399 '''
1345 class H { } 1400 class H { }
1346 int T3; 1401 int T3;
1347 var _T4;'''); // not imported 1402 var _T4;'''); // not imported
1348 addTestSource(''' 1403 addTestSource('''
1349 import "/testAB.dart"; 1404 import "/testAB.dart";
1350 import "/testCD.dart" hide D; 1405 import "/testCD.dart" hide D;
1351 import "/testEEF.dart" show EE; 1406 import "/testEEF.dart" show EE;
1352 import "/testG.dart" as g; 1407 import "/testG.dart" as g;
1353 int T5; 1408 int T5;
1354 var _T6; 1409 var _T6;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 test_Block_final3() { 1490 test_Block_final3() {
1436 addTestSource('main() {final ^ v;}'); 1491 addTestSource('main() {final ^ v;}');
1437 computeFast(); 1492 computeFast();
1438 return computeFull((bool result) { 1493 return computeFull((bool result) {
1439 assertSuggestImportedClass('String'); 1494 assertSuggestImportedClass('String');
1440 }); 1495 });
1441 } 1496 }
1442 1497
1443 test_Block_final_final() { 1498 test_Block_final_final() {
1444 // Block BlockFunctionBody MethodDeclaration 1499 // Block BlockFunctionBody MethodDeclaration
1445 addSource('/testAB.dart', ''' 1500 addSource(
1501 '/testAB.dart',
1502 '''
1446 export "dart:math" hide max; 1503 export "dart:math" hide max;
1447 class A {int x;} 1504 class A {int x;}
1448 @deprecated D1() {int x;} 1505 @deprecated D1() {int x;}
1449 class _B {boo() { partBoo() {}} }'''); 1506 class _B {boo() { partBoo() {}} }''');
1450 addSource('/testCD.dart', ''' 1507 addSource(
1508 '/testCD.dart',
1509 '''
1451 String T1; 1510 String T1;
1452 var _T2; 1511 var _T2;
1453 class C { } 1512 class C { }
1454 class D { }'''); 1513 class D { }''');
1455 addSource('/testEEF.dart', ''' 1514 addSource(
1515 '/testEEF.dart',
1516 '''
1456 class EE { } 1517 class EE { }
1457 class F { }'''); 1518 class F { }''');
1458 addSource('/testG.dart', 'class G { }'); 1519 addSource('/testG.dart', 'class G { }');
1459 addSource('/testH.dart', ''' 1520 addSource(
1521 '/testH.dart',
1522 '''
1460 class H { } 1523 class H { }
1461 int T3; 1524 int T3;
1462 var _T4;'''); // not imported 1525 var _T4;'''); // not imported
1463 addTestSource(''' 1526 addTestSource('''
1464 import "/testAB.dart"; 1527 import "/testAB.dart";
1465 import "/testCD.dart" hide D; 1528 import "/testCD.dart" hide D;
1466 import "/testEEF.dart" show EE; 1529 import "/testEEF.dart" show EE;
1467 import "/testG.dart" as g; 1530 import "/testG.dart" as g;
1468 int T5; 1531 int T5;
1469 var _T6; 1532 var _T6;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 // TODO (danrubel) suggest HtmlElement as low relevance 1597 // TODO (danrubel) suggest HtmlElement as low relevance
1535 assertNotSuggested('HtmlElement'); 1598 assertNotSuggested('HtmlElement');
1536 assertSuggestImportedClass('Uri'); 1599 assertSuggestImportedClass('Uri');
1537 assertNotSuggested('parseIPv6Address'); 1600 assertNotSuggested('parseIPv6Address');
1538 assertNotSuggested('parseHex'); 1601 assertNotSuggested('parseHex');
1539 }); 1602 });
1540 } 1603 }
1541 1604
1542 test_Block_final_var() { 1605 test_Block_final_var() {
1543 // Block BlockFunctionBody MethodDeclaration 1606 // Block BlockFunctionBody MethodDeclaration
1544 addSource('/testAB.dart', ''' 1607 addSource(
1608 '/testAB.dart',
1609 '''
1545 export "dart:math" hide max; 1610 export "dart:math" hide max;
1546 class A {int x;} 1611 class A {int x;}
1547 @deprecated D1() {int x;} 1612 @deprecated D1() {int x;}
1548 class _B {boo() { partBoo() {}} }'''); 1613 class _B {boo() { partBoo() {}} }''');
1549 addSource('/testCD.dart', ''' 1614 addSource(
1615 '/testCD.dart',
1616 '''
1550 String T1; 1617 String T1;
1551 var _T2; 1618 var _T2;
1552 class C { } 1619 class C { }
1553 class D { }'''); 1620 class D { }''');
1554 addSource('/testEEF.dart', ''' 1621 addSource(
1622 '/testEEF.dart',
1623 '''
1555 class EE { } 1624 class EE { }
1556 class F { }'''); 1625 class F { }''');
1557 addSource('/testG.dart', 'class G { }'); 1626 addSource('/testG.dart', 'class G { }');
1558 addSource('/testH.dart', ''' 1627 addSource(
1628 '/testH.dart',
1629 '''
1559 class H { } 1630 class H { }
1560 int T3; 1631 int T3;
1561 var _T4;'''); // not imported 1632 var _T4;'''); // not imported
1562 addTestSource(''' 1633 addTestSource('''
1563 import "/testAB.dart"; 1634 import "/testAB.dart";
1564 import "/testCD.dart" hide D; 1635 import "/testCD.dart" hide D;
1565 import "/testEEF.dart" show EE; 1636 import "/testEEF.dart" show EE;
1566 import "/testG.dart" as g; 1637 import "/testG.dart" as g;
1567 int T5; 1638 int T5;
1568 var _T6; 1639 var _T6;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 assertNotSuggested('blog'); 1703 assertNotSuggested('blog');
1633 // TODO (danrubel) suggest HtmlElement as low relevance 1704 // TODO (danrubel) suggest HtmlElement as low relevance
1634 assertNotSuggested('HtmlElement'); 1705 assertNotSuggested('HtmlElement');
1635 assertSuggestImportedClass('Uri'); 1706 assertSuggestImportedClass('Uri');
1636 assertNotSuggested('parseIPv6Address'); 1707 assertNotSuggested('parseIPv6Address');
1637 assertNotSuggested('parseHex'); 1708 assertNotSuggested('parseHex');
1638 }); 1709 });
1639 } 1710 }
1640 1711
1641 test_Block_identifier_partial() { 1712 test_Block_identifier_partial() {
1642 addSource('/testAB.dart', ''' 1713 addSource(
1714 '/testAB.dart',
1715 '''
1643 export "dart:math" hide max; 1716 export "dart:math" hide max;
1644 class A {int x;} 1717 class A {int x;}
1645 @deprecated D1() {int x;} 1718 @deprecated D1() {int x;}
1646 class _B { }'''); 1719 class _B { }''');
1647 addSource('/testCD.dart', ''' 1720 addSource(
1721 '/testCD.dart',
1722 '''
1648 String T1; 1723 String T1;
1649 var _T2; 1724 var _T2;
1650 class C { } 1725 class C { }
1651 class D { }'''); 1726 class D { }''');
1652 addSource('/testEEF.dart', ''' 1727 addSource(
1728 '/testEEF.dart',
1729 '''
1653 class EE { } 1730 class EE { }
1654 class F { }'''); 1731 class F { }''');
1655 addSource('/testG.dart', 'class G { }'); 1732 addSource('/testG.dart', 'class G { }');
1656 addSource('/testH.dart', ''' 1733 addSource(
1734 '/testH.dart',
1735 '''
1657 class H { } 1736 class H { }
1658 class D3 { } 1737 class D3 { }
1659 int T3; 1738 int T3;
1660 var _T4;'''); // not imported 1739 var _T4;'''); // not imported
1661 addTestSource(''' 1740 addTestSource('''
1662 import "/testAB.dart"; 1741 import "/testAB.dart";
1663 import "/testCD.dart" hide D; 1742 import "/testCD.dart" hide D;
1664 import "/testEEF.dart" show EE; 1743 import "/testEEF.dart" show EE;
1665 import "/testG.dart" as g; 1744 import "/testG.dart" as g;
1666 int T5; 1745 int T5;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 //assertSuggestLocalTopLevelVar('T5', 'int'); 1794 //assertSuggestLocalTopLevelVar('T5', 'int');
1716 //assertSuggestLocalTopLevelVar('_T6', null); 1795 //assertSuggestLocalTopLevelVar('_T6', null);
1717 assertNotSuggested('=='); 1796 assertNotSuggested('==');
1718 // TODO (danrubel) suggest HtmlElement as low relevance 1797 // TODO (danrubel) suggest HtmlElement as low relevance
1719 assertNotSuggested('HtmlElement'); 1798 assertNotSuggested('HtmlElement');
1720 }); 1799 });
1721 } 1800 }
1722 1801
1723 test_Block_inherited_imported() { 1802 test_Block_inherited_imported() {
1724 // Block BlockFunctionBody MethodDeclaration ClassDeclaration 1803 // Block BlockFunctionBody MethodDeclaration ClassDeclaration
1725 addSource('/testB.dart', ''' 1804 addSource(
1805 '/testB.dart',
1806 '''
1726 lib B; 1807 lib B;
1727 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; } 1808 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; }
1728 class E extends F { var e1; e2() { } } 1809 class E extends F { var e1; e2() { } }
1729 class I { int i1; i2() { } } 1810 class I { int i1; i2() { } }
1730 class M { var m1; int m2() { } }'''); 1811 class M { var m1; int m2() { } }''');
1731 addTestSource(''' 1812 addTestSource('''
1732 import "/testB.dart"; 1813 import "/testB.dart";
1733 class A extends E implements I with M {a() {^}}'''); 1814 class A extends E implements I with M {a() {^}}''');
1734 computeFast(); 1815 computeFast();
1735 return computeFull((bool result) { 1816 return computeFull((bool result) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 assertSuggestLocalGetter('f3', null); 1852 assertSuggestLocalGetter('f3', null);
1772 assertSuggestLocalSetter('f4'); 1853 assertSuggestLocalSetter('f4');
1773 assertSuggestLocalMethod('e2', 'E', null); 1854 assertSuggestLocalMethod('e2', 'E', null);
1774 assertSuggestLocalMethod('f2', 'F', null); 1855 assertSuggestLocalMethod('f2', 'F', null);
1775 assertSuggestLocalMethod('i2', 'I', null); 1856 assertSuggestLocalMethod('i2', 'I', null);
1776 assertSuggestLocalMethod('m2', 'M', 'int'); 1857 assertSuggestLocalMethod('m2', 'M', 'int');
1777 }); 1858 });
1778 } 1859 }
1779 1860
1780 test_Block_local_function() { 1861 test_Block_local_function() {
1781 addSource('/testAB.dart', ''' 1862 addSource(
1863 '/testAB.dart',
1864 '''
1782 export "dart:math" hide max; 1865 export "dart:math" hide max;
1783 class A {int x;} 1866 class A {int x;}
1784 @deprecated D1() {int x;} 1867 @deprecated D1() {int x;}
1785 class _B {boo() { partBoo() {}} }'''); 1868 class _B {boo() { partBoo() {}} }''');
1786 addSource('/testCD.dart', ''' 1869 addSource(
1870 '/testCD.dart',
1871 '''
1787 String T1; 1872 String T1;
1788 var _T2; 1873 var _T2;
1789 class C { } 1874 class C { }
1790 class D { }'''); 1875 class D { }''');
1791 addSource('/testEEF.dart', ''' 1876 addSource(
1877 '/testEEF.dart',
1878 '''
1792 class EE { } 1879 class EE { }
1793 class F { }'''); 1880 class F { }''');
1794 addSource('/testG.dart', 'class G { }'); 1881 addSource('/testG.dart', 'class G { }');
1795 addSource('/testH.dart', ''' 1882 addSource(
1883 '/testH.dart',
1884 '''
1796 class H { } 1885 class H { }
1797 int T3; 1886 int T3;
1798 var _T4;'''); // not imported 1887 var _T4;'''); // not imported
1799 addTestSource(''' 1888 addTestSource('''
1800 import "/testAB.dart"; 1889 import "/testAB.dart";
1801 import "/testCD.dart" hide D; 1890 import "/testCD.dart" hide D;
1802 import "/testEEF.dart" show EE; 1891 import "/testEEF.dart" show EE;
1803 import "/testG.dart" as g; 1892 import "/testG.dart" as g;
1804 int T5; 1893 int T5;
1805 var _T6; 1894 var _T6;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 // TODO(danrubel) implement 1933 // TODO(danrubel) implement
1845 assertSuggestImportedClass('Foo2', 1934 assertSuggestImportedClass('Foo2',
1846 relevance: DART_RELEVANCE_LOW, importUri: 'package:myBar/bar.dart'); 1935 relevance: DART_RELEVANCE_LOW, importUri: 'package:myBar/bar.dart');
1847 assertSuggestImportedClass('Future', 1936 assertSuggestImportedClass('Future',
1848 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async'); 1937 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async');
1849 }); 1938 });
1850 } 1939 }
1851 1940
1852 test_CascadeExpression_selector1() { 1941 test_CascadeExpression_selector1() {
1853 // PropertyAccess CascadeExpression ExpressionStatement Block 1942 // PropertyAccess CascadeExpression ExpressionStatement Block
1854 addSource('/testB.dart', ''' 1943 addSource(
1944 '/testB.dart',
1945 '''
1855 class B { }'''); 1946 class B { }''');
1856 addTestSource(''' 1947 addTestSource('''
1857 import "/testB.dart"; 1948 import "/testB.dart";
1858 class A {var b; X _c;} 1949 class A {var b; X _c;}
1859 class X{} 1950 class X{}
1860 // looks like a cascade to the parser 1951 // looks like a cascade to the parser
1861 // but the user is trying to get completions for a non-cascade 1952 // but the user is trying to get completions for a non-cascade
1862 main() {A a; a.^.z}'''); 1953 main() {A a; a.^.z}''');
1863 computeFast(); 1954 computeFast();
1864 return computeFull((bool result) { 1955 return computeFull((bool result) {
1865 expect(request.replacementOffset, completionOffset); 1956 expect(request.replacementOffset, completionOffset);
1866 expect(request.replacementLength, 0); 1957 expect(request.replacementLength, 0);
1867 assertSuggestInvocationField('b', null); 1958 assertSuggestInvocationField('b', null);
1868 assertSuggestInvocationField('_c', 'X'); 1959 assertSuggestInvocationField('_c', 'X');
1869 assertNotSuggested('Object'); 1960 assertNotSuggested('Object');
1870 assertNotSuggested('A'); 1961 assertNotSuggested('A');
1871 assertNotSuggested('B'); 1962 assertNotSuggested('B');
1872 assertNotSuggested('X'); 1963 assertNotSuggested('X');
1873 assertNotSuggested('z'); 1964 assertNotSuggested('z');
1874 assertNotSuggested('=='); 1965 assertNotSuggested('==');
1875 }); 1966 });
1876 } 1967 }
1877 1968
1878 test_CascadeExpression_selector2() { 1969 test_CascadeExpression_selector2() {
1879 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement 1970 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement
1880 addSource('/testB.dart', ''' 1971 addSource(
1972 '/testB.dart',
1973 '''
1881 class B { }'''); 1974 class B { }''');
1882 addTestSource(''' 1975 addTestSource('''
1883 import "/testB.dart"; 1976 import "/testB.dart";
1884 class A {var b; X _c;} 1977 class A {var b; X _c;}
1885 class X{} 1978 class X{}
1886 main() {A a; a..^z}'''); 1979 main() {A a; a..^z}''');
1887 computeFast(); 1980 computeFast();
1888 return computeFull((bool result) { 1981 return computeFull((bool result) {
1889 expect(request.replacementOffset, completionOffset); 1982 expect(request.replacementOffset, completionOffset);
1890 expect(request.replacementLength, 1); 1983 expect(request.replacementLength, 1);
1891 assertSuggestInvocationField('b', null); 1984 assertSuggestInvocationField('b', null);
1892 assertSuggestInvocationField('_c', 'X'); 1985 assertSuggestInvocationField('_c', 'X');
1893 assertNotSuggested('Object'); 1986 assertNotSuggested('Object');
1894 assertNotSuggested('A'); 1987 assertNotSuggested('A');
1895 assertNotSuggested('B'); 1988 assertNotSuggested('B');
1896 assertNotSuggested('X'); 1989 assertNotSuggested('X');
1897 assertNotSuggested('z'); 1990 assertNotSuggested('z');
1898 assertNotSuggested('=='); 1991 assertNotSuggested('==');
1899 }); 1992 });
1900 } 1993 }
1901 1994
1902 test_CascadeExpression_selector2_withTrailingReturn() { 1995 test_CascadeExpression_selector2_withTrailingReturn() {
1903 // PropertyAccess CascadeExpression ExpressionStatement Block 1996 // PropertyAccess CascadeExpression ExpressionStatement Block
1904 addSource('/testB.dart', ''' 1997 addSource(
1998 '/testB.dart',
1999 '''
1905 class B { }'''); 2000 class B { }''');
1906 addTestSource(''' 2001 addTestSource('''
1907 import "/testB.dart"; 2002 import "/testB.dart";
1908 class A {var b; X _c;} 2003 class A {var b; X _c;}
1909 class X{} 2004 class X{}
1910 main() {A a; a..^ return}'''); 2005 main() {A a; a..^ return}''');
1911 computeFast(); 2006 computeFast();
1912 return computeFull((bool result) { 2007 return computeFull((bool result) {
1913 expect(request.replacementOffset, completionOffset); 2008 expect(request.replacementOffset, completionOffset);
1914 expect(request.replacementLength, 0); 2009 expect(request.replacementLength, 0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 assertSuggestParameter('e', null); 2090 assertSuggestParameter('e', null);
1996 assertSuggestParameter('s', 'StackTrace'); 2091 assertSuggestParameter('s', 'StackTrace');
1997 assertSuggestLocalMethod('a', 'A', null); 2092 assertSuggestLocalMethod('a', 'A', null);
1998 assertSuggestImportedClass('Object'); 2093 assertSuggestImportedClass('Object');
1999 assertNotSuggested('x'); 2094 assertNotSuggested('x');
2000 }); 2095 });
2001 } 2096 }
2002 2097
2003 test_ClassDeclaration_body() { 2098 test_ClassDeclaration_body() {
2004 // ClassDeclaration CompilationUnit 2099 // ClassDeclaration CompilationUnit
2005 addSource('/testB.dart', ''' 2100 addSource(
2101 '/testB.dart',
2102 '''
2006 class B { }'''); 2103 class B { }''');
2007 addTestSource(''' 2104 addTestSource('''
2008 import "testB.dart" as x; 2105 import "testB.dart" as x;
2009 @deprecated class A {^} 2106 @deprecated class A {^}
2010 class _B {} 2107 class _B {}
2011 A T;'''); 2108 A T;''');
2012 computeFast(); 2109 computeFast();
2013 return computeFull((bool result) { 2110 return computeFull((bool result) {
2014 expect(request.replacementOffset, completionOffset); 2111 expect(request.replacementOffset, completionOffset);
2015 expect(request.replacementLength, 0); 2112 expect(request.replacementLength, 0);
(...skipping 13 matching lines...) Expand all
2029 expect(suggestionO.element.isDeprecated, isFalse); 2126 expect(suggestionO.element.isDeprecated, isFalse);
2030 expect(suggestionO.element.isPrivate, isFalse); 2127 expect(suggestionO.element.isPrivate, isFalse);
2031 } 2128 }
2032 assertNotSuggested('T'); 2129 assertNotSuggested('T');
2033 assertSuggestLibraryPrefix('x'); 2130 assertSuggestLibraryPrefix('x');
2034 }); 2131 });
2035 } 2132 }
2036 2133
2037 test_ClassDeclaration_body_final() { 2134 test_ClassDeclaration_body_final() {
2038 // ClassDeclaration CompilationUnit 2135 // ClassDeclaration CompilationUnit
2039 addSource('/testB.dart', ''' 2136 addSource(
2137 '/testB.dart',
2138 '''
2040 class B { }'''); 2139 class B { }''');
2041 addTestSource(''' 2140 addTestSource('''
2042 import "testB.dart" as x; 2141 import "testB.dart" as x;
2043 class A {final ^} 2142 class A {final ^}
2044 class _B {} 2143 class _B {}
2045 A T;'''); 2144 A T;''');
2046 computeFast(); 2145 computeFast();
2047 return computeFull((bool result) { 2146 return computeFull((bool result) {
2048 expect(request.replacementOffset, completionOffset); 2147 expect(request.replacementOffset, completionOffset);
2049 expect(request.replacementLength, 0); 2148 expect(request.replacementLength, 0);
2050 assertSuggestLocalClass('A'); 2149 assertSuggestLocalClass('A');
2051 assertSuggestLocalClass('_B'); 2150 assertSuggestLocalClass('_B');
2052 assertSuggestImportedClass('Object'); 2151 assertSuggestImportedClass('Object');
2053 assertNotSuggested('T'); 2152 assertNotSuggested('T');
2054 assertSuggestLibraryPrefix('x'); 2153 assertSuggestLibraryPrefix('x');
2055 }); 2154 });
2056 } 2155 }
2057 2156
2157 test_ClassDeclaration_body_final_field() {
2158 // ClassDeclaration CompilationUnit
2159 addSource(
2160 '/testB.dart',
2161 '''
2162 class B { }''');
2163 addTestSource('''
2164 import "testB.dart" as x;
2165 class A {final ^ A(){}}
2166 class _B {}
2167 A T;''');
2168 computeFast();
2169 return computeFull((bool result) {
2170 expect(request.replacementOffset, completionOffset);
2171 expect(request.replacementLength, 0);
2172 assertSuggestLocalClass('A');
2173 assertSuggestLocalClass('_B');
2174 assertSuggestImportedClass('String');
2175 assertNotSuggested('T');
2176 assertSuggestLibraryPrefix('x');
2177 });
2178 }
2179
2180 test_ClassDeclaration_body_final_field2() {
2181 // ClassDeclaration CompilationUnit
2182 addSource(
2183 '/testB.dart',
2184 '''
2185 class B { }''');
2186 addTestSource('''
2187 import "testB.dart" as Soo;
2188 class A {final S^ A();}
2189 class _B {}
2190 A Sew;''');
2191 computeFast();
2192 return computeFull((bool result) {
2193 expect(request.replacementOffset, completionOffset - 1);
2194 expect(request.replacementLength, 1);
2195 assertSuggestLocalClass('A');
2196 assertSuggestLocalClass('_B');
2197 assertSuggestImportedClass('String');
2198 assertNotSuggested('Sew');
2199 assertSuggestLibraryPrefix('Soo');
2200 });
2201 }
2202
2058 test_ClassDeclaration_body_final_final() { 2203 test_ClassDeclaration_body_final_final() {
2059 // ClassDeclaration CompilationUnit 2204 // ClassDeclaration CompilationUnit
2060 addSource('/testB.dart', ''' 2205 addSource(
2206 '/testB.dart',
2207 '''
2061 class B { }'''); 2208 class B { }''');
2062 addTestSource(''' 2209 addTestSource('''
2063 import "testB.dart" as x; 2210 import "testB.dart" as x;
2064 class A {final ^ final foo;} 2211 class A {final ^ final foo;}
2065 class _B {} 2212 class _B {}
2066 A T;'''); 2213 A T;''');
2067 computeFast(); 2214 computeFast();
2068 return computeFull((bool result) { 2215 return computeFull((bool result) {
2069 expect(request.replacementOffset, completionOffset); 2216 expect(request.replacementOffset, completionOffset);
2070 expect(request.replacementLength, 0); 2217 expect(request.replacementLength, 0);
2071 assertSuggestLocalClass('A'); 2218 assertSuggestLocalClass('A');
2072 assertSuggestLocalClass('_B'); 2219 assertSuggestLocalClass('_B');
2073 assertSuggestImportedClass('Object'); 2220 assertSuggestImportedClass('Object');
2074 assertNotSuggested('T'); 2221 assertNotSuggested('T');
2075 assertSuggestLibraryPrefix('x'); 2222 assertSuggestLibraryPrefix('x');
2076 }); 2223 });
2077 } 2224 }
2078 2225
2079 test_ClassDeclaration_body_final_var() { 2226 test_ClassDeclaration_body_final_var() {
2080 // ClassDeclaration CompilationUnit 2227 // ClassDeclaration CompilationUnit
2081 addSource('/testB.dart', ''' 2228 addSource(
2229 '/testB.dart',
2230 '''
2082 class B { }'''); 2231 class B { }''');
2083 addTestSource(''' 2232 addTestSource('''
2084 import "testB.dart" as x; 2233 import "testB.dart" as x;
2085 class A {final ^ var foo;} 2234 class A {final ^ var foo;}
2086 class _B {} 2235 class _B {}
2087 A T;'''); 2236 A T;''');
2088 computeFast(); 2237 computeFast();
2089 return computeFull((bool result) { 2238 return computeFull((bool result) {
2090 expect(request.replacementOffset, completionOffset); 2239 expect(request.replacementOffset, completionOffset);
2091 expect(request.replacementLength, 0); 2240 expect(request.replacementLength, 0);
2092 assertSuggestLocalClass('A'); 2241 assertSuggestLocalClass('A');
2093 assertSuggestLocalClass('_B'); 2242 assertSuggestLocalClass('_B');
2094 assertSuggestImportedClass('Object'); 2243 assertSuggestImportedClass('Object');
2095 assertNotSuggested('T'); 2244 assertNotSuggested('T');
2096 assertSuggestLibraryPrefix('x'); 2245 assertSuggestLibraryPrefix('x');
2097 }); 2246 });
2098 } 2247 }
2099 2248
2100 test_Combinator_hide() { 2249 test_Combinator_hide() {
2101 // SimpleIdentifier HideCombinator ImportDirective 2250 // SimpleIdentifier HideCombinator ImportDirective
2102 addSource('/testAB.dart', ''' 2251 addSource(
2252 '/testAB.dart',
2253 '''
2103 library libAB; 2254 library libAB;
2104 part '/partAB.dart'; 2255 part '/partAB.dart';
2105 class A { } 2256 class A { }
2106 class B { }'''); 2257 class B { }''');
2107 addSource('/partAB.dart', ''' 2258 addSource(
2259 '/partAB.dart',
2260 '''
2108 part of libAB; 2261 part of libAB;
2109 var T1; 2262 var T1;
2110 PB F1() => new PB(); 2263 PB F1() => new PB();
2111 class PB { }'''); 2264 class PB { }''');
2112 addSource('/testCD.dart', ''' 2265 addSource(
2266 '/testCD.dart',
2267 '''
2113 class C { } 2268 class C { }
2114 class D { }'''); 2269 class D { }''');
2115 addTestSource(''' 2270 addTestSource('''
2116 import "/testAB.dart" hide ^; 2271 import "/testAB.dart" hide ^;
2117 import "/testCD.dart"; 2272 import "/testCD.dart";
2118 class X {}'''); 2273 class X {}''');
2119 computeFast(); 2274 computeFast();
2120 return computeFull((bool result) { 2275 return computeFull((bool result) {
2121 assertNoSuggestions(); 2276 assertNoSuggestions();
2122 }); 2277 });
2123 } 2278 }
2124 2279
2125 test_Combinator_show() { 2280 test_Combinator_show() {
2126 // SimpleIdentifier HideCombinator ImportDirective 2281 // SimpleIdentifier HideCombinator ImportDirective
2127 addSource('/testAB.dart', ''' 2282 addSource(
2283 '/testAB.dart',
2284 '''
2128 library libAB; 2285 library libAB;
2129 part '/partAB.dart'; 2286 part '/partAB.dart';
2130 class A { } 2287 class A { }
2131 class B { }'''); 2288 class B { }''');
2132 addSource('/partAB.dart', ''' 2289 addSource(
2290 '/partAB.dart',
2291 '''
2133 part of libAB; 2292 part of libAB;
2134 var T1; 2293 var T1;
2135 PB F1() => new PB(); 2294 PB F1() => new PB();
2136 typedef PB2 F2(int blat); 2295 typedef PB2 F2(int blat);
2137 class Clz = Object with Object; 2296 class Clz = Object with Object;
2138 class PB { }'''); 2297 class PB { }''');
2139 addSource('/testCD.dart', ''' 2298 addSource(
2299 '/testCD.dart',
2300 '''
2140 class C { } 2301 class C { }
2141 class D { }'''); 2302 class D { }''');
2142 addTestSource(''' 2303 addTestSource('''
2143 import "/testAB.dart" show ^; 2304 import "/testAB.dart" show ^;
2144 import "/testCD.dart"; 2305 import "/testCD.dart";
2145 class X {}'''); 2306 class X {}''');
2146 computeFast(); 2307 computeFast();
2147 return computeFull((bool result) { 2308 return computeFull((bool result) {
2148 assertNoSuggestions(); 2309 assertNoSuggestions();
2149 }); 2310 });
2150 } 2311 }
2151 2312
2152 test_ConditionalExpression_elseExpression() { 2313 test_ConditionalExpression_elseExpression() {
2153 // SimpleIdentifier ConditionalExpression ReturnStatement 2314 // SimpleIdentifier ConditionalExpression ReturnStatement
2154 addSource('/testA.dart', ''' 2315 addSource(
2316 '/testA.dart',
2317 '''
2155 int T1; 2318 int T1;
2156 F1() { } 2319 F1() { }
2157 class A {int x;}'''); 2320 class A {int x;}''');
2158 addTestSource(''' 2321 addTestSource('''
2159 import "/testA.dart"; 2322 import "/testA.dart";
2160 int T2; 2323 int T2;
2161 F2() { } 2324 F2() { }
2162 class B {int x;} 2325 class B {int x;}
2163 class C {foo(){var f; {var x;} return a ? T1 : T^}}'''); 2326 class C {foo(){var f; {var x;} return a ? T1 : T^}}''');
2164 computeFast(); 2327 computeFast();
2165 return computeFull((bool result) { 2328 return computeFull((bool result) {
2166 // top level results are partially filtered based on first char 2329 // top level results are partially filtered based on first char
2167 assertSuggestLocalTopLevelVar('T2', 'int'); 2330 assertSuggestLocalTopLevelVar('T2', 'int');
2168 // TODO (danrubel) getter is being suggested instead of top level var 2331 // TODO (danrubel) getter is being suggested instead of top level var
2169 //assertSuggestImportedTopLevelVar('T1', 'int'); 2332 //assertSuggestImportedTopLevelVar('T1', 'int');
2170 }); 2333 });
2171 } 2334 }
2172 2335
2173 test_ConditionalExpression_elseExpression_empty() { 2336 test_ConditionalExpression_elseExpression_empty() {
2174 // SimpleIdentifier ConditionalExpression ReturnStatement 2337 // SimpleIdentifier ConditionalExpression ReturnStatement
2175 addSource('/testA.dart', ''' 2338 addSource(
2339 '/testA.dart',
2340 '''
2176 int T1; 2341 int T1;
2177 F1() { } 2342 F1() { }
2178 class A {int x;}'''); 2343 class A {int x;}''');
2179 addTestSource(''' 2344 addTestSource('''
2180 import "/testA.dart"; 2345 import "/testA.dart";
2181 int T2; 2346 int T2;
2182 F2() { } 2347 F2() { }
2183 class B {int x;} 2348 class B {int x;}
2184 class C {foo(){var f; {var x;} return a ? T1 : ^}}'''); 2349 class C {foo(){var f; {var x;} return a ? T1 : ^}}''');
2185 computeFast(); 2350 computeFast();
2186 return computeFull((bool result) { 2351 return computeFull((bool result) {
2187 assertNotSuggested('x'); 2352 assertNotSuggested('x');
2188 assertSuggestLocalVariable('f', null); 2353 assertSuggestLocalVariable('f', null);
2189 assertSuggestLocalMethod('foo', 'C', null); 2354 assertSuggestLocalMethod('foo', 'C', null);
2190 assertSuggestLocalClass('C'); 2355 assertSuggestLocalClass('C');
2191 assertSuggestLocalFunction('F2', null); 2356 assertSuggestLocalFunction('F2', null);
2192 assertSuggestLocalTopLevelVar('T2', 'int'); 2357 assertSuggestLocalTopLevelVar('T2', 'int');
2193 assertSuggestImportedClass('A'); 2358 assertSuggestImportedClass('A');
2194 assertSuggestImportedFunction('F1', null); 2359 assertSuggestImportedFunction('F1', null);
2195 // TODO (danrubel) getter is being suggested instead of top level var 2360 // TODO (danrubel) getter is being suggested instead of top level var
2196 //assertSuggestImportedTopLevelVar('T1', 'int'); 2361 //assertSuggestImportedTopLevelVar('T1', 'int');
2197 }); 2362 });
2198 } 2363 }
2199 2364
2200 test_ConditionalExpression_partial_thenExpression() { 2365 test_ConditionalExpression_partial_thenExpression() {
2201 // SimpleIdentifier ConditionalExpression ReturnStatement 2366 // SimpleIdentifier ConditionalExpression ReturnStatement
2202 addSource('/testA.dart', ''' 2367 addSource(
2368 '/testA.dart',
2369 '''
2203 int T1; 2370 int T1;
2204 F1() { } 2371 F1() { }
2205 class A {int x;}'''); 2372 class A {int x;}''');
2206 addTestSource(''' 2373 addTestSource('''
2207 import "/testA.dart"; 2374 import "/testA.dart";
2208 int T2; 2375 int T2;
2209 F2() { } 2376 F2() { }
2210 class B {int x;} 2377 class B {int x;}
2211 class C {foo(){var f; {var x;} return a ? T^}}'''); 2378 class C {foo(){var f; {var x;} return a ? T^}}''');
2212 computeFast(); 2379 computeFast();
2213 return computeFull((bool result) { 2380 return computeFull((bool result) {
2214 // top level results are partially filtered based on first char 2381 // top level results are partially filtered based on first char
2215 assertSuggestLocalTopLevelVar('T2', 'int'); 2382 assertSuggestLocalTopLevelVar('T2', 'int');
2216 // TODO (danrubel) getter is being suggested instead of top level var 2383 // TODO (danrubel) getter is being suggested instead of top level var
2217 //assertSuggestImportedTopLevelVar('T1', 'int'); 2384 //assertSuggestImportedTopLevelVar('T1', 'int');
2218 }); 2385 });
2219 } 2386 }
2220 2387
2221 test_ConditionalExpression_partial_thenExpression_empty() { 2388 test_ConditionalExpression_partial_thenExpression_empty() {
2222 // SimpleIdentifier ConditionalExpression ReturnStatement 2389 // SimpleIdentifier ConditionalExpression ReturnStatement
2223 addSource('/testA.dart', ''' 2390 addSource(
2391 '/testA.dart',
2392 '''
2224 int T1; 2393 int T1;
2225 F1() { } 2394 F1() { }
2226 class A {int x;}'''); 2395 class A {int x;}''');
2227 addTestSource(''' 2396 addTestSource('''
2228 import "/testA.dart"; 2397 import "/testA.dart";
2229 int T2; 2398 int T2;
2230 F2() { } 2399 F2() { }
2231 class B {int x;} 2400 class B {int x;}
2232 class C {foo(){var f; {var x;} return a ? ^}}'''); 2401 class C {foo(){var f; {var x;} return a ? ^}}''');
2233 computeFast(); 2402 computeFast();
2234 return computeFull((bool result) { 2403 return computeFull((bool result) {
2235 assertNotSuggested('x'); 2404 assertNotSuggested('x');
2236 assertSuggestLocalVariable('f', null); 2405 assertSuggestLocalVariable('f', null);
2237 assertSuggestLocalMethod('foo', 'C', null); 2406 assertSuggestLocalMethod('foo', 'C', null);
2238 assertSuggestLocalClass('C'); 2407 assertSuggestLocalClass('C');
2239 assertSuggestLocalFunction('F2', null); 2408 assertSuggestLocalFunction('F2', null);
2240 assertSuggestLocalTopLevelVar('T2', 'int'); 2409 assertSuggestLocalTopLevelVar('T2', 'int');
2241 assertSuggestImportedClass('A'); 2410 assertSuggestImportedClass('A');
2242 assertSuggestImportedFunction('F1', null); 2411 assertSuggestImportedFunction('F1', null);
2243 // TODO (danrubel) getter is being suggested instead of top level var 2412 // TODO (danrubel) getter is being suggested instead of top level var
2244 //assertSuggestImportedTopLevelVar('T1', 'int'); 2413 //assertSuggestImportedTopLevelVar('T1', 'int');
2245 }); 2414 });
2246 } 2415 }
2247 2416
2248 test_ConditionalExpression_thenExpression() { 2417 test_ConditionalExpression_thenExpression() {
2249 // SimpleIdentifier ConditionalExpression ReturnStatement 2418 // SimpleIdentifier ConditionalExpression ReturnStatement
2250 addSource('/testA.dart', ''' 2419 addSource(
2420 '/testA.dart',
2421 '''
2251 int T1; 2422 int T1;
2252 F1() { } 2423 F1() { }
2253 class A {int x;}'''); 2424 class A {int x;}''');
2254 addTestSource(''' 2425 addTestSource('''
2255 import "/testA.dart"; 2426 import "/testA.dart";
2256 int T2; 2427 int T2;
2257 F2() { } 2428 F2() { }
2258 class B {int x;} 2429 class B {int x;}
2259 class C {foo(){var f; {var x;} return a ? T^ : c}}'''); 2430 class C {foo(){var f; {var x;} return a ? T^ : c}}''');
2260 computeFast(); 2431 computeFast();
2261 return computeFull((bool result) { 2432 return computeFull((bool result) {
2262 // top level results are partially filtered based on first char 2433 // top level results are partially filtered based on first char
2263 assertSuggestLocalTopLevelVar('T2', 'int'); 2434 assertSuggestLocalTopLevelVar('T2', 'int');
2264 // TODO (danrubel) getter is being suggested instead of top level var 2435 // TODO (danrubel) getter is being suggested instead of top level var
2265 //assertSuggestImportedTopLevelVar('T1', 'int'); 2436 //assertSuggestImportedTopLevelVar('T1', 'int');
2266 }); 2437 });
2267 } 2438 }
2268 2439
2269 test_ConstructorName_importedClass() { 2440 test_ConstructorName_importedClass() {
2270 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 2441 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
2271 // InstanceCreationExpression 2442 // InstanceCreationExpression
2272 addSource('/testB.dart', ''' 2443 addSource(
2444 '/testB.dart',
2445 '''
2273 lib B; 2446 lib B;
2274 int T1; 2447 int T1;
2275 F1() { } 2448 F1() { }
2276 class X {X.c(); X._d(); z() {}}'''); 2449 class X {X.c(); X._d(); z() {}}''');
2277 addTestSource(''' 2450 addTestSource('''
2278 import "/testB.dart"; 2451 import "/testB.dart";
2279 var m; 2452 var m;
2280 main() {new X.^}'''); 2453 main() {new X.^}''');
2281 computeFast(); 2454 computeFast();
2282 return computeFull((bool result) { 2455 return computeFull((bool result) {
2283 expect(request.replacementOffset, completionOffset); 2456 expect(request.replacementOffset, completionOffset);
2284 expect(request.replacementLength, 0); 2457 expect(request.replacementLength, 0);
2285 assertSuggestNamedConstructor('c', 'X'); 2458 assertSuggestNamedConstructor('c', 'X');
2286 assertNotSuggested('F1'); 2459 assertNotSuggested('F1');
2287 assertNotSuggested('T1'); 2460 assertNotSuggested('T1');
2288 assertNotSuggested('_d'); 2461 assertNotSuggested('_d');
2289 assertNotSuggested('z'); 2462 assertNotSuggested('z');
2290 assertNotSuggested('m'); 2463 assertNotSuggested('m');
2291 }); 2464 });
2292 } 2465 }
2293 2466
2294 test_ConstructorName_importedFactory() { 2467 test_ConstructorName_importedFactory() {
2295 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 2468 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
2296 // InstanceCreationExpression 2469 // InstanceCreationExpression
2297 addSource('/testB.dart', ''' 2470 addSource(
2471 '/testB.dart',
2472 '''
2298 lib B; 2473 lib B;
2299 int T1; 2474 int T1;
2300 F1() { } 2475 F1() { }
2301 class X {factory X.c(); factory X._d(); z() {}}'''); 2476 class X {factory X.c(); factory X._d(); z() {}}''');
2302 addTestSource(''' 2477 addTestSource('''
2303 import "/testB.dart"; 2478 import "/testB.dart";
2304 var m; 2479 var m;
2305 main() {new X.^}'''); 2480 main() {new X.^}''');
2306 computeFast(); 2481 computeFast();
2307 return computeFull((bool result) { 2482 return computeFull((bool result) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 assertSuggestLocalMethod('a', 'A', null); 2565 assertSuggestLocalMethod('a', 'A', null);
2391 assertSuggestLocalClass('A'); 2566 assertSuggestLocalClass('A');
2392 assertSuggestImportedClass('String'); 2567 assertSuggestImportedClass('String');
2393 assertSuggestImportedFunction('identical', 'bool'); 2568 assertSuggestImportedFunction('identical', 'bool');
2394 assertNotSuggested('bar'); 2569 assertNotSuggested('bar');
2395 }); 2570 });
2396 } 2571 }
2397 2572
2398 test_ExpressionStatement_identifier() { 2573 test_ExpressionStatement_identifier() {
2399 // SimpleIdentifier ExpressionStatement Block 2574 // SimpleIdentifier ExpressionStatement Block
2400 addSource('/testA.dart', ''' 2575 addSource(
2576 '/testA.dart',
2577 '''
2401 _B F1() { } 2578 _B F1() { }
2402 class A {int x;} 2579 class A {int x;}
2403 class _B { }'''); 2580 class _B { }''');
2404 addTestSource(''' 2581 addTestSource('''
2405 import "/testA.dart"; 2582 import "/testA.dart";
2406 typedef int F2(int blat); 2583 typedef int F2(int blat);
2407 class Clz = Object with Object; 2584 class Clz = Object with Object;
2408 class C {foo(){^} void bar() {}}'''); 2585 class C {foo(){^} void bar() {}}''');
2409 computeFast(); 2586 computeFast();
2410 return computeFull((bool result) { 2587 return computeFull((bool result) {
2411 expect(request.replacementOffset, completionOffset); 2588 expect(request.replacementOffset, completionOffset);
2412 expect(request.replacementLength, 0); 2589 expect(request.replacementLength, 0);
2413 assertSuggestImportedClass('A'); 2590 assertSuggestImportedClass('A');
2414 assertSuggestImportedFunction('F1', '_B'); 2591 assertSuggestImportedFunction('F1', '_B');
2415 assertSuggestLocalClass('C'); 2592 assertSuggestLocalClass('C');
2416 assertSuggestLocalMethod('foo', 'C', null); 2593 assertSuggestLocalMethod('foo', 'C', null);
2417 assertSuggestLocalMethod('bar', 'C', 'void'); 2594 assertSuggestLocalMethod('bar', 'C', 'void');
2418 assertSuggestLocalFunctionTypeAlias('F2', 'int'); 2595 assertSuggestLocalFunctionTypeAlias('F2', 'int');
2419 assertSuggestLocalClassTypeAlias('Clz'); 2596 assertSuggestLocalClassTypeAlias('Clz');
2420 assertSuggestLocalClass('C'); 2597 assertSuggestLocalClass('C');
2421 assertNotSuggested('x'); 2598 assertNotSuggested('x');
2422 assertNotSuggested('_B'); 2599 assertNotSuggested('_B');
2423 }); 2600 });
2424 } 2601 }
2425 2602
2426 test_ExpressionStatement_name() { 2603 test_ExpressionStatement_name() {
2427 // ExpressionStatement Block BlockFunctionBody MethodDeclaration 2604 // ExpressionStatement Block BlockFunctionBody MethodDeclaration
2428 addSource('/testA.dart', ''' 2605 addSource(
2606 '/testA.dart',
2607 '''
2429 B T1; 2608 B T1;
2430 class B{}'''); 2609 class B{}''');
2431 addTestSource(''' 2610 addTestSource('''
2432 import "/testA.dart"; 2611 import "/testA.dart";
2433 class C {a() {C ^}}'''); 2612 class C {a() {C ^}}''');
2434 computeFast(); 2613 computeFast();
2435 return computeFull((bool result) { 2614 return computeFull((bool result) {
2436 assertNoSuggestions(); 2615 assertNoSuggestions();
2437 }); 2616 });
2438 } 2617 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 expect(request.replacementOffset, completionOffset - 1); 2804 expect(request.replacementOffset, completionOffset - 1);
2626 expect(request.replacementLength, 1); 2805 expect(request.replacementLength, 1);
2627 assertSuggestLocalVariable('index', 'int'); 2806 assertSuggestLocalVariable('index', 'int');
2628 assertSuggestLocalFunction('main', null); 2807 assertSuggestLocalFunction('main', null);
2629 assertNotSuggested('bar'); 2808 assertNotSuggested('bar');
2630 }); 2809 });
2631 } 2810 }
2632 2811
2633 test_FunctionDeclaration_returnType_afterComment() { 2812 test_FunctionDeclaration_returnType_afterComment() {
2634 // ClassDeclaration CompilationUnit 2813 // ClassDeclaration CompilationUnit
2635 addSource('/testA.dart', ''' 2814 addSource(
2815 '/testA.dart',
2816 '''
2636 int T1; 2817 int T1;
2637 F1() { } 2818 F1() { }
2638 typedef D1(); 2819 typedef D1();
2639 class C1 {C1(this.x) { } int x;}'''); 2820 class C1 {C1(this.x) { } int x;}''');
2640 addTestSource(''' 2821 addTestSource('''
2641 import "/testA.dart"; 2822 import "/testA.dart";
2642 int T2; 2823 int T2;
2643 F2() { } 2824 F2() { }
2644 typedef D2(); 2825 typedef D2();
2645 class C2 { } 2826 class C2 { }
(...skipping 10 matching lines...) Expand all
2656 assertNotSuggested('T2'); 2837 assertNotSuggested('T2');
2657 assertNotSuggested('F2'); 2838 assertNotSuggested('F2');
2658 assertSuggestLocalFunctionTypeAlias('D2', null); 2839 assertSuggestLocalFunctionTypeAlias('D2', null);
2659 assertSuggestLocalClass('C2'); 2840 assertSuggestLocalClass('C2');
2660 assertNotSuggested('name'); 2841 assertNotSuggested('name');
2661 }); 2842 });
2662 } 2843 }
2663 2844
2664 test_FunctionDeclaration_returnType_afterComment2() { 2845 test_FunctionDeclaration_returnType_afterComment2() {
2665 // FunctionDeclaration ClassDeclaration CompilationUnit 2846 // FunctionDeclaration ClassDeclaration CompilationUnit
2666 addSource('/testA.dart', ''' 2847 addSource(
2848 '/testA.dart',
2849 '''
2667 int T1; 2850 int T1;
2668 F1() { } 2851 F1() { }
2669 typedef D1(); 2852 typedef D1();
2670 class C1 {C1(this.x) { } int x;}'''); 2853 class C1 {C1(this.x) { } int x;}''');
2671 addTestSource(''' 2854 addTestSource('''
2672 import "/testA.dart"; 2855 import "/testA.dart";
2673 int T2; 2856 int T2;
2674 F2() { } 2857 F2() { }
2675 typedef D2(); 2858 typedef D2();
2676 class C2 { } 2859 class C2 { }
(...skipping 10 matching lines...) Expand all
2687 assertNotSuggested('T2'); 2870 assertNotSuggested('T2');
2688 assertNotSuggested('F2'); 2871 assertNotSuggested('F2');
2689 assertSuggestLocalFunctionTypeAlias('D2', null); 2872 assertSuggestLocalFunctionTypeAlias('D2', null);
2690 assertSuggestLocalClass('C2'); 2873 assertSuggestLocalClass('C2');
2691 assertNotSuggested('name'); 2874 assertNotSuggested('name');
2692 }); 2875 });
2693 } 2876 }
2694 2877
2695 test_FunctionDeclaration_returnType_afterComment3() { 2878 test_FunctionDeclaration_returnType_afterComment3() {
2696 // FunctionDeclaration ClassDeclaration CompilationUnit 2879 // FunctionDeclaration ClassDeclaration CompilationUnit
2697 addSource('/testA.dart', ''' 2880 addSource(
2881 '/testA.dart',
2882 '''
2698 int T1; 2883 int T1;
2699 F1() { } 2884 F1() { }
2700 typedef D1(); 2885 typedef D1();
2701 class C1 {C1(this.x) { } int x;}'''); 2886 class C1 {C1(this.x) { } int x;}''');
2702 addTestSource(''' 2887 addTestSource('''
2703 import "/testA.dart"; 2888 import "/testA.dart";
2704 int T2; 2889 int T2;
2705 F2() { } 2890 F2() { }
2706 typedef D2(); 2891 typedef D2();
2707 /// some dartdoc 2892 /// some dartdoc
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 import "dart^"; 2998 import "dart^";
2814 main() {}'''); 2999 main() {}''');
2815 computeFast(); 3000 computeFast();
2816 return computeFull((bool result) { 3001 return computeFull((bool result) {
2817 assertNoSuggestions(); 3002 assertNoSuggestions();
2818 }); 3003 });
2819 } 3004 }
2820 3005
2821 test_IndexExpression() { 3006 test_IndexExpression() {
2822 // ExpressionStatement Block 3007 // ExpressionStatement Block
2823 addSource('/testA.dart', ''' 3008 addSource(
3009 '/testA.dart',
3010 '''
2824 int T1; 3011 int T1;
2825 F1() { } 3012 F1() { }
2826 class A {int x;}'''); 3013 class A {int x;}''');
2827 addTestSource(''' 3014 addTestSource('''
2828 import "/testA.dart"; 3015 import "/testA.dart";
2829 int T2; 3016 int T2;
2830 F2() { } 3017 F2() { }
2831 class B {int x;} 3018 class B {int x;}
2832 class C {foo(){var f; {var x;} f[^]}}'''); 3019 class C {foo(){var f; {var x;} f[^]}}''');
2833 computeFast(); 3020 computeFast();
2834 return computeFull((bool result) { 3021 return computeFull((bool result) {
2835 assertNotSuggested('x'); 3022 assertNotSuggested('x');
2836 assertSuggestLocalVariable('f', null); 3023 assertSuggestLocalVariable('f', null);
2837 assertSuggestLocalMethod('foo', 'C', null); 3024 assertSuggestLocalMethod('foo', 'C', null);
2838 assertSuggestLocalClass('C'); 3025 assertSuggestLocalClass('C');
2839 assertSuggestLocalFunction('F2', null); 3026 assertSuggestLocalFunction('F2', null);
2840 assertSuggestLocalTopLevelVar('T2', 'int'); 3027 assertSuggestLocalTopLevelVar('T2', 'int');
2841 assertSuggestImportedClass('A'); 3028 assertSuggestImportedClass('A');
2842 assertSuggestImportedFunction('F1', null); 3029 assertSuggestImportedFunction('F1', null);
2843 // TODO (danrubel) getter is being suggested instead of top level var 3030 // TODO (danrubel) getter is being suggested instead of top level var
2844 //assertSuggestImportedTopLevelVar('T1', 'int'); 3031 //assertSuggestImportedTopLevelVar('T1', 'int');
2845 }); 3032 });
2846 } 3033 }
2847 3034
2848 test_IndexExpression2() { 3035 test_IndexExpression2() {
2849 // SimpleIdentifier IndexExpression ExpressionStatement Block 3036 // SimpleIdentifier IndexExpression ExpressionStatement Block
2850 addSource('/testA.dart', ''' 3037 addSource(
3038 '/testA.dart',
3039 '''
2851 int T1; 3040 int T1;
2852 F1() { } 3041 F1() { }
2853 class A {int x;}'''); 3042 class A {int x;}''');
2854 addTestSource(''' 3043 addTestSource('''
2855 import "/testA.dart"; 3044 import "/testA.dart";
2856 int T2; 3045 int T2;
2857 F2() { } 3046 F2() { }
2858 class B {int x;} 3047 class B {int x;}
2859 class C {foo(){var f; {var x;} f[T^]}}'''); 3048 class C {foo(){var f; {var x;} f[T^]}}''');
2860 computeFast(); 3049 computeFast();
2861 return computeFull((bool result) { 3050 return computeFull((bool result) {
2862 // top level results are partially filtered based on first char 3051 // top level results are partially filtered based on first char
2863 assertSuggestLocalTopLevelVar('T2', 'int'); 3052 assertSuggestLocalTopLevelVar('T2', 'int');
2864 // TODO (danrubel) getter is being suggested instead of top level var 3053 // TODO (danrubel) getter is being suggested instead of top level var
2865 //assertSuggestImportedTopLevelVar('T1', 'int'); 3054 //assertSuggestImportedTopLevelVar('T1', 'int');
2866 }); 3055 });
2867 } 3056 }
2868 3057
2869 test_InstanceCreationExpression_imported() { 3058 test_InstanceCreationExpression_imported() {
2870 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression 3059 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
2871 addSource('/testA.dart', ''' 3060 addSource(
3061 '/testA.dart',
3062 '''
2872 int T1; 3063 int T1;
2873 F1() { } 3064 F1() { }
2874 class A {A(this.x) { } int x;}'''); 3065 class A {A(this.x) { } int x;}''');
2875 addTestSource(''' 3066 addTestSource('''
2876 import "/testA.dart"; 3067 import "/testA.dart";
2877 import "dart:async"; 3068 import "dart:async";
2878 int T2; 3069 int T2;
2879 F2() { } 3070 F2() { }
2880 class B {B(this.x, [String boo]) { } int x;} 3071 class B {B(this.x, [String boo]) { } int x;}
2881 class C {foo(){var f; {var x;} new ^}}'''); 3072 class C {foo(){var f; {var x;} new ^}}''');
(...skipping 26 matching lines...) Expand all
2908 expect(request.replacementLength, 1); 3099 expect(request.replacementLength, 1);
2909 assertSuggestImportedConstructor('Future', 3100 assertSuggestImportedConstructor('Future',
2910 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async'); 3101 relevance: DART_RELEVANCE_LOW, importUri: 'dart:async');
2911 assertSuggestImportedConstructor('Foo', 3102 assertSuggestImportedConstructor('Foo',
2912 relevance: DART_RELEVANCE_LOW, importUri: 'testAB.dart'); 3103 relevance: DART_RELEVANCE_LOW, importUri: 'testAB.dart');
2913 }); 3104 });
2914 } 3105 }
2915 3106
2916 test_InterpolationExpression() { 3107 test_InterpolationExpression() {
2917 // SimpleIdentifier InterpolationExpression StringInterpolation 3108 // SimpleIdentifier InterpolationExpression StringInterpolation
2918 addSource('/testA.dart', ''' 3109 addSource(
3110 '/testA.dart',
3111 '''
2919 int T1; 3112 int T1;
2920 F1() { } 3113 F1() { }
2921 typedef D1(); 3114 typedef D1();
2922 class C1 {C1(this.x) { } int x;}'''); 3115 class C1 {C1(this.x) { } int x;}''');
2923 addTestSource(''' 3116 addTestSource('''
2924 import "/testA.dart"; 3117 import "/testA.dart";
2925 int T2; 3118 int T2;
2926 F2() { } 3119 F2() { }
2927 typedef D2(); 3120 typedef D2();
2928 class C2 { } 3121 class C2 { }
(...skipping 14 matching lines...) Expand all
2943 assertSuggestLocalTopLevelVar('T2', 'int'); 3136 assertSuggestLocalTopLevelVar('T2', 'int');
2944 assertSuggestLocalFunction('F2', null); 3137 assertSuggestLocalFunction('F2', null);
2945 assertNotSuggested('D2'); 3138 assertNotSuggested('D2');
2946 assertNotSuggested('C2'); 3139 assertNotSuggested('C2');
2947 assertSuggestLocalVariable('name', 'String'); 3140 assertSuggestLocalVariable('name', 'String');
2948 }); 3141 });
2949 } 3142 }
2950 3143
2951 test_InterpolationExpression_block() { 3144 test_InterpolationExpression_block() {
2952 // SimpleIdentifier InterpolationExpression StringInterpolation 3145 // SimpleIdentifier InterpolationExpression StringInterpolation
2953 addSource('/testA.dart', ''' 3146 addSource(
3147 '/testA.dart',
3148 '''
2954 int T1; 3149 int T1;
2955 F1() { } 3150 F1() { }
2956 typedef D1(); 3151 typedef D1();
2957 class C1 {C1(this.x) { } int x;}'''); 3152 class C1 {C1(this.x) { } int x;}''');
2958 addTestSource(''' 3153 addTestSource('''
2959 import "/testA.dart"; 3154 import "/testA.dart";
2960 int T2; 3155 int T2;
2961 F2() { } 3156 F2() { }
2962 typedef D2(); 3157 typedef D2();
2963 class C2 { } 3158 class C2 { }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 return computeFull((bool result) { 3219 return computeFull((bool result) {
3025 assertSuggestLocalVariable('name', 'String'); 3220 assertSuggestLocalVariable('name', 'String');
3026 // top level results are partially filtered 3221 // top level results are partially filtered
3027 //assertSuggestImportedClass('Object'); 3222 //assertSuggestImportedClass('Object');
3028 assertNotSuggested('length'); 3223 assertNotSuggested('length');
3029 }); 3224 });
3030 } 3225 }
3031 3226
3032 test_IsExpression() { 3227 test_IsExpression() {
3033 // SimpleIdentifier TypeName IsExpression IfStatement 3228 // SimpleIdentifier TypeName IsExpression IfStatement
3034 addSource('/testB.dart', ''' 3229 addSource(
3230 '/testB.dart',
3231 '''
3035 lib B; 3232 lib B;
3036 foo() { } 3233 foo() { }
3037 class X {X.c(); X._d(); z() {}}'''); 3234 class X {X.c(); X._d(); z() {}}''');
3038 addTestSource(''' 3235 addTestSource('''
3039 import "/testB.dart"; 3236 import "/testB.dart";
3040 class Y {Y.c(); Y._d(); z() {}} 3237 class Y {Y.c(); Y._d(); z() {}}
3041 main() {var x; if (x is ^) { }}'''); 3238 main() {var x; if (x is ^) { }}''');
3042 computeFast(); 3239 computeFast();
3043 return computeFull((bool result) { 3240 return computeFull((bool result) {
3044 expect(request.replacementOffset, completionOffset); 3241 expect(request.replacementOffset, completionOffset);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 expect(request.replacementOffset, completionOffset - 3); 3294 expect(request.replacementOffset, completionOffset - 3);
3098 expect(request.replacementLength, 3); 3295 expect(request.replacementLength, 3);
3099 assertNotSuggested('a'); 3296 assertNotSuggested('a');
3100 assertNotSuggested('main'); 3297 assertNotSuggested('main');
3101 assertSuggestLocalClass('A'); 3298 assertSuggestLocalClass('A');
3102 assertSuggestImportedClass('Object'); 3299 assertSuggestImportedClass('Object');
3103 }); 3300 });
3104 } 3301 }
3105 3302
3106 test_keyword() { 3303 test_keyword() {
3107 addSource('/testB.dart', ''' 3304 addSource(
3305 '/testB.dart',
3306 '''
3108 lib B; 3307 lib B;
3109 int newT1; 3308 int newT1;
3110 int T1; 3309 int T1;
3111 nowIsIt() { } 3310 nowIsIt() { }
3112 class X {factory X.c(); factory X._d(); z() {}}'''); 3311 class X {factory X.c(); factory X._d(); z() {}}''');
3113 addTestSource(''' 3312 addTestSource('''
3114 import "/testB.dart"; 3313 import "/testB.dart";
3115 String newer() {} 3314 String newer() {}
3116 var m; 3315 var m;
3117 main() {new^ X.c();}'''); 3316 main() {new^ X.c();}''');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 // SimpleStringLiteral ExpressionStatement Block 3357 // SimpleStringLiteral ExpressionStatement Block
3159 addTestSource('class A {a() {"hel^lo"}}'); 3358 addTestSource('class A {a() {"hel^lo"}}');
3160 computeFast(); 3359 computeFast();
3161 return computeFull((bool result) { 3360 return computeFull((bool result) {
3162 assertNoSuggestions(); 3361 assertNoSuggestions();
3163 }); 3362 });
3164 } 3363 }
3165 3364
3166 test_MapLiteralEntry() { 3365 test_MapLiteralEntry() {
3167 // MapLiteralEntry MapLiteral VariableDeclaration 3366 // MapLiteralEntry MapLiteral VariableDeclaration
3168 addSource('/testA.dart', ''' 3367 addSource(
3368 '/testA.dart',
3369 '''
3169 int T1; 3370 int T1;
3170 F1() { } 3371 F1() { }
3171 typedef D1(); 3372 typedef D1();
3172 class C1 {C1(this.x) { } int x;}'''); 3373 class C1 {C1(this.x) { } int x;}''');
3173 addTestSource(''' 3374 addTestSource('''
3174 import "/testA.dart"; 3375 import "/testA.dart";
3175 int T2; 3376 int T2;
3176 F2() { } 3377 F2() { }
3177 typedef D2(); 3378 typedef D2();
3178 class C2 { } 3379 class C2 { }
(...skipping 13 matching lines...) Expand all
3192 assertSuggestImportedClass('C1'); 3393 assertSuggestImportedClass('C1');
3193 assertSuggestLocalTopLevelVar('T2', 'int'); 3394 assertSuggestLocalTopLevelVar('T2', 'int');
3194 assertSuggestLocalFunction('F2', null); 3395 assertSuggestLocalFunction('F2', null);
3195 assertSuggestLocalFunctionTypeAlias('D2', null); 3396 assertSuggestLocalFunctionTypeAlias('D2', null);
3196 assertSuggestLocalClass('C2'); 3397 assertSuggestLocalClass('C2');
3197 }); 3398 });
3198 } 3399 }
3199 3400
3200 test_MapLiteralEntry1() { 3401 test_MapLiteralEntry1() {
3201 // MapLiteralEntry MapLiteral VariableDeclaration 3402 // MapLiteralEntry MapLiteral VariableDeclaration
3202 addSource('/testA.dart', ''' 3403 addSource(
3404 '/testA.dart',
3405 '''
3203 int T1; 3406 int T1;
3204 F1() { } 3407 F1() { }
3205 typedef D1(); 3408 typedef D1();
3206 class C1 {C1(this.x) { } int x;}'''); 3409 class C1 {C1(this.x) { } int x;}''');
3207 addTestSource(''' 3410 addTestSource('''
3208 import "/testA.dart"; 3411 import "/testA.dart";
3209 int T2; 3412 int T2;
3210 F2() { } 3413 F2() { }
3211 typedef D2(); 3414 typedef D2();
3212 class C2 { } 3415 class C2 { }
3213 foo = {T^'''); 3416 foo = {T^''');
3214 computeFast(); 3417 computeFast();
3215 return computeFull((bool result) { 3418 return computeFull((bool result) {
3216 expect(request.replacementOffset, completionOffset - 1); 3419 expect(request.replacementOffset, completionOffset - 1);
3217 expect(request.replacementLength, 1); 3420 expect(request.replacementLength, 1);
3218 // TODO(danrubel) Should be top level variable 3421 // TODO(danrubel) Should be top level variable
3219 if (contributor is ImportedReferenceContributor) { 3422 if (contributor is ImportedReferenceContributor) {
3220 assertSuggestGetter('T1', 'int'); 3423 assertSuggestGetter('T1', 'int');
3221 // assertSuggestImportedTopLevelVar('T1', 'int'); 3424 // assertSuggestImportedTopLevelVar('T1', 'int');
3222 } 3425 }
3223 assertSuggestLocalTopLevelVar('T2', 'int'); 3426 assertSuggestLocalTopLevelVar('T2', 'int');
3224 }); 3427 });
3225 } 3428 }
3226 3429
3227 test_MapLiteralEntry2() { 3430 test_MapLiteralEntry2() {
3228 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration 3431 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration
3229 addSource('/testA.dart', ''' 3432 addSource(
3433 '/testA.dart',
3434 '''
3230 int T1; 3435 int T1;
3231 F1() { } 3436 F1() { }
3232 typedef D1(); 3437 typedef D1();
3233 class C1 {C1(this.x) { } int x;}'''); 3438 class C1 {C1(this.x) { } int x;}''');
3234 addTestSource(''' 3439 addTestSource('''
3235 import "/testA.dart"; 3440 import "/testA.dart";
3236 int T2; 3441 int T2;
3237 F2() { } 3442 F2() { }
3238 typedef D2(); 3443 typedef D2();
3239 class C2 { } 3444 class C2 { }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 assertSuggestLocalFunction('bar', 'void'); 3546 assertSuggestLocalFunction('bar', 'void');
3342 assertSuggestLocalMethod('a', 'A', 'Z'); 3547 assertSuggestLocalMethod('a', 'A', 'Z');
3343 assertSuggestParameter('x', 'X'); 3548 assertSuggestParameter('x', 'X');
3344 assertSuggestParameter('y', 'int'); 3549 assertSuggestParameter('y', 'int');
3345 assertSuggestImportedClass('String'); 3550 assertSuggestImportedClass('String');
3346 }); 3551 });
3347 } 3552 }
3348 3553
3349 test_MethodDeclaration_returnType() { 3554 test_MethodDeclaration_returnType() {
3350 // ClassDeclaration CompilationUnit 3555 // ClassDeclaration CompilationUnit
3351 addSource('/testA.dart', ''' 3556 addSource(
3557 '/testA.dart',
3558 '''
3352 int T1; 3559 int T1;
3353 F1() { } 3560 F1() { }
3354 typedef D1(); 3561 typedef D1();
3355 class C1 {C1(this.x) { } int x;}'''); 3562 class C1 {C1(this.x) { } int x;}''');
3356 addTestSource(''' 3563 addTestSource('''
3357 import "/testA.dart"; 3564 import "/testA.dart";
3358 int T2; 3565 int T2;
3359 F2() { } 3566 F2() { }
3360 typedef D2(); 3567 typedef D2();
3361 class C2 {^ zoo(z) { } String name; }'''); 3568 class C2 {^ zoo(z) { } String name; }''');
3362 computeFast(); 3569 computeFast();
3363 return computeFull((bool result) { 3570 return computeFull((bool result) {
3364 expect(request.replacementOffset, completionOffset); 3571 expect(request.replacementOffset, completionOffset);
3365 expect(request.replacementLength, 0); 3572 expect(request.replacementLength, 0);
3366 assertSuggestImportedClass('Object'); 3573 assertSuggestImportedClass('Object');
3367 assertNotSuggested('T1'); 3574 assertNotSuggested('T1');
3368 assertNotSuggested('F1'); 3575 assertNotSuggested('F1');
3369 assertSuggestImportedFunctionTypeAlias('D1', null); 3576 assertSuggestImportedFunctionTypeAlias('D1', null);
3370 assertSuggestImportedClass('C1'); 3577 assertSuggestImportedClass('C1');
3371 assertNotSuggested('T2'); 3578 assertNotSuggested('T2');
3372 assertNotSuggested('F2'); 3579 assertNotSuggested('F2');
3373 assertSuggestLocalFunctionTypeAlias('D2', null); 3580 assertSuggestLocalFunctionTypeAlias('D2', null);
3374 assertSuggestLocalClass('C2'); 3581 assertSuggestLocalClass('C2');
3375 assertNotSuggested('name'); 3582 assertNotSuggested('name');
3376 }); 3583 });
3377 } 3584 }
3378 3585
3379 test_MethodDeclaration_returnType_afterComment() { 3586 test_MethodDeclaration_returnType_afterComment() {
3380 // ClassDeclaration CompilationUnit 3587 // ClassDeclaration CompilationUnit
3381 addSource('/testA.dart', ''' 3588 addSource(
3589 '/testA.dart',
3590 '''
3382 int T1; 3591 int T1;
3383 F1() { } 3592 F1() { }
3384 typedef D1(); 3593 typedef D1();
3385 class C1 {C1(this.x) { } int x;}'''); 3594 class C1 {C1(this.x) { } int x;}''');
3386 addTestSource(''' 3595 addTestSource('''
3387 import "/testA.dart"; 3596 import "/testA.dart";
3388 int T2; 3597 int T2;
3389 F2() { } 3598 F2() { }
3390 typedef D2(); 3599 typedef D2();
3391 class C2 {/* */ ^ zoo(z) { } String name; }'''); 3600 class C2 {/* */ ^ zoo(z) { } String name; }''');
3392 computeFast(); 3601 computeFast();
3393 return computeFull((bool result) { 3602 return computeFull((bool result) {
3394 expect(request.replacementOffset, completionOffset); 3603 expect(request.replacementOffset, completionOffset);
3395 expect(request.replacementLength, 0); 3604 expect(request.replacementLength, 0);
3396 assertSuggestImportedClass('Object'); 3605 assertSuggestImportedClass('Object');
3397 assertNotSuggested('T1'); 3606 assertNotSuggested('T1');
3398 assertNotSuggested('F1'); 3607 assertNotSuggested('F1');
3399 assertSuggestImportedFunctionTypeAlias('D1', null); 3608 assertSuggestImportedFunctionTypeAlias('D1', null);
3400 assertSuggestImportedClass('C1'); 3609 assertSuggestImportedClass('C1');
3401 assertNotSuggested('T2'); 3610 assertNotSuggested('T2');
3402 assertNotSuggested('F2'); 3611 assertNotSuggested('F2');
3403 assertSuggestLocalFunctionTypeAlias('D2', null); 3612 assertSuggestLocalFunctionTypeAlias('D2', null);
3404 assertSuggestLocalClass('C2'); 3613 assertSuggestLocalClass('C2');
3405 assertNotSuggested('name'); 3614 assertNotSuggested('name');
3406 }); 3615 });
3407 } 3616 }
3408 3617
3409 test_MethodDeclaration_returnType_afterComment2() { 3618 test_MethodDeclaration_returnType_afterComment2() {
3410 // MethodDeclaration ClassDeclaration CompilationUnit 3619 // MethodDeclaration ClassDeclaration CompilationUnit
3411 addSource('/testA.dart', ''' 3620 addSource(
3621 '/testA.dart',
3622 '''
3412 int T1; 3623 int T1;
3413 F1() { } 3624 F1() { }
3414 typedef D1(); 3625 typedef D1();
3415 class C1 {C1(this.x) { } int x;}'''); 3626 class C1 {C1(this.x) { } int x;}''');
3416 addTestSource(''' 3627 addTestSource('''
3417 import "/testA.dart"; 3628 import "/testA.dart";
3418 int T2; 3629 int T2;
3419 F2() { } 3630 F2() { }
3420 typedef D2(); 3631 typedef D2();
3421 class C2 {/** */ ^ zoo(z) { } String name; }'''); 3632 class C2 {/** */ ^ zoo(z) { } String name; }''');
3422 computeFast(); 3633 computeFast();
3423 return computeFull((bool result) { 3634 return computeFull((bool result) {
3424 expect(request.replacementOffset, completionOffset); 3635 expect(request.replacementOffset, completionOffset);
3425 expect(request.replacementLength, 0); 3636 expect(request.replacementLength, 0);
3426 assertSuggestImportedClass('Object'); 3637 assertSuggestImportedClass('Object');
3427 assertNotSuggested('T1'); 3638 assertNotSuggested('T1');
3428 assertNotSuggested('F1'); 3639 assertNotSuggested('F1');
3429 assertSuggestImportedFunctionTypeAlias('D1', null); 3640 assertSuggestImportedFunctionTypeAlias('D1', null);
3430 assertSuggestImportedClass('C1'); 3641 assertSuggestImportedClass('C1');
3431 assertNotSuggested('T2'); 3642 assertNotSuggested('T2');
3432 assertNotSuggested('F2'); 3643 assertNotSuggested('F2');
3433 assertSuggestLocalFunctionTypeAlias('D2', null); 3644 assertSuggestLocalFunctionTypeAlias('D2', null);
3434 assertSuggestLocalClass('C2'); 3645 assertSuggestLocalClass('C2');
3435 assertNotSuggested('name'); 3646 assertNotSuggested('name');
3436 }); 3647 });
3437 } 3648 }
3438 3649
3439 test_MethodDeclaration_returnType_afterComment3() { 3650 test_MethodDeclaration_returnType_afterComment3() {
3440 // MethodDeclaration ClassDeclaration CompilationUnit 3651 // MethodDeclaration ClassDeclaration CompilationUnit
3441 addSource('/testA.dart', ''' 3652 addSource(
3653 '/testA.dart',
3654 '''
3442 int T1; 3655 int T1;
3443 F1() { } 3656 F1() { }
3444 typedef D1(); 3657 typedef D1();
3445 class C1 {C1(this.x) { } int x;}'''); 3658 class C1 {C1(this.x) { } int x;}''');
3446 addTestSource(''' 3659 addTestSource('''
3447 import "/testA.dart"; 3660 import "/testA.dart";
3448 int T2; 3661 int T2;
3449 F2() { } 3662 F2() { }
3450 typedef D2(); 3663 typedef D2();
3451 class C2 { 3664 class C2 {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 assertSuggestInvocationMethod('nextDouble', 'Random', 'double'); 3723 assertSuggestInvocationMethod('nextDouble', 'Random', 'double');
3511 assertSuggestInvocationMethod('nextInt', 'Random', 'int'); 3724 assertSuggestInvocationMethod('nextInt', 'Random', 'int');
3512 assertNotSuggested('Random'); 3725 assertNotSuggested('Random');
3513 assertNotSuggested('Object'); 3726 assertNotSuggested('Object');
3514 assertNotSuggested('A'); 3727 assertNotSuggested('A');
3515 }); 3728 });
3516 } 3729 }
3517 3730
3518 test_partFile_TypeName() { 3731 test_partFile_TypeName() {
3519 // SimpleIdentifier TypeName ConstructorName 3732 // SimpleIdentifier TypeName ConstructorName
3520 addSource('/testB.dart', ''' 3733 addSource(
3734 '/testB.dart',
3735 '''
3521 lib B; 3736 lib B;
3522 int T1; 3737 int T1;
3523 F1() { } 3738 F1() { }
3524 class X {X.c(); X._d(); z() {}}'''); 3739 class X {X.c(); X._d(); z() {}}''');
3525 addSource('/testA.dart', ''' 3740 addSource(
3741 '/testA.dart',
3742 '''
3526 library libA; 3743 library libA;
3527 import "/testB.dart"; 3744 import "/testB.dart";
3528 part "$testFile"; 3745 part "$testFile";
3529 class A { } 3746 class A { }
3530 var m;'''); 3747 var m;''');
3531 addTestSource(''' 3748 addTestSource('''
3532 part of libA; 3749 part of libA;
3533 class B { factory B.bar(int x) => null; } 3750 class B { factory B.bar(int x) => null; }
3534 main() {new ^}'''); 3751 main() {new ^}''');
3535 computeFast(); 3752 computeFast();
3536 return computeFull((bool result) { 3753 return computeFull((bool result) {
3537 expect(request.replacementOffset, completionOffset); 3754 expect(request.replacementOffset, completionOffset);
3538 expect(request.replacementLength, 0); 3755 expect(request.replacementLength, 0);
3539 assertSuggestLocalConstructor('B.bar'); 3756 assertSuggestLocalConstructor('B.bar');
3540 assertSuggestImportedConstructor('Object'); 3757 assertSuggestImportedConstructor('Object');
3541 assertSuggestImportedConstructor('X.c'); 3758 assertSuggestImportedConstructor('X.c');
3542 assertNotSuggested('X._d'); 3759 assertNotSuggested('X._d');
3543 assertSuggestImportedConstructor('A'); 3760 assertSuggestImportedConstructor('A');
3544 assertNotSuggested('F1'); 3761 assertNotSuggested('F1');
3545 assertNotSuggested('T1'); 3762 assertNotSuggested('T1');
3546 assertNotSuggested('_d'); 3763 assertNotSuggested('_d');
3547 assertNotSuggested('z'); 3764 assertNotSuggested('z');
3548 assertNotSuggested('m'); 3765 assertNotSuggested('m');
3549 }); 3766 });
3550 } 3767 }
3551 3768
3552 test_partFile_TypeName2() { 3769 test_partFile_TypeName2() {
3553 // SimpleIdentifier TypeName ConstructorName 3770 // SimpleIdentifier TypeName ConstructorName
3554 addSource('/testB.dart', ''' 3771 addSource(
3772 '/testB.dart',
3773 '''
3555 lib B; 3774 lib B;
3556 int T1; 3775 int T1;
3557 F1() { } 3776 F1() { }
3558 class X {X.c(); X._d(); z() {}}'''); 3777 class X {X.c(); X._d(); z() {}}''');
3559 addSource('/testA.dart', ''' 3778 addSource(
3779 '/testA.dart',
3780 '''
3560 part of libA; 3781 part of libA;
3561 class B { }'''); 3782 class B { }''');
3562 addTestSource(''' 3783 addTestSource('''
3563 library libA; 3784 library libA;
3564 import "/testB.dart"; 3785 import "/testB.dart";
3565 part "/testA.dart"; 3786 part "/testA.dart";
3566 class A { A({String boo: 'hoo'}) { } } 3787 class A { A({String boo: 'hoo'}) { } }
3567 main() {new ^} 3788 main() {new ^}
3568 var m;'''); 3789 var m;''');
3569 computeFast(); 3790 computeFast();
3570 return computeFull((bool result) { 3791 return computeFull((bool result) {
3571 expect(request.replacementOffset, completionOffset); 3792 expect(request.replacementOffset, completionOffset);
3572 expect(request.replacementLength, 0); 3793 expect(request.replacementLength, 0);
3573 assertSuggestLocalConstructor('A'); 3794 assertSuggestLocalConstructor('A');
3574 assertSuggestImportedConstructor('Object'); 3795 assertSuggestImportedConstructor('Object');
3575 assertSuggestImportedConstructor('X.c'); 3796 assertSuggestImportedConstructor('X.c');
3576 assertNotSuggested('X._d'); 3797 assertNotSuggested('X._d');
3577 assertSuggestImportedConstructor('B'); 3798 assertSuggestImportedConstructor('B');
3578 assertNotSuggested('F1'); 3799 assertNotSuggested('F1');
3579 assertNotSuggested('T1'); 3800 assertNotSuggested('T1');
3580 assertNotSuggested('_d'); 3801 assertNotSuggested('_d');
3581 assertNotSuggested('z'); 3802 assertNotSuggested('z');
3582 assertNotSuggested('m'); 3803 assertNotSuggested('m');
3583 }); 3804 });
3584 } 3805 }
3585 3806
3586 test_PrefixedIdentifier_class_const() { 3807 test_PrefixedIdentifier_class_const() {
3587 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block 3808 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block
3588 addSource('/testB.dart', ''' 3809 addSource(
3810 '/testB.dart',
3811 '''
3589 lib B; 3812 lib B;
3590 class I { 3813 class I {
3591 static const scI = 'boo'; 3814 static const scI = 'boo';
3592 X get f => new A(); 3815 X get f => new A();
3593 get _g => new A();} 3816 get _g => new A();}
3594 class B implements I { 3817 class B implements I {
3595 static const int scB = 12; 3818 static const int scB = 12;
3596 var b; X _c; 3819 var b; X _c;
3597 X get d => new A();get _e => new A(); 3820 X get d => new A();get _e => new A();
3598 set s1(I x) {} set _s2(I x) {} 3821 set s1(I x) {} set _s2(I x) {}
(...skipping 26 matching lines...) Expand all
3625 assertNotSuggested('A'); 3848 assertNotSuggested('A');
3626 assertNotSuggested('X'); 3849 assertNotSuggested('X');
3627 assertNotSuggested('w'); 3850 assertNotSuggested('w');
3628 assertNotSuggested('Object'); 3851 assertNotSuggested('Object');
3629 assertNotSuggested('=='); 3852 assertNotSuggested('==');
3630 }); 3853 });
3631 } 3854 }
3632 3855
3633 test_PrefixedIdentifier_class_imported() { 3856 test_PrefixedIdentifier_class_imported() {
3634 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3857 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3635 addSource('/testB.dart', ''' 3858 addSource(
3859 '/testB.dart',
3860 '''
3636 lib B; 3861 lib B;
3637 class I {X get f => new A();get _g => new A();} 3862 class I {X get f => new A();get _g => new A();}
3638 class A implements I { 3863 class A implements I {
3639 static const int sc = 12; 3864 static const int sc = 12;
3640 @deprecated var b; X _c; 3865 @deprecated var b; X _c;
3641 X get d => new A();get _e => new A(); 3866 X get d => new A();get _e => new A();
3642 set s1(I x) {} set _s2(I x) {} 3867 set s1(I x) {} set _s2(I x) {}
3643 m(X x) {} I _n(X x) {}} 3868 m(X x) {} I _n(X x) {}}
3644 class X{}'''); 3869 class X{}''');
3645 addTestSource(''' 3870 addTestSource('''
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3707 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3932 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3708 addTestSource('String get g => "one"; f() {g.^}'); 3933 addTestSource('String get g => "one"; f() {g.^}');
3709 computeFast(); 3934 computeFast();
3710 return computeFull((bool result) { 3935 return computeFull((bool result) {
3711 assertSuggestInvocationGetter('length', 'int'); 3936 assertSuggestInvocationGetter('length', 'int');
3712 }); 3937 });
3713 } 3938 }
3714 3939
3715 test_PrefixedIdentifier_library() { 3940 test_PrefixedIdentifier_library() {
3716 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3941 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3717 addSource('/testB.dart', ''' 3942 addSource(
3943 '/testB.dart',
3944 '''
3718 lib B; 3945 lib B;
3719 var T1; 3946 var T1;
3720 class X { } 3947 class X { }
3721 class Y { }'''); 3948 class Y { }''');
3722 addTestSource(''' 3949 addTestSource('''
3723 import "/testB.dart" as b; 3950 import "/testB.dart" as b;
3724 var T2; 3951 var T2;
3725 class A { } 3952 class A { }
3726 main() {b.^}'''); 3953 main() {b.^}''');
3727 computeFast(); 3954 computeFast();
3728 return computeFull((bool result) { 3955 return computeFull((bool result) {
3729 expect(request.replacementOffset, completionOffset); 3956 expect(request.replacementOffset, completionOffset);
3730 expect(request.replacementLength, 0); 3957 expect(request.replacementLength, 0);
3731 assertSuggestInvocationClass('X'); 3958 assertSuggestInvocationClass('X');
3732 assertSuggestInvocationClass('Y'); 3959 assertSuggestInvocationClass('Y');
3733 assertSuggestInvocationTopLevelVar('T1', null); 3960 assertSuggestInvocationTopLevelVar('T1', null);
3734 assertNotSuggested('T2'); 3961 assertNotSuggested('T2');
3735 assertNotSuggested('Object'); 3962 assertNotSuggested('Object');
3736 assertNotSuggested('b'); 3963 assertNotSuggested('b');
3737 assertNotSuggested('A'); 3964 assertNotSuggested('A');
3738 assertNotSuggested('=='); 3965 assertNotSuggested('==');
3739 }); 3966 });
3740 } 3967 }
3741 3968
3742 test_PrefixedIdentifier_library_typesOnly() { 3969 test_PrefixedIdentifier_library_typesOnly() {
3743 // SimpleIdentifier PrefixedIdentifier TypeName 3970 // SimpleIdentifier PrefixedIdentifier TypeName
3744 addSource('/testB.dart', ''' 3971 addSource(
3972 '/testB.dart',
3973 '''
3745 lib B; 3974 lib B;
3746 var T1; 3975 var T1;
3747 class X { } 3976 class X { }
3748 class Y { }'''); 3977 class Y { }''');
3749 addTestSource(''' 3978 addTestSource('''
3750 import "/testB.dart" as b; 3979 import "/testB.dart" as b;
3751 var T2; 3980 var T2;
3752 class A { } 3981 class A { }
3753 foo(b.^ f) {}'''); 3982 foo(b.^ f) {}''');
3754 computeFast(); 3983 computeFast();
3755 return computeFull((bool result) { 3984 return computeFull((bool result) {
3756 expect(request.replacementOffset, completionOffset); 3985 expect(request.replacementOffset, completionOffset);
3757 expect(request.replacementLength, 0); 3986 expect(request.replacementLength, 0);
3758 assertSuggestInvocationClass('X'); 3987 assertSuggestInvocationClass('X');
3759 assertSuggestInvocationClass('Y'); 3988 assertSuggestInvocationClass('Y');
3760 assertNotSuggested('T1'); 3989 assertNotSuggested('T1');
3761 assertNotSuggested('T2'); 3990 assertNotSuggested('T2');
3762 assertNotSuggested('Object'); 3991 assertNotSuggested('Object');
3763 assertNotSuggested('b'); 3992 assertNotSuggested('b');
3764 assertNotSuggested('A'); 3993 assertNotSuggested('A');
3765 assertNotSuggested('=='); 3994 assertNotSuggested('==');
3766 }); 3995 });
3767 } 3996 }
3768 3997
3769 test_PrefixedIdentifier_library_typesOnly2() { 3998 test_PrefixedIdentifier_library_typesOnly2() {
3770 // SimpleIdentifier PrefixedIdentifier TypeName 3999 // SimpleIdentifier PrefixedIdentifier TypeName
3771 addSource('/testB.dart', ''' 4000 addSource(
4001 '/testB.dart',
4002 '''
3772 lib B; 4003 lib B;
3773 var T1; 4004 var T1;
3774 class X { } 4005 class X { }
3775 class Y { }'''); 4006 class Y { }''');
3776 addTestSource(''' 4007 addTestSource('''
3777 import "/testB.dart" as b; 4008 import "/testB.dart" as b;
3778 var T2; 4009 var T2;
3779 class A { } 4010 class A { }
3780 foo(b.^) {}'''); 4011 foo(b.^) {}''');
3781 computeFast(); 4012 computeFast();
3782 return computeFull((bool result) { 4013 return computeFull((bool result) {
3783 expect(request.replacementOffset, completionOffset); 4014 expect(request.replacementOffset, completionOffset);
3784 expect(request.replacementLength, 0); 4015 expect(request.replacementLength, 0);
3785 assertSuggestInvocationClass('X'); 4016 assertSuggestInvocationClass('X');
3786 assertSuggestInvocationClass('Y'); 4017 assertSuggestInvocationClass('Y');
3787 assertNotSuggested('T1'); 4018 assertNotSuggested('T1');
3788 assertNotSuggested('T2'); 4019 assertNotSuggested('T2');
3789 assertNotSuggested('Object'); 4020 assertNotSuggested('Object');
3790 assertNotSuggested('b'); 4021 assertNotSuggested('b');
3791 assertNotSuggested('A'); 4022 assertNotSuggested('A');
3792 assertNotSuggested('=='); 4023 assertNotSuggested('==');
3793 }); 4024 });
3794 } 4025 }
3795 4026
3796 test_PrefixedIdentifier_parameter() { 4027 test_PrefixedIdentifier_parameter() {
3797 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 4028 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3798 addSource('/testB.dart', ''' 4029 addSource(
4030 '/testB.dart',
4031 '''
3799 lib B; 4032 lib B;
3800 class _W {M y; var _z;} 4033 class _W {M y; var _z;}
3801 class X extends _W {} 4034 class X extends _W {}
3802 class M{}'''); 4035 class M{}''');
3803 addTestSource(''' 4036 addTestSource('''
3804 import "/testB.dart"; 4037 import "/testB.dart";
3805 foo(X x) {x.^}'''); 4038 foo(X x) {x.^}''');
3806 computeFast(); 4039 computeFast();
3807 return computeFull((bool result) { 4040 return computeFull((bool result) {
3808 expect(request.replacementOffset, completionOffset); 4041 expect(request.replacementOffset, completionOffset);
3809 expect(request.replacementLength, 0); 4042 expect(request.replacementLength, 0);
3810 assertSuggestInvocationField('y', 'M'); 4043 assertSuggestInvocationField('y', 'M');
3811 assertNotSuggested('_z'); 4044 assertNotSuggested('_z');
3812 assertNotSuggested('=='); 4045 assertNotSuggested('==');
3813 }); 4046 });
3814 } 4047 }
3815 4048
3816 test_PrefixedIdentifier_prefix() { 4049 test_PrefixedIdentifier_prefix() {
3817 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 4050 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3818 addSource('/testA.dart', ''' 4051 addSource(
4052 '/testA.dart',
4053 '''
3819 class A {static int bar = 10;} 4054 class A {static int bar = 10;}
3820 _B() {}'''); 4055 _B() {}''');
3821 addTestSource(''' 4056 addTestSource('''
3822 import "/testA.dart"; 4057 import "/testA.dart";
3823 class X {foo(){A^.bar}}'''); 4058 class X {foo(){A^.bar}}''');
3824 computeFast(); 4059 computeFast();
3825 return computeFull((bool result) { 4060 return computeFull((bool result) {
3826 expect(request.replacementOffset, completionOffset - 1); 4061 expect(request.replacementOffset, completionOffset - 1);
3827 expect(request.replacementLength, 1); 4062 expect(request.replacementLength, 1);
3828 assertSuggestImportedClass('A'); 4063 assertSuggestImportedClass('A');
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 // TopLevelVariableDeclaration 4514 // TopLevelVariableDeclaration
4280 addTestSource('class A {} var ^'); 4515 addTestSource('class A {} var ^');
4281 computeFast(); 4516 computeFast();
4282 return computeFull((bool result) { 4517 return computeFull((bool result) {
4283 assertNoSuggestions(); 4518 assertNoSuggestions();
4284 }); 4519 });
4285 } 4520 }
4286 4521
4287 test_TypeArgumentList() { 4522 test_TypeArgumentList() {
4288 // SimpleIdentifier BinaryExpression ExpressionStatement 4523 // SimpleIdentifier BinaryExpression ExpressionStatement
4289 addSource('/testA.dart', ''' 4524 addSource(
4525 '/testA.dart',
4526 '''
4290 class C1 {int x;} 4527 class C1 {int x;}
4291 F1() => 0; 4528 F1() => 0;
4292 typedef String T1(int blat);'''); 4529 typedef String T1(int blat);''');
4293 addTestSource(''' 4530 addTestSource('''
4294 import "/testA.dart";' 4531 import "/testA.dart";'
4295 class C2 {int x;} 4532 class C2 {int x;}
4296 F2() => 0; 4533 F2() => 0;
4297 typedef int T2(int blat); 4534 typedef int T2(int blat);
4298 class C<E> {} 4535 class C<E> {}
4299 main() { C<^> c; }'''); 4536 main() { C<^> c; }''');
4300 computeFast(); 4537 computeFast();
4301 return computeFull((bool result) { 4538 return computeFull((bool result) {
4302 expect(request.replacementOffset, completionOffset); 4539 expect(request.replacementOffset, completionOffset);
4303 expect(request.replacementLength, 0); 4540 expect(request.replacementLength, 0);
4304 assertSuggestImportedClass('Object'); 4541 assertSuggestImportedClass('Object');
4305 assertSuggestImportedClass('C1'); 4542 assertSuggestImportedClass('C1');
4306 assertSuggestImportedFunctionTypeAlias('T1', 'String'); 4543 assertSuggestImportedFunctionTypeAlias('T1', 'String');
4307 assertSuggestLocalClass('C2'); 4544 assertSuggestLocalClass('C2');
4308 assertSuggestLocalFunctionTypeAlias('T2', 'int'); 4545 assertSuggestLocalFunctionTypeAlias('T2', 'int');
4309 assertNotSuggested('F1'); 4546 assertNotSuggested('F1');
4310 assertNotSuggested('F2'); 4547 assertNotSuggested('F2');
4311 }); 4548 });
4312 } 4549 }
4313 4550
4314 test_TypeArgumentList2() { 4551 test_TypeArgumentList2() {
4315 // TypeName TypeArgumentList TypeName 4552 // TypeName TypeArgumentList TypeName
4316 addSource('/testA.dart', ''' 4553 addSource(
4554 '/testA.dart',
4555 '''
4317 class C1 {int x;} 4556 class C1 {int x;}
4318 F1() => 0; 4557 F1() => 0;
4319 typedef String T1(int blat);'''); 4558 typedef String T1(int blat);''');
4320 addTestSource(''' 4559 addTestSource('''
4321 import "/testA.dart";' 4560 import "/testA.dart";'
4322 class C2 {int x;} 4561 class C2 {int x;}
4323 F2() => 0; 4562 F2() => 0;
4324 typedef int T2(int blat); 4563 typedef int T2(int blat);
4325 class C<E> {} 4564 class C<E> {}
4326 main() { C<C^> c; }'''); 4565 main() { C<C^> c; }''');
4327 computeFast(); 4566 computeFast();
4328 return computeFull((bool result) { 4567 return computeFull((bool result) {
4329 expect(request.replacementOffset, completionOffset - 1); 4568 expect(request.replacementOffset, completionOffset - 1);
4330 expect(request.replacementLength, 1); 4569 expect(request.replacementLength, 1);
4331 assertSuggestImportedClass('C1'); 4570 assertSuggestImportedClass('C1');
4332 assertSuggestLocalClass('C2'); 4571 assertSuggestLocalClass('C2');
4333 }); 4572 });
4334 } 4573 }
4335 4574
4336 test_VariableDeclaration_name() { 4575 test_VariableDeclaration_name() {
4337 // SimpleIdentifier VariableDeclaration VariableDeclarationList 4576 // SimpleIdentifier VariableDeclaration VariableDeclarationList
4338 // VariableDeclarationStatement Block 4577 // VariableDeclarationStatement Block
4339 addSource('/testB.dart', ''' 4578 addSource(
4579 '/testB.dart',
4580 '''
4340 lib B; 4581 lib B;
4341 foo() { } 4582 foo() { }
4342 class _B { } 4583 class _B { }
4343 class X {X.c(); X._d(); z() {}}'''); 4584 class X {X.c(); X._d(); z() {}}''');
4344 addTestSource(''' 4585 addTestSource('''
4345 import "/testB.dart"; 4586 import "/testB.dart";
4346 class Y {Y.c(); Y._d(); z() {}} 4587 class Y {Y.c(); Y._d(); z() {}}
4347 main() {var ^}'''); 4588 main() {var ^}''');
4348 computeFast(); 4589 computeFast();
4349 return computeFull((bool result) { 4590 return computeFull((bool result) {
4350 assertNoSuggestions(); 4591 assertNoSuggestions();
4351 }); 4592 });
4352 } 4593 }
4353 4594
4354 test_VariableDeclarationList_final() { 4595 test_VariableDeclarationList_final() {
4355 // VariableDeclarationList VariableDeclarationStatement Block 4596 // VariableDeclarationList VariableDeclarationStatement Block
4356 addTestSource('main() {final ^} class C { }'); 4597 addTestSource('main() {final ^} class C { }');
4357 computeFast(); 4598 computeFast();
4358 return computeFull((bool result) { 4599 return computeFull((bool result) {
4359 assertSuggestImportedClass('Object'); 4600 assertSuggestImportedClass('Object');
4360 assertSuggestLocalClass('C'); 4601 assertSuggestLocalClass('C');
4361 assertNotSuggested('=='); 4602 assertNotSuggested('==');
4362 }); 4603 });
4363 } 4604 }
4364 4605
4365 test_VariableDeclarationStatement_RHS() { 4606 test_VariableDeclarationStatement_RHS() {
4366 // SimpleIdentifier VariableDeclaration VariableDeclarationList 4607 // SimpleIdentifier VariableDeclaration VariableDeclarationList
4367 // VariableDeclarationStatement 4608 // VariableDeclarationStatement
4368 addSource('/testB.dart', ''' 4609 addSource(
4610 '/testB.dart',
4611 '''
4369 lib B; 4612 lib B;
4370 foo() { } 4613 foo() { }
4371 class _B { } 4614 class _B { }
4372 class X {X.c(); X._d(); z() {}}'''); 4615 class X {X.c(); X._d(); z() {}}''');
4373 addTestSource(''' 4616 addTestSource('''
4374 import "/testB.dart"; 4617 import "/testB.dart";
4375 class Y {Y.c(); Y._d(); z() {}} 4618 class Y {Y.c(); Y._d(); z() {}}
4376 class C {bar(){var f; {var x;} var e = ^}}'''); 4619 class C {bar(){var f; {var x;} var e = ^}}''');
4377 computeFast(); 4620 computeFast();
4378 return computeFull((bool result) { 4621 return computeFull((bool result) {
4379 expect(request.replacementOffset, completionOffset); 4622 expect(request.replacementOffset, completionOffset);
4380 expect(request.replacementLength, 0); 4623 expect(request.replacementLength, 0);
4381 assertSuggestImportedClass('X'); 4624 assertSuggestImportedClass('X');
4382 assertNotSuggested('_B'); 4625 assertNotSuggested('_B');
4383 assertSuggestLocalClass('Y'); 4626 assertSuggestLocalClass('Y');
4384 assertSuggestLocalClass('C'); 4627 assertSuggestLocalClass('C');
4385 assertSuggestLocalVariable('f', null); 4628 assertSuggestLocalVariable('f', null);
4386 assertNotSuggested('x'); 4629 assertNotSuggested('x');
4387 assertNotSuggested('e'); 4630 assertNotSuggested('e');
4388 }); 4631 });
4389 } 4632 }
4390 4633
4391 test_VariableDeclarationStatement_RHS_missing_semicolon() { 4634 test_VariableDeclarationStatement_RHS_missing_semicolon() {
4392 // VariableDeclaration VariableDeclarationList 4635 // VariableDeclaration VariableDeclarationList
4393 // VariableDeclarationStatement 4636 // VariableDeclarationStatement
4394 addSource('/testB.dart', ''' 4637 addSource(
4638 '/testB.dart',
4639 '''
4395 lib B; 4640 lib B;
4396 foo1() { } 4641 foo1() { }
4397 void bar1() { } 4642 void bar1() { }
4398 class _B { } 4643 class _B { }
4399 class X {X.c(); X._d(); z() {}}'''); 4644 class X {X.c(); X._d(); z() {}}''');
4400 addTestSource(''' 4645 addTestSource('''
4401 import "/testB.dart"; 4646 import "/testB.dart";
4402 foo2() { } 4647 foo2() { }
4403 void bar2() { } 4648 void bar2() { }
4404 class Y {Y.c(); Y._d(); z() {}} 4649 class Y {Y.c(); Y._d(); z() {}}
4405 class C {bar(){var f; {var x;} var e = ^ var g}}'''); 4650 class C {bar(){var f; {var x;} var e = ^ var g}}''');
4406 computeFast(); 4651 computeFast();
4407 return computeFull((bool result) { 4652 return computeFull((bool result) {
4408 expect(request.replacementOffset, completionOffset); 4653 expect(request.replacementOffset, completionOffset);
4409 expect(request.replacementLength, 0); 4654 expect(request.replacementLength, 0);
4410 assertSuggestImportedClass('X'); 4655 assertSuggestImportedClass('X');
4411 assertSuggestImportedFunction('foo1', null); 4656 assertSuggestImportedFunction('foo1', null);
4412 assertNotSuggested('bar1'); 4657 assertNotSuggested('bar1');
4413 assertSuggestLocalFunction('foo2', null); 4658 assertSuggestLocalFunction('foo2', null);
4414 assertNotSuggested('bar2'); 4659 assertNotSuggested('bar2');
4415 assertNotSuggested('_B'); 4660 assertNotSuggested('_B');
4416 assertSuggestLocalClass('Y'); 4661 assertSuggestLocalClass('Y');
4417 assertSuggestLocalClass('C'); 4662 assertSuggestLocalClass('C');
4418 assertSuggestLocalVariable('f', null); 4663 assertSuggestLocalVariable('f', null);
4419 assertNotSuggested('x'); 4664 assertNotSuggested('x');
4420 assertNotSuggested('e'); 4665 assertNotSuggested('e');
4421 }); 4666 });
4422 } 4667 }
4423 } 4668 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698