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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_navigation.dart

Issue 367793002: Update Element/navigation/outline to use Location. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgotten file Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/computer/computer_navigation.dart
diff --git a/pkg/analysis_server/lib/src/computer/computer_navigation.dart b/pkg/analysis_server/lib/src/computer/computer_navigation.dart
index ffbfd29faf647d5c70cebcf366c57ba5969648d5..dedf75c0ca64fd4859b5e4baf7ab8629684dd3ff 100644
--- a/pkg/analysis_server/lib/src/computer/computer_navigation.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_navigation.dart
@@ -4,13 +4,10 @@
library computer.navigation;
-import 'dart:collection';
-
import 'package:analysis_server/src/constants.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/src/generated/scanner.dart';
-import 'package:analyzer/src/generated/source.dart';
import 'element.dart' as computer;
@@ -21,7 +18,7 @@ import 'element.dart' as computer;
class DartUnitNavigationComputer {
final CompilationUnit _unit;
- final List<Map<String, Object>> _regions = <HashMap<String, Object>>[];
+ final List<Map<String, Object>> _regions = <Map<String, Object>>[];
DartUnitNavigationComputer(this._unit);
@@ -34,14 +31,17 @@ class DartUnitNavigationComputer {
}
void _addRegion(int offset, int length, Element element) {
- Map<String, Object> target = _createTarget(element);
- if (target == null) {
+ if (element == null) {
return;
}
+ if (element is FieldFormalParameterElement) {
+ element = (element as FieldFormalParameterElement).field;
+ }
+ var elementJson = new computer.Element.fromEngine(element).toJson();
_regions.add({
OFFSET: offset,
LENGTH: length,
- TARGETS: [target]
+ TARGETS: [elementJson]
});
}
@@ -74,37 +74,6 @@ class DartUnitNavigationComputer {
int length = b.end - offset;
_addRegion(offset, length, element);
}
-
- /**
- * Returns the JSON for the given [Element], maybe `null` if `null` was given.
- */
- Map<String, Object> _createTarget(Element element) {
- if (element == null) {
- return null;
- }
- if (element is FieldFormalParameterElement) {
- element = (element as FieldFormalParameterElement).field;
- }
- // prepare Source
- Source source = element.source;
- if (source == null) {
- return null;
- }
- // prepare location
- int offset = element.nameOffset;
- int length = element.displayName.length;
- if (element is CompilationUnitElement) {
- offset = 0;
- length = 0;
- }
- // return as JSON
- return {
- FILE: source.fullName,
- OFFSET: offset,
- LENGTH: length,
- ELEMENT: new computer.Element.fromEngine(element).toJson()
- };
- }
}
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/computer/computer_outline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698