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

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

Issue 342983007: Update navigation computer to include Element instead of id. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d329425d9a4d9e2decc8435aa4754f5ce947065e..27aca2b4985d96735d30a74f92175ba1ab1e6d76 100644
--- a/pkg/analysis_server/lib/src/computer/computer_navigation.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_navigation.dart
@@ -4,11 +4,14 @@
library computer.navigation;
+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;
+
/**
* A computer for navigation regions in a Dart [CompilationUnit].
@@ -16,7 +19,7 @@ import 'package:analyzer/src/generated/source.dart';
class DartUnitNavigationComputer {
final CompilationUnit _unit;
- List<Map<String, Object>> _regions = <Map<String, Object>>[];
+ final List<Map<String, Object>> _regions = <Map<String, Object>>[];
DartUnitNavigationComputer(this._unit);
@@ -34,12 +37,24 @@ class DartUnitNavigationComputer {
return;
}
_regions.add({
- 'offset': offset,
- 'length': length,
- 'targets': [target]
+ OFFSET: offset,
+ LENGTH: length,
+ TARGETS: [target]
});
}
+ void _addRegionForNode(AstNode node, Element element) {
+ int offset = node.offset;
+ int length = node.length;
+ _addRegion(offset, length, element);
+ }
+
+ void _addRegionForToken(Token token, Element element) {
+ int offset = token.offset;
+ int length = token.length;
+ _addRegion(offset, length, element);
+ }
+
void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) {
int offset = a.offset;
int length = b.end - offset;
@@ -58,18 +73,6 @@ class DartUnitNavigationComputer {
_addRegion(offset, length, element);
}
- void _addRegionForNode(AstNode node, Element element) {
- int offset = node.offset;
- int length = node.length;
- _addRegion(offset, length, element);
- }
-
- void _addRegionForToken(Token token, Element element) {
- int offset = token.offset;
- int length = token.length;
- _addRegion(offset, length, element);
- }
-
/**
* Returns the JSON for the given [Element], maybe `null` if `null` was given.
*/
@@ -94,10 +97,10 @@ class DartUnitNavigationComputer {
}
// return as JSON
return {
- 'file': source.fullName,
- 'offset': offset,
- 'length': length,
- 'elementId': element.location.encoding
+ FILE: source.fullName,
+ OFFSET: offset,
+ LENGTH: length,
+ ELEMENT: new computer.Element.fromEngine(element).toJson()
};
}
}
@@ -131,7 +134,8 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor {
lastNode = firstNode;
}
if (firstNode != null && lastNode != null) {
- computer._addRegion_nodeStart_nodeEnd(firstNode, lastNode, node.element);
+ computer._addRegion_nodeStart_nodeEnd(firstNode, lastNode,
+ node.element);
}
}
return super.visitConstructorDeclaration(node);
@@ -175,13 +179,15 @@ class _DartUnitNavigationComputerVisitor extends RecursiveAstVisitor {
@override
visitPartDirective(PartDirective node) {
- computer._addRegion_tokenStart_nodeEnd(node.keyword, node.uri, node.element);
+ computer._addRegion_tokenStart_nodeEnd(node.keyword, node.uri,
+ node.element);
return super.visitPartDirective(node);
}
@override
visitPartOfDirective(PartOfDirective node) {
- computer._addRegion_tokenStart_nodeEnd(node.keyword, node.libraryName, node.element);
+ computer._addRegion_tokenStart_nodeEnd(node.keyword, node.libraryName,
+ node.element);
return super.visitPartOfDirective(node);
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698