From 91859536db8cf4b59235c01474621f81641f9032 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Fri, 9 Jul 2021 09:36:22 +0200 Subject: [jdk17] Add support for default cases --- src/delombok/lombok/delombok/PrettyPrinter.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/delombok/lombok') 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 pats = readObject(tree, "pats", null); // JDK 12+ + List pats = readObject(tree, "labels", null); // JDK 17+ if (pats == null) { - JCExpression pat = readObject(tree, "pat", null); // JDK -11 - pats = pat == null ? List.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.nil() : List.of(pat); } - if (pats.isEmpty()) { + if (pats.isEmpty() || pats.get(0).getClass().getName().endsWith("$JCDefaultCaseLabel")) { aPrint("default"); } else { aPrint("case "); -- cgit