| 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.outline; | 5 library computer.outline; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/constants.dart'; | 7 import 'package:analysis_server/src/constants.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 nameNode.offset, nameNode.length, | 242 nameNode.offset, nameNode.length, |
| 243 sourceRegion.offset, sourceRegion.length, | 243 sourceRegion.offset, sourceRegion.length, |
| 244 method.isAbstract, method.isStatic, | 244 method.isAbstract, method.isStatic, |
| 245 parametersStr, returnTypeStr); | 245 parametersStr, returnTypeStr); |
| 246 parent.children.add(outline); | 246 parent.children.add(outline); |
| 247 _addLocalFunctionOutlines(outline, method.body); | 247 _addLocalFunctionOutlines(outline, method.body); |
| 248 } | 248 } |
| 249 | 249 |
| 250 _Outline _newUnitOutline() { | 250 _Outline _newUnitOutline() { |
| 251 return new _Outline( | 251 return new _Outline( |
| 252 _OutlineKind.COMPILATION_UNIT, null, | 252 _OutlineKind.COMPILATION_UNIT, "<unit>", |
| 253 _unit.offset, _unit.length, | 253 _unit.offset, _unit.length, |
| 254 _unit.offset, _unit.length, | 254 _unit.offset, _unit.length, |
| 255 false, false, | 255 false, false, |
| 256 null, null); | 256 null, null); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void _newVariableOutline(_Outline parent, String typeName, _OutlineKind kind,
VariableDeclaration variable, bool isStatic) { | 259 void _newVariableOutline(_Outline parent, String typeName, _OutlineKind kind,
VariableDeclaration variable, bool isStatic) { |
| 260 SimpleIdentifier nameNode = variable.name; | 260 SimpleIdentifier nameNode = variable.name; |
| 261 String name = nameNode.name; | 261 String name = nameNode.name; |
| 262 _SourceRegion sourceRegion = _getSourceRegion(variable); | 262 _SourceRegion sourceRegion = _getSourceRegion(variable); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 static const List<_Outline> EMPTY_ARRAY = const <_Outline>[]; | 331 static const List<_Outline> EMPTY_ARRAY = const <_Outline>[]; |
| 332 | 332 |
| 333 final _OutlineKind kind; | 333 final _OutlineKind kind; |
| 334 final String name; | 334 final String name; |
| 335 final int nameOffset; | 335 final int nameOffset; |
| 336 final int nameLength; | 336 final int nameLength; |
| 337 final int elementOffset; | 337 final int elementOffset; |
| 338 final int elementLength; | 338 final int elementLength; |
| 339 final bool isAbstract; | 339 final bool isAbstract; |
| 340 final bool isStatic; | 340 final bool isStatic; |
| 341 final String arguments; | 341 final String parameters; |
| 342 final String returnType; | 342 final String returnType; |
| 343 final List<_Outline> children = <_Outline>[]; | 343 final List<_Outline> children = <_Outline>[]; |
| 344 | 344 |
| 345 _Outline(this.kind, this.name, | 345 _Outline(this.kind, this.name, |
| 346 this.nameOffset, this.nameLength, | 346 this.nameOffset, this.nameLength, |
| 347 this.elementOffset, this.elementLength, | 347 this.elementOffset, this.elementLength, |
| 348 this.isAbstract, this.isStatic, | 348 this.isAbstract, this.isStatic, |
| 349 this.arguments, this.returnType); | 349 this.parameters, this.returnType); |
| 350 | 350 |
| 351 Map<String, Object> toJson() { | 351 Map<String, Object> toJson() { |
| 352 return { | 352 Map<String, Object> json = { |
| 353 KIND: kind.name, | 353 KIND: kind.name, |
| 354 NAME: name, | 354 NAME: name, |
| 355 NAME_OFFSET: nameOffset, | 355 NAME_OFFSET: nameOffset, |
| 356 NAME_LENGTH: nameLength, | 356 NAME_LENGTH: nameLength, |
| 357 ELEMENT_OFFSET: elementOffset, | 357 ELEMENT_OFFSET: elementOffset, |
| 358 ELEMENT_LENGTH: elementLength, | 358 ELEMENT_LENGTH: elementLength, |
| 359 IS_ABSTRACT: isAbstract, | 359 IS_ABSTRACT: isAbstract, |
| 360 IS_STATIC: isStatic, | 360 IS_STATIC: isStatic |
| 361 ARGUMENTS: arguments, | |
| 362 RETURN_TYPE: returnType, | |
| 363 CHILDREN: children.map((child) => child.toJson()).toList(growable: false) | |
| 364 }; | 361 }; |
| 362 if (parameters != null) { |
| 363 json[PARAMETERS] = parameters; |
| 364 } |
| 365 if (returnType != null) { |
| 366 json[RETURN_TYPE] = returnType; |
| 367 } |
| 368 if (children.isNotEmpty) { |
| 369 json[CHILDREN] = children.map((child) => child.toJson()).toList(); |
| 370 } |
| 371 return json; |
| 365 } | 372 } |
| 366 } | 373 } |
| OLD | NEW |