| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 'expected exactly one $completion', | 89 'expected exactly one $completion', |
| 90 request.suggestions.where((s) => s.completion == completion)); | 90 request.suggestions.where((s) => s.completion == completion)); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 }); | 94 }); |
| 95 if (cs == null) { | 95 if (cs == null) { |
| 96 _failedCompletion('expected $completion $csKind', request.suggestions); | 96 _failedCompletion('expected $completion $csKind', request.suggestions); |
| 97 } | 97 } |
| 98 expect(cs.kind, equals(csKind)); | 98 expect(cs.kind, equals(csKind)); |
| 99 expect(cs.relevance, equals(relevance)); | 99 if (isDeprecated) { |
| 100 expect(cs.relevance, equals(CompletionRelevance.LOW)); |
| 101 } else { |
| 102 expect(cs.relevance, equals(relevance)); |
| 103 } |
| 100 expect(cs.selectionOffset, equals(completion.length)); | 104 expect(cs.selectionOffset, equals(completion.length)); |
| 101 expect(cs.selectionLength, equals(0)); | 105 expect(cs.selectionLength, equals(0)); |
| 102 expect(cs.isDeprecated, equals(isDeprecated)); | 106 expect(cs.isDeprecated, equals(isDeprecated)); |
| 103 expect(cs.isPotential, equals(isPotential)); | 107 expect(cs.isPotential, equals(isPotential)); |
| 104 return cs; | 108 return cs; |
| 105 } | 109 } |
| 106 | 110 |
| 107 CompletionSuggestion assertSuggestClass(String name, | 111 CompletionSuggestion assertSuggestClass(String name, |
| 108 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, | 112 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, |
| 109 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 113 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // expect(param[0], equals('(')); | 181 // expect(param[0], equals('(')); |
| 178 // expect(param[param.length - 1], equals(')')); | 182 // expect(param[param.length - 1], equals(')')); |
| 179 // TODO (danrubel) Determine why return type is null | 183 // TODO (danrubel) Determine why return type is null |
| 180 // expect( | 184 // expect( |
| 181 // element.returnType, | 185 // element.returnType, |
| 182 // equals(returnType != null ? returnType : 'dynamic')); | 186 // equals(returnType != null ? returnType : 'dynamic')); |
| 183 return cs; | 187 return cs; |
| 184 } | 188 } |
| 185 | 189 |
| 186 CompletionSuggestion assertSuggestGetter(String name, String returnType, | 190 CompletionSuggestion assertSuggestGetter(String name, String returnType, |
| 187 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, | 191 {CompletionRelevance relevance: CompletionRelevance.DEFAULT, |
| 188 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 192 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 193 bool isDeprecated: false}) { |
| 189 CompletionSuggestion cs = assertSuggest( | 194 CompletionSuggestion cs = assertSuggest( |
| 190 name, | 195 name, |
| 191 csKind: kind, | 196 csKind: kind, |
| 192 relevance: relevance, | 197 relevance: relevance, |
| 193 elemKind: protocol.ElementKind.GETTER); | 198 elemKind: protocol.ElementKind.GETTER, |
| 199 isDeprecated: isDeprecated); |
| 194 expect(cs.returnType, equals(returnType)); | 200 expect(cs.returnType, equals(returnType)); |
| 195 protocol.Element element = cs.element; | 201 protocol.Element element = cs.element; |
| 196 expect(element, isNotNull); | 202 expect(element, isNotNull); |
| 197 expect(element.kind, equals(protocol.ElementKind.GETTER)); | 203 expect(element.kind, equals(protocol.ElementKind.GETTER)); |
| 198 expect(element.name, equals(name)); | 204 expect(element.name, equals(name)); |
| 199 //TODO (danrubel) getter should have parameters | 205 //TODO (danrubel) getter should have parameters |
| 200 // but not used in code completion | 206 // but not used in code completion |
| 201 //expect(element.parameters, '()'); | 207 //expect(element.parameters, '()'); |
| 202 expect( | 208 expect( |
| 203 element.returnType, | 209 element.returnType, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 kind); | 510 kind); |
| 505 } else { | 511 } else { |
| 506 return assertNotSuggested(name); | 512 return assertNotSuggested(name); |
| 507 } | 513 } |
| 508 } | 514 } |
| 509 | 515 |
| 510 CompletionSuggestion assertSuggestImportedGetter(String name, | 516 CompletionSuggestion assertSuggestImportedGetter(String name, |
| 511 String returnType, [CompletionRelevance relevance = | 517 String returnType, [CompletionRelevance relevance = |
| 512 CompletionRelevance.DEFAULT]) { | 518 CompletionRelevance.DEFAULT]) { |
| 513 if (computer is ImportedComputer) { | 519 if (computer is ImportedComputer) { |
| 514 return assertSuggestGetter(name, returnType, relevance); | 520 return assertSuggestGetter(name, returnType, relevance: relevance); |
| 515 } else { | 521 } else { |
| 516 return assertNotSuggested(name); | 522 return assertNotSuggested(name); |
| 517 } | 523 } |
| 518 } | 524 } |
| 519 | 525 |
| 520 CompletionSuggestion assertSuggestImportedMethod(String name, | 526 CompletionSuggestion assertSuggestImportedMethod(String name, |
| 521 String declaringType, String returnType, [CompletionRelevance relevance = | 527 String declaringType, String returnType, [CompletionRelevance relevance = |
| 522 CompletionRelevance.DEFAULT]) { | 528 CompletionRelevance.DEFAULT]) { |
| 523 if (computer is ImportedComputer) { | 529 if (computer is ImportedComputer) { |
| 524 return assertSuggestMethod(name, declaringType, returnType, relevance); | 530 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 540 CompletionSuggestion assertSuggestInvocationClass(String name, | 546 CompletionSuggestion assertSuggestInvocationClass(String name, |
| 541 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { | 547 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { |
| 542 if (computer is InvocationComputer) { | 548 if (computer is InvocationComputer) { |
| 543 return assertSuggestClass(name, relevance); | 549 return assertSuggestClass(name, relevance); |
| 544 } else { | 550 } else { |
| 545 return assertNotSuggested(name); | 551 return assertNotSuggested(name); |
| 546 } | 552 } |
| 547 } | 553 } |
| 548 | 554 |
| 549 CompletionSuggestion assertSuggestInvocationGetter(String name, | 555 CompletionSuggestion assertSuggestInvocationGetter(String name, |
| 550 String returnType, [CompletionRelevance relevance = | 556 String returnType, {CompletionRelevance relevance: CompletionRelevance.DEF
AULT, |
| 551 CompletionRelevance.DEFAULT]) { | 557 bool isDeprecated: false}) { |
| 552 if (computer is InvocationComputer) { | 558 if (computer is InvocationComputer) { |
| 553 return assertSuggestGetter(name, returnType, relevance); | 559 return assertSuggestGetter( |
| 560 name, |
| 561 returnType, |
| 562 relevance: relevance, |
| 563 isDeprecated: isDeprecated); |
| 554 } else { | 564 } else { |
| 555 return assertNotSuggested(name); | 565 return assertNotSuggested(name); |
| 556 } | 566 } |
| 557 } | 567 } |
| 558 | 568 |
| 559 CompletionSuggestion assertSuggestInvocationMethod(String name, | 569 CompletionSuggestion assertSuggestInvocationMethod(String name, |
| 560 String declaringType, String returnType, [CompletionRelevance relevance = | 570 String declaringType, String returnType, [CompletionRelevance relevance = |
| 561 CompletionRelevance.DEFAULT]) { | 571 CompletionRelevance.DEFAULT]) { |
| 562 if (computer is InvocationComputer) { | 572 if (computer is InvocationComputer) { |
| 563 return assertSuggestMethod(name, declaringType, returnType, relevance); | 573 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 isDeprecated, | 633 isDeprecated, |
| 624 relevance); | 634 relevance); |
| 625 } else { | 635 } else { |
| 626 return assertNotSuggested(name); | 636 return assertNotSuggested(name); |
| 627 } | 637 } |
| 628 } | 638 } |
| 629 | 639 |
| 630 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, | 640 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, |
| 631 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { | 641 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { |
| 632 if (computer is LocalComputer) { | 642 if (computer is LocalComputer) { |
| 633 return assertSuggestGetter(name, returnType, relevance); | 643 return assertSuggestGetter(name, returnType, relevance: relevance); |
| 634 } else { | 644 } else { |
| 635 return assertNotSuggested(name); | 645 return assertNotSuggested(name); |
| 636 } | 646 } |
| 637 } | 647 } |
| 638 | 648 |
| 639 CompletionSuggestion assertSuggestLocalMethod(String name, | 649 CompletionSuggestion assertSuggestLocalMethod(String name, |
| 640 String declaringType, String returnType, [CompletionRelevance relevance = | 650 String declaringType, String returnType, [CompletionRelevance relevance = |
| 641 CompletionRelevance.DEFAULT]) { | 651 CompletionRelevance.DEFAULT]) { |
| 642 if (computer is LocalComputer) { | 652 if (computer is LocalComputer) { |
| 643 return assertSuggestMethod(name, declaringType, returnType, relevance); | 653 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| 644 } else { | 654 } else { |
| 645 return assertNotSuggested(name); | 655 return assertNotSuggested(name); |
| 646 } | 656 } |
| 647 } | 657 } |
| 648 | 658 |
| 649 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, | 659 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, |
| 650 String returnType, [CompletionRelevance relevance = | 660 String returnType, [CompletionRelevance relevance = |
| 651 CompletionRelevance.DEFAULT]) { | 661 CompletionRelevance.DEFAULT]) { |
| 652 if (computer is LocalComputer) { | 662 if (computer is LocalComputer) { |
| 653 return assertSuggestTopLevelVar(name, returnType, relevance); | 663 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 654 } else { | 664 } else { |
| 655 return assertNotSuggested(name); | 665 return assertNotSuggested(name); |
| 656 } | 666 } |
| 657 } | 667 } |
| 658 | 668 |
| 659 test_ArgumentList() { | 669 test_ArgumentList() { |
| 660 // ArgumentList MethodInvocation ExpressionStatement Block | 670 // ArgumentList MethodInvocation ExpressionStatement Block |
| 661 addSource('/libA.dart', ''' | 671 addSource('/libA.dart', ''' |
| 662 library A; | 672 library A; |
| 673 bool hasLength(int expected) { } |
| 674 void baz() { }'''); |
| 675 addTestSource(''' |
| 676 import '/libA.dart' |
| 677 String bar() => true; |
| 678 void main() {expect(^)}'''); |
| 679 computeFast(); |
| 680 return computeFull(true).then((_) { |
| 681 assertSuggestLocalFunction('bar', 'String'); |
| 682 assertSuggestImportedFunction('hasLength', 'bool'); |
| 683 assertNotSuggested('main'); |
| 684 assertNotSuggested('baz'); |
| 685 }); |
| 686 } |
| 687 |
| 688 test_ArgumentList_namedParam() { |
| 689 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation |
| 690 // ExpressionStatement |
| 691 addSource('/libA.dart', ''' |
| 692 library A; |
| 663 bool hasLength(int expected) { }'''); | 693 bool hasLength(int expected) { }'''); |
| 664 addTestSource(''' | 694 addTestSource(''' |
| 665 import '/libA.dart' | 695 import '/libA.dart' |
| 666 main() {expect(^)}'''); | 696 String bar() => true; |
| 697 void main() {expect(foo: ^)}'''); |
| 667 computeFast(); | 698 computeFast(); |
| 668 return computeFull(true).then((_) { | 699 return computeFull(true).then((_) { |
| 669 assertSuggestLocalFunction('main', null); | 700 assertSuggestLocalFunction('bar', 'String'); |
| 670 assertSuggestImportedFunction('hasLength', 'bool'); | 701 assertSuggestImportedFunction('hasLength', 'bool'); |
| 702 assertNotSuggested('main'); |
| 671 }); | 703 }); |
| 672 } | 704 } |
| 673 | 705 |
| 674 test_AssignmentExpression_name() { | 706 test_AssignmentExpression_name() { |
| 675 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 707 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 676 // VariableDeclarationStatement Block | 708 // VariableDeclarationStatement Block |
| 677 addTestSource('class A {} main() {int a; int ^b = 1;}'); | 709 addTestSource('class A {} main() {int a; int ^b = 1;}'); |
| 678 computeFast(); | 710 computeFast(); |
| 679 return computeFull(true).then((_) { | 711 return computeFull(true).then((_) { |
| 680 assertNoSuggestions(); | 712 assertNoSuggestions(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 assertSuggestLocalVariable('f', null); | 818 assertSuggestLocalVariable('f', null); |
| 787 // Don't suggest locals out of scope | 819 // Don't suggest locals out of scope |
| 788 assertNotSuggested('r'); | 820 assertNotSuggested('r'); |
| 789 assertNotSuggested('x'); | 821 assertNotSuggested('x'); |
| 790 | 822 |
| 791 assertSuggestImportedClass('A'); | 823 assertSuggestImportedClass('A'); |
| 792 assertNotSuggested('_B'); | 824 assertNotSuggested('_B'); |
| 793 assertSuggestImportedClass('C'); | 825 assertSuggestImportedClass('C'); |
| 794 // hidden element suggested as low relevance | 826 // hidden element suggested as low relevance |
| 795 assertSuggestImportedClass('D', CompletionRelevance.LOW); | 827 assertSuggestImportedClass('D', CompletionRelevance.LOW); |
| 796 assertSuggestImportedFunction('D1', null, true); | 828 assertSuggestImportedFunction('D1', null, true, CompletionRelevance.LOW); |
| 797 assertSuggestLocalFunction('D2', 'Z'); | 829 assertSuggestLocalFunction('D2', 'Z'); |
| 798 assertSuggestImportedClass('EE'); | 830 assertSuggestImportedClass('EE'); |
| 799 // hidden element suggested as low relevance | 831 // hidden element suggested as low relevance |
| 800 assertSuggestImportedClass('F', CompletionRelevance.LOW); | 832 assertSuggestImportedClass('F', CompletionRelevance.LOW); |
| 801 assertSuggestLibraryPrefix('g'); | 833 assertSuggestLibraryPrefix('g'); |
| 802 assertNotSuggested('G'); | 834 assertNotSuggested('G'); |
| 803 assertSuggestImportedClass('H', CompletionRelevance.LOW); | 835 assertSuggestImportedClass('H', CompletionRelevance.LOW); |
| 804 assertSuggestImportedClass('Object'); | 836 assertSuggestImportedClass('Object'); |
| 805 assertSuggestImportedFunction('min', 'num', false); | 837 assertSuggestImportedFunction('min', 'num', false); |
| 806 assertSuggestImportedFunction( | 838 assertSuggestImportedFunction( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 assertSuggestInvocationGetter('_c', 'X'); | 938 assertSuggestInvocationGetter('_c', 'X'); |
| 907 assertNotSuggested('Object'); | 939 assertNotSuggested('Object'); |
| 908 assertNotSuggested('A'); | 940 assertNotSuggested('A'); |
| 909 assertNotSuggested('B'); | 941 assertNotSuggested('B'); |
| 910 assertNotSuggested('X'); | 942 assertNotSuggested('X'); |
| 911 assertNotSuggested('z'); | 943 assertNotSuggested('z'); |
| 912 assertNotSuggested('=='); | 944 assertNotSuggested('=='); |
| 913 }); | 945 }); |
| 914 } | 946 } |
| 915 | 947 |
| 948 test_CascadeExpression_selector2_withTrailingReturn() { |
| 949 // PropertyAccess CascadeExpression ExpressionStatement Block |
| 950 addSource('/testB.dart', ''' |
| 951 class B { }'''); |
| 952 addTestSource(''' |
| 953 import "/testB.dart"; |
| 954 class A {var b; X _c;} |
| 955 class X{} |
| 956 main() {A a; a..^ return}'''); |
| 957 computeFast(); |
| 958 return computeFull(true).then((_) { |
| 959 assertSuggestInvocationGetter('b', null); |
| 960 assertSuggestInvocationGetter('_c', 'X'); |
| 961 assertNotSuggested('Object'); |
| 962 assertNotSuggested('A'); |
| 963 assertNotSuggested('B'); |
| 964 assertNotSuggested('X'); |
| 965 assertNotSuggested('z'); |
| 966 assertNotSuggested('=='); |
| 967 }); |
| 968 } |
| 969 |
| 916 test_CascadeExpression_target() { | 970 test_CascadeExpression_target() { |
| 917 // SimpleIdentifier CascadeExpression ExpressionStatement | 971 // SimpleIdentifier CascadeExpression ExpressionStatement |
| 918 addTestSource(''' | 972 addTestSource(''' |
| 919 class A {var b; X _c;} | 973 class A {var b; X _c;} |
| 920 class X{} | 974 class X{} |
| 921 main() {A a; a^..b}'''); | 975 main() {A a; a^..b}'''); |
| 922 computeFast(); | 976 computeFast(); |
| 923 return computeFull(true).then((_) { | 977 return computeFull(true).then((_) { |
| 924 assertNotSuggested('b'); | 978 assertNotSuggested('b'); |
| 925 assertNotSuggested('_c'); | 979 assertNotSuggested('_c'); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 // ClassDeclaration CompilationUnit | 1014 // ClassDeclaration CompilationUnit |
| 961 addSource('/testB.dart', ''' | 1015 addSource('/testB.dart', ''' |
| 962 class B { }'''); | 1016 class B { }'''); |
| 963 addTestSource(''' | 1017 addTestSource(''' |
| 964 import "testB.dart" as x; | 1018 import "testB.dart" as x; |
| 965 @deprecated class A {^} | 1019 @deprecated class A {^} |
| 966 class _B {} | 1020 class _B {} |
| 967 A T;'''); | 1021 A T;'''); |
| 968 computeFast(); | 1022 computeFast(); |
| 969 return computeFull(true).then((_) { | 1023 return computeFull(true).then((_) { |
| 970 CompletionSuggestion suggestionA = assertSuggestLocalClass('A'); | 1024 CompletionSuggestion suggestionA = |
| 1025 assertSuggestLocalClass('A', CompletionRelevance.LOW); |
| 971 if (suggestionA != null) { | 1026 if (suggestionA != null) { |
| 972 expect(suggestionA.element.isDeprecated, isTrue); | 1027 expect(suggestionA.element.isDeprecated, isTrue); |
| 973 expect(suggestionA.element.isPrivate, isFalse); | 1028 expect(suggestionA.element.isPrivate, isFalse); |
| 974 } | 1029 } |
| 975 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); | 1030 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); |
| 976 if (suggestionB != null) { | 1031 if (suggestionB != null) { |
| 977 expect(suggestionB.element.isDeprecated, isFalse); | 1032 expect(suggestionB.element.isDeprecated, isFalse); |
| 978 expect(suggestionB.element.isPrivate, isTrue); | 1033 expect(suggestionB.element.isPrivate, isTrue); |
| 979 } | 1034 } |
| 980 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); | 1035 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 test_MethodDeclaration_body_getters() { | 1514 test_MethodDeclaration_body_getters() { |
| 1460 // Block BlockFunctionBody MethodDeclaration | 1515 // Block BlockFunctionBody MethodDeclaration |
| 1461 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); | 1516 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); |
| 1462 computeFast(); | 1517 computeFast(); |
| 1463 return computeFull(true).then((_) { | 1518 return computeFull(true).then((_) { |
| 1464 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | 1519 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); |
| 1465 if (methodA != null) { | 1520 if (methodA != null) { |
| 1466 expect(methodA.element.isDeprecated, isFalse); | 1521 expect(methodA.element.isDeprecated, isFalse); |
| 1467 expect(methodA.element.isPrivate, isFalse); | 1522 expect(methodA.element.isPrivate, isFalse); |
| 1468 } | 1523 } |
| 1469 CompletionSuggestion getterF = assertSuggestLocalGetter('f', 'X'); | 1524 CompletionSuggestion getterF = |
| 1525 assertSuggestLocalGetter('f', 'X', CompletionRelevance.LOW); |
| 1470 if (getterF != null) { | 1526 if (getterF != null) { |
| 1471 expect(getterF.element.isDeprecated, isTrue); | 1527 expect(getterF.element.isDeprecated, isTrue); |
| 1472 expect(getterF.element.isPrivate, isFalse); | 1528 expect(getterF.element.isPrivate, isFalse); |
| 1473 } | 1529 } |
| 1474 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); | 1530 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); |
| 1475 if (getterG != null) { | 1531 if (getterG != null) { |
| 1476 expect(getterG.element.isDeprecated, isFalse); | 1532 expect(getterG.element.isDeprecated, isFalse); |
| 1477 expect(getterG.element.isPrivate, isTrue); | 1533 expect(getterG.element.isPrivate, isTrue); |
| 1478 } | 1534 } |
| 1479 }); | 1535 }); |
| 1480 } | 1536 } |
| 1481 | 1537 |
| 1482 test_MethodDeclaration_members() { | 1538 test_MethodDeclaration_members() { |
| 1483 // Block BlockFunctionBody MethodDeclaration | 1539 // Block BlockFunctionBody MethodDeclaration |
| 1484 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | 1540 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); |
| 1485 computeFast(); | 1541 computeFast(); |
| 1486 return computeFull(true).then((_) { | 1542 return computeFull(true).then((_) { |
| 1487 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); | 1543 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); |
| 1488 if (methodA != null) { | 1544 if (methodA != null) { |
| 1489 expect(methodA.element.isDeprecated, isFalse); | 1545 expect(methodA.element.isDeprecated, isFalse); |
| 1490 expect(methodA.element.isPrivate, isTrue); | 1546 expect(methodA.element.isPrivate, isTrue); |
| 1491 } | 1547 } |
| 1492 CompletionSuggestion getterF = assertSuggestLocalGetter('f', 'X'); | 1548 CompletionSuggestion getterF = |
| 1549 assertSuggestLocalGetter('f', 'X', CompletionRelevance.LOW); |
| 1493 if (getterF != null) { | 1550 if (getterF != null) { |
| 1494 expect(getterF.element.isDeprecated, isTrue); | 1551 expect(getterF.element.isDeprecated, isTrue); |
| 1495 expect(getterF.element.isPrivate, isFalse); | 1552 expect(getterF.element.isPrivate, isFalse); |
| 1496 } | 1553 } |
| 1497 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); | 1554 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); |
| 1498 if (getterG != null) { | 1555 if (getterG != null) { |
| 1499 expect(getterG.element.isDeprecated, isFalse); | 1556 expect(getterG.element.isDeprecated, isFalse); |
| 1500 expect(getterG.element.isPrivate, isTrue); | 1557 expect(getterG.element.isPrivate, isTrue); |
| 1501 } | 1558 } |
| 1502 assertSuggestImportedClass('bool'); | 1559 assertSuggestImportedClass('bool'); |
| 1503 }); | 1560 }); |
| 1504 } | 1561 } |
| 1505 | 1562 |
| 1506 test_MethodDeclaration_parameters_named() { | 1563 test_MethodDeclaration_parameters_named() { |
| 1507 // Block BlockFunctionBody MethodDeclaration | 1564 // Block BlockFunctionBody MethodDeclaration |
| 1508 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); | 1565 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); |
| 1509 computeFast(); | 1566 computeFast(); |
| 1510 return computeFull(true).then((_) { | 1567 return computeFull(true).then((_) { |
| 1511 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | 1568 CompletionSuggestion methodA = |
| 1569 assertSuggestLocalMethod('a', 'A', 'Z', CompletionRelevance.LOW); |
| 1512 if (methodA != null) { | 1570 if (methodA != null) { |
| 1513 expect(methodA.element.isDeprecated, isTrue); | 1571 expect(methodA.element.isDeprecated, isTrue); |
| 1514 expect(methodA.element.isPrivate, isFalse); | 1572 expect(methodA.element.isPrivate, isFalse); |
| 1515 } | 1573 } |
| 1516 assertSuggestParameter('x', 'X'); | 1574 assertSuggestParameter('x', 'X'); |
| 1517 assertSuggestParameter('y', null); | 1575 assertSuggestParameter('y', null); |
| 1518 assertSuggestParameter('b', null); | 1576 assertSuggestParameter('b', null); |
| 1519 assertSuggestImportedClass('int'); | 1577 assertSuggestImportedClass('int'); |
| 1520 assertNotSuggested('_'); | 1578 assertNotSuggested('_'); |
| 1521 }); | 1579 }); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 }); | 1673 }); |
| 1616 } | 1674 } |
| 1617 | 1675 |
| 1618 test_PrefixedIdentifier_class_imported() { | 1676 test_PrefixedIdentifier_class_imported() { |
| 1619 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 1677 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 1620 addSource('/testB.dart', ''' | 1678 addSource('/testB.dart', ''' |
| 1621 lib B; | 1679 lib B; |
| 1622 class I {X get f => new A();get _g => new A();} | 1680 class I {X get f => new A();get _g => new A();} |
| 1623 class A implements I { | 1681 class A implements I { |
| 1624 static const int sc = 12; | 1682 static const int sc = 12; |
| 1625 var b; X _c; | 1683 @deprecated var b; X _c; |
| 1626 X get d => new A();get _e => new A(); | 1684 X get d => new A();get _e => new A(); |
| 1627 set s1(I x) {} set _s2(I x) {} | 1685 set s1(I x) {} set _s2(I x) {} |
| 1628 m(X x) {} I _n(X x) {}} | 1686 m(X x) {} I _n(X x) {}} |
| 1629 class X{}'''); | 1687 class X{}'''); |
| 1630 addTestSource(''' | 1688 addTestSource(''' |
| 1631 import "/testB.dart"; | 1689 import "/testB.dart"; |
| 1632 main() {A a; a.^}'''); | 1690 main() {A a; a.^}'''); |
| 1633 computeFast(); | 1691 computeFast(); |
| 1634 return computeFull(true).then((_) { | 1692 return computeFull(true).then((_) { |
| 1635 assertSuggestInvocationGetter('sc', 'int'); | 1693 assertSuggestInvocationGetter('sc', 'int'); |
| 1636 assertSuggestInvocationGetter('b', null); | 1694 assertSuggestInvocationGetter('b', null, isDeprecated: true); |
| 1637 assertNotSuggested('_c'); | 1695 assertNotSuggested('_c'); |
| 1638 assertSuggestInvocationGetter('d', 'X'); | 1696 assertSuggestInvocationGetter('d', 'X'); |
| 1639 assertNotSuggested('_e'); | 1697 assertNotSuggested('_e'); |
| 1640 assertSuggestInvocationGetter('f', 'X'); | 1698 assertSuggestInvocationGetter('f', 'X'); |
| 1641 assertNotSuggested('_g'); | 1699 assertNotSuggested('_g'); |
| 1642 assertSuggestInvocationSetter('s1'); | 1700 assertSuggestInvocationSetter('s1'); |
| 1643 assertNotSuggested('_s2'); | 1701 assertNotSuggested('_s2'); |
| 1644 assertSuggestInvocationMethod('m', 'A', null); | 1702 assertSuggestInvocationMethod('m', 'A', null); |
| 1645 assertNotSuggested('_n'); | 1703 assertNotSuggested('_n'); |
| 1646 assertNotSuggested('a'); | 1704 assertNotSuggested('a'); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 assertNotSuggested('bar2'); | 1925 assertNotSuggested('bar2'); |
| 1868 assertNotSuggested('_B'); | 1926 assertNotSuggested('_B'); |
| 1869 assertSuggestLocalClass('Y'); | 1927 assertSuggestLocalClass('Y'); |
| 1870 assertSuggestLocalClass('C'); | 1928 assertSuggestLocalClass('C'); |
| 1871 assertSuggestLocalVariable('f', null); | 1929 assertSuggestLocalVariable('f', null); |
| 1872 assertNotSuggested('x'); | 1930 assertNotSuggested('x'); |
| 1873 assertNotSuggested('e'); | 1931 assertNotSuggested('e'); |
| 1874 }); | 1932 }); |
| 1875 } | 1933 } |
| 1876 } | 1934 } |
| OLD | NEW |