< prev index next >

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

Print this page
rev 51104 : imported patch switch

@@ -25,10 +25,11 @@
 
 package com.sun.tools.javac.tree;
 
 import java.io.*;
 
+import com.sun.source.tree.CaseTree.CaseKind;
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.source.tree.ModuleTree.ModuleKind;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;

@@ -833,22 +834,47 @@
         }
     }
 
     public void visitCase(JCCase tree) {
         try {
-            if (tree.pat == null) {
+            if (tree.pats.isEmpty()) {
                 print("default");
             } else {
                 print("case ");
-                printExpr(tree.pat);
+                printExprs(tree.pats);
             }
-            print(": ");
+            if (tree.caseKind == JCCase.STATEMENT) {
+                print(":");
             println();
             indent();
             printStats(tree.stats);
             undent();
             align();
+            } else {
+                print(" -> ");
+                printStat(tree.stats.head);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+ 
+    public void visitSwitchExpression(JCSwitchExpression tree) {
+        try {
+            print("switch ");
+            if (tree.selector.hasTag(PARENS)) {
+                printExpr(tree.selector);
+            } else {
+                print("(");
+                printExpr(tree.selector);
+                print(")");
+            }
+            print(" {");
+            println();
+            printStats(tree.cases);
+            align();
+            print("}");
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
 

@@ -954,11 +980,11 @@
     }
 
     public void visitBreak(JCBreak tree) {
         try {
             print("break");
-            if (tree.label != null) print(" " + tree.label);
+            if (tree.value != null) print(" " + tree.value);
             print(";");
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
     }
< prev index next >