| 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 @ReflectiveTestCase() | 21 @reflectiveTest |
| 22 class KeywordComputerTest extends AbstractCompletionTest { | 22 class KeywordComputerTest extends AbstractCompletionTest { |
| 23 | 23 |
| 24 void assertSuggestKeywords(Iterable<Keyword> expectedKeywords, | 24 void assertSuggestKeywords(Iterable<Keyword> expectedKeywords, |
| 25 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 25 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 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}'); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); | 307 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); |
| 308 } | 308 } |
| 309 | 309 |
| 310 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { | 310 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { |
| 311 if (iter1.length != iter2.length) return false; | 311 if (iter1.length != iter2.length) return false; |
| 312 if (iter1.any((k) => !iter2.contains(k))) return false; | 312 if (iter1.any((k) => !iter2.contains(k))) return false; |
| 313 if (iter2.any((k) => !iter1.contains(k))) return false; | 313 if (iter2.any((k) => !iter1.contains(k))) return false; |
| 314 return true; | 314 return true; |
| 315 } | 315 } |
| 316 } | 316 } |
| OLD | NEW |