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

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

Issue 1060713005: rename completion computer to contributor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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 | Annotate | Revision Log
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 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 18 matching lines...) Expand all
29 29
30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) {
31 String c1 = s1.completion.toLowerCase(); 31 String c1 = s1.completion.toLowerCase();
32 String c2 = s2.completion.toLowerCase(); 32 String c2 = s2.completion.toLowerCase();
33 return c1.compareTo(c2); 33 return c1.compareTo(c2);
34 } 34 }
35 35
36 abstract class AbstractCompletionTest extends AbstractContextTest { 36 abstract class AbstractCompletionTest extends AbstractContextTest {
37 Index index; 37 Index index;
38 SearchEngineImpl searchEngine; 38 SearchEngineImpl searchEngine;
39 DartCompletionComputer computer; 39 DartCompletionContributor contributor;
40 String testFile = '/completionTest.dart'; 40 String testFile = '/completionTest.dart';
41 Source testSource; 41 Source testSource;
42 CompilationUnit testUnit; 42 CompilationUnit testUnit;
43 int completionOffset; 43 int completionOffset;
44 AstNode completionNode; 44 AstNode completionNode;
45 bool _computeFastCalled = false; 45 bool _computeFastCalled = false;
46 DartCompletionRequest request; 46 DartCompletionRequest request;
47 DartCompletionCache cache; 47 DartCompletionCache cache;
48 DartCompletionManager _completionManager; 48 DartCompletionManager _completionManager;
49 49
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 expect(element.name, equals(name)); 314 expect(element.name, equals(name));
315 expect(element.parameters, isNull); 315 expect(element.parameters, isNull);
316 expect(element.returnType, isNull); 316 expect(element.returnType, isNull);
317 assertHasNoParameterInfo(cs); 317 assertHasNoParameterInfo(cs);
318 return cs; 318 return cs;
319 } 319 }
320 320
321 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, 321 CompletionSuggestion assertSuggestLibraryPrefix(String prefix,
322 [int relevance = DART_RELEVANCE_DEFAULT, 322 [int relevance = DART_RELEVANCE_DEFAULT,
323 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 323 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
324 // Library prefix should only be suggested by ImportedComputer 324 // Library prefix should only be suggested by ImportedReferenceContributor
325 return assertNotSuggested(prefix); 325 return assertNotSuggested(prefix);
326 } 326 }
327 327
328 CompletionSuggestion assertSuggestMethod( 328 CompletionSuggestion assertSuggestMethod(
329 String name, String declaringType, String returnType, 329 String name, String declaringType, String returnType,
330 {int relevance: DART_RELEVANCE_DEFAULT, 330 {int relevance: DART_RELEVANCE_DEFAULT,
331 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 331 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
332 bool isDeprecated: false}) { 332 bool isDeprecated: false}) {
333 CompletionSuggestion cs = assertSuggest(name, 333 CompletionSuggestion cs = assertSuggest(name,
334 csKind: kind, relevance: relevance, isDeprecated: isDeprecated); 334 csKind: kind, relevance: relevance, isDeprecated: isDeprecated);
335 expect(cs.declaringType, equals(declaringType)); 335 expect(cs.declaringType, equals(declaringType));
336 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 336 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
337 protocol.Element element = cs.element; 337 protocol.Element element = cs.element;
338 expect(element, isNotNull); 338 expect(element, isNotNull);
339 expect(element.kind, equals(protocol.ElementKind.METHOD)); 339 expect(element.kind, equals(protocol.ElementKind.METHOD));
340 expect(element.name, equals(name)); 340 expect(element.name, equals(name));
341 String param = element.parameters; 341 String param = element.parameters;
342 expect(param, isNotNull); 342 expect(param, isNotNull);
343 expect(param[0], equals('(')); 343 expect(param[0], equals('('));
344 expect(param[param.length - 1], equals(')')); 344 expect(param[param.length - 1], equals(')'));
345 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 345 expect(element.returnType, returnType != null ? returnType : 'dynamic');
346 assertHasParameterInfo(cs); 346 assertHasParameterInfo(cs);
347 return cs; 347 return cs;
348 } 348 }
349 349
350 CompletionSuggestion assertSuggestNamedConstructor( 350 CompletionSuggestion assertSuggestNamedConstructor(
351 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT, 351 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT,
352 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 352 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
353 if (computer is InvocationComputer) { 353 if (contributor is PrefixedElementContributor) {
354 CompletionSuggestion cs = 354 CompletionSuggestion cs =
355 assertSuggest(name, csKind: kind, relevance: relevance); 355 assertSuggest(name, csKind: kind, relevance: relevance);
356 protocol.Element element = cs.element; 356 protocol.Element element = cs.element;
357 expect(element, isNotNull); 357 expect(element, isNotNull);
358 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); 358 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
359 expect(element.name, equals(name)); 359 expect(element.name, equals(name));
360 String param = element.parameters; 360 String param = element.parameters;
361 expect(param, isNotNull); 361 expect(param, isNotNull);
362 expect(param[0], equals('(')); 362 expect(param[0], equals('('));
363 expect(param[param.length - 1], equals(')')); 363 expect(param[param.length - 1], equals(')'));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); 406 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE));
407 expect(element.name, equals(name)); 407 expect(element.name, equals(name));
408 expect(element.parameters, isNull); 408 expect(element.parameters, isNull);
409 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 409 expect(element.returnType, returnType != null ? returnType : 'dynamic');
410 assertHasNoParameterInfo(cs); 410 assertHasNoParameterInfo(cs);
411 return cs; 411 return cs;
412 } 412 }
413 413
414 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, 414 void assertSuggestTopLevelVarGetterSetter(String name, String returnType,
415 [int relevance = DART_RELEVANCE_DEFAULT]) { 415 [int relevance = DART_RELEVANCE_DEFAULT]) {
416 if (computer is ImportedComputer) { 416 if (contributor is ImportedReferenceContributor) {
417 assertSuggestGetter(name, returnType); 417 assertSuggestGetter(name, returnType);
418 assertSuggestSetter(name); 418 assertSuggestSetter(name);
419 } else { 419 } else {
420 assertNotSuggested(name); 420 assertNotSuggested(name);
421 } 421 }
422 } 422 }
423 423
424 bool computeFast() { 424 bool computeFast() {
425 _computeFastCalled = true; 425 _computeFastCalled = true;
426 _completionManager = new DartCompletionManager(context, searchEngine, 426 _completionManager = new DartCompletionManager(context, searchEngine,
427 testSource, cache, [computer], new CommonUsageComputer({})); 427 testSource, cache, [contributor], new CommonUsageComputer({}));
428 var result = _completionManager.computeFast(request); 428 var result = _completionManager.computeFast(request);
429 expect(request.replacementOffset, isNotNull); 429 expect(request.replacementOffset, isNotNull);
430 expect(request.replacementLength, isNotNull); 430 expect(request.replacementLength, isNotNull);
431 return result.isEmpty; 431 return result.isEmpty;
432 } 432 }
433 433
434 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { 434 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
435 if (!_computeFastCalled) { 435 if (!_computeFastCalled) {
436 expect(computeFast(), isFalse); 436 expect(computeFast(), isFalse);
437 } 437 }
438 resolve(fullAnalysis); 438 resolve(fullAnalysis);
439 return computer.computeFull(request).then(assertFunction); 439 return contributor.computeFull(request).then(assertFunction);
440 } 440 }
441 441
442 void failedCompletion(String message, 442 void failedCompletion(String message,
443 [Iterable<CompletionSuggestion> completions]) { 443 [Iterable<CompletionSuggestion> completions]) {
444 StringBuffer sb = new StringBuffer(message); 444 StringBuffer sb = new StringBuffer(message);
445 if (completions != null) { 445 if (completions != null) {
446 sb.write('\n found'); 446 sb.write('\n found');
447 completions.toList() 447 completions.toList()
448 ..sort(suggestionComparator) 448 ..sort(suggestionComparator)
449 ..forEach((CompletionSuggestion suggestion) { 449 ..forEach((CompletionSuggestion suggestion) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 if (!resolved) { 535 if (!resolved) {
536 fail('expected unit to be resolved'); 536 fail('expected unit to be resolved');
537 } 537 }
538 } 538 }
539 539
540 @override 540 @override
541 void setUp() { 541 void setUp() {
542 super.setUp(); 542 super.setUp();
543 index = createLocalMemoryIndex(); 543 index = createLocalMemoryIndex();
544 searchEngine = new SearchEngineImpl(index); 544 searchEngine = new SearchEngineImpl(index);
545 setUpComputer(); 545 setUpContributor();
546 } 546 }
547 547
548 void setUpComputer(); 548 void setUpContributor();
549 } 549 }
550 550
551 /** 551 /**
552 * Common tests for `ImportedTypeComputerTest`, `InvocationComputerTest`, 552 * Common tests for `ImportedTypeContributorTest`, `InvocationContributorTest`,
553 * and `LocalComputerTest`. 553 * and `LocalContributorTest`.
554 */ 554 */
555 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { 555 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest {
556 556
557 /** 557 /**
558 * Assert that the ImportedComputer uses cached results to produce identical 558 * Assert that the ImportedReferenceContributor uses cached results
559 * suggestions to the original set of suggestions. 559 * to produce identical suggestions to the original set of suggestions.
560 */ 560 */
561 void assertCachedCompute(_) { 561 void assertCachedCompute(_) {
562 // Subclasses override 562 // Subclasses override
563 } 563 }
564 564
565 CompletionSuggestion assertSuggestImportedClass(String name, 565 CompletionSuggestion assertSuggestImportedClass(String name,
566 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 566 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
567 int relevance: DART_RELEVANCE_DEFAULT}) { 567 int relevance: DART_RELEVANCE_DEFAULT}) {
568 if (computer is ImportedComputer) { 568 if (contributor is ImportedReferenceContributor) {
569 return assertSuggestClass(name, relevance: relevance, kind: kind); 569 return assertSuggestClass(name, relevance: relevance, kind: kind);
570 } else { 570 } else {
571 return assertNotSuggested(name); 571 return assertNotSuggested(name);
572 } 572 }
573 } 573 }
574 574
575 CompletionSuggestion assertSuggestImportedConstructor(String name, 575 CompletionSuggestion assertSuggestImportedConstructor(String name,
576 {int relevance: DART_RELEVANCE_DEFAULT}) { 576 {int relevance: DART_RELEVANCE_DEFAULT}) {
577 return assertNotSuggested(name); 577 return assertNotSuggested(name);
578 } 578 }
579 579
580 CompletionSuggestion assertSuggestImportedField(String name, String type, 580 CompletionSuggestion assertSuggestImportedField(String name, String type,
581 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { 581 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) {
582 return assertNotSuggested(name); 582 return assertNotSuggested(name);
583 } 583 }
584 584
585 CompletionSuggestion assertSuggestImportedFunction( 585 CompletionSuggestion assertSuggestImportedFunction(
586 String name, String returnType, 586 String name, String returnType,
587 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 587 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
588 bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) { 588 bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) {
589 return assertNotSuggested(name); 589 return assertNotSuggested(name);
590 } 590 }
591 591
592 CompletionSuggestion assertSuggestImportedFunctionTypeAlias( 592 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(
593 String name, String returnType, [bool isDeprecated = false, 593 String name, String returnType, [bool isDeprecated = false,
594 int relevance = DART_RELEVANCE_DEFAULT, 594 int relevance = DART_RELEVANCE_DEFAULT,
595 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 595 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
596 if (computer is ImportedComputer) { 596 if (contributor is ImportedReferenceContributor) {
597 return assertSuggestFunctionTypeAlias( 597 return assertSuggestFunctionTypeAlias(
598 name, returnType, isDeprecated, relevance, kind); 598 name, returnType, isDeprecated, relevance, kind);
599 } else { 599 } else {
600 return assertNotSuggested(name); 600 return assertNotSuggested(name);
601 } 601 }
602 } 602 }
603 603
604 CompletionSuggestion assertSuggestImportedGetter( 604 CompletionSuggestion assertSuggestImportedGetter(
605 String name, String returnType, 605 String name, String returnType,
606 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { 606 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {
607 return assertNotSuggested(name); 607 return assertNotSuggested(name);
608 } 608 }
609 609
610 CompletionSuggestion assertSuggestImportedMethod( 610 CompletionSuggestion assertSuggestImportedMethod(
611 String name, String declaringType, String returnType, 611 String name, String declaringType, String returnType,
612 {int relevance: DART_RELEVANCE_INHERITED_METHOD}) { 612 {int relevance: DART_RELEVANCE_INHERITED_METHOD}) {
613 return assertNotSuggested(name); 613 return assertNotSuggested(name);
614 } 614 }
615 615
616 CompletionSuggestion assertSuggestImportedSetter(String name, 616 CompletionSuggestion assertSuggestImportedSetter(String name,
617 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { 617 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {
618 return assertNotSuggested(name); 618 return assertNotSuggested(name);
619 } 619 }
620 620
621 CompletionSuggestion assertSuggestImportedTopLevelVar( 621 CompletionSuggestion assertSuggestImportedTopLevelVar(
622 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT, 622 String name, String returnType, [int relevance = DART_RELEVANCE_DEFAULT,
623 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 623 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
624 if (computer is ImportedComputer) { 624 if (contributor is ImportedReferenceContributor) {
625 return assertSuggestTopLevelVar(name, returnType, relevance, kind); 625 return assertSuggestTopLevelVar(name, returnType, relevance, kind);
626 } else { 626 } else {
627 return assertNotSuggested(name); 627 return assertNotSuggested(name);
628 } 628 }
629 } 629 }
630 630
631 CompletionSuggestion assertSuggestInvocationClass(String name, 631 CompletionSuggestion assertSuggestInvocationClass(String name,
632 [int relevance = DART_RELEVANCE_DEFAULT]) { 632 [int relevance = DART_RELEVANCE_DEFAULT]) {
633 if (computer is InvocationComputer) { 633 if (contributor is PrefixedElementContributor) {
634 return assertSuggestClass(name, relevance: relevance); 634 return assertSuggestClass(name, relevance: relevance);
635 } else { 635 } else {
636 return assertNotSuggested(name); 636 return assertNotSuggested(name);
637 } 637 }
638 } 638 }
639 639
640 CompletionSuggestion assertSuggestInvocationField(String name, String type, 640 CompletionSuggestion assertSuggestInvocationField(String name, String type,
641 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 641 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
642 return assertNotSuggested(name); 642 return assertNotSuggested(name);
643 } 643 }
644 644
645 CompletionSuggestion assertSuggestInvocationGetter( 645 CompletionSuggestion assertSuggestInvocationGetter(
646 String name, String returnType, 646 String name, String returnType,
647 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 647 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
648 if (computer is InvocationComputer) { 648 if (contributor is PrefixedElementContributor) {
649 return assertSuggestGetter(name, returnType, 649 return assertSuggestGetter(name, returnType,
650 relevance: relevance, isDeprecated: isDeprecated); 650 relevance: relevance, isDeprecated: isDeprecated);
651 } else { 651 } else {
652 return assertNotSuggested(name); 652 return assertNotSuggested(name);
653 } 653 }
654 } 654 }
655 655
656 CompletionSuggestion assertSuggestInvocationMethod( 656 CompletionSuggestion assertSuggestInvocationMethod(
657 String name, String declaringType, String returnType, 657 String name, String declaringType, String returnType,
658 [int relevance = DART_RELEVANCE_DEFAULT]) { 658 [int relevance = DART_RELEVANCE_DEFAULT]) {
659 if (computer is InvocationComputer) { 659 if (contributor is PrefixedElementContributor) {
660 return assertSuggestMethod(name, declaringType, returnType, 660 return assertSuggestMethod(name, declaringType, returnType,
661 relevance: relevance); 661 relevance: relevance);
662 } else { 662 } else {
663 return assertNotSuggested(name); 663 return assertNotSuggested(name);
664 } 664 }
665 } 665 }
666 666
667 CompletionSuggestion assertSuggestInvocationSetter(String name, 667 CompletionSuggestion assertSuggestInvocationSetter(String name,
668 [int relevance = DART_RELEVANCE_DEFAULT]) { 668 [int relevance = DART_RELEVANCE_DEFAULT]) {
669 if (computer is InvocationComputer) { 669 if (contributor is PrefixedElementContributor) {
670 return assertSuggestSetter(name); 670 return assertSuggestSetter(name);
671 } else { 671 } else {
672 return assertNotSuggested(name); 672 return assertNotSuggested(name);
673 } 673 }
674 } 674 }
675 675
676 CompletionSuggestion assertSuggestInvocationTopLevelVar( 676 CompletionSuggestion assertSuggestInvocationTopLevelVar(
677 String name, String returnType, 677 String name, String returnType,
678 [int relevance = DART_RELEVANCE_DEFAULT]) { 678 [int relevance = DART_RELEVANCE_DEFAULT]) {
679 if (computer is InvocationComputer) { 679 if (contributor is PrefixedElementContributor) {
680 return assertSuggestTopLevelVar(name, returnType, relevance); 680 return assertSuggestTopLevelVar(name, returnType, relevance);
681 } else { 681 } else {
682 return assertNotSuggested(name); 682 return assertNotSuggested(name);
683 } 683 }
684 } 684 }
685 685
686 CompletionSuggestion assertSuggestLocalClass(String name, 686 CompletionSuggestion assertSuggestLocalClass(String name,
687 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 687 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
688 int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 688 int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
689 return assertNotSuggested(name); 689 return assertNotSuggested(name);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 assertSuggestLibraryPrefix('g'); 1276 assertSuggestLibraryPrefix('g');
1277 assertNotSuggested('G'); 1277 assertNotSuggested('G');
1278 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); 1278 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW);
1279 assertSuggestImportedClass('Object'); 1279 assertSuggestImportedClass('Object');
1280 assertSuggestImportedFunction('min', 'num'); 1280 assertSuggestImportedFunction('min', 'num');
1281 //assertSuggestImportedFunction( 1281 //assertSuggestImportedFunction(
1282 // 'max', 1282 // 'max',
1283 // 'num', 1283 // 'num',
1284 // false, 1284 // false,
1285 // COMPLETION_RELEVANCE_LOW); 1285 // COMPLETION_RELEVANCE_LOW);
1286 if (computer is ImportedComputer) { 1286 if (contributor is ImportedReferenceContributor) {
1287 // TODO(danrubel) should be top level var suggestion 1287 // TODO(danrubel) should be top level var suggestion
1288 assertSuggestGetter('T1', 'String'); 1288 assertSuggestGetter('T1', 'String');
1289 } 1289 }
1290 assertNotSuggested('_T2'); 1290 assertNotSuggested('_T2');
1291 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW); 1291 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW);
1292 assertNotSuggested('_T4'); 1292 assertNotSuggested('_T4');
1293 assertSuggestLocalTopLevelVar('T5', 'int'); 1293 assertSuggestLocalTopLevelVar('T5', 'int');
1294 assertSuggestLocalTopLevelVar('_T6', null); 1294 assertSuggestLocalTopLevelVar('_T6', null);
1295 assertNotSuggested('=='); 1295 assertNotSuggested('==');
1296 assertSuggestLocalGetter('T7', 'String'); 1296 assertSuggestLocalGetter('T7', 'String');
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 F2() { } 2453 F2() { }
2454 typedef D2(); 2454 typedef D2();
2455 class C2 { } 2455 class C2 { }
2456 main() {String name; print("hello \$^");}'''); 2456 main() {String name; print("hello \$^");}''');
2457 computeFast(); 2457 computeFast();
2458 return computeFull((bool result) { 2458 return computeFull((bool result) {
2459 expect(request.replacementOffset, completionOffset); 2459 expect(request.replacementOffset, completionOffset);
2460 expect(request.replacementLength, 0); 2460 expect(request.replacementLength, 0);
2461 assertNotSuggested('Object'); 2461 assertNotSuggested('Object');
2462 // TODO(danrubel) should return top level var rather than getter 2462 // TODO(danrubel) should return top level var rather than getter
2463 if (computer is ImportedComputer) { 2463 if (contributor is ImportedReferenceContributor) {
2464 //assertSuggestImportedTopLevelVar('T1', 'int'); 2464 //assertSuggestImportedTopLevelVar('T1', 'int');
2465 assertSuggestGetter('T1', 'int'); 2465 assertSuggestGetter('T1', 'int');
2466 } 2466 }
2467 assertSuggestImportedFunction('F1', null); 2467 assertSuggestImportedFunction('F1', null);
2468 assertNotSuggested('D1'); 2468 assertNotSuggested('D1');
2469 assertNotSuggested('C1'); 2469 assertNotSuggested('C1');
2470 assertSuggestLocalTopLevelVar('T2', 'int'); 2470 assertSuggestLocalTopLevelVar('T2', 'int');
2471 assertSuggestLocalFunction('F2', null); 2471 assertSuggestLocalFunction('F2', null);
2472 assertNotSuggested('D2'); 2472 assertNotSuggested('D2');
2473 assertNotSuggested('C2'); 2473 assertNotSuggested('C2');
(...skipping 14 matching lines...) Expand all
2488 F2() { } 2488 F2() { }
2489 typedef D2(); 2489 typedef D2();
2490 class C2 { } 2490 class C2 { }
2491 main() {String name; print("hello \${^}");}'''); 2491 main() {String name; print("hello \${^}");}''');
2492 computeFast(); 2492 computeFast();
2493 return computeFull((bool result) { 2493 return computeFull((bool result) {
2494 expect(request.replacementOffset, completionOffset); 2494 expect(request.replacementOffset, completionOffset);
2495 expect(request.replacementLength, 0); 2495 expect(request.replacementLength, 0);
2496 assertSuggestImportedClass('Object'); 2496 assertSuggestImportedClass('Object');
2497 // TODO(danrubel) should return top level var rather than getter 2497 // TODO(danrubel) should return top level var rather than getter
2498 if (computer is ImportedComputer) { 2498 if (contributor is ImportedReferenceContributor) {
2499 //assertSuggestImportedTopLevelVar('T1', 'int'); 2499 //assertSuggestImportedTopLevelVar('T1', 'int');
2500 assertSuggestGetter('T1', 'int'); 2500 assertSuggestGetter('T1', 'int');
2501 } 2501 }
2502 assertSuggestImportedFunction('F1', null); 2502 assertSuggestImportedFunction('F1', null);
2503 assertSuggestImportedFunctionTypeAlias('D1', null); 2503 assertSuggestImportedFunctionTypeAlias('D1', null);
2504 assertSuggestImportedClass('C1'); 2504 assertSuggestImportedClass('C1');
2505 assertSuggestLocalTopLevelVar('T2', 'int'); 2505 assertSuggestLocalTopLevelVar('T2', 'int');
2506 assertSuggestLocalFunction('F2', null); 2506 assertSuggestLocalFunction('F2', null);
2507 assertSuggestLocalFunctionTypeAlias('D2', null); 2507 assertSuggestLocalFunctionTypeAlias('D2', null);
2508 assertSuggestLocalClass('C2'); 2508 assertSuggestLocalClass('C2');
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 computeFast(); 2645 computeFast();
2646 return computeFull((bool result) { 2646 return computeFull((bool result) {
2647 expect(request.replacementOffset, completionOffset - 3); 2647 expect(request.replacementOffset, completionOffset - 3);
2648 expect(request.replacementLength, 3); 2648 expect(request.replacementLength, 3);
2649 assertNotSuggested('c'); 2649 assertNotSuggested('c');
2650 assertNotSuggested('_d'); 2650 assertNotSuggested('_d');
2651 // Imported suggestion are filtered by 1st character 2651 // Imported suggestion are filtered by 1st character
2652 assertSuggestImportedFunction('nowIsIt', null); 2652 assertSuggestImportedFunction('nowIsIt', null);
2653 assertNotSuggested('T1'); 2653 assertNotSuggested('T1');
2654 // TODO (danrubel) this really should be TopLevelVar not getter/setter 2654 // TODO (danrubel) this really should be TopLevelVar not getter/setter
2655 if (computer is ImportedComputer) { 2655 if (contributor is ImportedReferenceContributor) {
2656 assertSuggestGetter('newT1', 'int'); 2656 assertSuggestGetter('newT1', 'int');
2657 } 2657 }
2658 assertNotSuggested('z'); 2658 assertNotSuggested('z');
2659 assertSuggestLocalTopLevelVar('m', 'dynamic'); 2659 assertSuggestLocalTopLevelVar('m', 'dynamic');
2660 assertSuggestLocalFunction('newer', 'String'); 2660 assertSuggestLocalFunction('newer', 'String');
2661 }); 2661 });
2662 } 2662 }
2663 2663
2664 test_Literal_list() { 2664 test_Literal_list() {
2665 // ']' ListLiteral ArgumentList MethodInvocation 2665 // ']' ListLiteral ArgumentList MethodInvocation
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 F2() { } 2703 F2() { }
2704 typedef D2(); 2704 typedef D2();
2705 class C2 { } 2705 class C2 { }
2706 foo = {^'''); 2706 foo = {^''');
2707 computeFast(); 2707 computeFast();
2708 return computeFull((bool result) { 2708 return computeFull((bool result) {
2709 expect(request.replacementOffset, completionOffset); 2709 expect(request.replacementOffset, completionOffset);
2710 expect(request.replacementLength, 0); 2710 expect(request.replacementLength, 0);
2711 assertSuggestImportedClass('Object'); 2711 assertSuggestImportedClass('Object');
2712 // TODO(danrubel) Should be top level variable 2712 // TODO(danrubel) Should be top level variable
2713 if (computer is ImportedComputer) { 2713 if (contributor is ImportedReferenceContributor) {
2714 assertSuggestGetter('T1', 'int'); 2714 assertSuggestGetter('T1', 'int');
2715 // assertSuggestImportedTopLevelVar('T1', 'int'); 2715 // assertSuggestImportedTopLevelVar('T1', 'int');
2716 } 2716 }
2717 assertSuggestImportedFunction('F1', null); 2717 assertSuggestImportedFunction('F1', null);
2718 assertSuggestImportedFunctionTypeAlias('D1', null); 2718 assertSuggestImportedFunctionTypeAlias('D1', null);
2719 assertSuggestImportedClass('C1'); 2719 assertSuggestImportedClass('C1');
2720 assertSuggestLocalTopLevelVar('T2', 'int'); 2720 assertSuggestLocalTopLevelVar('T2', 'int');
2721 assertSuggestLocalFunction('F2', null); 2721 assertSuggestLocalFunction('F2', null);
2722 assertSuggestLocalFunctionTypeAlias('D2', null); 2722 assertSuggestLocalFunctionTypeAlias('D2', null);
2723 assertSuggestLocalClass('C2'); 2723 assertSuggestLocalClass('C2');
(...skipping 12 matching lines...) Expand all
2736 int T2; 2736 int T2;
2737 F2() { } 2737 F2() { }
2738 typedef D2(); 2738 typedef D2();
2739 class C2 { } 2739 class C2 { }
2740 foo = {T^'''); 2740 foo = {T^''');
2741 computeFast(); 2741 computeFast();
2742 return computeFull((bool result) { 2742 return computeFull((bool result) {
2743 expect(request.replacementOffset, completionOffset - 1); 2743 expect(request.replacementOffset, completionOffset - 1);
2744 expect(request.replacementLength, 1); 2744 expect(request.replacementLength, 1);
2745 // TODO(danrubel) Should be top level variable 2745 // TODO(danrubel) Should be top level variable
2746 if (computer is ImportedComputer) { 2746 if (contributor is ImportedReferenceContributor) {
2747 assertSuggestGetter('T1', 'int'); 2747 assertSuggestGetter('T1', 'int');
2748 // assertSuggestImportedTopLevelVar('T1', 'int'); 2748 // assertSuggestImportedTopLevelVar('T1', 'int');
2749 } 2749 }
2750 assertSuggestLocalTopLevelVar('T2', 'int'); 2750 assertSuggestLocalTopLevelVar('T2', 'int');
2751 }); 2751 });
2752 } 2752 }
2753 2753
2754 test_MapLiteralEntry2() { 2754 test_MapLiteralEntry2() {
2755 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration 2755 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration
2756 addSource('/testA.dart', ''' 2756 addSource('/testA.dart', '''
2757 int T1; 2757 int T1;
2758 F1() { } 2758 F1() { }
2759 typedef D1(); 2759 typedef D1();
2760 class C1 {C1(this.x) { } int x;}'''); 2760 class C1 {C1(this.x) { } int x;}''');
2761 addTestSource(''' 2761 addTestSource('''
2762 import "/testA.dart"; 2762 import "/testA.dart";
2763 int T2; 2763 int T2;
2764 F2() { } 2764 F2() { }
2765 typedef D2(); 2765 typedef D2();
2766 class C2 { } 2766 class C2 { }
2767 foo = {7:T^};'''); 2767 foo = {7:T^};''');
2768 computeFast(); 2768 computeFast();
2769 return computeFull((bool result) { 2769 return computeFull((bool result) {
2770 expect(request.replacementOffset, completionOffset - 1); 2770 expect(request.replacementOffset, completionOffset - 1);
2771 expect(request.replacementLength, 1); 2771 expect(request.replacementLength, 1);
2772 // TODO(danrubel) Should be top level variable 2772 // TODO(danrubel) Should be top level variable
2773 if (computer is ImportedComputer) { 2773 if (contributor is ImportedReferenceContributor) {
2774 assertSuggestGetter('T1', 'int'); 2774 assertSuggestGetter('T1', 'int');
2775 // assertSuggestImportedTopLevelVar('T1', 'int'); 2775 // assertSuggestImportedTopLevelVar('T1', 'int');
2776 } 2776 }
2777 assertSuggestLocalTopLevelVar('T2', 'int'); 2777 assertSuggestLocalTopLevelVar('T2', 'int');
2778 }); 2778 });
2779 } 2779 }
2780 2780
2781 test_MethodDeclaration_body_getters() { 2781 test_MethodDeclaration_body_getters() {
2782 // Block BlockFunctionBody MethodDeclaration 2782 // Block BlockFunctionBody MethodDeclaration
2783 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); 2783 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}');
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 assertNotSuggested('bar2'); 3757 assertNotSuggested('bar2');
3758 assertNotSuggested('_B'); 3758 assertNotSuggested('_B');
3759 assertSuggestLocalClass('Y'); 3759 assertSuggestLocalClass('Y');
3760 assertSuggestLocalClass('C'); 3760 assertSuggestLocalClass('C');
3761 assertSuggestLocalVariable('f', null); 3761 assertSuggestLocalVariable('f', null);
3762 assertNotSuggested('x'); 3762 assertNotSuggested('x');
3763 assertNotSuggested('e'); 3763 assertNotSuggested('e');
3764 }); 3764 });
3765 } 3765 }
3766 } 3766 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698