Roberto Lublinerman has uploaded a new change for review.

  https://gwt-review.googlesource.com/2070


Change subject: Refactors JVisitor to standarize access to method/field at top of subtree.
......................................................................

Refactors JVisitor to standarize access to method/field at top of subtree.

Adds means to obtain the JMethod/JField at the top of a subtree when visiting subnodes.

Change-Id: I7eecc9d2ef363dd0b5227967e6e7b5161fab1ecc
---
M dev/core/src/com/google/gwt/dev/jjs/ast/JConstructor.java
M dev/core/src/com/google/gwt/dev/jjs/ast/JField.java
M dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
M dev/core/src/com/google/gwt/dev/jjs/ast/JVisitor.java
M dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
M dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
M dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
M dev/core/src/com/google/gwt/dev/jjs/impl/ImplicitUpcastAnalyzer.java
M dev/core/src/com/google/gwt/dev/jjs/impl/LongCastNormalizer.java
M dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
M dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRunAsyncs.java
M dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
M dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
A dev/core/test/com/google/gwt/dev/jjs/ast/JVisitorTest.java
14 files changed, 169 insertions(+), 103 deletions(-)



diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JConstructor.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JConstructor.java
index 1986666..677d6a8 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JConstructor.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JConstructor.java
@@ -125,10 +125,16 @@
   @Override
   public void traverse(JVisitor visitor, Context ctx) {
     String before = traceBefore(visitor);
+    // Keep track of parent JField when visiting descendants.
+    // Assumes no nesting of JFields and JMethods.
+    visitor.setCurrentMethod(this);
+
     if (visitor.visit(this, ctx)) {
       visitChildren(visitor);
     }
     visitor.endVisit(this, ctx);
+    visitor.resetCurrentMethod();
+
     traceAfter(visitor, before);
   }

diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JField.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JField.java
index f8307bc..679bceb 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JField.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JField.java
@@ -159,10 +159,15 @@
   }

   public void traverse(JVisitor visitor, Context ctx) {
+    // Keep track of parent JField when visiting descendants.
+    // Assumes no nesting of JFields and JMethods.
+    visitor.setCurrentField(this);
+
     if (visitor.visit(this, ctx)) {
       // Do not visit declStmt, it gets visited within its own code block.
     }
     visitor.endVisit(this, ctx);
+    visitor.resetCurrentField();
   }

   protected Object writeReplace() {
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
index dede802..8ecbc34 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JMethod.java
@@ -399,10 +399,14 @@
   public void traverse(JVisitor visitor, Context ctx) {
     String before = null;
     before = traceBefore(visitor);
+    // Keep track of parent JField when visiting descendants.
+    // Assumes no nesting of JFields and JMethods.
+    visitor.setCurrentMethod(this);
     if (visitor.visit(this, ctx)) {
       visitChildren(visitor);
     }
     visitor.endVisit(this, ctx);
+    visitor.resetCurrentMethod();
     traceAfter(visitor, before);
   }

diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JVisitor.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JVisitor.java
index 3d332ff..c6321d1 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JVisitor.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JVisitor.java
@@ -839,4 +839,53 @@
     return visit((JStatement) x, ctx);
   }

+  /**
+   * Keep track the JField when visiting nodes that sit below it.
+   * Assumes there is no nesting of JFields and JMethods
+   */
+  private JField currentField = null;
+
+  void setCurrentField(JField f) {
+    currentField = f;
+  }
+
+  void resetCurrentField() {
+    currentField = null;
+  }
+
+  /**
+   * Returns the JMethod node that sits above the node being visited.
+   *
+ * @return the JMethod node that is above the node being visited. {@code null} if the
+   *         the node being visited is not under a JMethod.
+   */
+  protected JField getCurrentField() {
+    return currentField;
+  }
+
+  /**
+   * Keep track the JMethod when visiting nodes that sit below it.
+   * Assumes there is no nesting of JFields and JMethods
+   */
+  private JMethod currentMethod = null;
+
+  void setCurrentMethod(JMethod m) {
+    currentMethod = m;
+  }
+
+  void resetCurrentMethod() {
+    currentMethod = null;
+  }
+
+  /**
+   * Returns the JField node that sits above the node being visited.
+   *
+   *
+ * @return the JField node that is above the node being visited. {@code null} if the
+   *         the node being visited is not under a JField.
+   */
+  protected JMethod getCurrentMethod() {
+    return currentMethod;
+  }
+
 }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
