aboutsummaryrefslogtreecommitdiff
path: root/src/delombok/lombok
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2021-07-09 09:36:22 +0200
committerRawi01 <Rawi01@users.noreply.github.com>2021-08-18 09:31:21 +0200
commit91859536db8cf4b59235c01474621f81641f9032 (patch)
treededa62d75a614231b7f19ef9cc9895bcd8205254 /src/delombok/lombok
parente050dafc9016519e79184e383eab9ffbd579bebd (diff)
downloadlombok-91859536db8cf4b59235c01474621f81641f9032.tar.gz
lombok-91859536db8cf4b59235c01474621f81641f9032.tar.bz2
lombok-91859536db8cf4b59235c01474621f81641f9032.zip
[jdk17] Add support for default cases
Diffstat (limited to 'src/delombok/lombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index bcf3f431..6074a01f 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -1324,13 +1324,16 @@ public class PrettyPrinter extends JCTree.Visitor {
@Override public void visitCase(JCCase tree) {
// Starting with JDK12, switches allow multiple expressions per case, and can take the form of an expression (preview feature).
- List<JCExpression> pats = readObject(tree, "pats", null); // JDK 12+
+ List<JCTree> pats = readObject(tree, "labels", null); // JDK 17+
if (pats == null) {
- JCExpression pat = readObject(tree, "pat", null); // JDK -11
- pats = pat == null ? List.<JCExpression>nil() : List.of(pat);
+ pats = readObject(tree, "pats", null); // JDK 12-17
+ }
+ if (pats == null) {
+ JCTree pat = readObject(tree, "pat", null); // JDK -11
+ pats = pat == null ? List.<JCTree>nil() : List.of(pat);
}
- if (pats.isEmpty()) {
+ if (pats.isEmpty() || pats.get(0).getClass().getName().endsWith("$JCDefaultCaseLabel")) {
aPrint("default");
} else {
aPrint("case ");