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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/bindings/BindingUtils.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/bindings/BindingUtils.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/bindings/BindingUtils.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/bindings/BindingUtils.java
index f29bbdbfcb44d61b24e2ea0a2b4eca37420aaaaa..d55760425ceba7a5ff9768c0c808a4a54c70ce1b 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/bindings/BindingUtils.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/bindings/BindingUtils.java
@@ -627,9 +627,7 @@ public class BindingUtils {
return null;
}
String variableName = variableBinding.getName();
- DartNode node = variableBinding.getNode();
- DartFunction functionNode = getEnclosingFunction(node);
- if (functionNode == null) {
+ if (variableBinding.getEnclosingElement() instanceof LibraryElement) {
try {
for (CompilationUnit unit : library.getCompilationUnits()) {
for (DartVariableDeclaration variable : unit.getGlobalVariables()) {
@@ -644,16 +642,19 @@ public class BindingUtils {
}
return null;
}
- com.google.dart.tools.core.model.DartFunction functionElement = getDartElement(library,
- (MethodElement) functionNode.getParent().getElement());
- try {
- for (DartVariableDeclaration variable : functionElement.getLocalVariables()) {
- if (variable.getElementName().equals(variableName)) {
- return variable;
+ if (variableBinding.getEnclosingElement() instanceof MethodElement) {
+ MethodElement methodElement = (MethodElement) variableBinding.getEnclosingElement();
+ com.google.dart.tools.core.model.DartFunction functionElement = getDartElement(library,
+ methodElement);
+ try {
+ for (DartVariableDeclaration variable : functionElement.getLocalVariables()) {
+ if (variable.getElementName().equals(variableName)) {
+ return variable;
+ }
}
+ } catch (DartModelException exception) {
+ DartCore.logError("Cannot access local variables within function", exception);
}
- } catch (DartModelException exception) {
- DartCore.logError("Cannot access local variables within function", exception);
}
return null;
}

Powered by Google App Engine
This is Rietveld 408576698