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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1490933002: New NodeLocator which uses positions of characters, not between them. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/test/generated/ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index f347a8a84dad00ba578e27c72775754ee2f7383e..9dbed8671f8d3ebb038b0c2e5ec311ed8ce047d7 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2953,15 +2953,7 @@ abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask {
*/
VariableDeclaration getDeclaration(CompilationUnit unit) {
VariableElement variable = target;
- // Usually: Type ^name = ...
- // Sometimes there is no space after the type: List<Type>^name = ...
- // So, we need to use an offset within (or right after) the name:
- // Type n^ame =
- // List<Type>n^ame =
- // Type x^=
- int searchOffset = variable.nameOffset + 1;
- NodeLocator locator = new NodeLocator(searchOffset);
- AstNode node = locator.searchWithin(unit);
+ AstNode node = new NodeLocator2(variable.nameOffset).searchWithin(unit);
VariableDeclaration declaration =
node.getAncestor((AstNode ancestor) => ancestor is VariableDeclaration);
if (declaration == null || declaration.name != node) {
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/test/generated/ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698