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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java

Issue 9703096: Remove Element.getNode() method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java
index a4d35edc56da5fd92c1d7135e088cc8108f72160..d4984017fdea273c92121d3ef3b8d55135692b67 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/NameOccurrencesFinder.java
@@ -1,12 +1,13 @@
package com.google.dart.tools.core.utilities.ast;
+import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartFunction;
import com.google.dart.compiler.ast.DartFunctionTypeAlias;
import com.google.dart.compiler.ast.DartMethodDefinition;
import com.google.dart.compiler.ast.DartNode;
-import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartParameter;
import com.google.dart.compiler.resolver.Element;
+import com.google.dart.compiler.resolver.NodeElement;
import com.google.dart.compiler.resolver.VariableElement;
import java.util.ArrayList;
@@ -55,14 +56,16 @@ public class NameOccurrencesFinder extends ASTVisitor<Void> {
}
private DartNode findTargetContainer() {
- if (target instanceof VariableElement) {
- return findAncestor(target.getNode(), DartMethodDefinition.class);
- } else if (target instanceof DartParameter) {
- // TODO determine all decls that can have parameters and include here
- return findAncestor(target.getNode(), DartMethodDefinition.class, DartFunction.class,
- DartFunctionTypeAlias.class);
- } else {
- return ast;
+ if (target instanceof NodeElement) {
+ DartNode targetNode = ((NodeElement) target).getNode();
+ if (target instanceof VariableElement) {
+ return findAncestor(targetNode, DartMethodDefinition.class);
+ } else if (target instanceof DartParameter) {
+ // TODO determine all decls that can have parameters and include here
+ return findAncestor(targetNode, DartMethodDefinition.class, DartFunction.class,
+ DartFunctionTypeAlias.class);
+ }
}
+ return ast;
}
}

Powered by Google App Engine
This is Rietveld 408576698