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

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

Issue 422573003: Implementation of the 'search.getTypeHierarchy' API. (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.element; 5 library computer.element;
6 6
7 import 'package:analysis_services/constants.dart'; 7 import 'package:analysis_services/constants.dart';
8 import 'package:analyzer/src/generated/element.dart' as engine; 8 import 'package:analyzer/src/generated/element.dart' as engine;
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/generated/utilities_dart.dart' as engine; 10 import 'package:analyzer/src/generated/utilities_dart.dart' as engine;
11 11
12 12
13 /** 13 /**
14 * Returns a JSON correponding to the given Engine element.
15 */
16 Map<String, Object> engineElementToJson(engine.Element element) {
17 return new Element.fromEngine(element).toJson();
18 }
19
20
21 /**
14 * Information about an element. 22 * Information about an element.
15 */ 23 */
16 class Element { 24 class Element {
17 static const List<Element> EMPTY_ARRAY = const <Element>[]; 25 static const List<Element> EMPTY_ARRAY = const <Element>[];
18 26
19 static const int FLAG_ABSTRACT = 0x01; 27 static const int FLAG_ABSTRACT = 0x01;
20 static const int FLAG_CONST = 0x02; 28 static const int FLAG_CONST = 0x02;
21 static const int FLAG_FINAL = 0x04; 29 static const int FLAG_FINAL = 0x04;
22 static const int FLAG_STATIC = 0x08; 30 static const int FLAG_STATIC = 0x08;
23 static const int FLAG_PRIVATE = 0x10; 31 static const int FLAG_PRIVATE = 0x10;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 355 }
348 // done 356 // done
349 return new Location( 357 return new Location(
350 source.fullName, 358 source.fullName,
351 offset, 359 offset,
352 length, 360 length,
353 startLine, 361 startLine,
354 startColumn); 362 startColumn);
355 } 363 }
356 364
365 factory Location.fromJson(Map<String, Object> map) {
366 return new Location(
367 map[FILE],
368 map[OFFSET],
369 map[LENGTH],
370 map[START_LINE],
371 map[START_COLUMN]);
372 }
373
357 factory Location.fromOffset(engine.Element element, int offset, int length) { 374 factory Location.fromOffset(engine.Element element, int offset, int length) {
358 Source source = element.source; 375 Source source = element.source;
359 LineInfo lineInfo = element.context.getLineInfo(source); 376 LineInfo lineInfo = element.context.getLineInfo(source);
360 // prepare location 377 // prepare location
361 LineInfo_Location lineLocation = lineInfo.getLocation(offset); 378 LineInfo_Location lineLocation = lineInfo.getLocation(offset);
362 int startLine = lineLocation.lineNumber; 379 int startLine = lineLocation.lineNumber;
363 int startColumn = lineLocation.columnNumber; 380 int startColumn = lineLocation.columnNumber;
364 // done 381 // done
365 return new Location( 382 return new Location(
366 source.fullName, 383 source.fullName,
367 offset, 384 offset,
368 length, 385 length,
369 startLine, 386 startLine,
370 startColumn); 387 startColumn);
371 } 388 }
372 389
373 factory Location.fromJson(Map<String, Object> map) {
374 return new Location(
375 map[FILE],
376 map[OFFSET],
377 map[LENGTH],
378 map[START_LINE],
379 map[START_COLUMN]);
380 }
381
382 Map<String, Object> toJson() { 390 Map<String, Object> toJson() {
383 return { 391 return {
384 FILE: file, 392 FILE: file,
385 OFFSET: offset, 393 OFFSET: offset,
386 LENGTH: length, 394 LENGTH: length,
387 START_LINE: startLine, 395 START_LINE: startLine,
388 START_COLUMN: startColumn 396 START_COLUMN: startColumn
389 }; 397 };
390 } 398 }
391 399
392 @override 400 @override
393 String toString() { 401 String toString() {
394 return 'Location(file=$file; offset=$offset; length=$length; ' 402 return 'Location(file=$file; offset=$offset; length=$length; '
395 'startLine=$startLine; startColumn=$startColumn)'; 403 'startLine=$startLine; startColumn=$startColumn)';
396 } 404 }
397 } 405 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | pkg/analysis_server/lib/src/search/type_hierarchy.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698