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/src/protocol.dart'; | 9 import 'package:analysis_server/src/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 .toList(); | 53 .toList(); |
54 if (shouldBeShadowed) { | 54 if (shouldBeShadowed) { |
55 expect(suggestionsForX, hasLength(1)); | 55 expect(suggestionsForX, hasLength(1)); |
56 expect(suggestionsForX[0].declaringType, 'Derived'); | 56 expect(suggestionsForX[0].declaringType, 'Derived'); |
57 } else { | 57 } else { |
58 expect(suggestionsForX, hasLength(2)); | 58 expect(suggestionsForX, hasLength(2)); |
59 } | 59 } |
60 }); | 60 }); |
61 } | 61 } |
62 | 62 |
| 63 fail_enumConst_deprecated() { |
| 64 addTestSource('@deprecated enum E { one, two } main() {E.^}'); |
| 65 return computeFull((bool result) { |
| 66 assertNotSuggested('E'); |
| 67 // TODO(danrubel) Investigate why enum suggestion is not marked |
| 68 // as deprecated if enum ast element is deprecated |
| 69 assertSuggestEnumConst('one', isDeprecated: true); |
| 70 assertSuggestEnumConst('two', isDeprecated: true); |
| 71 assertNotSuggested('index'); |
| 72 assertSuggestField('values', 'List<E>', isDeprecated: true); |
| 73 }); |
| 74 } |
| 75 |
63 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { | 76 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { |
64 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 77 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
65 addTestSource('const g = "hello"; f() {g.^ int y = 0;}'); | 78 addTestSource('const g = "hello"; f() {g.^ int y = 0;}'); |
66 computeFast(); | 79 computeFast(); |
67 return computeFull((bool result) { | 80 return computeFull((bool result) { |
68 assertSuggestInvocationGetter('length', 'int'); | 81 assertSuggestInvocationGetter('length', 'int'); |
69 }); | 82 }); |
70 } | 83 } |
71 | 84 |
72 @override | 85 @override |
73 void setUpContributor() { | 86 void setUpContributor() { |
74 contributor = new PrefixedElementContributor(); | 87 contributor = new PrefixedElementContributor(); |
75 } | 88 } |
76 | 89 |
| 90 test_enumConst() { |
| 91 addTestSource('enum E { one, two } main() {E.^}'); |
| 92 return computeFull((bool result) { |
| 93 assertNotSuggested('E'); |
| 94 assertSuggestEnumConst('one'); |
| 95 assertSuggestEnumConst('two'); |
| 96 assertNotSuggested('index'); |
| 97 assertSuggestField('values', 'List<E>'); |
| 98 }); |
| 99 } |
| 100 |
| 101 test_enumConst2() { |
| 102 addTestSource('enum E { one, two } main() {E.o^}'); |
| 103 return computeFull((bool result) { |
| 104 assertNotSuggested('E'); |
| 105 assertSuggestEnumConst('one'); |
| 106 assertSuggestEnumConst('two'); |
| 107 assertNotSuggested('index'); |
| 108 assertSuggestField('values', 'List<E>'); |
| 109 }); |
| 110 } |
| 111 |
| 112 test_enumConst3() { |
| 113 addTestSource('enum E { one, two } main() {E.^ int g;}'); |
| 114 return computeFull((bool result) { |
| 115 assertNotSuggested('E'); |
| 116 assertSuggestEnumConst('one'); |
| 117 assertSuggestEnumConst('two'); |
| 118 assertNotSuggested('index'); |
| 119 assertSuggestField('values', 'List<E>'); |
| 120 }); |
| 121 } |
| 122 |
| 123 test_enumConst_index() { |
| 124 addTestSource('enum E { one, two } main() {E.one.^}'); |
| 125 return computeFull((bool result) { |
| 126 assertNotSuggested('E'); |
| 127 assertNotSuggested('one'); |
| 128 assertNotSuggested('two'); |
| 129 assertSuggestField('index', 'int'); |
| 130 assertNotSuggested('values'); |
| 131 }); |
| 132 } |
| 133 |
| 134 test_enumConst_index2() { |
| 135 addTestSource('enum E { one, two } main() {E.one.i^}'); |
| 136 return computeFull((bool result) { |
| 137 assertNotSuggested('E'); |
| 138 assertNotSuggested('one'); |
| 139 assertNotSuggested('two'); |
| 140 assertSuggestField('index', 'int'); |
| 141 assertNotSuggested('values'); |
| 142 }); |
| 143 } |
| 144 |
| 145 test_enumConst_index3() { |
| 146 addTestSource('enum E { one, two } main() {E.one.^ int g;}'); |
| 147 return computeFull((bool result) { |
| 148 assertNotSuggested('E'); |
| 149 assertNotSuggested('one'); |
| 150 assertNotSuggested('two'); |
| 151 assertSuggestField('index', 'int'); |
| 152 assertNotSuggested('values'); |
| 153 }); |
| 154 } |
| 155 |
77 test_generic_field() { | 156 test_generic_field() { |
78 addTestSource(''' | 157 addTestSource(''' |
79 class C<T> { | 158 class C<T> { |
80 T t; | 159 T t; |
81 } | 160 } |
82 void f(C<int> c) { | 161 void f(C<int> c) { |
83 c.^ | 162 c.^ |
84 } | 163 } |
85 '''); | 164 '''); |
86 return computeFull((bool result) { | 165 return computeFull((bool result) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 assertNotSuggested('ms2'); | 638 assertNotSuggested('ms2'); |
560 assertSuggestInvocationMethod('m', 'C2', null, | 639 assertSuggestInvocationMethod('m', 'C2', null, |
561 relevance: DART_RELEVANCE_HIGH); | 640 relevance: DART_RELEVANCE_HIGH); |
562 assertNotSuggested('fi3'); | 641 assertNotSuggested('fi3'); |
563 assertNotSuggested('fs3'); | 642 assertNotSuggested('fs3'); |
564 assertNotSuggested('mi3'); | 643 assertNotSuggested('mi3'); |
565 assertNotSuggested('ms3'); | 644 assertNotSuggested('ms3'); |
566 }); | 645 }); |
567 } | 646 } |
568 } | 647 } |
OLD | NEW |