aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
authorMichael Ernst <mernst@cs.washington.edu>2021-12-07 11:16:11 -0800
committerMichael Ernst <mernst@cs.washington.edu>2021-12-07 11:16:11 -0800
commit3f5e4a2819d2f03d634a06861ff5487af320b719 (patch)
treeba9ab7ba2f582bb179624e2bb3f717bea5d9a421 /src/delombok
parent0b4cc60c2367845ebc362e4b254f9e96a66d53c3 (diff)
parentd3b763f9dab4a46e88ff10bc2132fb6f12fda639 (diff)
downloadlombok-3f5e4a2819d2f03d634a06861ff5487af320b719.tar.gz
lombok-3f5e4a2819d2f03d634a06861ff5487af320b719.tar.bz2
lombok-3f5e4a2819d2f03d634a06861ff5487af320b719.zip
Merge ../lombok-branch-master into nullness-annotations
Diffstat (limited to 'src/delombok')
-rwxr-xr-xsrc/delombok/lombok/delombok/Delombok.java4
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java41
2 files changed, 39 insertions, 6 deletions
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index 8d39f447..e4f17602 100755
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -43,9 +43,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
@@ -733,7 +733,7 @@ public class Delombok {
List<JCCompilationUnit> roots = new ArrayList<JCCompilationUnit>();
Map<JCCompilationUnit, File> baseMap = new IdentityHashMap<JCCompilationUnit, File>();
- Set<AbstractProcessor> processors = new HashSet<AbstractProcessor>();
+ Set<AbstractProcessor> processors = new LinkedHashSet<AbstractProcessor>();
processors.add(new lombok.javac.apt.LombokProcessor());
processors.addAll(additionalAnnotationProcessors);
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index bcf3f431..605b9391 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -545,6 +545,12 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.implementing, ", ");
}
+ List<JCExpression> permitting = readObject(tree, "permitting", List.<JCExpression>nil());
+ if (permitting.nonEmpty()) {
+ print(" permits ");
+ print(permitting, ", ");
+ }
+
println(" {");
indent++;
printClassMembers(tree.defs, isEnum, isInterface);
@@ -1016,6 +1022,8 @@ public class PrettyPrinter extends JCTree.Visitor {
if ((v & TRANSIENT) != 0) print("transient ");
if ((v & NATIVE) != 0) print("native ");
if ((v & ABSTRACT) != 0) print("abstract ");
+ if ((v & SEALED) != 0) print("sealed ");
+ if ((v & NON_SEALED) != 0) print("non-sealed ");
if ((v & STRICTFP) != 0) print("strictfp ");
if ((v & DEFAULT) != 0 && (v & INTERFACE) == 0) print("default ");
}
@@ -1324,13 +1332,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) {
+ pats = readObject(tree, "pats", null); // JDK 12-17
+ }
if (pats == null) {
- JCExpression pat = readObject(tree, "pat", null); // JDK -11
- pats = pat == null ? List.<JCExpression>nil() : List.of(pat);
+ JCTree pat = readObject(tree, "pat", null); // JDK -11
+ pats = pat == null ? List.<JCTree>nil() : List.of(pat);
}
- if (pats.isEmpty()) {
+ if (pats.isEmpty() || pats.size() == 1 && pats.head.getClass().getName().endsWith("$JCDefaultCaseLabel")) {
aPrint("default");
} else {
aPrint("case ");
@@ -1421,6 +1432,22 @@ public class PrettyPrinter extends JCTree.Visitor {
print((Name) readObject(var, "name", null));
}
+ void printDefaultCase(JCTree tree) {
+ print("default");
+ }
+
+ void printGuardPattern(JCTree tree) {
+ print((JCTree) readObject(tree, "patt", null));
+ print(" && ");
+ print((JCExpression) readObject(tree, "expr", null));
+ }
+
+ void printParenthesizedPattern(JCTree tree) {
+ print("(");
+ print((JCTree) readObject(tree, "pattern", null));
+ print(")");
+ }
+
@Override public void visitTry(JCTry tree) {
aPrint("try ");
List<?> resources = readObject(tree, "resources", List.nil());
@@ -1639,6 +1666,12 @@ public class PrettyPrinter extends JCTree.Visitor {
printYieldExpression(tree);
} else if (className.endsWith("$JCBindingPattern")) { // Introduced as preview in JDK14
printBindingPattern(tree);
+ } else if (className.endsWith("$JCDefaultCaseLabel")) { // Introduced in JDK17
+ printDefaultCase(tree);
+ } else if (className.endsWith("$JCGuardPattern")) { // Introduced in JDK17
+ printGuardPattern(tree);
+ } else if (className.endsWith("$JCParenthesizedPattern")) { // Introduced in JDK17
+ printParenthesizedPattern(tree);
} else {
throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
}