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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java

Issue 10051030: Fix for local variable rename, when it is expression of invocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java
index 8f989d11497cb64766d15a541abe89521a796947..e66442b5a49d1f4fa01ff47b27c08355cd86c469 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/dom/LinkedNodeFinder.java
@@ -1,11 +1,12 @@
package com.google.dart.tools.internal.corext.dom;
+import com.google.common.collect.Lists;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.resolver.Element;
-import java.util.ArrayList;
+import java.util.List;
/**
* Find all nodes connected to a given binding or node. e.g. Declaration of a field and all
@@ -35,21 +36,15 @@ public class LinkedNodeFinder {
private final Element fBinding;
- private final ArrayList<DartIdentifier> fResult;
+ private final List<DartIdentifier> fResult = Lists.newArrayList();
- public BindingFinder(Element binding, ArrayList<DartIdentifier> result) {
+ public BindingFinder(Element binding) {
fBinding = getDeclaration(binding);
- fResult = result;
}
@Override
public Void visitIdentifier(DartIdentifier node) {
Element binding = node.getElement();
- // TODO(scheglov) DartC should set Element for DartIdentifier,
- // so we would not need to ask parent
- if (binding == null) {
- binding = node.getParent().getElement();
- }
if (binding == null) {
return null;
}
@@ -138,9 +133,9 @@ public class LinkedNodeFinder {
* @return Return
*/
public static DartIdentifier[] findByBinding(DartNode root, Element binding) {
- ArrayList<DartIdentifier> res = new ArrayList<DartIdentifier>();
- BindingFinder nodeFinder = new BindingFinder(binding, res);
+ BindingFinder nodeFinder = new BindingFinder(binding);
root.accept(nodeFinder);
+ List<DartIdentifier> res = nodeFinder.fResult;
return res.toArray(new DartIdentifier[res.size()]);
}
@@ -154,9 +149,7 @@ public class LinkedNodeFinder {
* @return Return
*/
public static DartIdentifier[] findByNode(DartNode root, DartIdentifier name) {
- // TODO(scheglov) DartC should set Element for DartIdentifier,
- // so we would not need to ask parent
- Element binding = name.getParent().getElement();
+ Element binding = name.getElement();
if (binding != null) {
return findByBinding(root, binding);
}

Powered by Google App Engine
This is Rietveld 408576698