@@ -16,7 +16,6 @@ import 'completion_contributor_util.dart';
16
16
void main () {
17
17
defineReflectiveSuite (() {
18
18
defineReflectiveTests (KeywordContributorTest );
19
- defineReflectiveTests (KeywordContributorWithExtensionMethodsTest );
20
19
defineReflectiveTests (KeywordContributorWithNnbdTest );
21
20
});
22
21
}
@@ -91,14 +90,12 @@ class KeywordContributorTest extends DartCompletionContributorTest {
91
90
Keyword .CONST ,
92
91
Keyword .COVARIANT ,
93
92
Keyword .DYNAMIC ,
93
+ Keyword .EXTENSION ,
94
94
Keyword .FINAL ,
95
95
Keyword .TYPEDEF ,
96
96
Keyword .VAR ,
97
97
Keyword .VOID
98
98
];
99
- if (isEnabled (ExperimentalFeatures .extension_methods)) {
100
- keywords.add (Keyword .EXTENSION );
101
- }
102
99
if (isEnabled (ExperimentalFeatures .non_nullable)) {
103
100
keywords.add (Keyword .LATE );
104
101
}
@@ -113,16 +110,14 @@ class KeywordContributorTest extends DartCompletionContributorTest {
113
110
Keyword .COVARIANT ,
114
111
Keyword .DYNAMIC ,
115
112
Keyword .EXPORT ,
113
+ Keyword .EXTENSION ,
116
114
Keyword .FINAL ,
117
115
Keyword .IMPORT ,
118
116
Keyword .PART ,
119
117
Keyword .TYPEDEF ,
120
118
Keyword .VAR ,
121
119
Keyword .VOID
122
120
];
123
- if (isEnabled (ExperimentalFeatures .extension_methods)) {
124
- keywords.add (Keyword .EXTENSION );
125
- }
126
121
if (isEnabled (ExperimentalFeatures .non_nullable)) {
127
122
keywords.add (Keyword .LATE );
128
123
}
@@ -145,16 +140,32 @@ class KeywordContributorTest extends DartCompletionContributorTest {
145
140
Keyword .COVARIANT ,
146
141
Keyword .DYNAMIC ,
147
142
Keyword .EXPORT ,
143
+ Keyword .EXTENSION ,
148
144
Keyword .FINAL ,
149
145
Keyword .IMPORT ,
150
146
Keyword .PART ,
151
147
Keyword .TYPEDEF ,
152
148
Keyword .VAR ,
153
149
Keyword .VOID
154
150
];
155
- if (isEnabled (ExperimentalFeatures .extension_methods )) {
156
- keywords.add (Keyword .EXTENSION );
151
+ if (isEnabled (ExperimentalFeatures .non_nullable )) {
152
+ keywords.add (Keyword .LATE );
157
153
}
154
+ return keywords;
155
+ }
156
+
157
+ List <Keyword > get extensionBodyKeywords {
158
+ var keywords = [
159
+ Keyword .CONST ,
160
+ Keyword .DYNAMIC ,
161
+ Keyword .FINAL ,
162
+ Keyword .GET ,
163
+ Keyword .OPERATOR ,
164
+ Keyword .SET ,
165
+ Keyword .STATIC ,
166
+ Keyword .VAR ,
167
+ Keyword .VOID
168
+ ];
158
169
if (isEnabled (ExperimentalFeatures .non_nullable)) {
159
170
keywords.add (Keyword .LATE );
160
171
}
@@ -859,6 +870,12 @@ class KeywordContributorTest extends DartCompletionContributorTest {
859
870
assertSuggestKeywords (classBodyKeywords);
860
871
}
861
872
873
+ Future <void > test_class_body_empty () async {
874
+ addTestSource ('extension E on int {^}' );
875
+ await computeSuggestions ();
876
+ assertSuggestKeywords (extensionBodyKeywords);
877
+ }
878
+
862
879
Future <void > test_class_body_end () async {
863
880
addTestSource ('class A {var foo; ^}' );
864
881
await computeSuggestions ();
@@ -1075,6 +1092,56 @@ class C {
1075
1092
relevance: DART_RELEVANCE_HIGH );
1076
1093
}
1077
1094
1095
+ Future <void > test_extension_body_beginning () async {
1096
+ addTestSource ('extension E on int {^ foo() {}}' );
1097
+ await computeSuggestions ();
1098
+ assertSuggestKeywords (extensionBodyKeywords);
1099
+ }
1100
+
1101
+ Future <void > test_extension_body_between () async {
1102
+ addTestSource ('extension E on int {foo() {} ^ void bar() {}}' );
1103
+ await computeSuggestions ();
1104
+ assertSuggestKeywords (extensionBodyKeywords);
1105
+ }
1106
+
1107
+ Future <void > test_extension_body_end () async {
1108
+ addTestSource ('extension E on int {foo() {} ^}' );
1109
+ await computeSuggestions ();
1110
+ assertSuggestKeywords (extensionBodyKeywords);
1111
+ }
1112
+
1113
+ Future <void > test_extension_member_const_afterStatic () async {
1114
+ addTestSource ('''
1115
+ extension E on int {
1116
+ static c^
1117
+ }
1118
+ ''' );
1119
+ await computeSuggestions ();
1120
+ assertSuggestKeywords (staticMember);
1121
+ }
1122
+
1123
+ Future <void > test_extension_member_final_afterStatic () async {
1124
+ addTestSource ('''
1125
+ extension E on int {
1126
+ static f^
1127
+ }
1128
+ ''' );
1129
+ await computeSuggestions ();
1130
+ assertSuggestKeywords (staticMember);
1131
+ }
1132
+
1133
+ Future <void > test_extension_noBody_named () async {
1134
+ addTestSource ('extension E ^' );
1135
+ await computeSuggestions ();
1136
+ assertSuggestKeywords ([Keyword .ON ], relevance: DART_RELEVANCE_HIGH );
1137
+ }
1138
+
1139
+ Future <void > test_extension_noBody_unnamed () async {
1140
+ addTestSource ('extension ^' );
1141
+ await computeSuggestions ();
1142
+ assertSuggestKeywords ([Keyword .ON ], relevance: DART_RELEVANCE_HIGH );
1143
+ }
1144
+
1078
1145
Future <void > test_for_break_continue_insideClass () async {
1079
1146
addTestSource ('class A {foo() {for (int x in myList) {^}}}' );
1080
1147
await computeSuggestions ();
@@ -2026,6 +2093,19 @@ f() => <int>{1, ^, 2};
2026
2093
assertSuggestKeywords (methodParameter);
2027
2094
}
2028
2095
2096
+ Future <void > test_method_type_params () async {
2097
+ addTestSource ('''
2098
+ void f<T>() {}
2099
+
2100
+ void m() {
2101
+ f<^>();
2102
+ }
2103
+ ''' );
2104
+
2105
+ await computeSuggestions ();
2106
+ assertSuggestKeywords ([Keyword .DYNAMIC , Keyword .VOID ]);
2107
+ }
2108
+
2029
2109
Future <void > test_mixin () async {
2030
2110
addTestSource ('mixin M o^ { }' );
2031
2111
await computeSuggestions ();
@@ -2267,97 +2347,6 @@ f() => [...^];
2267
2347
}
2268
2348
}
2269
2349
2270
- @reflectiveTest
2271
- class KeywordContributorWithExtensionMethodsTest
2272
- extends KeywordContributorTest {
2273
- List <Keyword > get extensionBodyKeywords => [
2274
- Keyword .CONST ,
2275
- Keyword .DYNAMIC ,
2276
- Keyword .FINAL ,
2277
- Keyword .GET ,
2278
- Keyword .OPERATOR ,
2279
- Keyword .SET ,
2280
- Keyword .STATIC ,
2281
- Keyword .VAR ,
2282
- Keyword .VOID
2283
- ];
2284
-
2285
- @override
2286
- void setupResourceProvider () {
2287
- super .setupResourceProvider ();
2288
- createAnalysisOptionsFile (experiments: [EnableString .extension_methods]);
2289
- }
2290
-
2291
- Future <void > test_class_body_empty () async {
2292
- addTestSource ('extension E on int {^}' );
2293
- await computeSuggestions ();
2294
- assertSuggestKeywords (extensionBodyKeywords);
2295
- }
2296
-
2297
- Future <void > test_extension_body_beginning () async {
2298
- addTestSource ('extension E on int {^ foo() {}}' );
2299
- await computeSuggestions ();
2300
- assertSuggestKeywords (extensionBodyKeywords);
2301
- }
2302
-
2303
- Future <void > test_extension_body_between () async {
2304
- addTestSource ('extension E on int {foo() {} ^ void bar() {}}' );
2305
- await computeSuggestions ();
2306
- assertSuggestKeywords (extensionBodyKeywords);
2307
- }
2308
-
2309
- Future <void > test_extension_body_end () async {
2310
- addTestSource ('extension E on int {foo() {} ^}' );
2311
- await computeSuggestions ();
2312
- assertSuggestKeywords (extensionBodyKeywords);
2313
- }
2314
-
2315
- Future <void > test_extension_member_const_afterStatic () async {
2316
- addTestSource ('''
2317
- extension E on int {
2318
- static c^
2319
- }
2320
- ''' );
2321
- await computeSuggestions ();
2322
- assertSuggestKeywords (staticMember);
2323
- }
2324
-
2325
- Future <void > test_extension_member_final_afterStatic () async {
2326
- addTestSource ('''
2327
- extension E on int {
2328
- static f^
2329
- }
2330
- ''' );
2331
- await computeSuggestions ();
2332
- assertSuggestKeywords (staticMember);
2333
- }
2334
-
2335
- Future <void > test_extension_noBody_named () async {
2336
- addTestSource ('extension E ^' );
2337
- await computeSuggestions ();
2338
- assertSuggestKeywords ([Keyword .ON ], relevance: DART_RELEVANCE_HIGH );
2339
- }
2340
-
2341
- Future <void > test_extension_noBody_unnamed () async {
2342
- addTestSource ('extension ^' );
2343
- await computeSuggestions ();
2344
- assertSuggestKeywords ([Keyword .ON ], relevance: DART_RELEVANCE_HIGH );
2345
- }
2346
-
2347
- Future <void > test_method_type_params () async {
2348
- addTestSource ('''
2349
- void f<T>() {}
2350
-
2351
- void m() {
2352
- f<^>();
2353
- }
2354
- ''' );
2355
-
2356
- await computeSuggestions ();
2357
- assertSuggestKeywords ([Keyword .DYNAMIC , Keyword .VOID ]);
2358
- }
2359
- }
2360
-
2361
2350
@reflectiveTest
2362
2351
class KeywordContributorWithNnbdTest extends KeywordContributorTest {
2363
2352
@override
0 commit comments