diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2022-08-26 00:49:42 +0200 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2022-08-26 00:51:49 +0200 |
commit | 646723f6d30404b2974af4fbefad5d8843460fea (patch) | |
tree | 603cbab84d859250638b4de0d537d66a8998940b /src | |
parent | b57de5a558d310cdc80de0c304c45d268f6b989d (diff) | |
download | lombok-646723f6d30404b2974af4fbefad5d8843460fea.tar.gz lombok-646723f6d30404b2974af4fbefad5d8843460fea.tar.bz2 lombok-646723f6d30404b2974af4fbefad5d8843460fea.zip |
[jdk19] Add support for JCConstantCaseLabel
Diffstat (limited to 'src')
-rw-r--r-- | src/delombok/lombok/delombok/PrettyPrinter.java | 6 | ||||
-rw-r--r-- | src/utils/lombok/javac/JavacTreeMaker.java | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java index 605b9391..8e7bc7e5 100644 --- a/src/delombok/lombok/delombok/PrettyPrinter.java +++ b/src/delombok/lombok/delombok/PrettyPrinter.java @@ -1448,6 +1448,10 @@ public class PrettyPrinter extends JCTree.Visitor { print(")"); } + void printConstantCaseLabel(JCTree tree) { + print((JCTree) readObject(tree, "expr", null)); + } + @Override public void visitTry(JCTry tree) { aPrint("try "); List<?> resources = readObject(tree, "resources", List.nil()); @@ -1672,6 +1676,8 @@ public class PrettyPrinter extends JCTree.Visitor { printGuardPattern(tree); } else if (className.endsWith("$JCParenthesizedPattern")) { // Introduced in JDK17 printParenthesizedPattern(tree); + } else if (className.endsWith("$JCConstantCaseLabel")) { // Introduced in JDK19 + printConstantCaseLabel(tree); } else { throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree); } diff --git a/src/utils/lombok/javac/JavacTreeMaker.java b/src/utils/lombok/javac/JavacTreeMaker.java index d369b4e4..09855951 100644 --- a/src/utils/lombok/javac/JavacTreeMaker.java +++ b/src/utils/lombok/javac/JavacTreeMaker.java @@ -610,6 +610,8 @@ public class JavacTreeMaker { List<JCTree> labels; if (pat == null) { labels = tryResolve(DefaultCaseLabel) ? List.of(DefaultCaseLabel()) : List.<JCTree>nil(); + } else if (tryResolve(ConstantCaseLabel)) { + labels = List.<JCTree>of(ConstantCaseLabel(pat)); } else { labels = List.<JCTree>of(pat); } @@ -622,6 +624,12 @@ public class JavacTreeMaker { return invoke(DefaultCaseLabel); } + //javac versions: 19 + private static final MethodId<JCTree> ConstantCaseLabel = MethodId("ConstantCaseLabel", JCTree.class, JCExpression.class); + public JCTree ConstantCaseLabel(JCExpression expr) { + return invoke(ConstantCaseLabel, expr); + } + //javac versions: 6-8 private static final MethodId<JCSynchronized> Synchronized = MethodId("Synchronized"); public JCSynchronized Synchronized(JCExpression lock, JCBlock body) { |