Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_outline.dart

Issue 363723002: Change HashMap declarations back to Map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'dart:collection';
8
9 import 'package:analysis_server/src/computer/element.dart'; 7 import 'package:analysis_server/src/computer/element.dart';
10 import 'package:analysis_server/src/constants.dart'; 8 import 'package:analysis_server/src/constants.dart';
11 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart' as engine; 10 import 'package:analyzer/src/generated/element.dart' as engine;
13 11
14 12
15 /** 13 /**
16 * A computer for [CompilationUnit] outline. 14 * A computer for [CompilationUnit] outline.
17 */ 15 */
18 class DartUnitOutlineComputer { 16 class DartUnitOutlineComputer {
19 final CompilationUnit _unit; 17 final CompilationUnit _unit;
20 18
21 DartUnitOutlineComputer(this._unit); 19 DartUnitOutlineComputer(this._unit);
22 20
23 /** 21 /**
24 * Returns the computed outline, not `null`. 22 * Returns the computed outline, not `null`.
25 */ 23 */
26 HashMap<String, Object> compute() { 24 Map<String, Object> compute() {
27 Outline unitOutline = _newUnitOutline(); 25 Outline unitOutline = _newUnitOutline();
28 for (CompilationUnitMember unitMember in _unit.declarations) { 26 for (CompilationUnitMember unitMember in _unit.declarations) {
29 if (unitMember is ClassDeclaration) { 27 if (unitMember is ClassDeclaration) {
30 ClassDeclaration classDeclaration = unitMember; 28 ClassDeclaration classDeclaration = unitMember;
31 Outline classOutline = _newClassOutline(unitOutline, classDeclaration); 29 Outline classOutline = _newClassOutline(unitOutline, classDeclaration);
32 for (ClassMember classMember in classDeclaration.members) { 30 for (ClassMember classMember in classDeclaration.members) {
33 if (classMember is ConstructorDeclaration) { 31 if (classMember is ConstructorDeclaration) {
34 ConstructorDeclaration constructorDeclaration = classMember; 32 ConstructorDeclaration constructorDeclaration = classMember;
35 _newConstructorOutline(classOutline, constructorDeclaration); 33 _newConstructorOutline(classOutline, constructorDeclaration);
36 } 34 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 */ 301 */
304 final int length; 302 final int length;
305 303
306 /** 304 /**
307 * The offset of the first character of the element. 305 * The offset of the first character of the element.
308 */ 306 */
309 final int offset; 307 final int offset;
310 308
311 Outline(this.element, this.offset, this.length); 309 Outline(this.element, this.offset, this.length);
312 310
313 factory Outline.fromJson(HashMap<String, Object> map) { 311 factory Outline.fromJson(Map<String, Object> map) {
314 Element element = new Element.fromJson(map[ELEMENT]); 312 Element element = new Element.fromJson(map[ELEMENT]);
315 Outline outline = new Outline(element, map[OFFSET], map[LENGTH]); 313 Outline outline = new Outline(element, map[OFFSET], map[LENGTH]);
316 // add children 314 // add children
317 List<HashMap<String, Object>> childrenMaps = map[CHILDREN]; 315 List<Map<String, Object>> childrenMaps = map[CHILDREN];
318 if (childrenMaps != null) { 316 if (childrenMaps != null) {
319 childrenMaps.forEach((childMap) { 317 childrenMaps.forEach((childMap) {
320 outline.children.add(new Outline.fromJson(childMap)); 318 outline.children.add(new Outline.fromJson(childMap));
321 }); 319 });
322 } 320 }
323 // done 321 // done
324 return outline; 322 return outline;
325 } 323 }
326 324
327 HashMap<String, Object> toJson() { 325 Map<String, Object> toJson() {
328 HashMap<String, Object> json = { 326 Map<String, Object> json = {
329 ELEMENT: element.toJson(), 327 ELEMENT: element.toJson(),
330 OFFSET: offset, 328 OFFSET: offset,
331 LENGTH: length 329 LENGTH: length
332 }; 330 };
333 if (children.isNotEmpty) { 331 if (children.isNotEmpty) {
334 json[CHILDREN] = children.map((child) => child.toJson()).toList(); 332 json[CHILDREN] = children.map((child) => child.toJson()).toList();
335 } 333 }
336 return json; 334 return json;
337 } 335 }
338 } 336 }
(...skipping 16 matching lines...) Expand all
355 353
356 354
357 /** 355 /**
358 * A range of characters. 356 * A range of characters.
359 */ 357 */
360 class _SourceRegion { 358 class _SourceRegion {
361 final int length; 359 final int length;
362 final int offset; 360 final int offset;
363 _SourceRegion(this.offset, this.length); 361 _SourceRegion(this.offset, this.length);
364 } 362 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_navigation.dart ('k') | pkg/analysis_server/lib/src/computer/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698