| 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/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 9 import 'package:analysis_server/src/services/completion/keyword_contributor.dart
'; | 9 import 'package:analysis_server/src/services/completion/keyword_contributor.dart
'; |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 assertSuggestKeywords(DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); | 169 assertSuggestKeywords(DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); |
| 170 } | 170 } |
| 171 | 171 |
| 172 test_after_class2() { | 172 test_after_class2() { |
| 173 addTestSource('class A {} c^'); | 173 addTestSource('class A {} c^'); |
| 174 expect(computeFast(), isTrue); | 174 expect(computeFast(), isTrue); |
| 175 assertSuggestKeywords(DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); | 175 assertSuggestKeywords(DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); |
| 176 } | 176 } |
| 177 | 177 |
| 178 test_after_import() { | 178 test_after_import() { |
| 179 addTestSource('import foo; ^'); | 179 addTestSource('import "foo"; ^'); |
| 180 expect(computeFast(), isTrue); | 180 expect(computeFast(), isTrue); |
| 181 assertSuggestKeywords( | 181 assertSuggestKeywords( |
| 182 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); | 182 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); |
| 183 } | 183 } |
| 184 | 184 |
| 185 test_after_import2() { | 185 test_after_import2() { |
| 186 addTestSource('import foo; c^'); | 186 addTestSource('import "foo"; c^'); |
| 187 expect(computeFast(), isTrue); | 187 expect(computeFast(), isTrue); |
| 188 assertSuggestKeywords( | 188 assertSuggestKeywords( |
| 189 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); | 189 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); |
| 190 } | 190 } |
| 191 | 191 |
| 192 test_before_import() { | 192 test_before_import() { |
| 193 addTestSource('^ import foo;'); | 193 addTestSource('^ import foo;'); |
| 194 expect(computeFast(), isTrue); | 194 expect(computeFast(), isTrue); |
| 195 assertSuggestKeywords([ | 195 assertSuggestKeywords([ |
| 196 Keyword.EXPORT, | 196 Keyword.EXPORT, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 expect(computeFast(), isTrue); | 397 expect(computeFast(), isTrue); |
| 398 assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS); | 398 assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS); |
| 399 } | 399 } |
| 400 | 400 |
| 401 test_function_body_inUnit_afterBlock() { | 401 test_function_body_inUnit_afterBlock() { |
| 402 addTestSource('main() {{}^}'); | 402 addTestSource('main() {{}^}'); |
| 403 expect(computeFast(), isTrue); | 403 expect(computeFast(), isTrue); |
| 404 assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS); | 404 assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS); |
| 405 } | 405 } |
| 406 | 406 |
| 407 test_import() { |
| 408 addTestSource('import "foo" deferred as foo ^;'); |
| 409 expect(computeFast(), isTrue); |
| 410 assertSuggestKeywords([], DART_RELEVANCE_HIGH); |
| 411 } |
| 412 |
| 413 test_import_as() { |
| 414 addTestSource('import "foo" deferred ^;'); |
| 415 expect(computeFast(), isTrue); |
| 416 assertSuggestKeywords([Keyword.AS], DART_RELEVANCE_HIGH); |
| 417 } |
| 418 |
| 419 test_import_as2() { |
| 420 addTestSource('import "foo" deferred a^;'); |
| 421 expect(computeFast(), isTrue); |
| 422 assertSuggestKeywords([Keyword.AS], DART_RELEVANCE_HIGH); |
| 423 } |
| 424 |
| 425 test_import_as3() { |
| 426 addTestSource('import "foo" deferred a^'); |
| 427 expect(computeFast(), isTrue); |
| 428 assertSuggestKeywords([Keyword.AS], DART_RELEVANCE_HIGH); |
| 429 } |
| 430 |
| 431 test_import_deferred() { |
| 432 addTestSource('import "foo" ^ as foo;'); |
| 433 expect(computeFast(), isTrue); |
| 434 assertSuggestKeywords([Keyword.DEFERRED], DART_RELEVANCE_HIGH); |
| 435 } |
| 436 |
| 437 test_import_deferred_not() { |
| 438 addTestSource('import "foo" as foo ^;'); |
| 439 expect(computeFast(), isTrue); |
| 440 assertSuggestKeywords([], DART_RELEVANCE_HIGH); |
| 441 } |
| 442 |
| 443 test_import_deferred_as() { |
| 444 addTestSource('import "foo" ^;'); |
| 445 expect(computeFast(), isTrue); |
| 446 assertSuggestKeywords([Keyword.AS, Keyword.DEFERRED], DART_RELEVANCE_HIGH); |
| 447 } |
| 448 |
| 449 test_import_deferred_as2() { |
| 450 addTestSource('import "foo" d^;'); |
| 451 expect(computeFast(), isTrue); |
| 452 assertSuggestKeywords([Keyword.AS, Keyword.DEFERRED], DART_RELEVANCE_HIGH); |
| 453 } |
| 454 |
| 455 test_import_deferred_as3() { |
| 456 addTestSource('import "foo" ^'); |
| 457 expect(computeFast(), isTrue); |
| 458 assertSuggestKeywords([Keyword.AS, Keyword.DEFERRED], DART_RELEVANCE_HIGH); |
| 459 } |
| 460 |
| 461 test_import_deferred_as4() { |
| 462 addTestSource('import "foo" d^'); |
| 463 expect(computeFast(), isTrue); |
| 464 assertSuggestKeywords([Keyword.AS, Keyword.DEFERRED], DART_RELEVANCE_HIGH); |
| 465 } |
| 466 |
| 407 test_library() { | 467 test_library() { |
| 408 addTestSource('library foo;^'); | 468 addTestSource('library foo;^'); |
| 409 expect(computeFast(), isTrue); | 469 expect(computeFast(), isTrue); |
| 410 assertSuggestKeywords( | 470 assertSuggestKeywords( |
| 411 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); | 471 DIRECTIVE_AND_DECLARATION_KEYWORDS, DART_RELEVANCE_HIGH); |
| 412 } | 472 } |
| 413 | 473 |
| 414 test_library_name() { | 474 test_library_name() { |
| 415 addTestSource('library ^'); | 475 addTestSource('library ^'); |
| 416 expect(computeFast(), isTrue); | 476 expect(computeFast(), isTrue); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); | 516 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); |
| 457 } | 517 } |
| 458 | 518 |
| 459 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { | 519 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { |
| 460 if (iter1.length != iter2.length) return false; | 520 if (iter1.length != iter2.length) return false; |
| 461 if (iter1.any((k) => !iter2.contains(k))) return false; | 521 if (iter1.any((k) => !iter2.contains(k))) return false; |
| 462 if (iter2.any((k) => !iter1.contains(k))) return false; | 522 if (iter2.any((k) => !iter1.contains(k))) return false; |
| 463 return true; | 523 return true; |
| 464 } | 524 } |
| 465 } | 525 } |
| OLD | NEW |