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.dart.keyword; | 5 library test.services.completion.dart.keyword; |
6 | 6 |
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
9 import 'package:analysis_server/src/services/completion/dart/keyword_contributor
.dart'; | 9 import 'package:analysis_server/src/services/completion/dart/keyword_contributor
.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 pseudoKeywords: ['async'], relevance: DART_RELEVANCE_HIGH); | 364 pseudoKeywords: ['async'], relevance: DART_RELEVANCE_HIGH); |
365 } | 365 } |
366 | 366 |
367 test_anonymous_function_async5() async { | 367 test_anonymous_function_async5() async { |
368 addTestSource('main() {foo(() ^}}'); | 368 addTestSource('main() {foo(() ^}}'); |
369 await computeSuggestions(); | 369 await computeSuggestions(); |
370 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE, | 370 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE, |
371 pseudoKeywords: ['async', 'async*', 'sync*']); | 371 pseudoKeywords: ['async', 'async*', 'sync*']); |
372 } | 372 } |
373 | 373 |
| 374 test_anonymous_function_async6() async { |
| 375 addTestSource('main() {foo("bar", () as^{}}'); |
| 376 await computeSuggestions(); |
| 377 assertSuggestKeywords([], |
| 378 pseudoKeywords: ['async', 'async*', 'sync*'], |
| 379 relevance: DART_RELEVANCE_HIGH); |
| 380 } |
| 381 |
| 382 test_anonymous_function_async7() async { |
| 383 addTestSource('main() {foo("bar", () as^ => null'); |
| 384 await computeSuggestions(); |
| 385 assertSuggestKeywords([], |
| 386 pseudoKeywords: ['async', 'async*', 'sync*'], |
| 387 relevance: DART_RELEVANCE_HIGH); |
| 388 } |
| 389 |
374 test_argument() async { | 390 test_argument() async { |
375 addTestSource('main() {foo(^);}'); | 391 addTestSource('main() {foo(^);}'); |
376 await computeSuggestions(); | 392 await computeSuggestions(); |
377 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE); | 393 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE); |
378 } | 394 } |
379 | 395 |
380 test_argument2() async { | 396 test_argument2() async { |
381 addTestSource('main() {foo(n^);}'); | 397 addTestSource('main() {foo(n^);}'); |
382 await computeSuggestions(); | 398 await computeSuggestions(); |
383 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE); | 399 assertSuggestKeywords(EXPRESSION_START_NO_INSTANCE); |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, | 1188 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, |
1173 relevance: DART_RELEVANCE_HIGH); | 1189 relevance: DART_RELEVANCE_HIGH); |
1174 } | 1190 } |
1175 | 1191 |
1176 test_is_expression() async { | 1192 test_is_expression() async { |
1177 addTestSource('main() {if (x is^)}'); | 1193 addTestSource('main() {if (x is^)}'); |
1178 await computeSuggestions(); | 1194 await computeSuggestions(); |
1179 assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH); | 1195 assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH); |
1180 } | 1196 } |
1181 | 1197 |
| 1198 test_is_expression_partial() async { |
| 1199 addTestSource('main() {if (x i^)}'); |
| 1200 await computeSuggestions(); |
| 1201 assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH); |
| 1202 } |
| 1203 |
1182 test_library() async { | 1204 test_library() async { |
1183 addTestSource('library foo;^'); | 1205 addTestSource('library foo;^'); |
1184 await computeSuggestions(); | 1206 await computeSuggestions(); |
1185 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, | 1207 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, |
1186 relevance: DART_RELEVANCE_HIGH); | 1208 relevance: DART_RELEVANCE_HIGH); |
1187 } | 1209 } |
1188 | 1210 |
1189 test_library_declaration() async { | 1211 test_library_declaration() async { |
1190 addTestSource('library ^'); | 1212 addTestSource('library ^'); |
1191 await computeSuggestions(); | 1213 await computeSuggestions(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 await computeSuggestions(); | 1355 await computeSuggestions(); |
1334 assertSuggestKeywords(EXPRESSION_START_INSTANCE); | 1356 assertSuggestKeywords(EXPRESSION_START_INSTANCE); |
1335 } | 1357 } |
1336 | 1358 |
1337 test_method_body_return() async { | 1359 test_method_body_return() async { |
1338 addTestSource('class A { foo() {return ^}}'); | 1360 addTestSource('class A { foo() {return ^}}'); |
1339 await computeSuggestions(); | 1361 await computeSuggestions(); |
1340 assertSuggestKeywords(EXPRESSION_START_INSTANCE); | 1362 assertSuggestKeywords(EXPRESSION_START_INSTANCE); |
1341 } | 1363 } |
1342 | 1364 |
| 1365 test_method_invocation() async { |
| 1366 addTestSource('class A { foo() {bar.^}}'); |
| 1367 await computeSuggestions(); |
| 1368 assertNoSuggestions(); |
| 1369 } |
| 1370 |
| 1371 test_method_invocation2() async { |
| 1372 addTestSource('class A { foo() {bar.as^}}'); |
| 1373 await computeSuggestions(); |
| 1374 assertNoSuggestions(); |
| 1375 } |
| 1376 |
1343 test_method_param() async { | 1377 test_method_param() async { |
1344 addTestSource('class A { foo(^) {});}'); | 1378 addTestSource('class A { foo(^) {});}'); |
1345 await computeSuggestions(); | 1379 await computeSuggestions(); |
1346 expect(suggestions, isEmpty); | 1380 expect(suggestions, isEmpty); |
1347 } | 1381 } |
1348 | 1382 |
1349 test_method_param2() async { | 1383 test_method_param2() async { |
1350 addTestSource('class A { foo(t^) {});}'); | 1384 addTestSource('class A { foo(t^) {});}'); |
1351 await computeSuggestions(); | 1385 await computeSuggestions(); |
1352 expect(suggestions, isEmpty); | 1386 expect(suggestions, isEmpty); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 (c) => msg.writeln(' $c, ${other.contains(c) ? '' : '<<<<<<<<<<<'}')); | 1580 (c) => msg.writeln(' $c, ${other.contains(c) ? '' : '<<<<<<<<<<<'}')); |
1547 } | 1581 } |
1548 | 1582 |
1549 bool _equalSets(Iterable<String> iter1, Iterable<String> iter2) { | 1583 bool _equalSets(Iterable<String> iter1, Iterable<String> iter2) { |
1550 if (iter1.length != iter2.length) return false; | 1584 if (iter1.length != iter2.length) return false; |
1551 if (iter1.any((c) => !iter2.contains(c))) return false; | 1585 if (iter1.any((c) => !iter2.contains(c))) return false; |
1552 if (iter2.any((c) => !iter1.contains(c))) return false; | 1586 if (iter2.any((c) => !iter1.contains(c))) return false; |
1553 return true; | 1587 return true; |
1554 } | 1588 } |
1555 } | 1589 } |
OLD | NEW |