| 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(KeywordContributorTest); |
| 19 } | 19 } |
| 20 | 20 |
| 21 @reflectiveTest | 21 @reflectiveTest |
| 22 class KeywordComputerTest extends AbstractCompletionTest { | 22 class KeywordContributorTest extends AbstractCompletionTest { |
| 23 static const List<Keyword> CLASS_BODY_KEYWORDS = const [ | 23 static const List<Keyword> CLASS_BODY_KEYWORDS = const [ |
| 24 Keyword.CONST, | 24 Keyword.CONST, |
| 25 Keyword.DYNAMIC, | 25 Keyword.DYNAMIC, |
| 26 Keyword.FACTORY, | 26 Keyword.FACTORY, |
| 27 Keyword.FINAL, | 27 Keyword.FINAL, |
| 28 Keyword.GET, | 28 Keyword.GET, |
| 29 Keyword.OPERATOR, | 29 Keyword.OPERATOR, |
| 30 Keyword.SET, | 30 Keyword.SET, |
| 31 Keyword.STATIC, | 31 Keyword.STATIC, |
| 32 Keyword.VAR, | 32 Keyword.VAR, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 expect(s.relevance, equals(relevance), reason: k.toString()); | 152 expect(s.relevance, equals(relevance), reason: k.toString()); |
| 153 expect(s.selectionOffset, equals(s.completion.length)); | 153 expect(s.selectionOffset, equals(s.completion.length)); |
| 154 expect(s.selectionLength, equals(0)); | 154 expect(s.selectionLength, equals(0)); |
| 155 expect(s.isDeprecated, equals(false)); | 155 expect(s.isDeprecated, equals(false)); |
| 156 expect(s.isPotential, equals(false)); | 156 expect(s.isPotential, equals(false)); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 @override | 161 @override |
| 162 void setUpComputer() { | 162 void setUpContributor() { |
| 163 computer = new KeywordComputer(); | 163 contributor = new KeywordContributor(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 test_after_class() { | 166 test_after_class() { |
| 167 addTestSource('class A {} ^'); | 167 addTestSource('class A {} ^'); |
| 168 expect(computeFast(), isTrue); | 168 expect(computeFast(), isTrue); |
| 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^'); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); | 456 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); |
| 457 } | 457 } |
| 458 | 458 |
| 459 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { | 459 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { |
| 460 if (iter1.length != iter2.length) return false; | 460 if (iter1.length != iter2.length) return false; |
| 461 if (iter1.any((k) => !iter2.contains(k))) return false; | 461 if (iter1.any((k) => !iter2.contains(k))) return false; |
| 462 if (iter2.any((k) => !iter1.contains(k))) return false; | 462 if (iter2.any((k) => !iter1.contains(k))) return false; |
| 463 return true; | 463 return true; |
| 464 } | 464 } |
| 465 } | 465 } |
| OLD | NEW |