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

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

Issue 1402353009: [Atom] Issue 424. Fix for 'getNavigation' and index expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/get_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 a4971ce51f03efcb9a1f2202dc668d0bf57c38f0..6850f7e5163e29914ca47de9de39b49104a238e0 100644
--- a/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
+++ b/pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart
@@ -198,7 +198,9 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor {
@override
visitIndexExpression(IndexExpression node) {
super.visitIndexExpression(node);
- computer._addRegionForToken(node.rightBracket, node.bestElement);
+ MethodElement element = node.bestElement;
+ computer._addRegionForToken(node.leftBracket, element);
+ computer._addRegionForToken(node.rightBracket, element);
}
@override
@@ -310,10 +312,6 @@ class _DartRangeAstVisitor extends UnifyingAstVisitor {
_DartRangeAstVisitor(this.start, this.end, this.visitor);
- bool isInRange(int offset) {
- return start <= offset && offset <= end;
- }
-
@override
visitNode(AstNode node) {
// The node ends before the range starts.
@@ -326,7 +324,14 @@ class _DartRangeAstVisitor extends UnifyingAstVisitor {
}
// The node starts or ends in the range.
if (node is! CompilationUnit) {
- if (isInRange(node.offset) || isInRange(node.end) || node is Directive) {
+ if (node is Directive) {
+ node.accept(visitor);
+ return;
+ }
+ if (_isNodeInRange(node)) {
+ while (_isNodeInRange(node)) {
Brian Wilkerson 2015/10/25 15:28:04 I don't understand this while loop, so I'm probabl
scheglov 2015/10/25 18:29:44 Thank you. Reworked.
+ node = node.parent;
+ }
node.accept(visitor);
return;
}
@@ -334,4 +339,12 @@ class _DartRangeAstVisitor extends UnifyingAstVisitor {
// Go deeper.
super.visitNode(node);
}
+
+ bool _isNodeInRange(AstNode node) {
+ return _isOffsetInRange(node.offset) || _isOffsetInRange(node.end);
+ }
+
+ bool _isOffsetInRange(int offset) {
+ return start <= offset && offset <= end;
+ }
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/get_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698