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.invocation; | 5 library test.services.completion.invocation; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 .toList(); | 54 .toList(); |
55 if (shouldBeShadowed) { | 55 if (shouldBeShadowed) { |
56 expect(suggestionsForX, hasLength(1)); | 56 expect(suggestionsForX, hasLength(1)); |
57 expect(suggestionsForX[0].declaringType, 'Derived'); | 57 expect(suggestionsForX[0].declaringType, 'Derived'); |
58 } else { | 58 } else { |
59 expect(suggestionsForX, hasLength(2)); | 59 expect(suggestionsForX, hasLength(2)); |
60 } | 60 } |
61 }); | 61 }); |
62 } | 62 } |
63 | 63 |
64 fail_enumConst_deprecated() { | |
65 addTestSource('@deprecated enum E { one, two } main() {E.^}'); | |
66 return computeFull((bool result) { | |
67 assertNotSuggested('E'); | |
68 // TODO(danrubel) Investigate why enum suggestion is not marked | |
69 // as deprecated if enum ast element is deprecated | |
70 assertSuggestEnumConst('one', isDeprecated: true); | |
71 assertSuggestEnumConst('two', isDeprecated: true); | |
72 assertNotSuggested('index'); | |
73 assertSuggestField('values', 'List<E>', isDeprecated: true); | |
74 }); | |
75 } | |
76 | |
77 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { | 64 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { |
78 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 65 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
79 addTestSource('const g = "hello"; f() {g.^ int y = 0;}'); | 66 addTestSource('const g = "hello"; f() {g.^ int y = 0;}'); |
80 computeFast(); | 67 computeFast(); |
81 return computeFull((bool result) { | 68 return computeFull((bool result) { |
82 assertSuggestInvocationGetter('length', 'int'); | 69 assertSuggestInvocationGetter('length', 'int'); |
83 }); | 70 }); |
84 } | 71 } |
85 | 72 |
86 @override | 73 @override |
87 void setUpContributor() { | 74 void setUpContributor() { |
88 contributor = new PrefixedElementContributor(); | 75 contributor = new PrefixedElementContributor(); |
89 } | 76 } |
90 | 77 |
91 test_enumConst() { | 78 test_enumConst() { |
92 addTestSource('enum E { one, two } main() {E.^}'); | 79 addTestSource('enum E { one, two } main() {E.^}'); |
93 return computeFull((bool result) { | 80 return computeFull((bool result) { |
94 assertNotSuggested('E'); | 81 assertNotSuggested('E'); |
95 assertSuggestEnumConst('one'); | 82 // Suggested by StaticMemberContributor |
96 assertSuggestEnumConst('two'); | 83 assertNotSuggested('one'); |
| 84 assertNotSuggested('two'); |
97 assertNotSuggested('index'); | 85 assertNotSuggested('index'); |
98 assertSuggestField('values', 'List<E>'); | 86 assertNotSuggested('values'); |
99 }); | 87 }); |
100 } | 88 } |
101 | 89 |
102 test_enumConst2() { | 90 test_enumConst2() { |
103 addTestSource('enum E { one, two } main() {E.o^}'); | 91 addTestSource('enum E { one, two } main() {E.o^}'); |
104 return computeFull((bool result) { | 92 return computeFull((bool result) { |
105 assertNotSuggested('E'); | 93 assertNotSuggested('E'); |
106 assertSuggestEnumConst('one'); | 94 // Suggested by StaticMemberContributor |
107 assertSuggestEnumConst('two'); | 95 assertNotSuggested('one'); |
| 96 assertNotSuggested('two'); |
108 assertNotSuggested('index'); | 97 assertNotSuggested('index'); |
109 assertSuggestField('values', 'List<E>'); | 98 assertNotSuggested('values'); |
110 }); | 99 }); |
111 } | 100 } |
112 | 101 |
113 test_enumConst3() { | 102 test_enumConst3() { |
114 addTestSource('enum E { one, two } main() {E.^ int g;}'); | 103 addTestSource('enum E { one, two } main() {E.^ int g;}'); |
115 return computeFull((bool result) { | 104 return computeFull((bool result) { |
116 assertNotSuggested('E'); | 105 assertNotSuggested('E'); |
117 assertSuggestEnumConst('one'); | 106 // Suggested by StaticMemberContributor |
118 assertSuggestEnumConst('two'); | 107 assertNotSuggested('one'); |
| 108 assertNotSuggested('two'); |
119 assertNotSuggested('index'); | 109 assertNotSuggested('index'); |
120 assertSuggestField('values', 'List<E>'); | 110 assertNotSuggested('values'); |
121 }); | 111 }); |
122 } | 112 } |
123 | 113 |
124 test_enumConst_index() { | 114 test_enumConst_index() { |
125 addTestSource('enum E { one, two } main() {E.one.^}'); | 115 addTestSource('enum E { one, two } main() {E.one.^}'); |
126 return computeFull((bool result) { | 116 return computeFull((bool result) { |
127 assertNotSuggested('E'); | 117 assertNotSuggested('E'); |
128 assertNotSuggested('one'); | 118 assertNotSuggested('one'); |
129 assertNotSuggested('two'); | 119 assertNotSuggested('two'); |
130 assertSuggestField('index', 'int'); | 120 assertSuggestField('index', 'int'); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // as a parmeter to it, and it will check the appropriate field in | 203 // as a parmeter to it, and it will check the appropriate field in |
214 // the suggestion object. | 204 // the suggestion object. |
215 CompletionSuggestion suggestion = assertSuggestSetter('t'); | 205 CompletionSuggestion suggestion = assertSuggestSetter('t'); |
216 expect(suggestion.element.parameters, '(int value)'); | 206 expect(suggestion.element.parameters, '(int value)'); |
217 }); | 207 }); |
218 } | 208 } |
219 | 209 |
220 test_keyword() { | 210 test_keyword() { |
221 addTestSource('class C { static C get instance => null; } main() {C.in^}'); | 211 addTestSource('class C { static C get instance => null; } main() {C.in^}'); |
222 return computeFull((bool result) { | 212 return computeFull((bool result) { |
223 assertSuggestGetter('instance', 'C'); | 213 // Suggested by StaticMemberContributor |
| 214 assertNotSuggested('instance'); |
224 }); | 215 }); |
225 } | 216 } |
226 | 217 |
227 test_libraryPrefix() { | 218 test_libraryPrefix() { |
228 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 219 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
229 addTestSource('import "dart:async" as bar; foo() {bar.^}'); | 220 addTestSource('import "dart:async" as bar; foo() {bar.^}'); |
230 return computeFull((bool result) { | 221 return computeFull((bool result) { |
231 assertSuggestClass('Future'); | 222 assertSuggestClass('Future'); |
232 assertNotSuggested('loadLibrary'); | 223 assertNotSuggested('loadLibrary'); |
233 }); | 224 }); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 addTestSource(''' | 465 addTestSource(''' |
475 class C { | 466 class C { |
476 int f1; | 467 int f1; |
477 static int f2; | 468 static int f2; |
478 m1() {} | 469 m1() {} |
479 static m2() {} | 470 static m2() {} |
480 } | 471 } |
481 void main() {C.^}'''); | 472 void main() {C.^}'''); |
482 return computeFull((bool result) { | 473 return computeFull((bool result) { |
483 assertNotSuggested('f1'); | 474 assertNotSuggested('f1'); |
484 assertSuggestInvocationField('f2', 'int'); | 475 // Suggested by StaticMemberContributor |
| 476 assertNotSuggested('f2'); |
485 assertNotSuggested('m1'); | 477 assertNotSuggested('m1'); |
486 assertSuggestMethod('m2', 'C', null); | 478 assertNotSuggested('m2'); |
487 }); | 479 }); |
488 } | 480 } |
489 | 481 |
490 test_only_static2() { | 482 test_only_static2() { |
491 // SimpleIdentifier MethodInvocation ExpressionStatement | 483 // SimpleIdentifier MethodInvocation ExpressionStatement |
492 addTestSource(''' | 484 addTestSource(''' |
493 class C { | 485 class C { |
494 int f1; | 486 int f1; |
495 static int f2; | 487 static int f2; |
496 m1() {} | 488 m1() {} |
497 static m2() {} | 489 static m2() {} |
498 } | 490 } |
499 void main() {C.^ print("something");}'''); | 491 void main() {C.^ print("something");}'''); |
500 return computeFull((bool result) { | 492 return computeFull((bool result) { |
501 assertNotSuggested('f1'); | 493 assertNotSuggested('f1'); |
502 assertSuggestInvocationField('f2', 'int'); | 494 // Suggested by StaticMemberContributor |
| 495 assertNotSuggested('f2'); |
503 assertNotSuggested('m1'); | 496 assertNotSuggested('m1'); |
504 assertSuggestMethod('m2', 'C', null); | 497 assertNotSuggested('m2'); |
505 }); | 498 }); |
506 } | 499 } |
507 | 500 |
508 test_param() { | 501 test_param() { |
509 addTestSource('foo(String x) {x.^}'); | 502 addTestSource('foo(String x) {x.^}'); |
510 return computeFull((bool result) { | 503 return computeFull((bool result) { |
511 assertSuggestGetter('length', 'int'); | 504 assertSuggestGetter('length', 'int'); |
512 }); | 505 }); |
513 } | 506 } |
514 | 507 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 assertNotSuggested('ms2'); | 659 assertNotSuggested('ms2'); |
667 assertSuggestInvocationMethod('m', 'C2', null, | 660 assertSuggestInvocationMethod('m', 'C2', null, |
668 relevance: DART_RELEVANCE_HIGH); | 661 relevance: DART_RELEVANCE_HIGH); |
669 assertNotSuggested('fi3'); | 662 assertNotSuggested('fi3'); |
670 assertNotSuggested('fs3'); | 663 assertNotSuggested('fs3'); |
671 assertNotSuggested('mi3'); | 664 assertNotSuggested('mi3'); |
672 assertNotSuggested('ms3'); | 665 assertNotSuggested('ms3'); |
673 }); | 666 }); |
674 } | 667 } |
675 } | 668 } |
OLD | NEW |