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

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

Issue 10562020: Clean up DartAstUtilities.getElement(), analysis should provide element for every identifier (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/DartAstUtilities.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
index 4253419d83d85cfb4ea576268dcc3e9ef5ef256f..1738d8ba03e3984e12b31bdd7ff2e0b5cb64b606 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
@@ -15,21 +15,14 @@ package com.google.dart.tools.core.utilities.ast;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartExpression;
-import com.google.dart.compiler.ast.DartField;
-import com.google.dart.compiler.ast.DartFunctionTypeAlias;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartMethodDefinition;
-import com.google.dart.compiler.ast.DartMethodInvocation;
import com.google.dart.compiler.ast.DartNewExpression;
import com.google.dart.compiler.ast.DartNode;
-import com.google.dart.compiler.ast.DartParameter;
-import com.google.dart.compiler.ast.DartParameterizedTypeNode;
import com.google.dart.compiler.ast.DartPropertyAccess;
import com.google.dart.compiler.ast.DartRedirectConstructorInvocation;
import com.google.dart.compiler.ast.DartSuperConstructorInvocation;
import com.google.dart.compiler.ast.DartTypeNode;
-import com.google.dart.compiler.ast.DartUnqualifiedInvocation;
-import com.google.dart.compiler.ast.DartVariable;
import com.google.dart.compiler.resolver.Element;
import com.google.dart.compiler.resolver.MethodElement;
import com.google.dart.compiler.type.InterfaceType;
@@ -62,85 +55,6 @@ public class DartAstUtilities {
|| parent instanceof DartSuperConstructorInvocation) {
targetElement = parent.getElement();
}
- // analyze "targetElement"
- if (targetElement == null) {
- if (parent instanceof DartTypeNode) {
- DartNode grandparent = parent.getParent();
- if (grandparent instanceof DartNewExpression) {
- targetElement = ((DartNewExpression) grandparent).getElement();
- }
- if (targetElement == null) {
- Type type = DartAstUtilities.getType((DartTypeNode) parent);
- if (type != null) {
- targetElement = type.getElement();
- }
- }
- } else if (parent instanceof DartMethodInvocation) {
- DartMethodInvocation invocation = (DartMethodInvocation) parent;
- if (node == invocation.getFunctionName()) {
- targetElement = invocation.getElement();
- }
- } else if (parent instanceof DartPropertyAccess) {
- DartPropertyAccess access = (DartPropertyAccess) parent;
- if (node == access.getName()) {
- targetElement = access.getElement();
- }
- } else if (parent instanceof DartUnqualifiedInvocation) {
- DartUnqualifiedInvocation invocation = (DartUnqualifiedInvocation) parent;
- if (node == invocation.getTarget()) {
- targetElement = invocation.getElement();
- }
- } else if (parent instanceof DartParameterizedTypeNode) {
- DartParameterizedTypeNode typeNode = (DartParameterizedTypeNode) parent;
- DartNode grandparent = typeNode.getParent();
- if (grandparent instanceof DartClass) {
- DartClass classDef = (DartClass) grandparent;
- if (typeNode == classDef.getDefaultClass()) {
- targetElement = classDef.getElement().getDefaultClass().getElement();
- }
- }
- } else if (includeDeclarations) {
- DartNode nameNode = node;
- if (parent instanceof DartPropertyAccess) {
- nameNode = parent;
- parent = nameNode.getParent();
- }
- if (parent instanceof DartClass) {
- DartClass classDefinition = (DartClass) parent;
- if (nameNode == classDefinition.getName()) {
- targetElement = classDefinition.getElement();
- }
- } else if (parent instanceof DartField) {
- DartField field = (DartField) parent;
- if (nameNode == field.getName()) {
- targetElement = field.getElement();
- }
- } else if (parent instanceof DartMethodDefinition) {
- DartMethodDefinition method = (DartMethodDefinition) parent;
- if (nameNode == method.getName()) {
- targetElement = method.getElement();
- }
- } else if (parent instanceof DartParameter) {
- DartParameter parameter = (DartParameter) parent;
- if (nameNode == parameter.getName()) {
- targetElement = parameter.getElement();
- }
- } else if (parent instanceof DartVariable) {
- DartVariable variable = (DartVariable) parent;
- if (nameNode == variable.getName()) {
- targetElement = variable.getElement();
- }
- } else if (parent instanceof DartFunctionTypeAlias) {
- DartFunctionTypeAlias alias = (DartFunctionTypeAlias) parent;
- if (nameNode == alias.getName()) {
- targetElement = alias.getElement();
- }
- }
- }
- if (targetElement == null) {
- targetElement = node.getElement();
- }
- }
return targetElement;
}

Powered by Google App Engine
This is Rietveld 408576698