@@ -16,7 +16,6 @@ import 'completion_contributor_util.dart';
1616void main () {
1717 defineReflectiveSuite (() {
1818 defineReflectiveTests (KeywordContributorTest );
19- defineReflectiveTests (KeywordContributorWithExtensionMethodsTest );
2019 defineReflectiveTests (KeywordContributorWithNnbdTest );
2120 });
2221}
@@ -91,14 +90,12 @@ class KeywordContributorTest extends DartCompletionContributorTest {
9190 Keyword .CONST ,
9291 Keyword .COVARIANT ,
9392 Keyword .DYNAMIC ,
93+ Keyword .EXTENSION ,
9494 Keyword .FINAL ,
9595 Keyword .TYPEDEF ,
9696 Keyword .VAR ,
9797 Keyword .VOID
9898 ];
99- if (isEnabled (ExperimentalFeatures .extension_methods)) {
100- keywords.add (Keyword .EXTENSION );
101- }
10299 if (isEnabled (ExperimentalFeatures .non_nullable)) {
103100 keywords.add (Keyword .LATE );
104101 }
@@ -113,16 +110,14 @@ class KeywordContributorTest extends DartCompletionContributorTest {
113110 Keyword .COVARIANT ,
114111 Keyword .DYNAMIC ,
115112 Keyword .EXPORT ,
113+ Keyword .EXTENSION ,
116114 Keyword .FINAL ,
117115 Keyword .IMPORT ,
118116 Keyword .PART ,
119117 Keyword .TYPEDEF ,
120118 Keyword .VAR ,
121119 Keyword .VOID
122120 ];
123- if (isEnabled (ExperimentalFeatures .extension_methods)) {
124- keywords.add (Keyword .EXTENSION );
125- }
126121 if (isEnabled (ExperimentalFeatures .non_nullable)) {
127122 keywords.add (Keyword .LATE );
128123 }
@@ -145,16 +140,32 @@ class KeywordContributorTest extends DartCompletionContributorTest {
145140 Keyword .COVARIANT ,
146141 Keyword .DYNAMIC ,
147142 Keyword .EXPORT ,
143+ Keyword .EXTENSION ,
148144 Keyword .FINAL ,
149145 Keyword .IMPORT ,
150146 Keyword .PART ,
151147 Keyword .TYPEDEF ,
152148 Keyword .VAR ,
153149 Keyword .VOID
154150 ];
155- if (isEnabled (ExperimentalFeatures .extension_methods )) {
156- keywords.add (Keyword .EXTENSION );
151+ if (isEnabled (ExperimentalFeatures .non_nullable )) {
152+ keywords.add (Keyword .LATE );
157153 }
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+ ];
158169 if (isEnabled (ExperimentalFeatures .non_nullable)) {
159170 keywords.add (Keyword .LATE );
160171 }
@@ -859,6 +870,12 @@ class KeywordContributorTest extends DartCompletionContributorTest {
859870 assertSuggestKeywords (classBodyKeywords);
860871 }
861872
873+ Future <void > test_class_body_empty () async {
874+ addTestSource ('extension E on int {^}' );
875+ await computeSuggestions ();
876+ assertSuggestKeywords (extensionBodyKeywords);
877+ }
878+
862879 Future <void > test_class_body_end () async {
863880 addTestSource ('class A {var foo; ^}' );
864881 await computeSuggestions ();
@@ -1075,6 +1092,56 @@ class C {
10751092 relevance: DART_RELEVANCE_HIGH );
10761093 }
10771094
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+
10781145 Future <void > test_for_break_continue_insideClass () async {
10791146 addTestSource ('class A {foo() {for (int x in myList) {^}}}' );
10801147 await computeSuggestions ();
@@ -2026,6 +2093,19 @@ f() => <int>{1, ^, 2};
20262093 assertSuggestKeywords (methodParameter);
20272094 }
20282095
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+
20292109 Future <void > test_mixin () async {
20302110 addTestSource ('mixin M o^ { }' );
20312111 await computeSuggestions ();
@@ -2267,97 +2347,6 @@ f() => [...^];
22672347 }
22682348}
22692349
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-
23612350@reflectiveTest
23622351class KeywordContributorWithNnbdTest extends KeywordContributorTest {
23632352 @override
0 commit comments