aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java14
-rw-r--r--test/pretty/resource/after/RecordPattern.java15
-rw-r--r--test/pretty/resource/before/RecordPattern.java16
3 files changed, 45 insertions, 0 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index ee1380f6..13836d77 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -1461,6 +1461,18 @@ public class PrettyPrinter extends JCTree.Visitor {
}
}
+ void printRecordPattern(JCTree tree) {
+ print((JCTree) readObject(tree, "deconstructor", null));
+ print("(");
+ print(readObject(tree, "nested", List.<JCTree>nil()), ", ");
+ print(")");
+ JCVariableDecl var = readObject(tree, "var", null);
+ if (var != null) {
+ print(" ");
+ print(var.name);
+ }
+ }
+
@Override public void visitTry(JCTry tree) {
aPrint("try ");
List<?> resources = readObject(tree, "resources", List.nil());
@@ -1689,6 +1701,8 @@ public class PrettyPrinter extends JCTree.Visitor {
printConstantCaseLabel(tree);
} else if (className.endsWith("$JCPatternCaseLabel")) { // Introduced in JDK19
printPatternCaseLabel(tree);
+ } else if (className.endsWith("$JCRecordPattern")) { // Introduced in JDK19
+ printRecordPattern(tree);
} else {
throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
}
diff --git a/test/pretty/resource/after/RecordPattern.java b/test/pretty/resource/after/RecordPattern.java
new file mode 100644
index 00000000..ad9fae0b
--- /dev/null
+++ b/test/pretty/resource/after/RecordPattern.java
@@ -0,0 +1,15 @@
+record Point(int x, int y) {
+}
+record Rectangle(Point upperLeft, Point lowerRight) {
+}
+
+public class RecordPattern {
+ void recordPattern(Object o) {
+ if (o instanceof Point(int x, int y)) {
+ }
+ if (o instanceof Point(int x, int y) p) {
+ }
+ if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) {
+ }
+ }
+} \ No newline at end of file
diff --git a/test/pretty/resource/before/RecordPattern.java b/test/pretty/resource/before/RecordPattern.java
new file mode 100644
index 00000000..93c07965
--- /dev/null
+++ b/test/pretty/resource/before/RecordPattern.java
@@ -0,0 +1,16 @@
+// version 19:
+record Point(int x, int y) {
+}
+record Rectangle(Point upperLeft, Point lowerRight) {
+}
+
+public class RecordPattern {
+ void recordPattern(Object o) {
+ if (o instanceof Point(int x, int y)) {
+ }
+ if (o instanceof Point(int x, int y) p) {
+ }
+ if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) {
+ }
+ }
+} \ No newline at end of file