index 0907c57..2249cde 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
@@ -104,8 +104,6 @@
    * that more simplifications can be made on a single pass through a tree.
    */
   public class DeadCodeVisitor extends JModVisitor {
-    private JMethod currentMethod = null;
-
     /**
* Expressions whose result does not matter. A parent node should add any * children whose result does not matter to this set during the parent's
@@ -365,7 +363,7 @@
      */
     @Override
     public void endVisit(JIfStatement x, Context ctx) {
-      maybeReplaceMe(x, Simplifier.ifStatement(x, currentMethod), ctx);
+ maybeReplaceMe(x, Simplifier.ifStatement(x, getCurrentMethod()), ctx);
     }

     /**
@@ -387,11 +385,6 @@
         assert (!x.hasSideEffects());
         ctx.replaceMe(literal);
       }
-    }
-
-    @Override
-    public void endVisit(JMethod x, Context ctx) {
-      currentMethod = null;
     }

     /**
@@ -655,12 +648,6 @@
     @Override
     public boolean visit(JExpressionStatement x, Context ctx) {
       ignoringExpressionOutput.add(x.getExpr());
-      return true;
-    }
-
-    @Override
-    public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
       return true;
     }

diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
index d7ea10c..e6c3114 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
@@ -443,9 +443,9 @@
          * ordinalization. Instead, convert $VALUES to an array of int.
          */
         if (x.getField().getName().equals("$VALUES")
- && ((this.currentMethod.getEnclosingType() != x.getField().getEnclosingType()) ||
-                (!this.currentMethod.getName().equals("values") &&
-                 !this.currentMethod.getName().equals("$clinit")))) {
+ && ((getCurrentMethod().getEnclosingType() != x.getField().getEnclosingType()) ||
+                (!getCurrentMethod().getName().equals("values") &&
+                 !getCurrentMethod().getName().equals("$clinit")))) {
blackListIfEnum(x.getField().getEnclosingType(), x.getSourceInfo());
         }
       }
@@ -528,7 +528,7 @@
          * need to exempt static methodCalls for an enum class if it occurs
          * within the enum class itself (such as in $clinit() or values())
          */
- if (this.currentMethod.getEnclosingType() != x.getTarget().getEnclosingType()) { + if (getCurrentMethod().getEnclosingType() != x.getTarget().getEnclosingType()) { blackListIfEnum(x.getTarget().getEnclosingType(), x.getSourceInfo());
         }
       }
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
index 6b86885..bbb0b63 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
@@ -612,8 +612,6 @@

private final Map<JClassType, JsFunction> clinitMap = new HashMap<JClassType, JsFunction>();

