| 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 computer.highlights; | 5 library computer.highlights; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/constants.dart'; | 7 import 'package:analysis_server/src/protocol2.dart' show HighlightRegion, |
| 8 import 'package:analysis_server/src/services/json.dart'; | 8 HighlightRegionType; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/scanner.dart'; | 11 import 'package:analyzer/src/generated/scanner.dart'; |
| 12 | 12 |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. | 15 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. |
| 16 */ | 16 */ |
| 17 class DartUnitHighlightsComputer { | 17 class DartUnitHighlightsComputer { |
| 18 final CompilationUnit _unit; | 18 final CompilationUnit _unit; |
| 19 | 19 |
| 20 final List<HighlightRegion> _regions = <HighlightRegion>[]; | 20 final List<HighlightRegion> _regions = <HighlightRegion>[]; |
| 21 | 21 |
| 22 DartUnitHighlightsComputer(this._unit); | 22 DartUnitHighlightsComputer(this._unit); |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Returns the computed highlight regions, not `null`. | 25 * Returns the computed highlight regions, not `null`. |
| 26 */ | 26 */ |
| 27 List<HighlightRegion> compute() { | 27 List<HighlightRegion> compute() { |
| 28 _unit.accept(new _DartUnitHighlightsComputerVisitor(this)); | 28 _unit.accept(new _DartUnitHighlightsComputerVisitor(this)); |
| 29 _addCommentRanges(); | 29 _addCommentRanges(); |
| 30 return _regions; | 30 return _regions; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void _addCommentRanges() { | 33 void _addCommentRanges() { |
| 34 Token token = _unit.beginToken; | 34 Token token = _unit.beginToken; |
| 35 while (token != null && token.type != TokenType.EOF) { | 35 while (token != null && token.type != TokenType.EOF) { |
| 36 Token commentToken = token.precedingComments; | 36 Token commentToken = token.precedingComments; |
| 37 while (commentToken != null) { | 37 while (commentToken != null) { |
| 38 HighlightType highlightType = null; | 38 HighlightRegionType highlightType = null; |
| 39 if (commentToken.type == TokenType.MULTI_LINE_COMMENT) { | 39 if (commentToken.type == TokenType.MULTI_LINE_COMMENT) { |
| 40 if (commentToken.lexeme.startsWith('/**')) { | 40 if (commentToken.lexeme.startsWith('/**')) { |
| 41 highlightType = HighlightType.COMMENT_DOCUMENTATION; | 41 highlightType = HighlightRegionType.COMMENT_DOCUMENTATION; |
| 42 } else { | 42 } else { |
| 43 highlightType = HighlightType.COMMENT_BLOCK; | 43 highlightType = HighlightRegionType.COMMENT_BLOCK; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 if (commentToken.type == TokenType.SINGLE_LINE_COMMENT) { | 46 if (commentToken.type == TokenType.SINGLE_LINE_COMMENT) { |
| 47 highlightType = HighlightType.COMMENT_END_OF_LINE; | 47 highlightType = HighlightRegionType.COMMENT_END_OF_LINE; |
| 48 } | 48 } |
| 49 if (highlightType != null) { | 49 if (highlightType != null) { |
| 50 _addRegion_token(commentToken, highlightType); | 50 _addRegion_token(commentToken, highlightType); |
| 51 } | 51 } |
| 52 commentToken = commentToken.next; | 52 commentToken = commentToken.next; |
| 53 } | 53 } |
| 54 token = token.next; | 54 token = token.next; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 88 } | 88 } |
| 89 if (_addIdentifierRegion_method(node)) { | 89 if (_addIdentifierRegion_method(node)) { |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 if (_addIdentifierRegion_parameter(node)) { | 92 if (_addIdentifierRegion_parameter(node)) { |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 if (_addIdentifierRegion_typeParameter(node)) { | 95 if (_addIdentifierRegion_typeParameter(node)) { |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 _addRegion_node(node, HighlightType.IDENTIFIER_DEFAULT); | 98 _addRegion_node(node, HighlightRegionType.IDENTIFIER_DEFAULT); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void _addIdentifierRegion_annotation(Annotation node) { | 101 void _addIdentifierRegion_annotation(Annotation node) { |
| 102 ArgumentList arguments = node.arguments; | 102 ArgumentList arguments = node.arguments; |
| 103 if (arguments == null) { | 103 if (arguments == null) { |
| 104 _addRegion_node(node, HighlightType.ANNOTATION); | 104 _addRegion_node(node, HighlightRegionType.ANNOTATION); |
| 105 } else { | 105 } else { |
| 106 _addRegion_nodeStart_tokenEnd( | 106 _addRegion_nodeStart_tokenEnd( |
| 107 node, | 107 node, |
| 108 arguments.beginToken, | 108 arguments.beginToken, |
| 109 HighlightType.ANNOTATION); | 109 HighlightRegionType.ANNOTATION); |
| 110 _addRegion_token(arguments.endToken, HighlightType.ANNOTATION); | 110 _addRegion_token(arguments.endToken, HighlightRegionType.ANNOTATION); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool _addIdentifierRegion_class(SimpleIdentifier node) { | 114 bool _addIdentifierRegion_class(SimpleIdentifier node) { |
| 115 Element element = node.staticElement; | 115 Element element = node.staticElement; |
| 116 if (element is! ClassElement) { | 116 if (element is! ClassElement) { |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 return _addRegion_node(node, HighlightType.CLASS); | 119 return _addRegion_node(node, HighlightRegionType.CLASS); |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool _addIdentifierRegion_constructor(SimpleIdentifier node) { | 122 bool _addIdentifierRegion_constructor(SimpleIdentifier node) { |
| 123 Element element = node.staticElement; | 123 Element element = node.staticElement; |
| 124 if (element is! ConstructorElement) { | 124 if (element is! ConstructorElement) { |
| 125 return false; | 125 return false; |
| 126 } | 126 } |
| 127 return _addRegion_node(node, HighlightType.CONSTRUCTOR); | 127 return _addRegion_node(node, HighlightRegionType.CONSTRUCTOR); |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool _addIdentifierRegion_dynamicType(SimpleIdentifier node) { | 130 bool _addIdentifierRegion_dynamicType(SimpleIdentifier node) { |
| 131 // should be variable | 131 // should be variable |
| 132 Element element = node.staticElement; | 132 Element element = node.staticElement; |
| 133 if (element is! VariableElement) { | 133 if (element is! VariableElement) { |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| 136 // has propagated type | 136 // has propagated type |
| 137 if (node.propagatedType != null) { | 137 if (node.propagatedType != null) { |
| 138 return false; | 138 return false; |
| 139 } | 139 } |
| 140 // has dynamic static type | 140 // has dynamic static type |
| 141 DartType staticType = node.staticType; | 141 DartType staticType = node.staticType; |
| 142 if (staticType == null || !staticType.isDynamic) { | 142 if (staticType == null || !staticType.isDynamic) { |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 // OK | 145 // OK |
| 146 return _addRegion_node(node, HighlightType.DYNAMIC_TYPE); | 146 return _addRegion_node(node, HighlightRegionType.DYNAMIC_TYPE); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool _addIdentifierRegion_field(SimpleIdentifier node) { | 149 bool _addIdentifierRegion_field(SimpleIdentifier node) { |
| 150 Element element = node.bestElement; | 150 Element element = node.bestElement; |
| 151 if (element is FieldFormalParameterElement) { | 151 if (element is FieldFormalParameterElement) { |
| 152 element = (element as FieldFormalParameterElement).field; | 152 element = (element as FieldFormalParameterElement).field; |
| 153 } | 153 } |
| 154 if (element is PropertyAccessorElement) { | 154 if (element is PropertyAccessorElement) { |
| 155 element = (element as PropertyAccessorElement).variable; | 155 element = (element as PropertyAccessorElement).variable; |
| 156 } | 156 } |
| 157 if (element is FieldElement) { | 157 if (element is FieldElement) { |
| 158 if ((element as FieldElement).isStatic) { | 158 if ((element as FieldElement).isStatic) { |
| 159 return _addRegion_node(node, HighlightType.FIELD_STATIC); | 159 return _addRegion_node(node, HighlightRegionType.FIELD_STATIC); |
| 160 } else { | 160 } else { |
| 161 return _addRegion_node(node, HighlightType.FIELD); | 161 return _addRegion_node(node, HighlightRegionType.FIELD); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 if (element is TopLevelVariableElement) { | 164 if (element is TopLevelVariableElement) { |
| 165 return _addRegion_node(node, HighlightType.TOP_LEVEL_VARIABLE); | 165 return _addRegion_node(node, HighlightRegionType.TOP_LEVEL_VARIABLE); |
| 166 } | 166 } |
| 167 return false; | 167 return false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool _addIdentifierRegion_function(SimpleIdentifier node) { | 170 bool _addIdentifierRegion_function(SimpleIdentifier node) { |
| 171 Element element = node.staticElement; | 171 Element element = node.staticElement; |
| 172 if (element is! FunctionElement) { | 172 if (element is! FunctionElement) { |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 HighlightType type; | 175 HighlightRegionType type; |
| 176 if (node.inDeclarationContext()) { | 176 if (node.inDeclarationContext()) { |
| 177 type = HighlightType.FUNCTION_DECLARATION; | 177 type = HighlightRegionType.FUNCTION_DECLARATION; |
| 178 } else { | 178 } else { |
| 179 type = HighlightType.FUNCTION; | 179 type = HighlightRegionType.FUNCTION; |
| 180 } | 180 } |
| 181 return _addRegion_node(node, type); | 181 return _addRegion_node(node, type); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool _addIdentifierRegion_functionTypeAlias(SimpleIdentifier node) { | 184 bool _addIdentifierRegion_functionTypeAlias(SimpleIdentifier node) { |
| 185 Element element = node.staticElement; | 185 Element element = node.staticElement; |
| 186 if (element is! FunctionTypeAliasElement) { | 186 if (element is! FunctionTypeAliasElement) { |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 return _addRegion_node(node, HighlightType.FUNCTION_TYPE_ALIAS); | 189 return _addRegion_node(node, HighlightRegionType.FUNCTION_TYPE_ALIAS); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool _addIdentifierRegion_getterSetterDeclaration(SimpleIdentifier node) { | 192 bool _addIdentifierRegion_getterSetterDeclaration(SimpleIdentifier node) { |
| 193 // should be declaration | 193 // should be declaration |
| 194 AstNode parent = node.parent; | 194 AstNode parent = node.parent; |
| 195 if (!(parent is MethodDeclaration || parent is FunctionDeclaration)) { | 195 if (!(parent is MethodDeclaration || parent is FunctionDeclaration)) { |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 // should be property accessor | 198 // should be property accessor |
| 199 Element element = node.staticElement; | 199 Element element = node.staticElement; |
| 200 if (element is! PropertyAccessorElement) { | 200 if (element is! PropertyAccessorElement) { |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 // getter or setter | 203 // getter or setter |
| 204 PropertyAccessorElement propertyAccessorElement = | 204 PropertyAccessorElement propertyAccessorElement = |
| 205 element as PropertyAccessorElement; | 205 element as PropertyAccessorElement; |
| 206 if (propertyAccessorElement.isGetter) { | 206 if (propertyAccessorElement.isGetter) { |
| 207 return _addRegion_node(node, HighlightType.GETTER_DECLARATION); | 207 return _addRegion_node(node, HighlightRegionType.GETTER_DECLARATION); |
| 208 } else { | 208 } else { |
| 209 return _addRegion_node(node, HighlightType.SETTER_DECLARATION); | 209 return _addRegion_node(node, HighlightRegionType.SETTER_DECLARATION); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool _addIdentifierRegion_importPrefix(SimpleIdentifier node) { | 213 bool _addIdentifierRegion_importPrefix(SimpleIdentifier node) { |
| 214 Element element = node.staticElement; | 214 Element element = node.staticElement; |
| 215 if (element is! PrefixElement) { | 215 if (element is! PrefixElement) { |
| 216 return false; | 216 return false; |
| 217 } | 217 } |
| 218 return _addRegion_node(node, HighlightType.IMPORT_PREFIX); | 218 return _addRegion_node(node, HighlightRegionType.IMPORT_PREFIX); |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool _addIdentifierRegion_keyword(SimpleIdentifier node) { | 221 bool _addIdentifierRegion_keyword(SimpleIdentifier node) { |
| 222 String name = node.name; | 222 String name = node.name; |
| 223 if (name == "void") { | 223 if (name == "void") { |
| 224 return _addRegion_node(node, HighlightType.KEYWORD); | 224 return _addRegion_node(node, HighlightRegionType.KEYWORD); |
| 225 } | 225 } |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 | 228 |
| 229 bool _addIdentifierRegion_localVariable(SimpleIdentifier node) { | 229 bool _addIdentifierRegion_localVariable(SimpleIdentifier node) { |
| 230 Element element = node.staticElement; | 230 Element element = node.staticElement; |
| 231 if (element is! LocalVariableElement) { | 231 if (element is! LocalVariableElement) { |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 // OK | 234 // OK |
| 235 HighlightType type; | 235 HighlightRegionType type; |
| 236 if (node.inDeclarationContext()) { | 236 if (node.inDeclarationContext()) { |
| 237 type = HighlightType.LOCAL_VARIABLE_DECLARATION; | 237 type = HighlightRegionType.LOCAL_VARIABLE_DECLARATION; |
| 238 } else { | 238 } else { |
| 239 type = HighlightType.LOCAL_VARIABLE; | 239 type = HighlightRegionType.LOCAL_VARIABLE; |
| 240 } | 240 } |
| 241 return _addRegion_node(node, type); | 241 return _addRegion_node(node, type); |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool _addIdentifierRegion_method(SimpleIdentifier node) { | 244 bool _addIdentifierRegion_method(SimpleIdentifier node) { |
| 245 Element element = node.bestElement; | 245 Element element = node.bestElement; |
| 246 if (element is! MethodElement) { | 246 if (element is! MethodElement) { |
| 247 return false; | 247 return false; |
| 248 } | 248 } |
| 249 MethodElement methodElement = element as MethodElement; | 249 MethodElement methodElement = element as MethodElement; |
| 250 bool isStatic = methodElement.isStatic; | 250 bool isStatic = methodElement.isStatic; |
| 251 // OK | 251 // OK |
| 252 HighlightType type; | 252 HighlightRegionType type; |
| 253 if (node.inDeclarationContext()) { | 253 if (node.inDeclarationContext()) { |
| 254 if (isStatic) { | 254 if (isStatic) { |
| 255 type = HighlightType.METHOD_DECLARATION_STATIC; | 255 type = HighlightRegionType.METHOD_DECLARATION_STATIC; |
| 256 } else { | 256 } else { |
| 257 type = HighlightType.METHOD_DECLARATION; | 257 type = HighlightRegionType.METHOD_DECLARATION; |
| 258 } | 258 } |
| 259 } else { | 259 } else { |
| 260 if (isStatic) { | 260 if (isStatic) { |
| 261 type = HighlightType.METHOD_STATIC; | 261 type = HighlightRegionType.METHOD_STATIC; |
| 262 } else { | 262 } else { |
| 263 type = HighlightType.METHOD; | 263 type = HighlightRegionType.METHOD; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 return _addRegion_node(node, type); | 266 return _addRegion_node(node, type); |
| 267 } | 267 } |
| 268 | 268 |
| 269 bool _addIdentifierRegion_parameter(SimpleIdentifier node) { | 269 bool _addIdentifierRegion_parameter(SimpleIdentifier node) { |
| 270 Element element = node.staticElement; | 270 Element element = node.staticElement; |
| 271 if (element is! ParameterElement) { | 271 if (element is! ParameterElement) { |
| 272 return false; | 272 return false; |
| 273 } | 273 } |
| 274 return _addRegion_node(node, HighlightType.PARAMETER); | 274 return _addRegion_node(node, HighlightRegionType.PARAMETER); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) { | 277 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) { |
| 278 Element element = node.staticElement; | 278 Element element = node.staticElement; |
| 279 if (element is! TypeParameterElement) { | 279 if (element is! TypeParameterElement) { |
| 280 return false; | 280 return false; |
| 281 } | 281 } |
| 282 return _addRegion_node(node, HighlightType.TYPE_PARAMETER); | 282 return _addRegion_node(node, HighlightRegionType.TYPE_PARAMETER); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void _addRegion(int offset, int length, HighlightType type) { | 285 void _addRegion(int offset, int length, HighlightRegionType type) { |
| 286 _regions.add(new HighlightRegion(offset, length, type)); | 286 _regions.add(new HighlightRegion(type, offset, length)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool _addRegion_node(AstNode node, HighlightType type) { | 289 bool _addRegion_node(AstNode node, HighlightRegionType type) { |
| 290 int offset = node.offset; | 290 int offset = node.offset; |
| 291 int length = node.length; | 291 int length = node.length; |
| 292 _addRegion(offset, length, type); | 292 _addRegion(offset, length, type); |
| 293 return true; | 293 return true; |
| 294 } | 294 } |
| 295 | 295 |
| 296 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightType type) { | 296 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightRegionType typ
e) { |
| 297 int offset = a.offset; | 297 int offset = a.offset; |
| 298 int end = b.end; | 298 int end = b.end; |
| 299 _addRegion(offset, end - offset, type); | 299 _addRegion(offset, end - offset, type); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void _addRegion_token(Token token, HighlightType type) { | 302 void _addRegion_token(Token token, HighlightRegionType type) { |
| 303 if (token != null) { | 303 if (token != null) { |
| 304 int offset = token.offset; | 304 int offset = token.offset; |
| 305 int length = token.length; | 305 int length = token.length; |
| 306 _addRegion(offset, length, type); | 306 _addRegion(offset, length, type); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 void _addRegion_tokenStart_tokenEnd(Token a, Token b, HighlightType type) { | 310 void _addRegion_tokenStart_tokenEnd(Token a, Token b, HighlightRegionType type
) { |
| 311 int offset = a.offset; | 311 int offset = a.offset; |
| 312 int end = b.end; | 312 int end = b.end; |
| 313 _addRegion(offset, end - offset, type); | 313 _addRegion(offset, end - offset, type); |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 | 317 |
| 318 class HighlightRegion implements HasToJson { | |
| 319 final int offset; | |
| 320 final int length; | |
| 321 final HighlightType type; | |
| 322 | |
| 323 HighlightRegion(this.offset, this.length, this.type); | |
| 324 | |
| 325 factory HighlightRegion.fromJson(Map<String, Object> map) { | |
| 326 HighlightType type = HighlightType.valueOf(map[TYPE]); | |
| 327 return new HighlightRegion(map[OFFSET], map[LENGTH], type); | |
| 328 } | |
| 329 | |
| 330 Map<String, Object> toJson() { | |
| 331 Map<String, Object> json = <String, Object>{}; | |
| 332 json[OFFSET] = offset; | |
| 333 json[LENGTH] = length; | |
| 334 json[TYPE] = type.name; | |
| 335 return json; | |
| 336 } | |
| 337 | |
| 338 @override | |
| 339 String toString() => toJson().toString(); | |
| 340 } | |
| 341 | |
| 342 | |
| 343 /** | |
| 344 * Highlighting kinds constants. | |
| 345 */ | |
| 346 class HighlightType { | |
| 347 static const HighlightType ANNOTATION = const HighlightType('ANNOTATION'); | |
| 348 static const HighlightType BUILT_IN = const HighlightType('BUILT_IN'); | |
| 349 static const HighlightType CLASS = const HighlightType('CLASS'); | |
| 350 static const HighlightType COMMENT_BLOCK = | |
| 351 const HighlightType('COMMENT_BLOCK'); | |
| 352 static const HighlightType COMMENT_DOCUMENTATION = | |
| 353 const HighlightType('COMMENT_DOCUMENTATION'); | |
| 354 static const HighlightType COMMENT_END_OF_LINE = | |
| 355 const HighlightType('COMMENT_END_OF_LINE'); | |
| 356 static const HighlightType CONSTRUCTOR = const HighlightType('CONSTRUCTOR'); | |
| 357 static const HighlightType DIRECTIVE = const HighlightType('DIRECTIVE'); | |
| 358 static const HighlightType DYNAMIC_TYPE = const HighlightType('DYNAMIC_TYPE'); | |
| 359 static const HighlightType FIELD = const HighlightType('FIELD'); | |
| 360 static const HighlightType FIELD_STATIC = const HighlightType('FIELD_STATIC'); | |
| 361 static const HighlightType FUNCTION_DECLARATION = | |
| 362 const HighlightType('FUNCTION_DECLARATION'); | |
| 363 static const HighlightType FUNCTION = const HighlightType('FUNCTION'); | |
| 364 static const HighlightType FUNCTION_TYPE_ALIAS = | |
| 365 const HighlightType('FUNCTION_TYPE_ALIAS'); | |
| 366 static const HighlightType GETTER_DECLARATION = | |
| 367 const HighlightType('GETTER_DECLARATION'); | |
| 368 static const HighlightType KEYWORD = const HighlightType('KEYWORD'); | |
| 369 static const HighlightType IDENTIFIER_DEFAULT = | |
| 370 const HighlightType('IDENTIFIER_DEFAULT'); | |
| 371 static const HighlightType IMPORT_PREFIX = | |
| 372 const HighlightType('IMPORT_PREFIX'); | |
| 373 static const HighlightType LITERAL_BOOLEAN = | |
| 374 const HighlightType('LITERAL_BOOLEAN'); | |
| 375 static const HighlightType LITERAL_DOUBLE = | |
| 376 const HighlightType('LITERAL_DOUBLE'); | |
| 377 static const HighlightType LITERAL_INTEGER = | |
| 378 const HighlightType('LITERAL_INTEGER'); | |
| 379 static const HighlightType LITERAL_LIST = const HighlightType('LITERAL_LIST'); | |
| 380 static const HighlightType LITERAL_MAP = const HighlightType('LITERAL_MAP'); | |
| 381 static const HighlightType LITERAL_STRING = | |
| 382 const HighlightType('LITERAL_STRING'); | |
| 383 static const HighlightType LOCAL_VARIABLE_DECLARATION = | |
| 384 const HighlightType('LOCAL_VARIABLE_DECLARATION'); | |
| 385 static const HighlightType LOCAL_VARIABLE = | |
| 386 const HighlightType('LOCAL_VARIABLE'); | |
| 387 static const HighlightType METHOD_DECLARATION = | |
| 388 const HighlightType('METHOD_DECLARATION'); | |
| 389 static const HighlightType METHOD_DECLARATION_STATIC = | |
| 390 const HighlightType('METHOD_DECLARATION_STATIC'); | |
| 391 static const HighlightType METHOD = const HighlightType('METHOD'); | |
| 392 static const HighlightType METHOD_STATIC = | |
| 393 const HighlightType('METHOD_STATIC'); | |
| 394 static const HighlightType PARAMETER = const HighlightType('PARAMETER'); | |
| 395 static const HighlightType SETTER_DECLARATION = | |
| 396 const HighlightType('SETTER_DECLARATION'); | |
| 397 static const HighlightType TOP_LEVEL_VARIABLE = | |
| 398 const HighlightType('TOP_LEVEL_VARIABLE'); | |
| 399 static const HighlightType TYPE_NAME_DYNAMIC = | |
| 400 const HighlightType('TYPE_NAME_DYNAMIC'); | |
| 401 static const HighlightType TYPE_PARAMETER = | |
| 402 const HighlightType('TYPE_PARAMETER'); | |
| 403 | |
| 404 final String name; | |
| 405 | |
| 406 const HighlightType(this.name); | |
| 407 | |
| 408 @override | |
| 409 String toString() => name; | |
| 410 | |
| 411 static HighlightType valueOf(String name) { | |
| 412 if (ANNOTATION.name == name) return ANNOTATION; | |
| 413 if (BUILT_IN.name == name) return BUILT_IN; | |
| 414 if (CLASS.name == name) return CLASS; | |
| 415 if (COMMENT_BLOCK.name == name) return COMMENT_BLOCK; | |
| 416 if (COMMENT_DOCUMENTATION.name == name) return COMMENT_DOCUMENTATION; | |
| 417 if (COMMENT_END_OF_LINE.name == name) return COMMENT_END_OF_LINE; | |
| 418 if (CONSTRUCTOR.name == name) return CONSTRUCTOR; | |
| 419 if (DIRECTIVE.name == name) return DIRECTIVE; | |
| 420 if (DYNAMIC_TYPE.name == name) return DYNAMIC_TYPE; | |
| 421 if (FIELD.name == name) return FIELD; | |
| 422 if (FIELD_STATIC.name == name) return FIELD_STATIC; | |
| 423 if (FUNCTION_DECLARATION.name == name) return FUNCTION_DECLARATION; | |
| 424 if (FUNCTION.name == name) return FUNCTION; | |
| 425 if (FUNCTION_TYPE_ALIAS.name == name) return FUNCTION_TYPE_ALIAS; | |
| 426 if (GETTER_DECLARATION.name == name) return GETTER_DECLARATION; | |
| 427 if (KEYWORD.name == name) return KEYWORD; | |
| 428 if (IDENTIFIER_DEFAULT.name == name) return IDENTIFIER_DEFAULT; | |
| 429 if (IMPORT_PREFIX.name == name) return IMPORT_PREFIX; | |
| 430 if (LITERAL_BOOLEAN.name == name) return LITERAL_BOOLEAN; | |
| 431 if (LITERAL_DOUBLE.name == name) return LITERAL_DOUBLE; | |
| 432 if (LITERAL_INTEGER.name == name) return LITERAL_INTEGER; | |
| 433 if (LITERAL_LIST.name == name) return LITERAL_LIST; | |
| 434 if (LITERAL_MAP.name == name) return LITERAL_MAP; | |
| 435 if (LITERAL_STRING.name == name) return LITERAL_STRING; | |
| 436 if (LOCAL_VARIABLE_DECLARATION.name == | |
| 437 name) return LOCAL_VARIABLE_DECLARATION; | |
| 438 if (LOCAL_VARIABLE.name == name) return LOCAL_VARIABLE; | |
| 439 if (METHOD_DECLARATION.name == name) return METHOD_DECLARATION; | |
| 440 if (METHOD_DECLARATION_STATIC.name == | |
| 441 name) return METHOD_DECLARATION_STATIC; | |
| 442 if (METHOD.name == name) return METHOD; | |
| 443 if (METHOD_STATIC.name == name) return METHOD_STATIC; | |
| 444 if (PARAMETER.name == name) return PARAMETER; | |
| 445 if (SETTER_DECLARATION.name == name) return SETTER_DECLARATION; | |
| 446 if (TOP_LEVEL_VARIABLE.name == name) return TOP_LEVEL_VARIABLE; | |
| 447 if (TYPE_NAME_DYNAMIC.name == name) return TYPE_NAME_DYNAMIC; | |
| 448 if (TYPE_PARAMETER.name == name) return TYPE_PARAMETER; | |
| 449 throw new ArgumentError('Unknown HighlightType: $name'); | |
| 450 } | |
| 451 } | |
| 452 | |
| 453 | |
| 454 /** | 318 /** |
| 455 * An AST visitor for [DartUnitHighlightsComputer]. | 319 * An AST visitor for [DartUnitHighlightsComputer]. |
| 456 */ | 320 */ |
| 457 class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<Object> { | 321 class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<Object> { |
| 458 final DartUnitHighlightsComputer computer; | 322 final DartUnitHighlightsComputer computer; |
| 459 | 323 |
| 460 _DartUnitHighlightsComputerVisitor(this.computer); | 324 _DartUnitHighlightsComputerVisitor(this.computer); |
| 461 | 325 |
| 462 @override | 326 @override |
| 463 Object visitAnnotation(Annotation node) { | 327 Object visitAnnotation(Annotation node) { |
| 464 computer._addIdentifierRegion_annotation(node); | 328 computer._addIdentifierRegion_annotation(node); |
| 465 return super.visitAnnotation(node); | 329 return super.visitAnnotation(node); |
| 466 } | 330 } |
| 467 | 331 |
| 468 @override | 332 @override |
| 469 Object visitAsExpression(AsExpression node) { | 333 Object visitAsExpression(AsExpression node) { |
| 470 computer._addRegion_token(node.asOperator, HighlightType.BUILT_IN); | 334 computer._addRegion_token(node.asOperator, HighlightRegionType.BUILT_IN); |
| 471 return super.visitAsExpression(node); | 335 return super.visitAsExpression(node); |
| 472 } | 336 } |
| 473 | 337 |
| 474 @override | 338 @override |
| 475 Object visitAssertStatement(AssertStatement node) { | 339 Object visitAssertStatement(AssertStatement node) { |
| 476 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 340 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 477 return super.visitAssertStatement(node); | 341 return super.visitAssertStatement(node); |
| 478 } | 342 } |
| 479 | 343 |
| 480 @override | 344 @override |
| 481 Object visitBooleanLiteral(BooleanLiteral node) { | 345 Object visitBooleanLiteral(BooleanLiteral node) { |
| 482 computer._addRegion_node(node, HighlightType.KEYWORD); | 346 computer._addRegion_node(node, HighlightRegionType.KEYWORD); |
| 483 computer._addRegion_node(node, HighlightType.LITERAL_BOOLEAN); | 347 computer._addRegion_node(node, HighlightRegionType.LITERAL_BOOLEAN); |
| 484 return super.visitBooleanLiteral(node); | 348 return super.visitBooleanLiteral(node); |
| 485 } | 349 } |
| 486 | 350 |
| 487 @override | 351 @override |
| 488 Object visitBreakStatement(BreakStatement node) { | 352 Object visitBreakStatement(BreakStatement node) { |
| 489 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 353 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 490 return super.visitBreakStatement(node); | 354 return super.visitBreakStatement(node); |
| 491 } | 355 } |
| 492 | 356 |
| 493 @override | 357 @override |
| 494 Object visitCatchClause(CatchClause node) { | 358 Object visitCatchClause(CatchClause node) { |
| 495 computer._addRegion_token(node.catchKeyword, HighlightType.KEYWORD); | 359 computer._addRegion_token(node.catchKeyword, HighlightRegionType.KEYWORD); |
| 496 computer._addRegion_token(node.onKeyword, HighlightType.BUILT_IN); | 360 computer._addRegion_token(node.onKeyword, HighlightRegionType.BUILT_IN); |
| 497 return super.visitCatchClause(node); | 361 return super.visitCatchClause(node); |
| 498 } | 362 } |
| 499 | 363 |
| 500 @override | 364 @override |
| 501 Object visitClassDeclaration(ClassDeclaration node) { | 365 Object visitClassDeclaration(ClassDeclaration node) { |
| 502 computer._addRegion_token(node.classKeyword, HighlightType.KEYWORD); | 366 computer._addRegion_token(node.classKeyword, HighlightRegionType.KEYWORD); |
| 503 computer._addRegion_token(node.abstractKeyword, HighlightType.BUILT_IN); | 367 computer._addRegion_token(node.abstractKeyword, HighlightRegionType.BUILT_IN
); |
| 504 return super.visitClassDeclaration(node); | 368 return super.visitClassDeclaration(node); |
| 505 } | 369 } |
| 506 | 370 |
| 507 @override | 371 @override |
| 508 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 372 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 509 computer._addRegion_token(node.externalKeyword, HighlightType.BUILT_IN); | 373 computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN
); |
| 510 computer._addRegion_token(node.factoryKeyword, HighlightType.BUILT_IN); | 374 computer._addRegion_token(node.factoryKeyword, HighlightRegionType.BUILT_IN)
; |
| 511 return super.visitConstructorDeclaration(node); | 375 return super.visitConstructorDeclaration(node); |
| 512 } | 376 } |
| 513 | 377 |
| 514 @override | 378 @override |
| 515 Object visitContinueStatement(ContinueStatement node) { | 379 Object visitContinueStatement(ContinueStatement node) { |
| 516 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 380 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 517 return super.visitContinueStatement(node); | 381 return super.visitContinueStatement(node); |
| 518 } | 382 } |
| 519 | 383 |
| 520 @override | 384 @override |
| 521 Object visitDoStatement(DoStatement node) { | 385 Object visitDoStatement(DoStatement node) { |
| 522 computer._addRegion_token(node.doKeyword, HighlightType.KEYWORD); | 386 computer._addRegion_token(node.doKeyword, HighlightRegionType.KEYWORD); |
| 523 computer._addRegion_token(node.whileKeyword, HighlightType.KEYWORD); | 387 computer._addRegion_token(node.whileKeyword, HighlightRegionType.KEYWORD); |
| 524 return super.visitDoStatement(node); | 388 return super.visitDoStatement(node); |
| 525 } | 389 } |
| 526 | 390 |
| 527 @override | 391 @override |
| 528 Object visitDoubleLiteral(DoubleLiteral node) { | 392 Object visitDoubleLiteral(DoubleLiteral node) { |
| 529 computer._addRegion_node(node, HighlightType.LITERAL_DOUBLE); | 393 computer._addRegion_node(node, HighlightRegionType.LITERAL_DOUBLE); |
| 530 return super.visitDoubleLiteral(node); | 394 return super.visitDoubleLiteral(node); |
| 531 } | 395 } |
| 532 | 396 |
| 533 @override | 397 @override |
| 534 Object visitExportDirective(ExportDirective node) { | 398 Object visitExportDirective(ExportDirective node) { |
| 535 computer._addRegion_node(node, HighlightType.DIRECTIVE); | 399 computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); |
| 536 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 400 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 537 return super.visitExportDirective(node); | 401 return super.visitExportDirective(node); |
| 538 } | 402 } |
| 539 | 403 |
| 540 @override | 404 @override |
| 541 Object visitFieldDeclaration(FieldDeclaration node) { | 405 Object visitFieldDeclaration(FieldDeclaration node) { |
| 542 computer._addRegion_token(node.staticKeyword, HighlightType.BUILT_IN); | 406 computer._addRegion_token(node.staticKeyword, HighlightRegionType.BUILT_IN); |
| 543 return super.visitFieldDeclaration(node); | 407 return super.visitFieldDeclaration(node); |
| 544 } | 408 } |
| 545 | 409 |
| 546 @override | 410 @override |
| 547 Object visitForEachStatement(ForEachStatement node) { | 411 Object visitForEachStatement(ForEachStatement node) { |
| 548 computer._addRegion_token(node.forKeyword, HighlightType.KEYWORD); | 412 computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD); |
| 549 computer._addRegion_token(node.inKeyword, HighlightType.KEYWORD); | 413 computer._addRegion_token(node.inKeyword, HighlightRegionType.KEYWORD); |
| 550 return super.visitForEachStatement(node); | 414 return super.visitForEachStatement(node); |
| 551 } | 415 } |
| 552 | 416 |
| 553 @override | 417 @override |
| 554 Object visitForStatement(ForStatement node) { | 418 Object visitForStatement(ForStatement node) { |
| 555 computer._addRegion_token(node.forKeyword, HighlightType.KEYWORD); | 419 computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD); |
| 556 return super.visitForStatement(node); | 420 return super.visitForStatement(node); |
| 557 } | 421 } |
| 558 | 422 |
| 559 @override | 423 @override |
| 560 Object visitFunctionDeclaration(FunctionDeclaration node) { | 424 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 561 computer._addRegion_token(node.externalKeyword, HighlightType.BUILT_IN); | 425 computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN
); |
| 562 computer._addRegion_token(node.propertyKeyword, HighlightType.BUILT_IN); | 426 computer._addRegion_token(node.propertyKeyword, HighlightRegionType.BUILT_IN
); |
| 563 return super.visitFunctionDeclaration(node); | 427 return super.visitFunctionDeclaration(node); |
| 564 } | 428 } |
| 565 | 429 |
| 566 @override | 430 @override |
| 567 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 431 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 568 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 432 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 569 return super.visitFunctionTypeAlias(node); | 433 return super.visitFunctionTypeAlias(node); |
| 570 } | 434 } |
| 571 | 435 |
| 572 @override | 436 @override |
| 573 Object visitHideCombinator(HideCombinator node) { | 437 Object visitHideCombinator(HideCombinator node) { |
| 574 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 438 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 575 return super.visitHideCombinator(node); | 439 return super.visitHideCombinator(node); |
| 576 } | 440 } |
| 577 | 441 |
| 578 @override | 442 @override |
| 579 Object visitIfStatement(IfStatement node) { | 443 Object visitIfStatement(IfStatement node) { |
| 580 computer._addRegion_token(node.ifKeyword, HighlightType.KEYWORD); | 444 computer._addRegion_token(node.ifKeyword, HighlightRegionType.KEYWORD); |
| 581 return super.visitIfStatement(node); | 445 return super.visitIfStatement(node); |
| 582 } | 446 } |
| 583 | 447 |
| 584 @override | 448 @override |
| 585 Object visitImplementsClause(ImplementsClause node) { | 449 Object visitImplementsClause(ImplementsClause node) { |
| 586 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 450 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 587 return super.visitImplementsClause(node); | 451 return super.visitImplementsClause(node); |
| 588 } | 452 } |
| 589 | 453 |
| 590 @override | 454 @override |
| 591 Object visitImportDirective(ImportDirective node) { | 455 Object visitImportDirective(ImportDirective node) { |
| 592 computer._addRegion_node(node, HighlightType.DIRECTIVE); | 456 computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); |
| 593 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 457 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 594 computer._addRegion_token(node.deferredToken, HighlightType.BUILT_IN); | 458 computer._addRegion_token(node.deferredToken, HighlightRegionType.BUILT_IN); |
| 595 computer._addRegion_token(node.asToken, HighlightType.BUILT_IN); | 459 computer._addRegion_token(node.asToken, HighlightRegionType.BUILT_IN); |
| 596 return super.visitImportDirective(node); | 460 return super.visitImportDirective(node); |
| 597 } | 461 } |
| 598 | 462 |
| 599 @override | 463 @override |
| 600 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 464 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 601 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 465 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 602 return super.visitInstanceCreationExpression(node); | 466 return super.visitInstanceCreationExpression(node); |
| 603 } | 467 } |
| 604 | 468 |
| 605 @override | 469 @override |
| 606 Object visitIntegerLiteral(IntegerLiteral node) { | 470 Object visitIntegerLiteral(IntegerLiteral node) { |
| 607 computer._addRegion_node(node, HighlightType.LITERAL_INTEGER); | 471 computer._addRegion_node(node, HighlightRegionType.LITERAL_INTEGER); |
| 608 return super.visitIntegerLiteral(node); | 472 return super.visitIntegerLiteral(node); |
| 609 } | 473 } |
| 610 | 474 |
| 611 @override | 475 @override |
| 612 Object visitIsExpression(IsExpression node) { | 476 Object visitIsExpression(IsExpression node) { |
| 613 computer._addRegion_token(node.isOperator, HighlightType.KEYWORD); | 477 computer._addRegion_token(node.isOperator, HighlightRegionType.KEYWORD); |
| 614 return super.visitIsExpression(node); | 478 return super.visitIsExpression(node); |
| 615 } | 479 } |
| 616 | 480 |
| 617 @override | 481 @override |
| 618 Object visitLibraryDirective(LibraryDirective node) { | 482 Object visitLibraryDirective(LibraryDirective node) { |
| 619 computer._addRegion_node(node, HighlightType.DIRECTIVE); | 483 computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); |
| 620 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 484 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 621 return super.visitLibraryDirective(node); | 485 return super.visitLibraryDirective(node); |
| 622 } | 486 } |
| 623 | 487 |
| 624 @override | 488 @override |
| 625 Object visitListLiteral(ListLiteral node) { | 489 Object visitListLiteral(ListLiteral node) { |
| 626 computer._addRegion_node(node, HighlightType.LITERAL_LIST); | 490 computer._addRegion_node(node, HighlightRegionType.LITERAL_LIST); |
| 627 computer._addRegion_token(node.constKeyword, HighlightType.KEYWORD); | 491 computer._addRegion_token(node.constKeyword, HighlightRegionType.KEYWORD); |
| 628 return super.visitListLiteral(node); | 492 return super.visitListLiteral(node); |
| 629 } | 493 } |
| 630 | 494 |
| 631 @override | 495 @override |
| 632 Object visitMapLiteral(MapLiteral node) { | 496 Object visitMapLiteral(MapLiteral node) { |
| 633 computer._addRegion_node(node, HighlightType.LITERAL_MAP); | 497 computer._addRegion_node(node, HighlightRegionType.LITERAL_MAP); |
| 634 computer._addRegion_token(node.constKeyword, HighlightType.KEYWORD); | 498 computer._addRegion_token(node.constKeyword, HighlightRegionType.KEYWORD); |
| 635 return super.visitMapLiteral(node); | 499 return super.visitMapLiteral(node); |
| 636 } | 500 } |
| 637 | 501 |
| 638 @override | 502 @override |
| 639 Object visitMethodDeclaration(MethodDeclaration node) { | 503 Object visitMethodDeclaration(MethodDeclaration node) { |
| 640 computer._addRegion_token(node.externalKeyword, HighlightType.BUILT_IN); | 504 computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN
); |
| 641 computer._addRegion_token(node.modifierKeyword, HighlightType.BUILT_IN); | 505 computer._addRegion_token(node.modifierKeyword, HighlightRegionType.BUILT_IN
); |
| 642 computer._addRegion_token(node.operatorKeyword, HighlightType.BUILT_IN); | 506 computer._addRegion_token(node.operatorKeyword, HighlightRegionType.BUILT_IN
); |
| 643 computer._addRegion_token(node.propertyKeyword, HighlightType.BUILT_IN); | 507 computer._addRegion_token(node.propertyKeyword, HighlightRegionType.BUILT_IN
); |
| 644 return super.visitMethodDeclaration(node); | 508 return super.visitMethodDeclaration(node); |
| 645 } | 509 } |
| 646 | 510 |
| 647 @override | 511 @override |
| 648 Object visitNativeClause(NativeClause node) { | 512 Object visitNativeClause(NativeClause node) { |
| 649 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 513 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 650 return super.visitNativeClause(node); | 514 return super.visitNativeClause(node); |
| 651 } | 515 } |
| 652 | 516 |
| 653 @override | 517 @override |
| 654 Object visitNativeFunctionBody(NativeFunctionBody node) { | 518 Object visitNativeFunctionBody(NativeFunctionBody node) { |
| 655 computer._addRegion_token(node.nativeToken, HighlightType.BUILT_IN); | 519 computer._addRegion_token(node.nativeToken, HighlightRegionType.BUILT_IN); |
| 656 return super.visitNativeFunctionBody(node); | 520 return super.visitNativeFunctionBody(node); |
| 657 } | 521 } |
| 658 | 522 |
| 659 @override | 523 @override |
| 660 Object visitPartDirective(PartDirective node) { | 524 Object visitPartDirective(PartDirective node) { |
| 661 computer._addRegion_node(node, HighlightType.DIRECTIVE); | 525 computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); |
| 662 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 526 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 663 return super.visitPartDirective(node); | 527 return super.visitPartDirective(node); |
| 664 } | 528 } |
| 665 | 529 |
| 666 @override | 530 @override |
| 667 Object visitPartOfDirective(PartOfDirective node) { | 531 Object visitPartOfDirective(PartOfDirective node) { |
| 668 computer._addRegion_node(node, HighlightType.DIRECTIVE); | 532 computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); |
| 669 computer._addRegion_tokenStart_tokenEnd( | 533 computer._addRegion_tokenStart_tokenEnd( |
| 670 node.partToken, | 534 node.partToken, |
| 671 node.ofToken, | 535 node.ofToken, |
| 672 HighlightType.BUILT_IN); | 536 HighlightRegionType.BUILT_IN); |
| 673 return super.visitPartOfDirective(node); | 537 return super.visitPartOfDirective(node); |
| 674 } | 538 } |
| 675 | 539 |
| 676 @override | 540 @override |
| 677 Object visitRethrowExpression(RethrowExpression node) { | 541 Object visitRethrowExpression(RethrowExpression node) { |
| 678 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 542 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 679 return super.visitRethrowExpression(node); | 543 return super.visitRethrowExpression(node); |
| 680 } | 544 } |
| 681 | 545 |
| 682 @override | 546 @override |
| 683 Object visitReturnStatement(ReturnStatement node) { | 547 Object visitReturnStatement(ReturnStatement node) { |
| 684 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 548 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 685 return super.visitReturnStatement(node); | 549 return super.visitReturnStatement(node); |
| 686 } | 550 } |
| 687 | 551 |
| 688 @override | 552 @override |
| 689 Object visitShowCombinator(ShowCombinator node) { | 553 Object visitShowCombinator(ShowCombinator node) { |
| 690 computer._addRegion_token(node.keyword, HighlightType.BUILT_IN); | 554 computer._addRegion_token(node.keyword, HighlightRegionType.BUILT_IN); |
| 691 return super.visitShowCombinator(node); | 555 return super.visitShowCombinator(node); |
| 692 } | 556 } |
| 693 | 557 |
| 694 @override | 558 @override |
| 695 Object visitSimpleIdentifier(SimpleIdentifier node) { | 559 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 696 computer._addIdentifierRegion(node); | 560 computer._addIdentifierRegion(node); |
| 697 return super.visitSimpleIdentifier(node); | 561 return super.visitSimpleIdentifier(node); |
| 698 } | 562 } |
| 699 | 563 |
| 700 @override | 564 @override |
| 701 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | 565 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 702 computer._addRegion_node(node, HighlightType.LITERAL_STRING); | 566 computer._addRegion_node(node, HighlightRegionType.LITERAL_STRING); |
| 703 return super.visitSimpleStringLiteral(node); | 567 return super.visitSimpleStringLiteral(node); |
| 704 } | 568 } |
| 705 | 569 |
| 706 @override | 570 @override |
| 707 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 571 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 708 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 572 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 709 return super.visitSuperConstructorInvocation(node); | 573 return super.visitSuperConstructorInvocation(node); |
| 710 } | 574 } |
| 711 | 575 |
| 712 @override | 576 @override |
| 713 Object visitSwitchCase(SwitchCase node) { | 577 Object visitSwitchCase(SwitchCase node) { |
| 714 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 578 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 715 return super.visitSwitchCase(node); | 579 return super.visitSwitchCase(node); |
| 716 } | 580 } |
| 717 | 581 |
| 718 @override | 582 @override |
| 719 Object visitSwitchDefault(SwitchDefault node) { | 583 Object visitSwitchDefault(SwitchDefault node) { |
| 720 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 584 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 721 return super.visitSwitchDefault(node); | 585 return super.visitSwitchDefault(node); |
| 722 } | 586 } |
| 723 | 587 |
| 724 @override | 588 @override |
| 725 Object visitSwitchStatement(SwitchStatement node) { | 589 Object visitSwitchStatement(SwitchStatement node) { |
| 726 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 590 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 727 return super.visitSwitchStatement(node); | 591 return super.visitSwitchStatement(node); |
| 728 } | 592 } |
| 729 | 593 |
| 730 @override | 594 @override |
| 731 Object visitThisExpression(ThisExpression node) { | 595 Object visitThisExpression(ThisExpression node) { |
| 732 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 596 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 733 return super.visitThisExpression(node); | 597 return super.visitThisExpression(node); |
| 734 } | 598 } |
| 735 | 599 |
| 736 @override | 600 @override |
| 737 Object visitTryStatement(TryStatement node) { | 601 Object visitTryStatement(TryStatement node) { |
| 738 computer._addRegion_token(node.tryKeyword, HighlightType.KEYWORD); | 602 computer._addRegion_token(node.tryKeyword, HighlightRegionType.KEYWORD); |
| 739 computer._addRegion_token(node.finallyKeyword, HighlightType.KEYWORD); | 603 computer._addRegion_token(node.finallyKeyword, HighlightRegionType.KEYWORD); |
| 740 return super.visitTryStatement(node); | 604 return super.visitTryStatement(node); |
| 741 } | 605 } |
| 742 | 606 |
| 743 @override | 607 @override |
| 744 Object visitTypeName(TypeName node) { | 608 Object visitTypeName(TypeName node) { |
| 745 DartType type = node.type; | 609 DartType type = node.type; |
| 746 if (type != null) { | 610 if (type != null) { |
| 747 if (type.isDynamic && node.name.name == "dynamic") { | 611 if (type.isDynamic && node.name.name == "dynamic") { |
| 748 computer._addRegion_node(node, HighlightType.TYPE_NAME_DYNAMIC); | 612 computer._addRegion_node(node, HighlightRegionType.TYPE_NAME_DYNAMIC); |
| 749 return null; | 613 return null; |
| 750 } | 614 } |
| 751 } | 615 } |
| 752 return super.visitTypeName(node); | 616 return super.visitTypeName(node); |
| 753 } | 617 } |
| 754 | 618 |
| 755 @override | 619 @override |
| 756 Object visitVariableDeclarationList(VariableDeclarationList node) { | 620 Object visitVariableDeclarationList(VariableDeclarationList node) { |
| 757 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 621 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 758 return super.visitVariableDeclarationList(node); | 622 return super.visitVariableDeclarationList(node); |
| 759 } | 623 } |
| 760 | 624 |
| 761 @override | 625 @override |
| 762 Object visitWhileStatement(WhileStatement node) { | 626 Object visitWhileStatement(WhileStatement node) { |
| 763 computer._addRegion_token(node.keyword, HighlightType.KEYWORD); | 627 computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); |
| 764 return super.visitWhileStatement(node); | 628 return super.visitWhileStatement(node); |
| 765 } | 629 } |
| 766 | 630 |
| 767 @override | 631 @override |
| 768 Object visitWithClause(WithClause node) { | 632 Object visitWithClause(WithClause node) { |
| 769 computer._addRegion_token(node.withKeyword, HighlightType.KEYWORD); | 633 computer._addRegion_token(node.withKeyword, HighlightRegionType.KEYWORD); |
| 770 return super.visitWithClause(node); | 634 return super.visitWithClause(node); |
| 771 } | 635 } |
| 772 } | 636 } |
| OLD | NEW |