| 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:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| 10 | 11 |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. | 14 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. |
| 14 */ | 15 */ |
| 15 class DartUnitHighlightsComputer { | 16 class DartUnitHighlightsComputer { |
| 16 final CompilationUnit _unit; | 17 final CompilationUnit _unit; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 257 |
| 257 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) { | 258 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) { |
| 258 Element element = node.staticElement; | 259 Element element = node.staticElement; |
| 259 if (element is! TypeParameterElement) { | 260 if (element is! TypeParameterElement) { |
| 260 return false; | 261 return false; |
| 261 } | 262 } |
| 262 return _addRegion_node(node, HighlightType.TYPE_PARAMETER); | 263 return _addRegion_node(node, HighlightType.TYPE_PARAMETER); |
| 263 } | 264 } |
| 264 | 265 |
| 265 void _addRegion(int offset, int length, HighlightType type) { | 266 void _addRegion(int offset, int length, HighlightType type) { |
| 266 _regions.add({'offset': offset, 'length': length, 'type': type.name}); | 267 _regions.add({OFFSET: offset, LENGTH: length, TYPE: type.name}); |
| 267 } | 268 } |
| 268 | 269 |
| 269 bool _addRegion_node(AstNode node, HighlightType type) { | 270 bool _addRegion_node(AstNode node, HighlightType type) { |
| 270 int offset = node.offset; | 271 int offset = node.offset; |
| 271 int length = node.length; | 272 int length = node.length; |
| 272 _addRegion(offset, length, type); | 273 _addRegion(offset, length, type); |
| 273 return true; | 274 return true; |
| 274 } | 275 } |
| 275 | 276 |
| 276 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightType type) { | 277 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightType type) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 static const HighlightType METHOD = const HighlightType('METHOD'); | 504 static const HighlightType METHOD = const HighlightType('METHOD'); |
| 504 static const HighlightType METHOD_STATIC = const HighlightType('METHOD_STATIC'
); | 505 static const HighlightType METHOD_STATIC = const HighlightType('METHOD_STATIC'
); |
| 505 static const HighlightType PARAMETER = const HighlightType('PARAMETER'); | 506 static const HighlightType PARAMETER = const HighlightType('PARAMETER'); |
| 506 static const HighlightType SETTER_DECLARATION = const HighlightType('SETTER_DE
CLARATION'); | 507 static const HighlightType SETTER_DECLARATION = const HighlightType('SETTER_DE
CLARATION'); |
| 507 static const HighlightType TOP_LEVEL_VARIABLE = const HighlightType('TOP_LEVEL
_VARIABLE'); | 508 static const HighlightType TOP_LEVEL_VARIABLE = const HighlightType('TOP_LEVEL
_VARIABLE'); |
| 508 static const HighlightType TYPE_NAME_DYNAMIC = const HighlightType('TYPE_NAME_
DYNAMIC'); | 509 static const HighlightType TYPE_NAME_DYNAMIC = const HighlightType('TYPE_NAME_
DYNAMIC'); |
| 509 static const HighlightType TYPE_PARAMETER = const HighlightType('TYPE_PARAMETE
R'); | 510 static const HighlightType TYPE_PARAMETER = const HighlightType('TYPE_PARAMETE
R'); |
| 510 | 511 |
| 511 final String name; | 512 final String name; |
| 512 | 513 |
| 513 @override | |
| 514 String toString() => name; | |
| 515 | |
| 516 const HighlightType(this.name); | 514 const HighlightType(this.name); |
| 517 } | 515 } |
| OLD | NEW |