| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library service.computers; | 8 library service.computers; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/java_core.dart' show JavaStringBuilder, S
tringUtils; | 10 import 'package:analyzer/src/generated/java_core.dart' show JavaStringBuilder, S
tringUtils; |
| 11 import 'package:analyzer/src/generated/java_engine.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart' show Source; | 12 import 'package:analyzer/src/generated/source.dart' show Source; |
| 12 import 'package:analyzer/src/generated/scanner.dart' show Token; | 13 import 'package:analyzer/src/generated/scanner.dart' show Token; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart' show Element; | 15 import 'package:analyzer/src/generated/element.dart'; |
| 15 import 'service_interfaces.dart'; | 16 import 'service_interfaces.dart'; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * A concrete implementation of [SourceRegion]. | 19 * A concrete implementation of [SourceRegion]. |
| 19 */ | 20 */ |
| 20 class SourceRegionImpl implements SourceRegion { | 21 class SourceRegionImpl implements SourceRegion { |
| 21 final int offset; | 22 final int offset; |
| 22 | 23 |
| 23 final int length; | 24 final int length; |
| 24 | 25 |
| 25 SourceRegionImpl(this.offset, this.length); | 26 SourceRegionImpl(this.offset, this.length); |
| 26 | 27 |
| 27 @override | 28 @override |
| 28 bool containsInclusive(int x) => offset <= x && x <= offset + length; | 29 bool containsInclusive(int x) => offset <= x && x <= offset + length; |
| 29 | 30 |
| 30 @override | 31 @override |
| 32 bool operator ==(Object obj) { |
| 33 if (identical(obj, this)) { |
| 34 return true; |
| 35 } |
| 36 if (obj is! SourceRegion) { |
| 37 return false; |
| 38 } |
| 39 SourceRegion other = obj as SourceRegion; |
| 40 return other.offset == offset && other.length == length; |
| 41 } |
| 42 |
| 43 @override |
| 44 int get hashCode => ObjectUtilities.combineHashCodes(offset, length); |
| 45 |
| 46 @override |
| 31 String toString() { | 47 String toString() { |
| 32 JavaStringBuilder builder = new JavaStringBuilder(); | 48 JavaStringBuilder builder = new JavaStringBuilder(); |
| 33 builder.append("[offset="); | 49 builder.append("[offset="); |
| 34 builder.append(offset); | 50 builder.append(offset); |
| 35 builder.append(", length="); | 51 builder.append(", length="); |
| 36 builder.append(length); | 52 builder.append(length); |
| 37 builder.append("]"); | 53 builder.append("]"); |
| 38 return builder.toString(); | 54 return builder.toString(); |
| 39 } | 55 } |
| 40 } | 56 } |
| 41 | 57 |
| 42 /** | 58 /** |
| 43 * A concrete implementation of [Outline]. | 59 * A concrete implementation of [Outline]. |
| 44 */ | 60 */ |
| 45 class OutlineImpl implements Outline { | 61 class OutlineImpl implements Outline { |
| 46 final Outline parent; | 62 final Outline parent; |
| 47 | 63 |
| 64 final SourceRegion sourceRegion; |
| 65 |
| 48 final OutlineKind kind; | 66 final OutlineKind kind; |
| 49 | 67 |
| 50 final String name; | 68 final String name; |
| 51 | 69 |
| 52 final int offset; | 70 final int offset; |
| 53 | 71 |
| 54 final int length; | 72 final int length; |
| 55 | 73 |
| 56 final String arguments; | 74 final String parameters; |
| 57 | 75 |
| 58 final String returnType; | 76 final String returnType; |
| 59 | 77 |
| 78 final bool isAbstract; |
| 79 |
| 80 final bool isStatic; |
| 81 |
| 60 List<Outline> children = Outline.EMPTY_ARRAY; | 82 List<Outline> children = Outline.EMPTY_ARRAY; |
| 61 | 83 |
| 62 OutlineImpl(this.parent, this.kind, this.name, this.offset, this.length, this.
arguments, this.returnType); | 84 OutlineImpl(this.parent, this.sourceRegion, this.kind, this.name, this.offset,
this.length, this.parameters, this.returnType, this.isAbstract, this.isStatic); |
| 85 |
| 86 @override |
| 87 bool operator ==(Object obj) { |
| 88 if (identical(obj, this)) { |
| 89 return true; |
| 90 } |
| 91 if (obj is! OutlineImpl) { |
| 92 return false; |
| 93 } |
| 94 OutlineImpl other = obj as OutlineImpl; |
| 95 return (other.parent == parent) && other.offset == offset; |
| 96 } |
| 97 |
| 98 @override |
| 99 int get hashCode => offset; |
| 100 |
| 101 @override |
| 102 bool get isPrivate => StringUtilities.startsWithChar(name, 0x5F); |
| 63 | 103 |
| 64 @override | 104 @override |
| 65 String toString() { | 105 String toString() { |
| 66 JavaStringBuilder builder = new JavaStringBuilder(); | 106 JavaStringBuilder builder = new JavaStringBuilder(); |
| 67 builder.append("[name="); | 107 builder.append("[name="); |
| 68 builder.append(name); | 108 builder.append(name); |
| 69 builder.append(", kind="); | 109 builder.append(", kind="); |
| 70 builder.append(kind); | 110 builder.append(kind); |
| 71 builder.append(", offset="); | 111 builder.append(", offset="); |
| 72 builder.append(offset); | 112 builder.append(offset); |
| 73 builder.append(", length="); | 113 builder.append(", length="); |
| 74 builder.append(length); | 114 builder.append(length); |
| 75 builder.append(", arguments="); | 115 builder.append(", parameters="); |
| 76 builder.append(arguments); | 116 builder.append(parameters); |
| 77 builder.append(", return="); | 117 builder.append(", return="); |
| 78 builder.append(returnType); | 118 builder.append(returnType); |
| 79 builder.append(", children=["); | 119 builder.append(", children=["); |
| 80 builder.append(StringUtils.join(children, ", ")); | 120 builder.append(StringUtils.join(children, ", ")); |
| 81 builder.append("]]"); | 121 builder.append("]]"); |
| 82 return builder.toString(); | 122 return builder.toString(); |
| 83 } | 123 } |
| 84 } | 124 } |
| 85 | 125 |
| 86 /** | 126 /** |
| 127 * A concrete implementation of [HighlightRegion]. |
| 128 */ |
| 129 class HighlightRegionImpl extends SourceRegionImpl implements HighlightRegion { |
| 130 final HighlightType type; |
| 131 |
| 132 HighlightRegionImpl(int offset, int length, this.type) : super(offset, length)
; |
| 133 |
| 134 @override |
| 135 String toString() { |
| 136 JavaStringBuilder builder = new JavaStringBuilder(); |
| 137 builder.append("[offset="); |
| 138 builder.append(offset); |
| 139 builder.append(", length="); |
| 140 builder.append(length); |
| 141 builder.append(", type="); |
| 142 builder.append(type); |
| 143 builder.append("]"); |
| 144 return builder.toString(); |
| 145 } |
| 146 } |
| 147 |
| 148 /** |
| 87 * A computer for [NavigationRegion]s in a Dart [CompilationUnit]. | 149 * A computer for [NavigationRegion]s in a Dart [CompilationUnit]. |
| 88 */ | 150 */ |
| 89 class DartUnitNavigationComputer { | 151 class DartUnitNavigationComputer { |
| 90 final CompilationUnit _unit; | 152 final CompilationUnit _unit; |
| 91 | 153 |
| 92 List<NavigationRegion> _regions = []; | 154 List<NavigationRegion> _regions = []; |
| 93 | 155 |
| 94 DartUnitNavigationComputer(this._unit); | 156 DartUnitNavigationComputer(this._unit); |
| 95 | 157 |
| 96 /** | 158 /** |
| 97 * Returns the computed [NavigationRegion]s, not `null`. | 159 * Returns the computed [NavigationRegion]s, not `null`. |
| 98 */ | 160 */ |
| 99 List<NavigationRegion> compute() { | 161 List<NavigationRegion> compute() { |
| 100 _unit.accept(new RecursiveAstVisitor_DartUnitNavigationComputer_compute(this
)); | 162 _unit.accept(new RecursiveAstVisitor_DartUnitNavigationComputer_compute(this
)); |
| 101 return new List.from(_regions); | 163 return new List.from(_regions); |
| 102 } | 164 } |
| 103 | 165 |
| 104 /** | 166 /** |
| 105 * If the given [Element] is not `null`, then creates a corresponding | 167 * If the given [Element] is not `null`, then creates a corresponding |
| 106 * [NavigationRegion]. | 168 * [NavigationRegion]. |
| 107 */ | 169 */ |
| 108 void _addRegionForNode(AstNode node, Element element) { | |
| 109 int offset = node.offset; | |
| 110 int length = node.length; | |
| 111 _addRegion(offset, length, element); | |
| 112 } | |
| 113 | |
| 114 /** | |
| 115 * If the given [Element] is not `null`, then creates a corresponding | |
| 116 * [NavigationRegion]. | |
| 117 */ | |
| 118 void _addRegion(int offset, int length, Element element) { | 170 void _addRegion(int offset, int length, Element element) { |
| 119 NavigationTarget target = _createTarget(element); | 171 NavigationTarget target = _createTarget(element); |
| 120 if (target == null) { | 172 if (target == null) { |
| 121 return; | 173 return; |
| 122 } | 174 } |
| 123 _regions.add(new NavigationRegionImpl(offset, length, <NavigationTarget> [ta
rget])); | 175 _regions.add(new NavigationRegionImpl(offset, length, <NavigationTarget> [ta
rget])); |
| 124 } | 176 } |
| 125 | 177 |
| 126 /** | 178 /** |
| 127 * If the given [Element] is not `null`, then creates a corresponding | 179 * If the given [Element] is not `null`, then creates a corresponding |
| 128 * [NavigationRegion]. | 180 * [NavigationRegion]. |
| 129 */ | 181 */ |
| 182 void _addRegionForNode(AstNode node, Element element) { |
| 183 int offset = node.offset; |
| 184 int length = node.length; |
| 185 _addRegion(offset, length, element); |
| 186 } |
| 187 |
| 188 /** |
| 189 * If the given [Element] is not `null`, then creates a corresponding |
| 190 * [NavigationRegion]. |
| 191 */ |
| 130 void _addRegionForToken(Token token, Element element) { | 192 void _addRegionForToken(Token token, Element element) { |
| 131 int offset = token.offset; | 193 int offset = token.offset; |
| 132 int length = token.length; | 194 int length = token.length; |
| 133 _addRegion(offset, length, element); | 195 _addRegion(offset, length, element); |
| 134 } | 196 } |
| 135 | 197 |
| 136 /** | 198 /** |
| 137 * Returns the [NavigationTarget] for the given [Element], maybe `null` if | 199 * Returns the [NavigationTarget] for the given [Element], maybe `null` if |
| 138 * `null` was given. | 200 * `null` was given. |
| 139 */ | 201 */ |
| 140 NavigationTarget _createTarget(Element element) { | 202 NavigationTarget _createTarget(Element element) { |
| 141 if (element == null) { | 203 if (element == null) { |
| 142 return null; | 204 return null; |
| 143 } | 205 } |
| 206 if (element is FieldFormalParameterElement) { |
| 207 element = (element as FieldFormalParameterElement).field; |
| 208 } |
| 144 return new NavigationTargetImpl(element.source, _getElementId(element), elem
ent.nameOffset, element.displayName.length); | 209 return new NavigationTargetImpl(element.source, _getElementId(element), elem
ent.nameOffset, element.displayName.length); |
| 145 } | 210 } |
| 146 | 211 |
| 147 String _getElementId(Element element) => element.location.encoding; | 212 String _getElementId(Element element) => element.location.encoding; |
| 148 } | 213 } |
| 149 | 214 |
| 150 class RecursiveAstVisitor_DartUnitNavigationComputer_compute extends RecursiveAs
tVisitor<Object> { | 215 class RecursiveAstVisitor_DartUnitNavigationComputer_compute extends RecursiveAs
tVisitor<Object> { |
| 151 final DartUnitNavigationComputer DartUnitNavigationComputer_this; | 216 final DartUnitNavigationComputer DartUnitNavigationComputer_this; |
| 152 | 217 |
| 153 RecursiveAstVisitor_DartUnitNavigationComputer_compute(this.DartUnitNavigation
Computer_this) : super(); | 218 RecursiveAstVisitor_DartUnitNavigationComputer_compute(this.DartUnitNavigation
Computer_this) : super(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 } | 248 } |
| 184 | 249 |
| 185 @override | 250 @override |
| 186 Object visitSimpleIdentifier(SimpleIdentifier node) { | 251 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 187 DartUnitNavigationComputer_this._addRegionForNode(node, node.bestElement); | 252 DartUnitNavigationComputer_this._addRegionForNode(node, node.bestElement); |
| 188 return super.visitSimpleIdentifier(node); | 253 return super.visitSimpleIdentifier(node); |
| 189 } | 254 } |
| 190 } | 255 } |
| 191 | 256 |
| 192 /** | 257 /** |
| 258 * A computer for [HighlightRegion]s in a Dart [CompilationUnit]. |
| 259 */ |
| 260 class DartUnitHighlightsComputer { |
| 261 final CompilationUnit _unit; |
| 262 |
| 263 List<HighlightRegion> _regions = []; |
| 264 |
| 265 DartUnitHighlightsComputer(this._unit); |
| 266 |
| 267 /** |
| 268 * Returns the computed [HighlightRegion]s, not `null`. |
| 269 */ |
| 270 List<HighlightRegion> compute() { |
| 271 _unit.accept(new RecursiveAstVisitor_DartUnitHighlightsComputer_compute(this
)); |
| 272 return new List.from(_regions); |
| 273 } |
| 274 |
| 275 void _addIdentifierRegion(SimpleIdentifier node) { |
| 276 if (_addIdentifierRegion_keyword(node)) { |
| 277 return; |
| 278 } |
| 279 if (_addIdentifierRegion_class(node)) { |
| 280 return; |
| 281 } |
| 282 if (_addIdentifierRegion_constructor(node)) { |
| 283 return; |
| 284 } |
| 285 if (_addIdentifierRegion_dynamicType(node)) { |
| 286 return; |
| 287 } |
| 288 if (_addIdentifierRegion_getterSetterDeclaration(node)) { |
| 289 return; |
| 290 } |
| 291 if (_addIdentifierRegion_field(node)) { |
| 292 return; |
| 293 } |
| 294 if (_addIdentifierRegion_function(node)) { |
| 295 return; |
| 296 } |
| 297 if (_addIdentifierRegion_functionTypeAlias(node)) { |
| 298 return; |
| 299 } |
| 300 if (_addIdentifierRegion_importPrefix(node)) { |
| 301 return; |
| 302 } |
| 303 if (_addIdentifierRegion_localVariable(node)) { |
| 304 return; |
| 305 } |
| 306 if (_addIdentifierRegion_method(node)) { |
| 307 return; |
| 308 } |
| 309 if (_addIdentifierRegion_parameter(node)) { |
| 310 return; |
| 311 } |
| 312 if (_addIdentifierRegion_topLevelVariable(node)) { |
| 313 return; |
| 314 } |
| 315 if (_addIdentifierRegion_typeParameter(node)) { |
| 316 return; |
| 317 } |
| 318 _addRegion_node(node, HighlightType.IDENTIFIER_DEFAULT); |
| 319 } |
| 320 |
| 321 void _addIdentifierRegion_annotation(Annotation node) { |
| 322 ArgumentList arguments = node.arguments; |
| 323 if (arguments == null) { |
| 324 _addRegion_node(node, HighlightType.ANNOTATION); |
| 325 } else { |
| 326 _addRegion_nodeStart_tokenEnd(node, arguments.beginToken, HighlightType.AN
NOTATION); |
| 327 _addRegion_token(arguments.endToken, HighlightType.ANNOTATION); |
| 328 } |
| 329 } |
| 330 |
| 331 bool _addIdentifierRegion_class(SimpleIdentifier node) { |
| 332 Element element = node.staticElement; |
| 333 if (element is! ClassElement) { |
| 334 return false; |
| 335 } |
| 336 return _addRegion_node(node, HighlightType.CLASS); |
| 337 } |
| 338 |
| 339 bool _addIdentifierRegion_constructor(SimpleIdentifier node) { |
| 340 Element element = node.staticElement; |
| 341 if (element is! ConstructorElement) { |
| 342 return false; |
| 343 } |
| 344 return _addRegion_node(node, HighlightType.CONSTRUCTOR); |
| 345 } |
| 346 |
| 347 bool _addIdentifierRegion_dynamicType(SimpleIdentifier node) { |
| 348 // should be variable |
| 349 Element element = node.staticElement; |
| 350 if (element is! VariableElement) { |
| 351 return false; |
| 352 } |
| 353 // has propagated type |
| 354 if (node.propagatedType != null) { |
| 355 return false; |
| 356 } |
| 357 // has dynamic static type |
| 358 DartType staticType = node.staticType; |
| 359 if (staticType == null || !staticType.isDynamic) { |
| 360 return false; |
| 361 } |
| 362 // OK |
| 363 return _addRegion_node(node, HighlightType.DYNAMIC_TYPE); |
| 364 } |
| 365 |
| 366 bool _addIdentifierRegion_field(SimpleIdentifier node) { |
| 367 Element element = node.bestElement; |
| 368 if (element is FieldFormalParameterElement) { |
| 369 element = (element as FieldFormalParameterElement).field; |
| 370 } |
| 371 if (element is FieldElement) { |
| 372 if ((element as FieldElement).isStatic) { |
| 373 return _addRegion_node(node, HighlightType.FIELD_STATIC); |
| 374 } else { |
| 375 return _addRegion_node(node, HighlightType.FIELD); |
| 376 } |
| 377 } |
| 378 if (element is PropertyAccessorElement) { |
| 379 if ((element as PropertyAccessorElement).isStatic) { |
| 380 return _addRegion_node(node, HighlightType.FIELD_STATIC); |
| 381 } else { |
| 382 return _addRegion_node(node, HighlightType.FIELD); |
| 383 } |
| 384 } |
| 385 return false; |
| 386 } |
| 387 |
| 388 bool _addIdentifierRegion_function(SimpleIdentifier node) { |
| 389 Element element = node.staticElement; |
| 390 if (element is! FunctionElement) { |
| 391 return false; |
| 392 } |
| 393 HighlightType type; |
| 394 if (node.inDeclarationContext()) { |
| 395 type = HighlightType.FUNCTION_DECLARATION; |
| 396 } else { |
| 397 type = HighlightType.FUNCTION; |
| 398 } |
| 399 return _addRegion_node(node, type); |
| 400 } |
| 401 |
| 402 bool _addIdentifierRegion_functionTypeAlias(SimpleIdentifier node) { |
| 403 Element element = node.staticElement; |
| 404 if (element is! FunctionTypeAliasElement) { |
| 405 return false; |
| 406 } |
| 407 return _addRegion_node(node, HighlightType.FUNCTION_TYPE_ALIAS); |
| 408 } |
| 409 |
| 410 bool _addIdentifierRegion_getterSetterDeclaration(SimpleIdentifier node) { |
| 411 // should be declaration |
| 412 AstNode parent = node.parent; |
| 413 if (!(parent is MethodDeclaration || parent is FunctionDeclaration)) { |
| 414 return false; |
| 415 } |
| 416 // should be property accessor |
| 417 Element element = node.staticElement; |
| 418 if (element is! PropertyAccessorElement) { |
| 419 return false; |
| 420 } |
| 421 // getter or setter |
| 422 PropertyAccessorElement propertyAccessorElement = element as PropertyAccesso
rElement; |
| 423 if (propertyAccessorElement.isGetter) { |
| 424 return _addRegion_node(node, HighlightType.GETTER_DECLARATION); |
| 425 } else { |
| 426 return _addRegion_node(node, HighlightType.SETTER_DECLARATION); |
| 427 } |
| 428 } |
| 429 |
| 430 bool _addIdentifierRegion_importPrefix(SimpleIdentifier node) { |
| 431 Element element = node.staticElement; |
| 432 if (element is! PrefixElement) { |
| 433 return false; |
| 434 } |
| 435 return _addRegion_node(node, HighlightType.IMPORT_PREFIX); |
| 436 } |
| 437 |
| 438 bool _addIdentifierRegion_keyword(SimpleIdentifier node) { |
| 439 String name = node.name; |
| 440 if (name == "void") { |
| 441 return _addRegion_node(node, HighlightType.KEYWORD); |
| 442 } |
| 443 return false; |
| 444 } |
| 445 |
| 446 bool _addIdentifierRegion_localVariable(SimpleIdentifier node) { |
| 447 Element element = node.staticElement; |
| 448 if (element is! LocalVariableElement) { |
| 449 return false; |
| 450 } |
| 451 // OK |
| 452 HighlightType type; |
| 453 if (node.inDeclarationContext()) { |
| 454 type = HighlightType.LOCAL_VARIABLE_DECLARATION; |
| 455 } else { |
| 456 type = HighlightType.LOCAL_VARIABLE; |
| 457 } |
| 458 return _addRegion_node(node, type); |
| 459 } |
| 460 |
| 461 bool _addIdentifierRegion_method(SimpleIdentifier node) { |
| 462 Element element = node.bestElement; |
| 463 if (element is! MethodElement) { |
| 464 return false; |
| 465 } |
| 466 MethodElement methodElement = element as MethodElement; |
| 467 bool isStatic = methodElement.isStatic; |
| 468 // OK |
| 469 HighlightType type; |
| 470 if (node.inDeclarationContext()) { |
| 471 if (isStatic) { |
| 472 type = HighlightType.METHOD_DECLARATION_STATIC; |
| 473 } else { |
| 474 type = HighlightType.METHOD_DECLARATION; |
| 475 } |
| 476 } else { |
| 477 if (isStatic) { |
| 478 type = HighlightType.METHOD_STATIC; |
| 479 } else { |
| 480 type = HighlightType.METHOD; |
| 481 } |
| 482 } |
| 483 return _addRegion_node(node, type); |
| 484 } |
| 485 |
| 486 bool _addIdentifierRegion_parameter(SimpleIdentifier node) { |
| 487 Element element = node.staticElement; |
| 488 if (element is! ParameterElement) { |
| 489 return false; |
| 490 } |
| 491 return _addRegion_node(node, HighlightType.PARAMETER); |
| 492 } |
| 493 |
| 494 bool _addIdentifierRegion_topLevelVariable(SimpleIdentifier node) { |
| 495 Element element = node.staticElement; |
| 496 if (element is! TopLevelVariableElement) { |
| 497 return false; |
| 498 } |
| 499 return _addRegion_node(node, HighlightType.TOP_LEVEL_VARIABLE); |
| 500 } |
| 501 |
| 502 bool _addIdentifierRegion_typeParameter(SimpleIdentifier node) { |
| 503 Element element = node.staticElement; |
| 504 if (element is! TypeParameterElement) { |
| 505 return false; |
| 506 } |
| 507 return _addRegion_node(node, HighlightType.TYPE_PARAMETER); |
| 508 } |
| 509 |
| 510 void _addRegion(int offset, int length, HighlightType type) { |
| 511 _regions.add(new HighlightRegionImpl(offset, length, type)); |
| 512 } |
| 513 |
| 514 bool _addRegion_node(AstNode node, HighlightType type) { |
| 515 int offset = node.offset; |
| 516 int length = node.length; |
| 517 _addRegion(offset, length, type); |
| 518 return true; |
| 519 } |
| 520 |
| 521 void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightType type) { |
| 522 int offset = a.offset; |
| 523 int end = b.end; |
| 524 _addRegion(offset, end - offset, type); |
| 525 } |
| 526 |
| 527 void _addRegion_token(Token token, HighlightType type) { |
| 528 if (token != null) { |
| 529 int offset = token.offset; |
| 530 int length = token.length; |
| 531 _addRegion(offset, length, type); |
| 532 } |
| 533 } |
| 534 |
| 535 void _addRegion_tokenStart_tokenEnd(Token a, Token b, HighlightType type) { |
| 536 int offset = a.offset; |
| 537 int end = b.end; |
| 538 _addRegion(offset, end - offset, type); |
| 539 } |
| 540 } |
| 541 |
| 542 class RecursiveAstVisitor_DartUnitHighlightsComputer_compute extends RecursiveAs
tVisitor<Object> { |
| 543 final DartUnitHighlightsComputer DartUnitHighlightsComputer_this; |
| 544 |
| 545 RecursiveAstVisitor_DartUnitHighlightsComputer_compute(this.DartUnitHighlights
Computer_this) : super(); |
| 546 |
| 547 @override |
| 548 Object visitAnnotation(Annotation node) { |
| 549 DartUnitHighlightsComputer_this._addIdentifierRegion_annotation(node); |
| 550 return super.visitAnnotation(node); |
| 551 } |
| 552 |
| 553 @override |
| 554 Object visitAsExpression(AsExpression node) { |
| 555 DartUnitHighlightsComputer_this._addRegion_token(node.asOperator, HighlightT
ype.BUILT_IN); |
| 556 return super.visitAsExpression(node); |
| 557 } |
| 558 |
| 559 @override |
| 560 Object visitBooleanLiteral(BooleanLiteral node) { |
| 561 DartUnitHighlightsComputer_this._addRegion_node(node, HighlightType.LITERAL_
BOOLEAN); |
| 562 return super.visitBooleanLiteral(node); |
| 563 } |
| 564 |
| 565 @override |
| 566 Object visitCatchClause(CatchClause node) { |
| 567 DartUnitHighlightsComputer_this._addRegion_token(node.onKeyword, HighlightTy
pe.BUILT_IN); |
| 568 return super.visitCatchClause(node); |
| 569 } |
| 570 |
| 571 @override |
| 572 Object visitClassDeclaration(ClassDeclaration node) { |
| 573 DartUnitHighlightsComputer_this._addRegion_token(node.abstractKeyword, Highl
ightType.BUILT_IN); |
| 574 return super.visitClassDeclaration(node); |
| 575 } |
| 576 |
| 577 @override |
| 578 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 579 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, Highl
ightType.BUILT_IN); |
| 580 DartUnitHighlightsComputer_this._addRegion_token(node.factoryKeyword, Highli
ghtType.BUILT_IN); |
| 581 return super.visitConstructorDeclaration(node); |
| 582 } |
| 583 |
| 584 @override |
| 585 Object visitDoubleLiteral(DoubleLiteral node) { |
| 586 DartUnitHighlightsComputer_this._addRegion_node(node, HighlightType.LITERAL_
DOUBLE); |
| 587 return super.visitDoubleLiteral(node); |
| 588 } |
| 589 |
| 590 @override |
| 591 Object visitExportDirective(ExportDirective node) { |
| 592 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 593 return super.visitExportDirective(node); |
| 594 } |
| 595 |
| 596 @override |
| 597 Object visitFieldDeclaration(FieldDeclaration node) { |
| 598 DartUnitHighlightsComputer_this._addRegion_token(node.staticKeyword, Highlig
htType.BUILT_IN); |
| 599 return super.visitFieldDeclaration(node); |
| 600 } |
| 601 |
| 602 @override |
| 603 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 604 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, Highl
ightType.BUILT_IN); |
| 605 DartUnitHighlightsComputer_this._addRegion_token(node.propertyKeyword, Highl
ightType.BUILT_IN); |
| 606 return super.visitFunctionDeclaration(node); |
| 607 } |
| 608 |
| 609 @override |
| 610 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 611 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 612 return super.visitFunctionTypeAlias(node); |
| 613 } |
| 614 |
| 615 @override |
| 616 Object visitHideCombinator(HideCombinator node) { |
| 617 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 618 return super.visitHideCombinator(node); |
| 619 } |
| 620 |
| 621 @override |
| 622 Object visitImplementsClause(ImplementsClause node) { |
| 623 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 624 return super.visitImplementsClause(node); |
| 625 } |
| 626 |
| 627 @override |
| 628 Object visitImportDirective(ImportDirective node) { |
| 629 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 630 DartUnitHighlightsComputer_this._addRegion_token(node.deferredToken, Highlig
htType.BUILT_IN); |
| 631 DartUnitHighlightsComputer_this._addRegion_token(node.asToken, HighlightType
.BUILT_IN); |
| 632 return super.visitImportDirective(node); |
| 633 } |
| 634 |
| 635 @override |
| 636 Object visitIntegerLiteral(IntegerLiteral node) { |
| 637 DartUnitHighlightsComputer_this._addRegion_node(node, HighlightType.LITERAL_
INTEGER); |
| 638 return super.visitIntegerLiteral(node); |
| 639 } |
| 640 |
| 641 @override |
| 642 Object visitLibraryDirective(LibraryDirective node) { |
| 643 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 644 return super.visitLibraryDirective(node); |
| 645 } |
| 646 |
| 647 @override |
| 648 Object visitMethodDeclaration(MethodDeclaration node) { |
| 649 DartUnitHighlightsComputer_this._addRegion_token(node.externalKeyword, Highl
ightType.BUILT_IN); |
| 650 DartUnitHighlightsComputer_this._addRegion_token(node.modifierKeyword, Highl
ightType.BUILT_IN); |
| 651 DartUnitHighlightsComputer_this._addRegion_token(node.operatorKeyword, Highl
ightType.BUILT_IN); |
| 652 DartUnitHighlightsComputer_this._addRegion_token(node.propertyKeyword, Highl
ightType.BUILT_IN); |
| 653 return super.visitMethodDeclaration(node); |
| 654 } |
| 655 |
| 656 @override |
| 657 Object visitNativeClause(NativeClause node) { |
| 658 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 659 return super.visitNativeClause(node); |
| 660 } |
| 661 |
| 662 @override |
| 663 Object visitNativeFunctionBody(NativeFunctionBody node) { |
| 664 DartUnitHighlightsComputer_this._addRegion_token(node.nativeToken, Highlight
Type.BUILT_IN); |
| 665 return super.visitNativeFunctionBody(node); |
| 666 } |
| 667 |
| 668 @override |
| 669 Object visitPartDirective(PartDirective node) { |
| 670 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 671 return super.visitPartDirective(node); |
| 672 } |
| 673 |
| 674 @override |
| 675 Object visitPartOfDirective(PartOfDirective node) { |
| 676 DartUnitHighlightsComputer_this._addRegion_tokenStart_tokenEnd(node.partToke
n, node.ofToken, HighlightType.BUILT_IN); |
| 677 return super.visitPartOfDirective(node); |
| 678 } |
| 679 |
| 680 @override |
| 681 Object visitShowCombinator(ShowCombinator node) { |
| 682 DartUnitHighlightsComputer_this._addRegion_token(node.keyword, HighlightType
.BUILT_IN); |
| 683 return super.visitShowCombinator(node); |
| 684 } |
| 685 |
| 686 @override |
| 687 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 688 DartUnitHighlightsComputer_this._addIdentifierRegion(node); |
| 689 return super.visitSimpleIdentifier(node); |
| 690 } |
| 691 |
| 692 @override |
| 693 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 694 DartUnitHighlightsComputer_this._addRegion_node(node, HighlightType.LITERAL_
STRING); |
| 695 return super.visitSimpleStringLiteral(node); |
| 696 } |
| 697 |
| 698 @override |
| 699 Object visitTypeName(TypeName node) { |
| 700 DartType type = node.type; |
| 701 if (type != null) { |
| 702 if (type.isDynamic && node.name.name == "dynamic") { |
| 703 DartUnitHighlightsComputer_this._addRegion_node(node, HighlightType.TYPE
_NAME_DYNAMIC); |
| 704 return null; |
| 705 } |
| 706 } |
| 707 return super.visitTypeName(node); |
| 708 } |
| 709 } |
| 710 |
| 711 /** |
| 193 * A concrete implementation of [NavigationRegion]. | 712 * A concrete implementation of [NavigationRegion]. |
| 194 */ | 713 */ |
| 195 class NavigationRegionImpl extends SourceRegionImpl implements NavigationRegion
{ | 714 class NavigationRegionImpl extends SourceRegionImpl implements NavigationRegion
{ |
| 196 final List<NavigationTarget> targets; | 715 final List<NavigationTarget> targets; |
| 197 | 716 |
| 198 NavigationRegionImpl(int offset, int length, this.targets) : super(offset, len
gth); | 717 NavigationRegionImpl(int offset, int length, this.targets) : super(offset, len
gth); |
| 199 | 718 |
| 200 @override | 719 @override |
| 201 String toString() { | 720 String toString() { |
| 202 JavaStringBuilder builder = new JavaStringBuilder(); | 721 JavaStringBuilder builder = new JavaStringBuilder(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 ConstructorDeclaration constructorDeclaration = classMember; | 781 ConstructorDeclaration constructorDeclaration = classMember; |
| 263 _newConstructorOutline(classOutline, classChildren, constructorDecla
ration); | 782 _newConstructorOutline(classOutline, classChildren, constructorDecla
ration); |
| 264 } | 783 } |
| 265 if (classMember is FieldDeclaration) { | 784 if (classMember is FieldDeclaration) { |
| 266 FieldDeclaration fieldDeclaration = classMember; | 785 FieldDeclaration fieldDeclaration = classMember; |
| 267 VariableDeclarationList fields = fieldDeclaration.fields; | 786 VariableDeclarationList fields = fieldDeclaration.fields; |
| 268 if (fields != null) { | 787 if (fields != null) { |
| 269 TypeName fieldType = fields.type; | 788 TypeName fieldType = fields.type; |
| 270 String fieldTypeName = fieldType != null ? fieldType.toSource() :
""; | 789 String fieldTypeName = fieldType != null ? fieldType.toSource() :
""; |
| 271 for (VariableDeclaration field in fields.variables) { | 790 for (VariableDeclaration field in fields.variables) { |
| 272 _newField(classOutline, classChildren, fieldTypeName, field); | 791 _newField(classOutline, classChildren, fieldTypeName, field, fie
ldDeclaration.isStatic); |
| 273 } | 792 } |
| 274 } | 793 } |
| 275 } | 794 } |
| 276 if (classMember is MethodDeclaration) { | 795 if (classMember is MethodDeclaration) { |
| 277 MethodDeclaration methodDeclaration = classMember; | 796 MethodDeclaration methodDeclaration = classMember; |
| 278 _newMethodOutline(classOutline, classChildren, methodDeclaration); | 797 _newMethodOutline(classOutline, classChildren, methodDeclaration); |
| 279 } | 798 } |
| 280 } | 799 } |
| 281 classOutline.children = new List.from(classChildren); | 800 classOutline.children = new List.from(classChildren); |
| 282 } | 801 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 296 unitOutline.children = new List.from(unitChildren); | 815 unitOutline.children = new List.from(unitChildren); |
| 297 return unitOutline; | 816 return unitOutline; |
| 298 } | 817 } |
| 299 | 818 |
| 300 void _addLocalFunctionOutlines(OutlineImpl parenet, FunctionBody body) { | 819 void _addLocalFunctionOutlines(OutlineImpl parenet, FunctionBody body) { |
| 301 List<Outline> localOutlines = []; | 820 List<Outline> localOutlines = []; |
| 302 body.accept(new RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunction
Outlines(this, parenet, localOutlines)); | 821 body.accept(new RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunction
Outlines(this, parenet, localOutlines)); |
| 303 parenet.children = new List.from(localOutlines); | 822 parenet.children = new List.from(localOutlines); |
| 304 } | 823 } |
| 305 | 824 |
| 306 OutlineImpl _newClassOutline(Outline unitOutline, List<Outline> unitChildren,
ClassDeclaration classDeclartion) { | 825 /** |
| 307 SimpleIdentifier nameNode = classDeclartion.name; | 826 * Returns the [AstNode]'s source region. |
| 827 */ |
| 828 SourceRegion _getSourceRegion(AstNode node) { |
| 829 int endOffset = node.end; |
| 830 // prepare position of the node among its siblings |
| 831 int firstOffset; |
| 832 List<AstNode> siblings; |
| 833 AstNode parent = node.parent; |
| 834 // field |
| 835 if (parent is VariableDeclarationList) { |
| 836 VariableDeclarationList variableList = parent as VariableDeclarationList; |
| 837 List<VariableDeclaration> variables = variableList.variables; |
| 838 int variableIndex = variables.indexOf(node); |
| 839 if (variableIndex == variables.length - 1) { |
| 840 endOffset = variableList.parent.end; |
| 841 } |
| 842 if (variableIndex == 0) { |
| 843 node = parent.parent; |
| 844 parent = node.parent; |
| 845 } else if (variableIndex >= 1) { |
| 846 firstOffset = variables[variableIndex - 1].end; |
| 847 return new SourceRegionImpl(firstOffset, endOffset - firstOffset); |
| 848 } |
| 849 } |
| 850 // unit or class member |
| 851 if (parent is CompilationUnit) { |
| 852 firstOffset = 0; |
| 853 siblings = (parent as CompilationUnit).declarations; |
| 854 } else if (parent is ClassDeclaration) { |
| 855 ClassDeclaration classDeclaration = parent as ClassDeclaration; |
| 856 firstOffset = classDeclaration.leftBracket.end; |
| 857 siblings = classDeclaration.members; |
| 858 } else { |
| 859 int offset = node.offset; |
| 860 return new SourceRegionImpl(offset, endOffset - offset); |
| 861 } |
| 862 // first child: [endOfParent, endOfNode] |
| 863 int index = siblings.indexOf(node); |
| 864 if (index == 0) { |
| 865 return new SourceRegionImpl(firstOffset, endOffset - firstOffset); |
| 866 } |
| 867 // not first child: [endOfPreviousSibling, endOfNode] |
| 868 int prevSiblingEnd = siblings[index - 1].end; |
| 869 return new SourceRegionImpl(prevSiblingEnd, endOffset - prevSiblingEnd); |
| 870 } |
| 871 |
| 872 OutlineImpl _newClassOutline(Outline unitOutline, List<Outline> unitChildren,
ClassDeclaration classDeclaration) { |
| 873 SimpleIdentifier nameNode = classDeclaration.name; |
| 308 String name = nameNode.name; | 874 String name = nameNode.name; |
| 309 OutlineImpl outline = new OutlineImpl(unitOutline, OutlineKind.CLASS, name,
nameNode.offset, name.length, null, null); | 875 OutlineImpl outline = new OutlineImpl(unitOutline, _getSourceRegion(classDec
laration), OutlineKind.CLASS, name, nameNode.offset, name.length, null, null, cl
assDeclaration.isAbstract, false); |
| 310 unitChildren.add(outline); | 876 unitChildren.add(outline); |
| 311 return outline; | 877 return outline; |
| 312 } | 878 } |
| 313 | 879 |
| 314 void _newClassTypeAlias(Outline unitOutline, List<Outline> unitChildren, Class
TypeAlias alias) { | 880 void _newClassTypeAlias(Outline unitOutline, List<Outline> unitChildren, Class
TypeAlias alias) { |
| 315 SimpleIdentifier nameNode = alias.name; | 881 SimpleIdentifier nameNode = alias.name; |
| 316 unitChildren.add(new OutlineImpl(unitOutline, OutlineKind.CLASS_TYPE_ALIAS,
nameNode.name, nameNode.offset, nameNode.length, null, null)); | 882 unitChildren.add(new OutlineImpl(unitOutline, _getSourceRegion(alias), Outli
neKind.CLASS_TYPE_ALIAS, nameNode.name, nameNode.offset, nameNode.length, null,
null, alias.isAbstract, false)); |
| 317 } | 883 } |
| 318 | 884 |
| 319 void _newConstructorOutline(OutlineImpl classOutline, List<Outline> children,
ConstructorDeclaration constructorDeclaration) { | 885 void _newConstructorOutline(OutlineImpl classOutline, List<Outline> children,
ConstructorDeclaration constructorDeclaration) { |
| 320 Identifier returnType = constructorDeclaration.returnType; | 886 Identifier returnType = constructorDeclaration.returnType; |
| 321 String name = returnType.name; | 887 String name = returnType.name; |
| 322 int offset = returnType.offset; | 888 int offset = returnType.offset; |
| 323 int length = returnType.length; | 889 int length = returnType.length; |
| 324 SimpleIdentifier constructorNameNode = constructorDeclaration.name; | 890 SimpleIdentifier constructorNameNode = constructorDeclaration.name; |
| 325 if (constructorNameNode != null) { | 891 if (constructorNameNode != null) { |
| 326 name += ".${constructorNameNode.name}"; | 892 name += ".${constructorNameNode.name}"; |
| 327 offset = constructorNameNode.offset; | 893 offset = constructorNameNode.offset; |
| 328 length = constructorNameNode.length; | 894 length = constructorNameNode.length; |
| 329 } | 895 } |
| 330 FormalParameterList parameters = constructorDeclaration.parameters; | 896 FormalParameterList parameters = constructorDeclaration.parameters; |
| 331 OutlineImpl outline = new OutlineImpl(classOutline, OutlineKind.CONSTRUCTOR,
name, offset, length, parameters != null ? parameters.toSource() : "", null); | 897 OutlineImpl outline = new OutlineImpl(classOutline, _getSourceRegion(constru
ctorDeclaration), OutlineKind.CONSTRUCTOR, name, offset, length, parameters != n
ull ? parameters.toSource() : "", null, false, false); |
| 332 children.add(outline); | 898 children.add(outline); |
| 333 _addLocalFunctionOutlines(outline, constructorDeclaration.body); | 899 _addLocalFunctionOutlines(outline, constructorDeclaration.body); |
| 334 } | 900 } |
| 335 | 901 |
| 336 void _newField(OutlineImpl classOutline, List<Outline> children, String fieldT
ypeName, VariableDeclaration field) { | 902 void _newField(OutlineImpl classOutline, List<Outline> children, String fieldT
ypeName, VariableDeclaration field, bool isStatic) { |
| 337 SimpleIdentifier nameNode = field.name; | 903 SimpleIdentifier nameNode = field.name; |
| 338 children.add(new OutlineImpl(classOutline, OutlineKind.FIELD, nameNode.name,
nameNode.offset, nameNode.length, null, fieldTypeName)); | 904 children.add(new OutlineImpl(classOutline, _getSourceRegion(field), OutlineK
ind.FIELD, nameNode.name, nameNode.offset, nameNode.length, null, fieldTypeName,
false, isStatic)); |
| 339 } | 905 } |
| 340 | 906 |
| 341 void _newFunctionOutline(Outline unitOutline, List<Outline> unitChildren, Func
tionDeclaration functionDeclaration) { | 907 void _newFunctionOutline(Outline unitOutline, List<Outline> unitChildren, Func
tionDeclaration functionDeclaration) { |
| 342 TypeName returnType = functionDeclaration.returnType; | 908 TypeName returnType = functionDeclaration.returnType; |
| 343 SimpleIdentifier nameNode = functionDeclaration.name; | 909 SimpleIdentifier nameNode = functionDeclaration.name; |
| 344 FunctionExpression functionExpression = functionDeclaration.functionExpressi
on; | 910 FunctionExpression functionExpression = functionDeclaration.functionExpressi
on; |
| 345 FormalParameterList parameters = functionExpression.parameters; | 911 FormalParameterList parameters = functionExpression.parameters; |
| 346 OutlineKind kind; | 912 OutlineKind kind; |
| 347 if (functionDeclaration.isGetter) { | 913 if (functionDeclaration.isGetter) { |
| 348 kind = OutlineKind.GETTER; | 914 kind = OutlineKind.GETTER; |
| 349 } else if (functionDeclaration.isSetter) { | 915 } else if (functionDeclaration.isSetter) { |
| 350 kind = OutlineKind.SETTER; | 916 kind = OutlineKind.SETTER; |
| 351 } else { | 917 } else { |
| 352 kind = OutlineKind.FUNCTION; | 918 kind = OutlineKind.FUNCTION; |
| 353 } | 919 } |
| 354 OutlineImpl outline = new OutlineImpl(unitOutline, kind, nameNode.name, name
Node.offset, nameNode.length, parameters != null ? parameters.toSource() : "", r
eturnType != null ? returnType.toSource() : ""); | 920 OutlineImpl outline = new OutlineImpl(unitOutline, _getSourceRegion(function
Declaration), kind, nameNode.name, nameNode.offset, nameNode.length, parameters
!= null ? parameters.toSource() : "", returnType != null ? returnType.toSource()
: "", false, false); |
| 355 unitChildren.add(outline); | 921 unitChildren.add(outline); |
| 356 _addLocalFunctionOutlines(outline, functionExpression.body); | 922 _addLocalFunctionOutlines(outline, functionExpression.body); |
| 357 } | 923 } |
| 358 | 924 |
| 359 void _newFunctionTypeAliasOutline(Outline unitOutline, List<Outline> unitChild
ren, FunctionTypeAlias alias) { | 925 void _newFunctionTypeAliasOutline(Outline unitOutline, List<Outline> unitChild
ren, FunctionTypeAlias alias) { |
| 360 TypeName returnType = alias.returnType; | 926 TypeName returnType = alias.returnType; |
| 361 SimpleIdentifier nameNode = alias.name; | 927 SimpleIdentifier nameNode = alias.name; |
| 362 FormalParameterList parameters = alias.parameters; | 928 FormalParameterList parameters = alias.parameters; |
| 363 unitChildren.add(new OutlineImpl(unitOutline, OutlineKind.FUNCTION_TYPE_ALIA
S, nameNode.name, nameNode.offset, nameNode.length, parameters != null ? paramet
ers.toSource() : "", returnType != null ? returnType.toSource() : "")); | 929 unitChildren.add(new OutlineImpl(unitOutline, _getSourceRegion(alias), Outli
neKind.FUNCTION_TYPE_ALIAS, nameNode.name, nameNode.offset, nameNode.length, par
ameters != null ? parameters.toSource() : "", returnType != null ? returnType.to
Source() : "", false, false)); |
| 364 } | 930 } |
| 365 | 931 |
| 366 void _newMethodOutline(OutlineImpl classOutline, List<Outline> children, Metho
dDeclaration methodDeclaration) { | 932 void _newMethodOutline(OutlineImpl classOutline, List<Outline> children, Metho
dDeclaration methodDeclaration) { |
| 367 TypeName returnType = methodDeclaration.returnType; | 933 TypeName returnType = methodDeclaration.returnType; |
| 368 SimpleIdentifier nameNode = methodDeclaration.name; | 934 SimpleIdentifier nameNode = methodDeclaration.name; |
| 369 FormalParameterList parameters = methodDeclaration.parameters; | 935 FormalParameterList parameters = methodDeclaration.parameters; |
| 370 OutlineKind kind; | 936 OutlineKind kind; |
| 371 if (methodDeclaration.isGetter) { | 937 if (methodDeclaration.isGetter) { |
| 372 kind = OutlineKind.GETTER; | 938 kind = OutlineKind.GETTER; |
| 373 } else if (methodDeclaration.isSetter) { | 939 } else if (methodDeclaration.isSetter) { |
| 374 kind = OutlineKind.SETTER; | 940 kind = OutlineKind.SETTER; |
| 375 } else { | 941 } else { |
| 376 kind = OutlineKind.METHOD; | 942 kind = OutlineKind.METHOD; |
| 377 } | 943 } |
| 378 OutlineImpl outline = new OutlineImpl(classOutline, kind, nameNode.name, nam
eNode.offset, nameNode.length, parameters != null ? parameters.toSource() : "",
returnType != null ? returnType.toSource() : ""); | 944 OutlineImpl outline = new OutlineImpl(classOutline, _getSourceRegion(methodD
eclaration), kind, nameNode.name, nameNode.offset, nameNode.length, parameters !
= null ? parameters.toSource() : "", returnType != null ? returnType.toSource()
: "", methodDeclaration.isAbstract, methodDeclaration.isStatic); |
| 379 children.add(outline); | 945 children.add(outline); |
| 380 _addLocalFunctionOutlines(outline, methodDeclaration.body); | 946 _addLocalFunctionOutlines(outline, methodDeclaration.body); |
| 381 } | 947 } |
| 382 | 948 |
| 383 OutlineImpl _newUnitOutline() => new OutlineImpl(null, OutlineKind.COMPILATION
_UNIT, null, 0, 0, null, null); | 949 OutlineImpl _newUnitOutline() => new OutlineImpl(null, new SourceRegionImpl(_u
nit.offset, _unit.length), OutlineKind.COMPILATION_UNIT, null, 0, 0, null, null,
false, false); |
| 384 } | 950 } |
| 385 | 951 |
| 386 class RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines exten
ds RecursiveAstVisitor<Object> { | 952 class RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines exten
ds RecursiveAstVisitor<Object> { |
| 387 final DartUnitOutlineComputer DartUnitOutlineComputer_this; | 953 final DartUnitOutlineComputer DartUnitOutlineComputer_this; |
| 388 | 954 |
| 389 OutlineImpl parenet; | 955 OutlineImpl parenet; |
| 390 | 956 |
| 391 List<Outline> localOutlines; | 957 List<Outline> localOutlines; |
| 392 | 958 |
| 393 RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines(this.Dart
UnitOutlineComputer_this, this.parenet, this.localOutlines) : super(); | 959 RecursiveAstVisitor_DartUnitOutlineComputer_addLocalFunctionOutlines(this.Dart
UnitOutlineComputer_this, this.parenet, this.localOutlines) : super(); |
| 394 | 960 |
| 395 @override | 961 @override |
| 396 Object visitFunctionDeclaration(FunctionDeclaration node) { | 962 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 397 DartUnitOutlineComputer_this._newFunctionOutline(parenet, localOutlines, nod
e); | 963 DartUnitOutlineComputer_this._newFunctionOutline(parenet, localOutlines, nod
e); |
| 398 return null; | 964 return null; |
| 399 } | 965 } |
| 400 } | 966 } |
| OLD | NEW |