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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java

Issue 11787017: Initial implementation of MemoryIndexStoreImpl and IndexContributor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update for review comments Created 7 years, 11 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.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java
index a75768c6a4a4f890a65cd21759dd8c3f72defe34..d57b5f3c8b097b55a130d1cb638e789f29317eb2 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/SimpleIdentifier.java
@@ -14,6 +14,7 @@
package com.google.dart.engine.ast;
import com.google.dart.engine.scanner.Token;
+import com.google.dart.engine.scanner.TokenType;
/**
* Instances of the class {@code SimpleIdentifier} represent a simple identifier.
@@ -71,6 +72,36 @@ public class SimpleIdentifier extends Identifier {
return token;
}
+ /**
+ * Looks to see if this identifier is used to read value.
+ */
+ public boolean inGetterContext() {
+ if (getParent() instanceof AssignmentExpression) {
+ AssignmentExpression expr = (AssignmentExpression) getParent();
+ if (expr.getLeftHandSide() == this && expr.getOperator().getType() == TokenType.EQ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Looks to see if this identifier is used to write value.
+ */
+ public boolean inSetterContext() {
+ if (getParent() instanceof PrefixExpression) {
+ PrefixExpression expr = (PrefixExpression) getParent();
+ return expr.getOperand() == this && expr.getOperator().getType().isIncrementOperator();
+ }
+ if (getParent() instanceof PostfixExpression) {
+ return true;
+ }
+ if (getParent() instanceof AssignmentExpression) {
+ return true;
Brian Wilkerson 2013/01/07 23:10:10 Doesn't this need to check that the identifier is
scheglov 2013/01/07 23:21:35 Done.
+ }
+ return false;
+ }
+
@Override
public boolean isSynthetic() {
return token.isSynthetic();

Powered by Google App Engine
This is Rietveld 408576698