-    private JMethod currentMethod = null;
-
     /**
      * The JavaScript functions corresponding to the entry methods of the
      * program ({@link JProgram#getEntryMethods()}).
@@ -1118,7 +1116,6 @@
       if (entryIndex != null) {
         entryFunctions[entryIndex] = jsFunc;
       }
-      currentMethod = null;
     }

     @Override
@@ -1511,7 +1508,6 @@
       if (x.isAbstract()) {
         return false;
       }
-      currentMethod = x;
       return true;
     }

@@ -2154,7 +2150,7 @@
       }

       JDeclaredType targetType = x.getEnclosingType().getClinitTarget();
-      if (!currentMethod.getEnclosingType().checkClinitTo(targetType)) {
+ if (!getCurrentMethod().getEnclosingType().checkClinitTo(targetType)) {
         return null;
       } else if (targetType.equals(program.getTypeClassLiteralHolder())) {
         return null;
@@ -2250,16 +2246,10 @@

   private class RecordCrossClassCalls extends JVisitor {

-    private JMethod currentMethod;
-
-    @Override
-    public void endVisit(JMethod x, Context ctx) {
-      currentMethod = null;
-    }

     @Override
     public void endVisit(JMethodCall x, Context ctx) {
-      JDeclaredType sourceType = currentMethod.getEnclosingType();
+      JDeclaredType sourceType = getCurrentMethod().getEnclosingType();
       JDeclaredType targetType = x.getTarget().getEnclosingType();
       if (sourceType.checkClinitTo(targetType)) {
         crossClassTargets.add(x.getTarget());
@@ -2284,12 +2274,6 @@
         liveCtors.add((JConstructor) x.getTarget());
       }
       endVisit((JMethodCall) x, ctx);
-    }
-
-    @Override
-    public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
-      return true;
     }
   }

diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ImplicitUpcastAnalyzer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ImplicitUpcastAnalyzer.java
index d02a81e..8bdaaa3 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ImplicitUpcastAnalyzer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ImplicitUpcastAnalyzer.java
@@ -48,7 +48,6 @@
  */
 public class ImplicitUpcastAnalyzer extends JVisitor {

-  protected JMethod currentMethod;
   private final JType javaScriptObjectType;
   private final JType nullType;
   private final JType throwableType;
@@ -161,7 +160,7 @@
   public void endVisit(JReturnStatement x, Context ctx) {
     if (x.getExpr() != null) {
       // check against the current method return type
- processIfTypesNotEqual(x.getExpr().getType(), currentMethod.getType(), x.getSourceInfo()); + processIfTypesNotEqual(x.getExpr().getType(), getCurrentMethod().getType(), x.getSourceInfo());
     }
   }

@@ -187,13 +186,6 @@
       type = ((JReferenceType) type).getUnderlyingType();
     }
     processIfTypesNotEqual(type, throwableType, x.getSourceInfo());
