| 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_computer.dart'; | 9 import 'package:analysis_server/src/services/completion/keyword_computer.dart'; |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 import '../../reflective_tests.dart'; | 13 import '../../reflective_tests.dart'; |
| 14 import 'completion_test_util.dart'; | 14 import 'completion_test_util.dart'; |
| 15 | 15 |
| 16 main() { | 16 main() { |
| 17 groupSep = ' | '; | 17 groupSep = ' | '; |
| 18 runReflectiveTests(KeywordComputerTest); | 18 runReflectiveTests(KeywordComputerTest); |
| 19 } | 19 } |
| 20 | 20 |
| 21 @reflectiveTest | 21 @reflectiveTest |
| 22 class KeywordComputerTest extends AbstractCompletionTest { | 22 class KeywordComputerTest extends AbstractCompletionTest { |
| 23 | 23 |
| 24 void assertSuggestKeywords(Iterable<Keyword> expectedKeywords, [int relevance | 24 void assertSuggestKeywords(Iterable<Keyword> expectedKeywords, [int relevance |
| 25 = COMPLETION_RELEVANCE_DEFAULT]) { | 25 = DART_RELEVANCE_KEYWORD]) { |
| 26 Set<Keyword> actualKeywords = new Set<Keyword>(); | 26 Set<Keyword> actualKeywords = new Set<Keyword>(); |
| 27 request.suggestions.forEach((CompletionSuggestion s) { | 27 request.suggestions.forEach((CompletionSuggestion s) { |
| 28 if (s.kind == CompletionSuggestionKind.KEYWORD) { | 28 if (s.kind == CompletionSuggestionKind.KEYWORD) { |
| 29 Keyword k = Keyword.keywords[s.completion]; | 29 Keyword k = Keyword.keywords[s.completion]; |
| 30 if (k == null) { | 30 if (k == null) { |
| 31 fail('Invalid keyword suggested: ${s.completion}'); | 31 fail('Invalid keyword suggested: ${s.completion}'); |
| 32 } else { | 32 } else { |
| 33 if (!actualKeywords.add(k)) { | 33 if (!actualKeywords.add(k)) { |
| 34 fail('Duplicate keyword suggested: ${s.completion}'); | 34 fail('Duplicate keyword suggested: ${s.completion}'); |
| 35 } | 35 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); | 449 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { | 452 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { |
| 453 if (iter1.length != iter2.length) return false; | 453 if (iter1.length != iter2.length) return false; |
| 454 if (iter1.any((k) => !iter2.contains(k))) return false; | 454 if (iter1.any((k) => !iter2.contains(k))) return false; |
| 455 if (iter2.any((k) => !iter1.contains(k))) return false; | 455 if (iter2.any((k) => !iter1.contains(k))) return false; |
| 456 return true; | 456 return true; |
| 457 } | 457 } |
| 458 } | 458 } |
| OLD | NEW |