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.integration.analysis.highlights; | 5 library test.integration.analysis.highlights; |
6 | 6 |
7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
8 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
9 | 10 |
10 import '../../reflective_tests.dart'; | |
11 import '../integration_tests.dart'; | 11 import '../integration_tests.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 runReflectiveTests(AnalysisHighlightsTest); | 14 defineReflectiveTests(AnalysisHighlightsTest); |
15 } | 15 } |
16 | 16 |
17 @reflectiveTest | 17 @reflectiveTest |
18 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { | 18 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { |
19 test_highlights() { | 19 test_highlights() { |
20 String pathname = sourcePath('test.dart'); | 20 String pathname = sourcePath('test.dart'); |
21 String text = r''' | 21 String text = r''' |
22 import 'dart:async' as async; | 22 import 'dart:async' as async; |
23 | 23 |
24 /** | 24 /** |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 }); | 89 }); |
90 return analysisFinished.then((_) { | 90 return analysisFinished.then((_) { |
91 // There should be 1 error due to the fact that unresolvedIdentifier is | 91 // There should be 1 error due to the fact that unresolvedIdentifier is |
92 // unresolved. | 92 // unresolved. |
93 expect(currentAnalysisErrors[pathname], hasLength(1)); | 93 expect(currentAnalysisErrors[pathname], hasLength(1)); |
94 void check(HighlightRegionType type, List<String> expected) { | 94 void check(HighlightRegionType type, List<String> expected) { |
95 expect(highlights[type], equals(expected.toSet())); | 95 expect(highlights[type], equals(expected.toSet())); |
96 highlights.remove(type); | 96 highlights.remove(type); |
97 } | 97 } |
98 check(HighlightRegionType.ANNOTATION, ['@override']); | 98 check(HighlightRegionType.ANNOTATION, ['@override']); |
99 check(HighlightRegionType.BUILT_IN, | 99 check(HighlightRegionType.BUILT_IN, [ |
100 ['as', 'get', 'import', 'set', 'static', 'typedef']); | 100 'as', |
| 101 'get', |
| 102 'import', |
| 103 'set', |
| 104 'static', |
| 105 'typedef' |
| 106 ]); |
101 check(HighlightRegionType.CLASS, [ | 107 check(HighlightRegionType.CLASS, [ |
102 'Class', | 108 'Class', |
103 'Class2', | 109 'Class2', |
104 'Future', | 110 'Future', |
105 'Map', | 111 'Map', |
106 'int' | 112 'int' |
107 ]); | 113 ]); |
108 check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']); | 114 check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']); |
109 check(HighlightRegionType.COMMENT_DOCUMENTATION, [ | 115 check(HighlightRegionType.COMMENT_DOCUMENTATION, |
110 '/**\n * Doc comment\n */' | 116 ['/**\n * Doc comment\n */']); |
111 ]); | |
112 check( | 117 check( |
113 HighlightRegionType.COMMENT_END_OF_LINE, ['// End of line comment']); | 118 HighlightRegionType.COMMENT_END_OF_LINE, ['// End of line comment']); |
114 check(HighlightRegionType.CONSTRUCTOR, ['constructor']); | 119 check(HighlightRegionType.CONSTRUCTOR, ['constructor']); |
115 check(HighlightRegionType.DIRECTIVE, ["import 'dart:async' as async;"]); | 120 check(HighlightRegionType.DIRECTIVE, ["import 'dart:async' as async;"]); |
116 check(HighlightRegionType.DYNAMIC_TYPE, ['dynamicType']); | 121 check(HighlightRegionType.DYNAMIC_TYPE, ['dynamicType']); |
117 check(HighlightRegionType.FIELD, ['field']); | 122 check(HighlightRegionType.FIELD, ['field']); |
118 check(HighlightRegionType.FIELD_STATIC, ['staticField']); | 123 check(HighlightRegionType.FIELD_STATIC, ['staticField']); |
119 check(HighlightRegionType.FUNCTION, ['print']); | 124 check(HighlightRegionType.FUNCTION, ['print']); |
120 check(HighlightRegionType.FUNCTION_DECLARATION, ['function']); | 125 check(HighlightRegionType.FUNCTION_DECLARATION, ['function']); |
121 check(HighlightRegionType.FUNCTION_TYPE_ALIAS, ['functionType']); | 126 check(HighlightRegionType.FUNCTION_TYPE_ALIAS, ['functionType']); |
122 check(HighlightRegionType.GETTER_DECLARATION, ['getter']); | 127 check(HighlightRegionType.GETTER_DECLARATION, ['getter']); |
123 check(HighlightRegionType.IDENTIFIER_DEFAULT, ['unresolvedIdentifier']); | 128 check(HighlightRegionType.IDENTIFIER_DEFAULT, ['unresolvedIdentifier']); |
124 check(HighlightRegionType.IMPORT_PREFIX, ['async']); | 129 check(HighlightRegionType.IMPORT_PREFIX, ['async']); |
125 check(HighlightRegionType.KEYWORD, ['class', 'true', 'return']); | 130 check(HighlightRegionType.KEYWORD, ['class', 'true', 'return']); |
126 check(HighlightRegionType.LITERAL_BOOLEAN, ['true']); | 131 check(HighlightRegionType.LITERAL_BOOLEAN, ['true']); |
127 check(HighlightRegionType.LITERAL_DOUBLE, ['1.0']); | 132 check(HighlightRegionType.LITERAL_DOUBLE, ['1.0']); |
128 check(HighlightRegionType.LITERAL_INTEGER, ['2', '42']); | 133 check(HighlightRegionType.LITERAL_INTEGER, ['2', '42']); |
129 check(HighlightRegionType.LITERAL_LIST, ['[]']); | 134 check(HighlightRegionType.LITERAL_LIST, ['[]']); |
130 check(HighlightRegionType.LITERAL_MAP, | 135 check(HighlightRegionType.LITERAL_MAP, [ |
131 ['{1.0: [].toList()}', '{2: local}']); | 136 '{1.0: [].toList()}', |
| 137 '{2: local}' |
| 138 ]); |
132 check(HighlightRegionType.LITERAL_STRING, ["'dart:async'", "'string'"]); | 139 check(HighlightRegionType.LITERAL_STRING, ["'dart:async'", "'string'"]); |
133 check(HighlightRegionType.LOCAL_VARIABLE, ['local']); | 140 check(HighlightRegionType.LOCAL_VARIABLE, ['local']); |
134 check(HighlightRegionType.LOCAL_VARIABLE_DECLARATION, ['local']); | 141 check(HighlightRegionType.LOCAL_VARIABLE_DECLARATION, ['local']); |
135 check(HighlightRegionType.METHOD, ['toList']); | 142 check(HighlightRegionType.METHOD, ['toList']); |
136 check(HighlightRegionType.METHOD_DECLARATION, ['method']); | 143 check(HighlightRegionType.METHOD_DECLARATION, ['method']); |
137 check(HighlightRegionType.METHOD_DECLARATION_STATIC, ['staticMethod']); | 144 check(HighlightRegionType.METHOD_DECLARATION_STATIC, ['staticMethod']); |
138 check(HighlightRegionType.METHOD_STATIC, ['wait']); | 145 check(HighlightRegionType.METHOD_STATIC, ['wait']); |
139 check(HighlightRegionType.PARAMETER, ['parameter']); | 146 check(HighlightRegionType.PARAMETER, ['parameter']); |
140 check(HighlightRegionType.SETTER_DECLARATION, ['setter']); | 147 check(HighlightRegionType.SETTER_DECLARATION, ['setter']); |
141 check(HighlightRegionType.TOP_LEVEL_VARIABLE, | 148 check(HighlightRegionType.TOP_LEVEL_VARIABLE, [ |
142 ['override', 'topLevelVariable']); | 149 'override', |
| 150 'topLevelVariable' |
| 151 ]); |
143 check(HighlightRegionType.TYPE_NAME_DYNAMIC, ['dynamic']); | 152 check(HighlightRegionType.TYPE_NAME_DYNAMIC, ['dynamic']); |
144 check(HighlightRegionType.TYPE_PARAMETER, ['TypeParameter']); | 153 check(HighlightRegionType.TYPE_PARAMETER, ['TypeParameter']); |
145 expect(highlights, isEmpty); | 154 expect(highlights, isEmpty); |
146 }); | 155 }); |
147 } | 156 } |
148 } | 157 } |
OLD | NEW |