-  }
-
-  @Override
-  public boolean visit(JMethod x, Context ctx) {
-    // save this, so can use it later for checking JReturnStatement
-    currentMethod = x;
-    return true;
   }

   /**
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/LongCastNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/LongCastNormalizer.java
index be68c72..ebd2714 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/LongCastNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/LongCastNormalizer.java
@@ -21,7 +21,6 @@
 import com.google.gwt.dev.jjs.ast.JConditional;
 import com.google.gwt.dev.jjs.ast.JDeclarationStatement;
 import com.google.gwt.dev.jjs.ast.JExpression;
-import com.google.gwt.dev.jjs.ast.JMethod;
 import com.google.gwt.dev.jjs.ast.JMethodCall;
 import com.google.gwt.dev.jjs.ast.JModVisitor;
 import com.google.gwt.dev.jjs.ast.JNewArray;
@@ -45,7 +44,6 @@
    */
   private class ImplicitCastVisitor extends JModVisitor {

-    private JMethod currentMethod;
     private final JPrimitiveType longType;

     public ImplicitCastVisitor(JPrimitiveType longType) {
@@ -131,11 +129,6 @@
     }

     @Override
-    public void endVisit(JMethod x, Context ctx) {
-      currentMethod = null;
-    }
-
-    @Override
     public void endVisit(JMethodCall x, Context ctx) {
       List<JParameter> params = x.getTarget().getParams();
       for (int i = 0; i < params.size(); ++i) {
@@ -169,18 +162,12 @@
     public void endVisit(JReturnStatement x, Context ctx) {
       JExpression expr = x.getExpr();
       if (expr != null) {
- JExpression newExpr = checkAndReplace(expr, currentMethod.getType()); + JExpression newExpr = checkAndReplace(expr, getCurrentMethod().getType());
         if (expr != newExpr) {
JReturnStatement newStmt = new JReturnStatement(x.getSourceInfo(), newExpr);
           ctx.replaceMe(newStmt);
         }
       }
-    }
-
-    @Override
-    public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
-      return true;
     }

     /**
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java b/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
index beaf790..bac8bb4 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
@@ -86,15 +86,10 @@
     private JExpression ignoringReturnValueFor;

     @Override
-    public void endVisit(JMethod x, Context ctx) {
-      currentMethod = null;
-    }
-
-    @Override
     public void endVisit(JMethodCall x, Context ctx) {
       JMethod method = x.getTarget();

-      if (currentMethod == method) {
+      if (getCurrentMethod() == method) {
         // Never try to inline a recursive call!
         return;
       }
@@ -144,7 +139,6 @@

     @Override
     public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
       if (program.getStaticImpl(x) != null) {
         /*
* Never inline a static impl into the calling instance method. We used
@@ -164,7 +158,7 @@

     private JMethodCall createClinitCall(JMethodCall x) {
JDeclaredType targetType = x.getTarget().getEnclosingType().getClinitTarget();
-      if (!currentMethod.getEnclosingType().checkClinitTo(targetType)) {
+ if (!getCurrentMethod().getEnclosingType().checkClinitTo(targetType)) { // Access from this class to the target class won't trigger a clinit
         return null;
       }
@@ -277,7 +271,7 @@
      */
     private void replaceWithMulti(Context ctx, JMultiExpression multi) {
       ctx.replaceMe(multi);
-      modifiedMethods.add(currentMethod);
+      modifiedMethods.add(getCurrentMethod());
     }

     /**
@@ -505,8 +499,6 @@
     optimizeEvent.end("didChange", "" + stats.didChange());
     return stats;
   }
-
-  private JMethod currentMethod;

   private final JProgram program;

diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRunAsyncs.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRunAsyncs.java
index 2e9222a..662aca2 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRunAsyncs.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRunAsyncs.java
@@ -53,16 +53,15 @@
  */
 public class ReplaceRunAsyncs {
   private class AsyncCreateVisitor extends JModVisitor {
-    private JMethod currentMethod;
     private final JMethod runAsyncOnsuccess = program
         .getIndexedMethod("RunAsyncCallback.onSuccess");

     @Override
     public void endVisit(JMethodCall x, Context ctx) {
       JMethod method = x.getTarget();
-      if (method == runAsyncOnsuccess
- && (currentMethod != null && currentMethod.getEnclosingType() == program
-              .getIndexedType("AsyncFragmentLoader"))) {
+      if (method == runAsyncOnsuccess &&
+ (getCurrentMethod() != null && getCurrentMethod().getEnclosingType() ==
+          program.getIndexedType("AsyncFragmentLoader"))) {
         /*
* Note: The volatile marker on the method flags it so that we don't
          * optimize calls from AsyncFragmentLoader to implementations of
@@ -76,7 +75,7 @@
         String name;
         switch (x.getArgs().size()) {
           case 1:
-            name = getImplicitName(currentMethod);
+            name = getImplicitName(getCurrentMethod());
             asyncCallback = x.getArgs().get(0);
             break;
           case 2:
@@ -119,12 +118,6 @@
         runAsyncs.add(runAsyncNode);
         ctx.replaceMe(runAsyncNode);
       }
-    }
-
-    @Override
-    public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
-      return true;
     }

     private boolean isRunAsyncMethod(JMethod method) {
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java b/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
index 70ec21c..71c286a 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/TypeTightener.java
@@ -195,8 +195,6 @@
    * visitor each time.
    */
   public class RecordVisitor extends JVisitor {
-    private JMethod currentMethod;
-
     @Override
     public void endVisit(JBinaryOperation x, Context ctx) {
       if (x.isAssignment() && (x.getType() instanceof JReferenceType)) {
@@ -233,7 +231,6 @@
         // TODO: do I still need this?
         addAssignment(x, x.getLiteralInitializer());
       }
-      currentMethod = null;
     }

     @Override
@@ -243,7 +240,6 @@
           addOverrider(method, x);
         }
       }
-      currentMethod = null;
     }

     @Override
@@ -263,8 +259,8 @@

     @Override
     public void endVisit(JReturnStatement x, Context ctx) {
-      if (currentMethod.getType() instanceof JReferenceType) {
-        addReturn(currentMethod, x.getExpr());
+      if (getCurrentMethod().getType() instanceof JReferenceType) {
+        addReturn(getCurrentMethod(), x.getExpr());
       }
     }

@@ -302,8 +298,6 @@
      */
     @Override
     public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
-
       if (x.canBePolymorphic()) {
         /*
* Add an assignment to each parameter from that same parameter in every diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java b/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
index 5aa134c..791aab4 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/UnifyAst.java
@@ -121,8 +121,6 @@

   private class UnifyVisitor extends JModVisitor {

-    private JMethod currentMethod;
-
     @Override
     public void endVisit(JArrayType x, Context ctx) {
       assert false : "Should not get here";
@@ -218,11 +216,6 @@
     @Override
     public void endVisit(JInterfaceType x, Context ctx) {
       assert false : "Should not get here";
-    }
-
-    @Override
-    public void endVisit(JMethod x, Context ctx) {
-      currentMethod = null;
     }

     @Override
@@ -323,12 +316,6 @@
     }

     @Override
-    public boolean visit(JMethod x, Context ctx) {
-      currentMethod = x;
-      return true;
-    }
-
-    @Override
     public boolean visit(JMethodCall x, Context ctx) {
       JMethod target = translate(x.getTarget());
       x.resolve(target);
@@ -376,7 +363,7 @@
         }
         JExpression result =
JGwtCreate.createInstantiationExpression(x.getSourceInfo(), (JClassType) answerType,
-                currentMethod.getEnclosingType());
+                getCurrentMethod().getEnclosingType());
         if (result == null) {
error(x, "Rebind result '" + answer + "' has no default (zero argument) constructors");
           return null;
diff --git a/dev/core/test/com/google/gwt/dev/jjs/ast/JVisitorTest.java b/dev/core/test/com/google/gwt/dev/jjs/ast/JVisitorTest.java
new file mode 100644
index 0000000..2e67f45
--- /dev/null
+++ b/dev/core/test/com/google/gwt/dev/jjs/ast/JVisitorTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.jjs.ast;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.jjs.impl.JJSTestBase;
+
+/**
+ * Tests {@link JVisitor}.
+ */
+public class JVisitorTest extends JJSTestBase {
+
+
+
+  /** Tests {@link JVisitor#getCurrentMethod }
+   */
+ public void testGetCurrentMethodSimple() throws UnableToCompleteException {
+    JVisitor v = new JVisitor() {
+      @Override
+      public void endVisit(JStatement x, Context ctx) {
+        // Statements can only appear inside method declarations.
+ assertNotNull("getCurrentMethod() must return not null while visiting a method",
+            getCurrentMethod());
+ assertNull("getCurrentField() must return null while visiting a method",
+            getCurrentField());
+      }
+
+      public void endVisit(JMethod x, Context ctx) {
+        // Statements can only appear inside method declarations.
+        assertEquals(x, getCurrentMethod());
+ assertNull("getCurrentField() must return null while visiting a method",
+            getCurrentField());
+      }
+
+      public void endVisit(JField x, Context ctx) {
+        // Statements can only appear inside method declarations.
+        assertEquals(x, getCurrentField());
+ assertNull("getCurrentMethod() must return null while visiting a method",
+            getCurrentMethod());
+      }
+
+      public void endVisit(JDeclaredType x, Context ctx) {
+        // Statements can only appear inside method declarations.
+ assertNull("getCurrentField() must return null while visiting a class",
+            getCurrentField());
+ assertNull("getCurrentMethod() must return null while visiting a class ",
+            getCurrentMethod());
+      }
+
+    };
+
+    JProgram program = compileSnippet("void",  "new ClassA();");
+    v.accept(program);
+  }
+
+  public void setUp() throws Exception {
+    addSnippetClassDecl(
+        "static class  ClassA { " +
+        "  static public int field1;" +
+        "  static private ClassA field2;" +
+        "  int field3;" +
+        "  protected ClassA field4;" +
+        "  int field5 = 5;" +
+        "  int field6 = ClassA.method1();" +
+        "  static { field1 = 3; }" +
+        "  static public int method1() { return 2; }" +
+        "  public int method2() { return 3; }" +
+        "  public ClassA() { field4 = null; }" +
+        "}"
+    );
+
+  }
+}

--
To view, visit https://gwt-review.googlesource.com/2070
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7eecc9d2ef363dd0b5227967e6e7b5161fab1ecc
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Roberto Lublinerman <rlu...@google.com>

--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to