| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; | 11 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; |
| 12 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 12 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 13 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | 13 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; |
| 14 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 14 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 15 import 'package:analysis_server/src/services/completion/imported_computer.dart'; | 15 import 'package:analysis_server/src/services/completion/imported_computer.dart'; |
| 16 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 16 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 17 import 'package:analysis_server/src/services/completion/local_computer.dart'; | |
| 18 import 'package:analysis_server/src/services/index/index.dart'; | 17 import 'package:analysis_server/src/services/index/index.dart'; |
| 19 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 18 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 19 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 21 import 'package:analyzer/src/generated/ast.dart'; | 20 import 'package:analyzer/src/generated/ast.dart'; |
| 22 import 'package:analyzer/src/generated/element.dart'; | 21 import 'package:analyzer/src/generated/element.dart'; |
| 23 import 'package:analyzer/src/generated/engine.dart'; | 22 import 'package:analyzer/src/generated/engine.dart'; |
| 24 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 25 import 'package:unittest/unittest.dart'; | 24 import 'package:unittest/unittest.dart'; |
| 26 | 25 |
| 27 import '../../abstract_context.dart'; | 26 import '../../abstract_context.dart'; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); | 338 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); |
| 340 expect(element.parameters, isNull); | 339 expect(element.parameters, isNull); |
| 341 expect(element.returnType, isNull); | 340 expect(element.returnType, isNull); |
| 342 assertHasNoParameterInfo(cs); | 341 assertHasNoParameterInfo(cs); |
| 343 return cs; | 342 return cs; |
| 344 } else { | 343 } else { |
| 345 return assertNotSuggested(prefix); | 344 return assertNotSuggested(prefix); |
| 346 } | 345 } |
| 347 } | 346 } |
| 348 | 347 |
| 349 CompletionSuggestion assertSuggestLocalVariable(String name, | |
| 350 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | |
| 351 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | |
| 352 // Local variables should only be suggested by LocalComputer | |
| 353 if (computer is LocalComputer) { | |
| 354 CompletionSuggestion cs = | |
| 355 assertSuggest(name, csKind: kind, relevance: relevance); | |
| 356 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 357 protocol.Element element = cs.element; | |
| 358 expect(element, isNotNull); | |
| 359 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE)); | |
| 360 expect(element.name, equals(name)); | |
| 361 expect(element.parameters, isNull); | |
| 362 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | |
| 363 assertHasNoParameterInfo(cs); | |
| 364 return cs; | |
| 365 } else { | |
| 366 return assertNotSuggested(name); | |
| 367 } | |
| 368 } | |
| 369 | |
| 370 CompletionSuggestion assertSuggestMethod(String name, String declaringType, | 348 CompletionSuggestion assertSuggestMethod(String name, String declaringType, |
| 371 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, | 349 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, |
| 372 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 350 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 373 bool isDeprecated: false}) { | 351 bool isDeprecated: false}) { |
| 374 CompletionSuggestion cs = assertSuggest( | 352 CompletionSuggestion cs = assertSuggest( |
| 375 name, | 353 name, |
| 376 csKind: kind, | 354 csKind: kind, |
| 377 relevance: relevance, | 355 relevance: relevance, |
| 378 isDeprecated: isDeprecated); | 356 isDeprecated: isDeprecated); |
| 379 expect(cs.declaringType, equals(declaringType)); | 357 expect(cs.declaringType, equals(declaringType)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 407 expect(param[param.length - 1], equals(')')); | 385 expect(param[param.length - 1], equals(')')); |
| 408 expect(element.returnType, equals(returnType)); | 386 expect(element.returnType, equals(returnType)); |
| 409 assertHasParameterInfo(cs); | 387 assertHasParameterInfo(cs); |
| 410 return cs; | 388 return cs; |
| 411 } else { | 389 } else { |
| 412 return assertNotSuggested(name); | 390 return assertNotSuggested(name); |
| 413 } | 391 } |
| 414 } | 392 } |
| 415 | 393 |
| 416 CompletionSuggestion assertSuggestParameter(String name, String returnType, | 394 CompletionSuggestion assertSuggestParameter(String name, String returnType, |
| 417 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = | 395 {int relevance: DART_RELEVANCE_PARAMETER}) { |
| 418 CompletionSuggestionKind.INVOCATION]) { | 396 return assertNotSuggested(name); |
| 419 // Parameters should only be suggested by LocalComputer | |
| 420 if (computer is LocalComputer) { | |
| 421 CompletionSuggestion cs = | |
| 422 assertSuggest(name, csKind: kind, relevance: relevance); | |
| 423 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | |
| 424 protocol.Element element = cs.element; | |
| 425 expect(element, isNotNull); | |
| 426 expect(element.kind, equals(protocol.ElementKind.PARAMETER)); | |
| 427 expect(element.name, equals(name)); | |
| 428 expect(element.parameters, isNull); | |
| 429 expect( | |
| 430 element.returnType, | |
| 431 equals(returnType != null ? returnType : 'dynamic')); | |
| 432 return cs; | |
| 433 } else { | |
| 434 return assertNotSuggested(name); | |
| 435 } | |
| 436 } | 397 } |
| 437 | 398 |
| 438 CompletionSuggestion assertSuggestSetter(String name, [int relevance = | 399 CompletionSuggestion assertSuggestSetter(String name, [int relevance = |
| 439 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 400 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 440 CompletionSuggestionKind.INVOCATION]) { | 401 CompletionSuggestionKind.INVOCATION]) { |
| 441 CompletionSuggestion cs = assertSuggest( | 402 CompletionSuggestion cs = assertSuggest( |
| 442 name, | 403 name, |
| 443 csKind: kind, | 404 csKind: kind, |
| 444 relevance: relevance, | 405 relevance: relevance, |
| 445 elemKind: protocol.ElementKind.SETTER); | 406 elemKind: protocol.ElementKind.SETTER); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { | 578 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { |
| 618 | 579 |
| 619 /** | 580 /** |
| 620 * Assert that the ImportedComputer uses cached results to produce identical | 581 * Assert that the ImportedComputer uses cached results to produce identical |
| 621 * suggestions to the original set of suggestions. | 582 * suggestions to the original set of suggestions. |
| 622 */ | 583 */ |
| 623 void assertCachedCompute(_) { | 584 void assertCachedCompute(_) { |
| 624 // Subclasses override | 585 // Subclasses override |
| 625 } | 586 } |
| 626 | 587 |
| 627 CompletionSuggestion assertLocalSuggestMethod(String name, | |
| 628 String declaringType, String returnType, [int relevance = | |
| 629 COMPLETION_RELEVANCE_DEFAULT]) { | |
| 630 if (computer is LocalComputer) { | |
| 631 return assertSuggestMethod( | |
| 632 name, | |
| 633 declaringType, | |
| 634 returnType, | |
| 635 relevance: relevance); | |
| 636 } else { | |
| 637 return assertNotSuggested(name); | |
| 638 } | |
| 639 } | |
| 640 | |
| 641 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = | 588 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = |
| 642 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 589 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 643 CompletionSuggestionKind.INVOCATION]) { | 590 CompletionSuggestionKind.INVOCATION]) { |
| 644 if (computer is ImportedComputer) { | 591 if (computer is ImportedComputer) { |
| 645 return assertSuggestClass(name, relevance: relevance, kind: kind); | 592 return assertSuggestClass(name, relevance: relevance, kind: kind); |
| 646 } else { | 593 } else { |
| 647 return assertNotSuggested(name); | 594 return assertNotSuggested(name); |
| 648 } | 595 } |
| 649 } | 596 } |
| 650 | 597 |
| 651 CompletionSuggestion assertSuggestImportedField(String name, String type, | 598 CompletionSuggestion assertSuggestImportedField(String name, String type, |
| 652 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 599 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { |
| 653 return assertNotSuggested(name); | 600 return assertNotSuggested(name); |
| 654 } | 601 } |
| 655 | 602 |
| 656 CompletionSuggestion assertSuggestImportedFunction(String name, | 603 CompletionSuggestion assertSuggestImportedFunction(String name, |
| 657 String returnType, [bool isDeprecated = false, int relevance = | 604 String returnType, [bool isDeprecated = false, int relevance = |
| 658 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 605 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 659 CompletionSuggestionKind.INVOCATION]) { | 606 CompletionSuggestionKind.INVOCATION]) { |
| 660 if (computer is ImportedComputer) { | 607 if (computer is ImportedComputer) { |
| 661 return assertSuggestFunction( | 608 return assertSuggestFunction( |
| 662 name, | 609 name, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 679 returnType, | 626 returnType, |
| 680 isDeprecated, | 627 isDeprecated, |
| 681 relevance, | 628 relevance, |
| 682 kind); | 629 kind); |
| 683 } else { | 630 } else { |
| 684 return assertNotSuggested(name); | 631 return assertNotSuggested(name); |
| 685 } | 632 } |
| 686 } | 633 } |
| 687 | 634 |
| 688 CompletionSuggestion assertSuggestImportedGetter(String name, | 635 CompletionSuggestion assertSuggestImportedGetter(String name, |
| 689 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 636 String returnType, {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { |
| 690 if (computer is ImportedComputer) { | 637 return assertNotSuggested(name); |
| 691 return assertSuggestGetter(name, returnType, relevance: relevance); | |
| 692 } else { | |
| 693 return assertNotSuggested(name); | |
| 694 } | |
| 695 } | 638 } |
| 696 | 639 |
| 697 CompletionSuggestion assertSuggestImportedMethod(String name, | 640 CompletionSuggestion assertSuggestImportedMethod(String name, |
| 698 String declaringType, String returnType, [int relevance = | 641 String declaringType, String returnType, {int relevance: |
| 699 COMPLETION_RELEVANCE_DEFAULT]) { | 642 DART_RELEVANCE_INHERITED_METHOD}) { |
| 700 if (computer is ImportedComputer) { | 643 return assertNotSuggested(name); |
| 701 return assertSuggestMethod( | |
| 702 name, | |
| 703 declaringType, | |
| 704 returnType, | |
| 705 relevance: relevance); | |
| 706 } else { | |
| 707 return assertNotSuggested(name); | |
| 708 } | |
| 709 } | 644 } |
| 710 | 645 |
| 711 CompletionSuggestion assertSuggestImportedSetter(String name, [int relevance = | 646 CompletionSuggestion assertSuggestImportedSetter(String name, {int relevance: |
| 712 COMPLETION_RELEVANCE_DEFAULT]) { | 647 DART_RELEVANCE_INHERITED_ACCESSOR}) { |
| 713 if (computer is ImportedComputer) { | 648 return assertNotSuggested(name); |
| 714 return assertSuggestSetter(name, relevance); | |
| 715 } else { | |
| 716 return assertNotSuggested(name); | |
| 717 } | |
| 718 } | 649 } |
| 719 | 650 |
| 720 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, | 651 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, |
| 721 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 652 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 722 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 653 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 723 if (computer is ImportedComputer) { | 654 if (computer is ImportedComputer) { |
| 724 return assertSuggestTopLevelVar(name, returnType, relevance, kind); | 655 return assertSuggestTopLevelVar(name, returnType, relevance, kind); |
| 725 } else { | 656 } else { |
| 726 return assertNotSuggested(name); | 657 return assertNotSuggested(name); |
| 727 } | 658 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return assertNotSuggested(name); | 717 return assertNotSuggested(name); |
| 787 } | 718 } |
| 788 } | 719 } |
| 789 | 720 |
| 790 CompletionSuggestion assertSuggestLocalClass(String name, {int relevance: | 721 CompletionSuggestion assertSuggestLocalClass(String name, {int relevance: |
| 791 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 722 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 792 return assertNotSuggested(name); | 723 return assertNotSuggested(name); |
| 793 } | 724 } |
| 794 | 725 |
| 795 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, | 726 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, |
| 796 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 727 {int relevance: COMPLETION_RELEVANCE_DEFAULT}) { |
| 797 if (computer is LocalComputer) { | 728 return assertNotSuggested(name); |
| 798 return assertSuggestClassTypeAlias(name, relevance); | |
| 799 } else { | |
| 800 return assertNotSuggested(name); | |
| 801 } | |
| 802 } | 729 } |
| 803 | 730 |
| 804 CompletionSuggestion assertSuggestLocalField(String name, String type, | 731 CompletionSuggestion assertSuggestLocalField(String name, String type, |
| 805 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 732 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { |
| 806 return assertNotSuggested(name); | 733 return assertNotSuggested(name); |
| 807 } | 734 } |
| 808 | 735 |
| 809 CompletionSuggestion assertSuggestLocalFunction(String name, | 736 CompletionSuggestion assertSuggestLocalFunction(String name, |
| 810 String returnType, [bool isDeprecated = false, int relevance = | 737 String returnType, {bool deprecated: false, int relevance: |
| 811 COMPLETION_RELEVANCE_DEFAULT]) { | 738 DART_RELEVANCE_LOCAL_FUNCTION}) { |
| 812 if (computer is LocalComputer) { | 739 return assertNotSuggested(name); |
| 813 return assertSuggestFunction(name, returnType, isDeprecated, relevance); | |
| 814 } else { | |
| 815 return assertNotSuggested(name); | |
| 816 } | |
| 817 } | 740 } |
| 818 | 741 |
| 819 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, | 742 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, |
| 820 String returnType, [bool isDeprecated = false, int relevance = | 743 String returnType, {bool deprecated: false, int relevance: |
| 821 COMPLETION_RELEVANCE_DEFAULT]) { | 744 COMPLETION_RELEVANCE_DEFAULT}) { |
| 822 if (computer is LocalComputer) { | 745 return assertNotSuggested(name); |
| 823 return assertSuggestFunctionTypeAlias( | |
| 824 name, | |
| 825 returnType, | |
| 826 isDeprecated, | |
| 827 relevance); | |
| 828 } else { | |
| 829 return assertNotSuggested(name); | |
| 830 } | |
| 831 } | 746 } |
| 832 | 747 |
| 833 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, | 748 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, |
| 834 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 749 {int relevance: DART_RELEVANCE_LOCAL_ACCESSOR, bool deprecated: false}) { |
| 835 return assertNotSuggested(name); | 750 return assertNotSuggested(name); |
| 836 } | 751 } |
| 837 | 752 |
| 838 CompletionSuggestion assertSuggestLocalMethod(String name, | 753 CompletionSuggestion assertSuggestLocalMethod(String name, |
| 839 String declaringType, String returnType, {int relevance: | 754 String declaringType, String returnType, {int relevance: |
| 840 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 755 DART_RELEVANCE_LOCAL_METHOD, bool deprecated: false}) { |
| 841 return assertNotSuggested(name); | 756 return assertNotSuggested(name); |
| 842 } | 757 } |
| 843 | 758 |
| 844 CompletionSuggestion assertSuggestLocalSetter(String name, [int relevance = | 759 CompletionSuggestion assertSuggestLocalSetter(String name, {int relevance: |
| 845 COMPLETION_RELEVANCE_DEFAULT]) { | 760 DART_RELEVANCE_LOCAL_ACCESSOR}) { |
| 846 if (computer is LocalComputer) { | 761 return assertNotSuggested(name); |
| 847 return assertSuggestSetter(name, relevance); | |
| 848 } else { | |
| 849 return assertNotSuggested(name); | |
| 850 } | |
| 851 } | 762 } |
| 852 | 763 |
| 853 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, | 764 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, |
| 854 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 765 String returnType, {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE
}) { |
| 855 if (computer is LocalComputer) { | 766 return assertNotSuggested(name); |
| 856 return assertSuggestTopLevelVar(name, returnType, relevance); | 767 } |
| 857 } else { | 768 |
| 858 return assertNotSuggested(name); | 769 CompletionSuggestion assertSuggestLocalVariable(String name, |
| 859 } | 770 String returnType, {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { |
| 771 return assertNotSuggested(name); |
| 860 } | 772 } |
| 861 | 773 |
| 862 CompletionSuggestion assertSuggestNonLocalClass(String name, [int relevance = | 774 CompletionSuggestion assertSuggestNonLocalClass(String name, [int relevance = |
| 863 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 775 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 864 CompletionSuggestionKind.INVOCATION]) { | 776 CompletionSuggestionKind.INVOCATION]) { |
| 865 return assertSuggestImportedClass(name, relevance, kind); | 777 return assertSuggestImportedClass(name, relevance, kind); |
| 866 } | 778 } |
| 867 | 779 |
| 868 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | 780 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { |
| 869 return super.computeFull( | 781 return super.computeFull( |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 } | 1135 } |
| 1224 void b() { }} | 1136 void b() { }} |
| 1225 class Z { }'''); | 1137 class Z { }'''); |
| 1226 computeFast(); | 1138 computeFast(); |
| 1227 return computeFull((bool result) { | 1139 return computeFull((bool result) { |
| 1228 expect(request.replacementOffset, completionOffset); | 1140 expect(request.replacementOffset, completionOffset); |
| 1229 expect(request.replacementLength, 0); | 1141 expect(request.replacementLength, 0); |
| 1230 | 1142 |
| 1231 assertSuggestLocalClass('X'); | 1143 assertSuggestLocalClass('X'); |
| 1232 assertSuggestLocalClass('Z'); | 1144 assertSuggestLocalClass('Z'); |
| 1233 assertLocalSuggestMethod('a', 'X', null); | 1145 assertSuggestLocalMethod('a', 'X', null); |
| 1234 assertLocalSuggestMethod('b', 'X', 'void'); | 1146 assertSuggestLocalMethod('b', 'X', 'void'); |
| 1235 assertSuggestLocalFunction('localF', null); | 1147 assertSuggestLocalFunction('localF', null); |
| 1236 assertSuggestLocalVariable('f', null); | 1148 assertSuggestLocalVariable('f', null); |
| 1237 // Don't suggest locals out of scope | 1149 // Don't suggest locals out of scope |
| 1238 assertNotSuggested('r'); | 1150 assertNotSuggested('r'); |
| 1239 assertNotSuggested('x'); | 1151 assertNotSuggested('x'); |
| 1240 | 1152 |
| 1241 assertSuggestImportedClass('A'); | 1153 assertSuggestImportedClass('A'); |
| 1242 assertNotSuggested('_B'); | 1154 assertNotSuggested('_B'); |
| 1243 assertSuggestImportedClass('C'); | 1155 assertSuggestImportedClass('C'); |
| 1244 // hidden element suggested as low relevance | 1156 // hidden element suggested as low relevance |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 Z D2() {int x;} | 1217 Z D2() {int x;} |
| 1306 class X {a() {var f; {var x;} D^ var r;} void b() { }} | 1218 class X {a() {var f; {var x;} D^ var r;} void b() { }} |
| 1307 class Z { }'''); | 1219 class Z { }'''); |
| 1308 computeFast(); | 1220 computeFast(); |
| 1309 return computeFull((bool result) { | 1221 return computeFull((bool result) { |
| 1310 expect(request.replacementOffset, completionOffset - 1); | 1222 expect(request.replacementOffset, completionOffset - 1); |
| 1311 expect(request.replacementLength, 1); | 1223 expect(request.replacementLength, 1); |
| 1312 | 1224 |
| 1313 assertSuggestLocalClass('X'); | 1225 assertSuggestLocalClass('X'); |
| 1314 assertSuggestLocalClass('Z'); | 1226 assertSuggestLocalClass('Z'); |
| 1315 assertLocalSuggestMethod('a', 'X', null); | 1227 assertSuggestLocalMethod('a', 'X', null); |
| 1316 assertLocalSuggestMethod('b', 'X', 'void'); | 1228 assertSuggestLocalMethod('b', 'X', 'void'); |
| 1317 assertSuggestLocalVariable('f', null); | 1229 assertSuggestLocalVariable('f', null); |
| 1318 // Don't suggest locals out of scope | 1230 // Don't suggest locals out of scope |
| 1319 assertNotSuggested('r'); | 1231 assertNotSuggested('r'); |
| 1320 assertNotSuggested('x'); | 1232 assertNotSuggested('x'); |
| 1321 | 1233 |
| 1322 // imported elements are portially filtered | 1234 // imported elements are portially filtered |
| 1323 //assertSuggestImportedClass('A'); | 1235 //assertSuggestImportedClass('A'); |
| 1324 assertNotSuggested('_B'); | 1236 assertNotSuggested('_B'); |
| 1325 //assertSuggestImportedClass('C'); | 1237 //assertSuggestImportedClass('C'); |
| 1326 // hidden element suggested as low relevance | 1238 // hidden element suggested as low relevance |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 | 1850 |
| 1939 test_FunctionExpression_body_function() { | 1851 test_FunctionExpression_body_function() { |
| 1940 // Block BlockFunctionBody FunctionExpression | 1852 // Block BlockFunctionBody FunctionExpression |
| 1941 addTestSource(''' | 1853 addTestSource(''' |
| 1942 void bar() { } | 1854 void bar() { } |
| 1943 String foo(List args) {x.then((R b) {^});}'''); | 1855 String foo(List args) {x.then((R b) {^});}'''); |
| 1944 computeFast(); | 1856 computeFast(); |
| 1945 return computeFull((bool result) { | 1857 return computeFull((bool result) { |
| 1946 expect(request.replacementOffset, completionOffset); | 1858 expect(request.replacementOffset, completionOffset); |
| 1947 expect(request.replacementLength, 0); | 1859 expect(request.replacementLength, 0); |
| 1948 var f = assertSuggestLocalFunction('foo', 'String', false); | 1860 var f = assertSuggestLocalFunction('foo', 'String', deprecated: false); |
| 1949 if (f != null) { | 1861 if (f != null) { |
| 1950 expect(f.element.isPrivate, isFalse); | 1862 expect(f.element.isPrivate, isFalse); |
| 1951 } | 1863 } |
| 1952 assertSuggestLocalFunction('bar', 'void'); | 1864 assertSuggestLocalFunction('bar', 'void'); |
| 1953 assertSuggestParameter('args', 'List'); | 1865 assertSuggestParameter('args', 'List'); |
| 1954 assertSuggestParameter('b', 'R'); | 1866 assertSuggestParameter('b', 'R'); |
| 1955 assertSuggestImportedClass('Object'); | 1867 assertSuggestImportedClass('Object'); |
| 1956 }); | 1868 }); |
| 1957 } | 1869 } |
| 1958 | 1870 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 expect(request.replacementLength, 0); | 2095 expect(request.replacementLength, 0); |
| 2184 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | 2096 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); |
| 2185 if (methodA != null) { | 2097 if (methodA != null) { |
| 2186 expect(methodA.element.isDeprecated, isFalse); | 2098 expect(methodA.element.isDeprecated, isFalse); |
| 2187 expect(methodA.element.isPrivate, isFalse); | 2099 expect(methodA.element.isPrivate, isFalse); |
| 2188 } | 2100 } |
| 2189 CompletionSuggestion getterF = assertSuggestLocalGetter( | 2101 CompletionSuggestion getterF = assertSuggestLocalGetter( |
| 2190 'f', | 2102 'f', |
| 2191 'X', | 2103 'X', |
| 2192 relevance: COMPLETION_RELEVANCE_LOW, | 2104 relevance: COMPLETION_RELEVANCE_LOW, |
| 2193 isDeprecated: true); | 2105 deprecated: true); |
| 2194 if (getterF != null) { | 2106 if (getterF != null) { |
| 2195 expect(getterF.element.isDeprecated, isTrue); | 2107 expect(getterF.element.isDeprecated, isTrue); |
| 2196 expect(getterF.element.isPrivate, isFalse); | 2108 expect(getterF.element.isPrivate, isFalse); |
| 2197 } | 2109 } |
| 2198 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); | 2110 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); |
| 2199 if (getterG != null) { | 2111 if (getterG != null) { |
| 2200 expect(getterG.element.isDeprecated, isFalse); | 2112 expect(getterG.element.isDeprecated, isFalse); |
| 2201 expect(getterG.element.isPrivate, isTrue); | 2113 expect(getterG.element.isPrivate, isTrue); |
| 2202 } | 2114 } |
| 2203 }); | 2115 }); |
| 2204 } | 2116 } |
| 2205 | 2117 |
| 2206 test_MethodDeclaration_members() { | 2118 test_MethodDeclaration_members() { |
| 2207 // Block BlockFunctionBody MethodDeclaration | 2119 // Block BlockFunctionBody MethodDeclaration |
| 2208 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | 2120 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); |
| 2209 computeFast(); | 2121 computeFast(); |
| 2210 return computeFull((bool result) { | 2122 return computeFull((bool result) { |
| 2211 expect(request.replacementOffset, completionOffset); | 2123 expect(request.replacementOffset, completionOffset); |
| 2212 expect(request.replacementLength, 0); | 2124 expect(request.replacementLength, 0); |
| 2213 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); | 2125 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); |
| 2214 if (methodA != null) { | 2126 if (methodA != null) { |
| 2215 expect(methodA.element.isDeprecated, isFalse); | 2127 expect(methodA.element.isDeprecated, isFalse); |
| 2216 expect(methodA.element.isPrivate, isTrue); | 2128 expect(methodA.element.isPrivate, isTrue); |
| 2217 } | 2129 } |
| 2218 CompletionSuggestion getterF = assertSuggestLocalField( | 2130 CompletionSuggestion getterF = assertSuggestLocalField( |
| 2219 'f', | 2131 'f', |
| 2220 'X', | 2132 'X', |
| 2221 relevance: COMPLETION_RELEVANCE_LOW, | 2133 relevance: COMPLETION_RELEVANCE_LOW, |
| 2222 isDeprecated: true); | 2134 deprecated: true); |
| 2223 if (getterF != null) { | 2135 if (getterF != null) { |
| 2224 expect(getterF.element.isDeprecated, isTrue); | 2136 expect(getterF.element.isDeprecated, isTrue); |
| 2225 expect(getterF.element.isPrivate, isFalse); | 2137 expect(getterF.element.isPrivate, isFalse); |
| 2226 expect(getterF.element.parameters, isNull); | 2138 expect(getterF.element.parameters, isNull); |
| 2227 } | 2139 } |
| 2228 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); | 2140 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); |
| 2229 if (getterG != null) { | 2141 if (getterG != null) { |
| 2230 expect(getterG.element.isDeprecated, isFalse); | 2142 expect(getterG.element.isDeprecated, isFalse); |
| 2231 expect(getterG.element.isPrivate, isTrue); | 2143 expect(getterG.element.isPrivate, isTrue); |
| 2232 expect(getterF.element.parameters, isNull); | 2144 expect(getterF.element.parameters, isNull); |
| 2233 } | 2145 } |
| 2234 assertSuggestImportedClass('bool'); | 2146 assertSuggestImportedClass('bool'); |
| 2235 }); | 2147 }); |
| 2236 } | 2148 } |
| 2237 | 2149 |
| 2238 test_MethodDeclaration_parameters_named() { | 2150 test_MethodDeclaration_parameters_named() { |
| 2239 // Block BlockFunctionBody MethodDeclaration | 2151 // Block BlockFunctionBody MethodDeclaration |
| 2240 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); | 2152 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); |
| 2241 computeFast(); | 2153 computeFast(); |
| 2242 return computeFull((bool result) { | 2154 return computeFull((bool result) { |
| 2243 expect(request.replacementOffset, completionOffset); | 2155 expect(request.replacementOffset, completionOffset); |
| 2244 expect(request.replacementLength, 0); | 2156 expect(request.replacementLength, 0); |
| 2245 CompletionSuggestion methodA = assertSuggestLocalMethod( | 2157 CompletionSuggestion methodA = assertSuggestLocalMethod( |
| 2246 'a', | 2158 'a', |
| 2247 'A', | 2159 'A', |
| 2248 'Z', | 2160 'Z', |
| 2249 relevance: COMPLETION_RELEVANCE_LOW, | 2161 relevance: COMPLETION_RELEVANCE_LOW, |
| 2250 isDeprecated: true); | 2162 deprecated: true); |
| 2251 if (methodA != null) { | 2163 if (methodA != null) { |
| 2252 expect(methodA.element.isDeprecated, isTrue); | 2164 expect(methodA.element.isDeprecated, isTrue); |
| 2253 expect(methodA.element.isPrivate, isFalse); | 2165 expect(methodA.element.isPrivate, isFalse); |
| 2254 } | 2166 } |
| 2255 assertSuggestParameter('x', 'X'); | 2167 assertSuggestParameter('x', 'X'); |
| 2256 assertSuggestParameter('y', null); | 2168 assertSuggestParameter('y', null); |
| 2257 assertSuggestParameter('b', null); | 2169 assertSuggestParameter('b', null); |
| 2258 assertSuggestImportedClass('int'); | 2170 assertSuggestImportedClass('int'); |
| 2259 assertNotSuggested('_'); | 2171 assertNotSuggested('_'); |
| 2260 }); | 2172 }); |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2784 assertNotSuggested('bar2'); | 2696 assertNotSuggested('bar2'); |
| 2785 assertNotSuggested('_B'); | 2697 assertNotSuggested('_B'); |
| 2786 assertSuggestLocalClass('Y'); | 2698 assertSuggestLocalClass('Y'); |
| 2787 assertSuggestLocalClass('C'); | 2699 assertSuggestLocalClass('C'); |
| 2788 assertSuggestLocalVariable('f', null); | 2700 assertSuggestLocalVariable('f', null); |
| 2789 assertNotSuggested('x'); | 2701 assertNotSuggested('x'); |
| 2790 assertNotSuggested('e'); | 2702 assertNotSuggested('e'); |
| 2791 }); | 2703 }); |
| 2792 } | 2704 } |
| 2793 } | 2705 } |
| OLD | NEW |