< prev index next >
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java
Print this page
rev 51258 : imported patch switch
*** 25,34 ****
--- 25,35 ----
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,854 ****
}
}
public void visitCase(JCCase tree) {
try {
! if (tree.pat == null) {
print("default");
} else {
print("case ");
! printExpr(tree.pat);
}
! print(": ");
println();
indent();
printStats(tree.stats);
undent();
align();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
--- 834,880 ----
}
}
public void visitCase(JCCase tree) {
try {
! if (tree.pats.isEmpty()) {
print("default");
} else {
print("case ");
! printExprs(tree.pats);
}
! 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,964 ****
}
public void visitBreak(JCBreak tree) {
try {
print("break");
! if (tree.label != null) print(" " + tree.label);
print(";");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
--- 980,990 ----
}
public void visitBreak(JCBreak tree) {
try {
print("break");
! if (tree.value != null) print(" " + tree.value);
print(";");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
< prev index next >