< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java

Print this page

        

@@ -233,10 +233,18 @@
      */
     public <T extends JCTree> void printExprs(List<T> trees) throws IOException {
         printExprs(trees, ", ");
     }
 
+
+    /** Derived visitor method: print pattern.
+     */
+
+    public void printPattern(JCTree tree) throws IOException {
+        printExpr(tree);
+    }
+
     /** Derived visitor method: print list of statements, each on a separate line.
      */
     public void printStats(List<? extends JCTree> trees) throws IOException {
         for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) {
             align();

@@ -876,10 +884,25 @@
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
 
+    public void visitBindingPattern(JCBindingPattern patt) {
+        try {
+            if (patt.vartype == null) {
+                print("var ");
+                print(patt.name);
+            } else {
+                printExpr(patt.vartype);
+                print(" ");
+                print(patt.name);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitSynchronized(JCSynchronized tree) {
         try {
             print("synchronized ");
             if (tree.lock.hasTag(PARENS)) {
                 printExpr(tree.lock);

@@ -1282,11 +1305,15 @@
     public void visitTypeTest(JCInstanceOf tree) {
         try {
             open(prec, TreeInfo.ordPrec);
             printExpr(tree.expr, TreeInfo.ordPrec);
             print(" instanceof ");
-            printExpr(tree.clazz, TreeInfo.ordPrec + 1);
+            if (tree.pattern instanceof JCPattern) {
+                printPattern(tree.pattern);
+            } else {
+                printExpr(tree.getType(), TreeInfo.ordPrec + 1);
+            }
             close(prec, TreeInfo.ordPrec);
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
< prev index next >