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

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

Issue 10918260: Issue 5044. Keep FieldElement as Element for field access (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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/DartElementLocator.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
index 266fcbedbd588c0beca606189d47ad7d5798ac7b..c99858048736411ccca5c9dfcf7356db5112f500 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java
@@ -23,13 +23,17 @@ import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartImportDirective;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.ast.DartPartOfDirective;
+import com.google.dart.compiler.ast.DartPropertyAccess;
import com.google.dart.compiler.ast.DartSourceDirective;
import com.google.dart.compiler.ast.DartStringLiteral;
import com.google.dart.compiler.ast.DartUnaryExpression;
import com.google.dart.compiler.ast.DartUnqualifiedInvocation;
+import com.google.dart.compiler.parser.Token;
import com.google.dart.compiler.resolver.Element;
import com.google.dart.compiler.resolver.ElementKind;
+import com.google.dart.compiler.resolver.FieldElement;
import com.google.dart.compiler.resolver.LibraryElement;
+import com.google.dart.compiler.resolver.MethodElement;
import com.google.dart.compiler.resolver.NodeElement;
import com.google.dart.compiler.resolver.VariableElement;
import com.google.dart.tools.core.DartCore;
@@ -282,6 +286,22 @@ public class DartElementLocator extends ASTVisitor<Void> {
if (targetElement == null) {
foundElement = null;
} else {
+ // pure assignment to field is call of setter
+ if (targetElement instanceof FieldElement) {
+ DartNode parent = node.getParent();
+ if (parent instanceof DartPropertyAccess
+ && ((DartPropertyAccess) parent).getName() == node) {
+ parent = parent.getParent();
+ }
+ if (parent instanceof DartBinaryExpression) {
+ FieldElement fieldElement = (FieldElement) targetElement;
+ MethodElement setter = fieldElement.getSetter();
+ if (((DartBinaryExpression) parent).getOperator() == Token.ASSIGN && setter != null) {
+ targetElement = setter;
+ }
+ }
+ }
+ // convert Element from Resolver into DartElement
if (targetElement instanceof VariableElement) {
VariableElement variableElement = (VariableElement) targetElement;
resolvedElement = variableElement;

Powered by Google App Engine
This is Rietveld 408576698