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

Unified Diff: pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart

Issue 1373593002: Add navigation region for 'library' directives. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/test/analysis/notification_navigation_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
diff --git a/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart b/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
index 671e752564a5d2a66a5aa6a4f55485a4587736b5..8b87629949fc819391227faa702bb83315cd2440 100644
--- a/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
+++ b/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
@@ -40,6 +40,52 @@ class DartNavigationComputer implements NavigationContributor {
}
}
+/**
+ * A Dart specific wrapper around [NavigationCollector].
+ */
+class _DartNavigationCollector {
+ final NavigationCollector collector;
+
+ _DartNavigationCollector(this.collector);
+
+ void _addRegion(int offset, int length, Element element) {
+ if (element is FieldFormalParameterElement) {
+ element = (element as FieldFormalParameterElement).field;
+ }
+ if (element == null || element == DynamicElementImpl.instance) {
+ return;
+ }
+ if (element.location == null) {
+ return;
+ }
+ protocol.ElementKind kind =
+ protocol.newElementKind_fromEngine(element.kind);
+ protocol.Location location = protocol.newLocation_fromElement(element);
+ if (location == null) {
+ return;
+ }
+ collector.addRegion(offset, length, kind, location);
+ }
+
+ void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) {
+ int offset = a.offset;
+ int length = b.end - offset;
+ _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);
+ }
+}
+
class _DartNavigationComputerVisitor extends RecursiveAstVisitor {
final _DartNavigationCollector computer;
@@ -130,6 +176,11 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor {
}
@override
+ visitLibraryDirective(LibraryDirective node) {
+ computer._addRegionForNode(node.name, node.element);
+ }
+
+ @override
visitPartDirective(PartDirective node) {
_addUriDirectiveRegion(node, node.element);
super.visitPartDirective(node);
@@ -223,52 +274,6 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor {
}
/**
- * A Dart specific wrapper around [NavigationCollector].
- */
-class _DartNavigationCollector {
- final NavigationCollector collector;
-
- _DartNavigationCollector(this.collector);
-
- void _addRegion(int offset, int length, Element element) {
- if (element is FieldFormalParameterElement) {
- element = (element as FieldFormalParameterElement).field;
- }
- if (element == null || element == DynamicElementImpl.instance) {
- return;
- }
- if (element.location == null) {
- return;
- }
- protocol.ElementKind kind =
- protocol.newElementKind_fromEngine(element.kind);
- protocol.Location location = protocol.newLocation_fromElement(element);
- if (location == null) {
- return;
- }
- collector.addRegion(offset, length, kind, location);
- }
-
- void _addRegion_nodeStart_nodeEnd(AstNode a, AstNode b, Element element) {
- int offset = a.offset;
- int length = b.end - offset;
- _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);
- }
-}
-
-/**
* An AST visitor that forwards nodes intersecting with the range from
* [start] to [end] to the given [visitor].
*/
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/notification_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698