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

Unified Diff: compiler/java/com/google/dart/compiler/ast/ASTNodes.java

Issue 10991064: Issue 5350. Type variable should be accessible in instance field (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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/ast/ASTNodes.java
diff --git a/compiler/java/com/google/dart/compiler/ast/ASTNodes.java b/compiler/java/com/google/dart/compiler/ast/ASTNodes.java
index 02f43d2eec3cc689ff1f6cc3e95f647043e1684b..104b56c8a9044ddcada92de9bfd5760df5c8837e 100644
--- a/compiler/java/com/google/dart/compiler/ast/ASTNodes.java
+++ b/compiler/java/com/google/dart/compiler/ast/ASTNodes.java
@@ -35,6 +35,53 @@ import java.util.List;
* {@link DartNode} and its subclasses).
*/
public class ASTNodes {
+
+ /**
+ * @return <code>true</code> if given {@link DartNode} is part of static method or top-level
+ * function.
+ */
+ public static boolean isStaticContext(DartNode node ) {
+ while (node != null) {
+ DartNode parent = node.getParent();
+ if (node instanceof DartMethodDefinition) {
+ DartMethodDefinition method = (DartMethodDefinition) node;
+ if (method.getModifiers().isStatic()) {
+ return true;
+ }
+ return parent instanceof DartUnit;
+ }
+ if (node instanceof DartField) {
+ DartField field = (DartField) node;
+ if (field.getModifiers().isStatic() || field.getModifiers().isConstant()) {
+ return true;
+ }
+ return parent != null && parent.getParent() instanceof DartUnit;
+ }
+ node = parent;
+ }
+ return false;
+ }
+
+ /**
+ * @return <code>true</code> if given {@link DartNode} is part of factory method.
+ */
+ public static boolean isFactoryContext(DartNode node) {
+ while (node != null) {
+ if (node instanceof DartMethodDefinition) {
+ DartMethodDefinition method = (DartMethodDefinition) node;
+ return method.getModifiers().isFactory();
+ }
+ node = node.getParent();
+ }
+ return false;
+ }
+
+ /**
+ * @return <code>true</code> if given {@link DartNode} is part of static method or factory.
+ */
+ public static boolean isStaticOrFactoryContext(DartNode node) {
+ return isFactoryContext(node) || isStaticContext(node);
+ }
/**
* Returns complete field access node for given field name.
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698