aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/AllArgsConstructor.java2
-rw-r--r--src/core/lombok/Builder.java2
-rw-r--r--src/core/lombok/NoArgsConstructor.java4
-rw-r--r--src/core/lombok/RequiredArgsConstructor.java2
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java4
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java2
-rw-r--r--src/core/lombok/eclipse/handlers/HandleExtensionMethod.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldDefaults.java2
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java34
-rw-r--r--src/core/lombok/experimental/SuperBuilder.java2
-rw-r--r--src/core/lombok/extern/jackson/Jacksonized.java2
-rw-r--r--src/core/lombok/javac/JavacResolution.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleExtensionMethod.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldDefaults.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java29
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java4
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java31
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java10
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java25
-rw-r--r--src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java131
-rw-r--r--src/utils/lombok/javac/JavacTreeMaker.java8
21 files changed, 285 insertions, 35 deletions
diff --git a/src/core/lombok/AllArgsConstructor.java b/src/core/lombok/AllArgsConstructor.java
index c059c65d..28d9c209 100644
--- a/src/core/lombok/AllArgsConstructor.java
+++ b/src/core/lombok/AllArgsConstructor.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* Generates an all-args constructor.
* An all-args constructor requires one argument for every field in the class.
* <p>
- * Complete documentation is found at <a href="https://projectlombok.org/features/Constructor">the project lombok features page for &#64;Constructor</a>.
+ * Complete documentation is found at <a href="https://projectlombok.org/features/constructor">the project lombok features page for &#64;Constructor</a>.
* <p>
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
*
diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java
index 64294e4b..06ca3853 100644
--- a/src/core/lombok/Builder.java
+++ b/src/core/lombok/Builder.java
@@ -160,7 +160,7 @@ public @interface Builder {
* For example, a method normally generated as {@code someField(String someField)} would instead be
* generated as {@code withSomeField(String someField)} if using {@code @Builder(setterPrefix = "with")}.
*
- * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally
+ * Note that using "with" to prefix builder setter methods is strongly discouraged as "with" normally
* suggests immutable data structures, and builders by definition are mutable objects.
*
* For {@code @Singular} fields, the generated methods are called {@code withName}, {@code withNames}, and {@code clearNames}, instead of
diff --git a/src/core/lombok/NoArgsConstructor.java b/src/core/lombok/NoArgsConstructor.java
index 672cd1c2..2ba69e48 100644
--- a/src/core/lombok/NoArgsConstructor.java
+++ b/src/core/lombok/NoArgsConstructor.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* Generates a no-args constructor.
* Will generate an error message if such a constructor cannot be written due to the existence of final fields.
* <p>
- * Complete documentation is found at <a href="https://projectlombok.org/features/Constructor">the project lombok features page for &#64;Constructor</a>.
+ * Complete documentation is found at <a href="https://projectlombok.org/features/constructor">the project lombok features page for &#64;Constructor</a>.
* <p>
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
* <p>
@@ -75,7 +75,7 @@ public @interface NoArgsConstructor {
* If {@code true}, initializes all final fields to 0 / null / false.
* Otherwise, a compile time error occurs.
*
- * @return Return {@code} true to force generation of a no-args constructor, picking defaults if necessary to assign required fields.
+ * @return {@code} true to force generation of a no-args constructor, picking defaults if necessary to assign required fields.
*/
boolean force() default false;
diff --git a/src/core/lombok/RequiredArgsConstructor.java b/src/core/lombok/RequiredArgsConstructor.java
index f21bd647..8f2f365a 100644
--- a/src/core/lombok/RequiredArgsConstructor.java
+++ b/src/core/lombok/RequiredArgsConstructor.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* Generates a constructor with required arguments.
* Required arguments are final fields and fields with constraints such as {@code @NonNull}.
* <p>
- * Complete documentation is found at <a href="https://projectlombok.org/features/Constructor">the project lombok features page for &#64;Constructor</a>.
+ * Complete documentation is found at <a href="https://projectlombok.org/features/constructor">the project lombok features page for &#64;Constructor</a>.
* <p>
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
*
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index 312d34d3..5e68f619 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -140,7 +140,7 @@ public class HandlerUtil {
"androidx.annotation.RecentlyNullable",
"com.android.annotations.NonNull",
"com.android.annotations.Nullable",
- // "com.google.api.server.spi.config.Nullable", - let's think about this one a litte, as it is targeted solely at parameters, so you can't even put it on fields. If we choose to support it, we should REMOVE it from the field, then - that's not something we currently support.
+ // "com.google.api.server.spi.config.Nullable", - let's think about this one a little, as it is targeted solely at parameters, so you can't even put it on fields. If we choose to support it, we should REMOVE it from the field, then - that's not something we currently support.
"com.google.firebase.database.annotations.NotNull",
"com.google.firebase.database.annotations.Nullable",
"com.mongodb.lang.NonNull",
@@ -197,7 +197,7 @@ public class HandlerUtil {
// Checker Framework annotations.
// To update Checker Framework annotations, run:
// grep --recursive --files-with-matches -e '^@Target\b.*TYPE_USE' $CHECKERFRAMEWORK/checker/src/main/java $CHECKERFRAMEWORK/checker-qual/src/main/java $CHECKERFRAMEWORK/checker-util/src/main/java $CHECKERFRAMEWORK/framework/src/main/java | grep '\.java$' | sed 's/.*\/java\//\t\t\t"/' | sed 's/\.java$/",/' | sed 's/\//./g' | sort
- // Only add new annotations, do not remove annotations that have been removed from the lastest version of the Checker Framework.
+ // Only add new annotations, do not remove annotations that have been removed from the latest version of the Checker Framework.
"org.checkerframework.checker.builder.qual.CalledMethods",
"org.checkerframework.checker.builder.qual.NotCalledMethods",
"org.checkerframework.checker.calledmethods.qual.CalledMethods",
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index d5ecfeaf..57c3afde 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -997,7 +997,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
if (field == null) {
- FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0);
+ FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
diff --git a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
index 5857780c..b84018c6 100644
--- a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
@@ -50,10 +50,10 @@ public class HandleExtensionMethod extends EclipseAnnotationHandler<ExtensionMet
int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
boolean notAClass = (modifiers &
- (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
+ (ClassFileConstants.AccAnnotation)) != 0;
if (typeDecl == null || notAClass) {
- annotationNode.addError("@ExtensionMethod is legal only on classes and enums.");
+ annotationNode.addError("@ExtensionMethod is legal only on classes and enums and interfaces.");
return;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
index 3297ba06..fd36454d 100644
--- a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
+++ b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
@@ -160,7 +160,7 @@ public class HandleFieldDefaults extends EclipseASTAdapter {
boolean defaultToFinal = makeFinalIsExplicit ? false : Boolean.TRUE.equals(typeNode.getAst().readConfiguration(ConfigurationKeys.FIELD_DEFAULTS_FINAL_EVERYWHERE));
if (!defaultToPrivate && !defaultToFinal && fieldDefaults == null) return;
- // Do not apply field defaults to records if set using the the config system
+ // Do not apply field defaults to records if set using the config system
if (fieldDefaults == null && !isClassOrEnum(typeNode)) return;
AccessLevel fdAccessLevel = (fieldDefaults != null && levelIsExplicit) ? fd.level() : defaultToPrivate ? AccessLevel.PRIVATE : null;
boolean fdToFinal = (fieldDefaults != null && makeFinalIsExplicit) ? fd.makeFinal() : defaultToFinal;
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 558c6ec2..e91478e0 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -51,7 +51,6 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.IfStatement;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
@@ -387,16 +386,16 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
injectMethod(job.builderType, generateStaticFillValuesMethod(job, annInstance.setterPrefix()));
}
- // Generate abstract self() and build() methods in the abstract builder.
- injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName));
- job.setBuilderToAbstract();
- injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName));
-
// Create the setter methods in the abstract builder.
for (BuilderFieldData bfd : job.builderFields) {
generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix());
}
+ // Generate abstract self() and build() methods in the abstract builder.
+ injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName));
+ job.setBuilderToAbstract();
+ injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName));
+
// Create the toString() method for the abstract builder.
if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) {
List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>();
@@ -948,7 +947,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
if (field == null) {
- FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0);
+ FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
@@ -1100,14 +1099,29 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if (td.fields != null) {
for (FieldDeclaration field : td.fields) {
if (field instanceof Initializer) continue;
- char[][] typeName = field.type.getTypeName();
- if (typeName.length >= 1) // Add the first token, because only that can collide.
- usedNames.add(String.valueOf(typeName[0]));
+ addFirstToken(usedNames, field.type);
+ }
+ }
+
+ // 4. Add extends and implements clauses.
+ addFirstToken(usedNames, td.superclass);
+ if (td.superInterfaces != null) {
+ for (TypeReference typeReference : td.superInterfaces) {
+ addFirstToken(usedNames, typeReference);
}
}
return usedNames;
}
+
+ private void addFirstToken(java.util.Set<String> usedNames, TypeReference type) {
+ if (type == null)
+ return;
+ // Add the first token, because only that can collide.
+ char[][] typeName = type.getTypeName();
+ if (typeName != null && typeName.length >= 1)
+ usedNames.add(String.valueOf(typeName[0]));
+ }
private String generateNonclashingNameFor(String classGenericName, java.util.Set<String> typeParamStrings) {
if (!typeParamStrings.contains(classGenericName)) return classGenericName;
diff --git a/src/core/lombok/experimental/SuperBuilder.java b/src/core/lombok/experimental/SuperBuilder.java
index 0733a616..193bda0f 100644
--- a/src/core/lombok/experimental/SuperBuilder.java
+++ b/src/core/lombok/experimental/SuperBuilder.java
@@ -69,7 +69,7 @@ public @interface SuperBuilder {
* For example, a method normally generated as {@code someField(String someField)} would instead be
* generated as {@code withSomeField(String someField)} if using {@code @SuperBuilder(setterPrefix = "with")}.
*
- * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally
+ * Note that using "with" to prefix builder setter methods is strongly discouraged as "with" normally
* suggests immutable data structures, and builders by definition are mutable objects.
*
* For {@code @Singular} fields, the generated methods are called {@code withName}, {@code withNames}, and {@code clearNames}, instead of
diff --git a/src/core/lombok/extern/jackson/Jacksonized.java b/src/core/lombok/extern/jackson/Jacksonized.java
index cf6678da..801ddbcb 100644
--- a/src/core/lombok/extern/jackson/Jacksonized.java
+++ b/src/core/lombok/extern/jackson/Jacksonized.java
@@ -49,7 +49,7 @@ import lombok.experimental.SuperBuilder;
* <li>Insert {@code @JsonPOJOBuilder(withPrefix="")} on the generated builder
* class to override Jackson's default prefix "with". If you configured a
* different prefix in lombok using {@code setterPrefix}, this value is used. If
- * you changed the name of the {@code build()} method using using
+ * you changed the name of the {@code build()} method using
* {@code buildMethodName}, this is also made known to Jackson.</li>
* <li>For {@code @SuperBuilder}, make the builder implementation class
* package-private.</li>
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index f1109f4e..6ff6efe7 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -244,8 +244,15 @@ public class JavacResolution {
}
private void attrib(JCTree tree, Env<AttrContext> env) {
- if (env.enclClass.type == null) try {
- env.enclClass.type = Type.noType;
+ try {
+ if (env.enclClass.type == null) {
+ if (env.enclClass.sym != null) {
+ env.enclClass.type = env.enclClass.sym.type;
+ }
+ }
+ if (env.enclClass.type == null) {
+ env.enclClass.type = Type.noType;
+ }
} catch (Throwable ignore) {
// This addresses issue #1553 which involves JDK9; if it doesn't exist, we probably don't need to set it.
}
diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
index dd565f72..af03d000 100644
--- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
@@ -73,10 +73,10 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
deleteAnnotationIfNeccessary(annotationNode, ExtensionMethod.class);
JavacNode typeNode = annotationNode.up();
- boolean isClassOrEnum = isClassOrEnum(typeNode);
+ boolean isClassOrEnumOrInterface = isClassOrEnumOrInterface(typeNode);
- if (!isClassOrEnum) {
- annotationNode.addError("@ExtensionMethod can only be used on a class or an enum");
+ if (!isClassOrEnumOrInterface) {
+ annotationNode.addError("@ExtensionMethod can only be used on a class or an enum or an interface");
return;
}
@@ -117,7 +117,8 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) {
if (member.getKind() != ElementKind.METHOD) continue;
MethodSymbol method = (MethodSymbol) member;
- if ((method.flags() & (STATIC | PUBLIC)) == 0) continue;
+ if ((method.flags() & STATIC) == 0) continue;
+ if ((method.flags() & PUBLIC) == 0) continue;
if (method.params().isEmpty()) continue;
extensionMethods.add(method);
}
diff --git a/src/core/lombok/javac/handlers/HandleFieldDefaults.java b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
index 9a6632dd..b373d1df 100644
--- a/src/core/lombok/javac/handlers/HandleFieldDefaults.java
+++ b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
@@ -140,7 +140,7 @@ public class HandleFieldDefaults extends JavacASTAdapter {
boolean defaultToFinal = makeFinalIsExplicit ? false : Boolean.TRUE.equals(typeNode.getAst().readConfiguration(ConfigurationKeys.FIELD_DEFAULTS_FINAL_EVERYWHERE));
if (!defaultToPrivate && !defaultToFinal && fieldDefaults == null) return;
- // Do not apply field defaults to records if set using the the config system
+ // Do not apply field defaults to records if set using the config system
if (fieldDefaults == null && !isClassOrEnum(typeNode)) return;
AccessLevel fdAccessLevel = (fieldDefaults != null && levelIsExplicit) ? fd.level() : defaultToPrivate ? AccessLevel.PRIVATE : null;
boolean fdToFinal = (fieldDefaults != null && makeFinalIsExplicit) ? fd.makeFinal() : defaultToFinal;
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 7418ac87..913f838c 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -336,6 +336,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
injectMethod(job.builderType, sfvm);
}
+ // Create the setter methods in the abstract builder.
+ for (BuilderFieldData bfd : job.builderFields) {
+ generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix());
+ }
+
// Generate abstract self() and build() methods in the abstract builder.
JCMethodDecl asm = generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName);
recursiveSetGeneratedBy(asm, annotationNode);
@@ -344,11 +349,6 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
recursiveSetGeneratedBy(abm, annotationNode);
injectMethod(job.builderType, abm);
- // Create the setter methods in the abstract builder.
- for (BuilderFieldData bfd : job.builderFields) {
- generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix());
- }
-
// Create the toString() method for the abstract builder.
java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>();
for (BuilderFieldData bfd : job.builderFields) {
@@ -1051,9 +1051,28 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
}
+ // 4. Add extends and implements clauses.
+ addFirstToken(usedNames, Javac.getExtendsClause(td));
+ for (JCExpression impl : td.getImplementsClause()) {
+ addFirstToken(usedNames, impl);
+ }
+
return usedNames;
}
+ private void addFirstToken(java.util.Set<String> usedNames, JCTree type) {
+ if (type == null)
+ return;
+ if (type instanceof JCTypeApply) {
+ type = ((JCTypeApply)type).clazz;
+ }
+ while (type instanceof JCFieldAccess && ((JCFieldAccess)type).selected != null) {
+ // Add the first token, because only that can collide.
+ type = ((JCFieldAccess)type).selected;
+ }
+ usedNames.add(type.toString());
+ }
+
private String generateNonclashingNameFor(String classGenericName, java.util.HashSet<String> typeParamStrings) {
if (!typeParamStrings.contains(classGenericName)) return classGenericName;
int counter = 2;
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index b17e34d8..9d153a72 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -2069,6 +2069,10 @@ public class JavacHandlerUtil {
return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | RECORD);
}
+ public static boolean isClassOrEnumOrInterface(JavacNode typeNode) {
+ return isClassAndDoesNotHaveFlags(typeNode, Flags.ANNOTATION | RECORD);
+ }
+
/**
* Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
*/
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index 605b9391..13836d77 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -1448,6 +1448,31 @@ public class PrettyPrinter extends JCTree.Visitor {
print(")");
}
+ void printConstantCaseLabel(JCTree tree) {
+ print((JCTree) readObject(tree, "expr", null));
+ }
+
+ void printPatternCaseLabel(JCTree tree) {
+ print((JCTree) readObject(tree, "pat", null));
+ JCTree guard = readObject(tree, "guard", null);
+ if (guard != null) {
+ print(" when ");
+ print(guard);
+ }
+ }
+
+ 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());
@@ -1672,6 +1697,12 @@ 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 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/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index d893b724..c0bfbe09 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -109,6 +109,8 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
patchRenameField(sm);
patchNullCheck(sm);
+ patchForTests(sm);
+
if (reloadExistingClasses) sm.reloadClasses(instrumentation);
}
@@ -1007,5 +1009,13 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.transplant()
.build());
}
+
+ private static void patchForTests(ScriptManager sm) {
+ sm.addScriptIfWitness(new String[] {"lombok/eclipse/EclipseTests"}, ScriptBuilder.wrapReturnValue()
+ .target(new MethodTarget("org.osgi.framework.FrameworkUtil", "getBundle", "org.osgi.framework.Bundle", "java.lang.Class"))
+ .request(StackRequest.RETURN_VALUE, StackRequest.PARAM1)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "getBundle", "java.lang.Object", "java.lang.Object", "java.lang.Class"))
+ .build());
+ }
}
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index a844239f..c7bdbc31 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -27,6 +27,7 @@ import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.CodeSource;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
@@ -854,4 +855,28 @@ final class PatchFixesHider {
return isGenerated(adjustment.getMember());
}
}
+
+ public static class Tests {
+ public static Object getBundle(Object original, Class<?> c) {
+ if (original != null) {
+ return original;
+ }
+
+ CodeSource codeSource = c.getProtectionDomain().getCodeSource();
+ if (codeSource == null) {
+ return null;
+ }
+
+ String jar = codeSource.getLocation().getFile();
+ String bundleName = jar.substring(jar.lastIndexOf("/") + 1, jar.indexOf("_"));
+
+ org.osgi.framework.Bundle[] bundles = org.eclipse.core.runtime.adaptor.EclipseStarter.getSystemBundleContext().getBundles();
+ for (org.osgi.framework.Bundle bundle : bundles) {
+ if (bundleName.equals(bundle.getSymbolicName())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+ }
}
diff --git a/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java b/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java
new file mode 100644
index 00000000..06e26bb6
--- /dev/null
+++ b/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java
@@ -0,0 +1,131 @@
+package lombok.eclipse.dependencies;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Download eclipse bundles.
+ */
+public class DownloadEclipseDependencies {
+
+ public static void main(String[] args) throws IOException {
+ String target = args[0];
+ String eclipseVersion = args[1];
+ String updatePage = args[2];
+ String[] packages = Arrays.copyOfRange(args, 3, args.length);
+
+ String pluginTarget = target + "/" + eclipseVersion + "/plugins/";
+
+ String indexData = readUrlAsString(updatePage);
+
+ for (String pkg : packages) {
+ Matcher matcher = Pattern.compile("(" + pkg.replace(".", "\\.") + "_.*?\\.jar)").matcher(indexData);
+ if (matcher.find()) {
+ String path = matcher.group(1);
+
+ try {
+ downloadFile(path, updatePage, pluginTarget);
+ } catch (Exception e) {
+ }
+ try {
+ int index = path.lastIndexOf("_");
+ String source = path.substring(0, index) + ".source" + path.substring(index);
+ downloadFile(source, updatePage, pluginTarget);
+ } catch (Exception e) {
+ }
+ } else {
+ System.out.println("Bundle \"" + pkg + "\" not found");
+ }
+ }
+
+ writeEclipseLibrary(target, eclipseVersion);
+ }
+
+ private static String readUrlAsString(String url) throws MalformedURLException, IOException {
+ InputStream in = getStreamForUrl(url);
+
+ StringBuilder sb = new StringBuilder();
+
+ int bufferSize = 1024;
+ char[] buffer = new char[bufferSize];
+ InputStreamReader reader = new InputStreamReader(in, "UTF-8");
+ for (int count = 0; (count = reader.read(buffer, 0, bufferSize)) > 0;) {
+ sb.append(buffer, 0, count);
+ }
+ return sb.toString();
+ }
+
+ private static void downloadFile(String filename, String repositoryUrl, String target) throws IOException {
+ Files.createDirectories(Paths.get(target));
+ Path targetFile = Paths.get(target, filename);
+ if (Files.exists(targetFile)) {
+ System.out.println("File '" + filename + "' already exists");
+ return;
+ }
+ System.out.print("Downloading '" + filename + "'... ");
+ try {
+ Files.copy(getStreamForUrl(repositoryUrl + filename), targetFile, StandardCopyOption.REPLACE_EXISTING);
+ System.out.println("[done]");
+ } catch(IOException e) {
+ System.out.println("[error]");
+ }
+ }
+
+ private static InputStream getStreamForUrl(String url) throws IOException, MalformedURLException {
+ HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+ connection.setRequestProperty("User-Agent", "lombok");
+ connection.setRequestProperty("Accept", "*/*");
+ InputStream in = new BufferedInputStream(connection.getInputStream());
+ return in;
+ }
+
+ private static void writeEclipseLibrary(String target, String eclipseVersion) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
+ sb.append("<eclipse-userlibraries version=\"2\">\n");
+ sb.append("<library name=\"");
+ sb.append(eclipseVersion);
+ sb.append("\" systemlibrary=\"false\">\n");
+
+ File[] files = new File(new File(target, eclipseVersion), "plugins").listFiles(new FilenameFilter() {
+ @Override public boolean accept(File dir, String name) {
+ return name.endsWith(".jar") && !name.contains(".source_");
+ }
+ });
+ Arrays.sort(files);
+
+ for (File file : files) {
+ sb.append("<archive path=\"");
+ sb.append(file.getAbsolutePath());
+ sb.append("\"");
+
+ String path = file.getAbsolutePath();
+ int index = path.lastIndexOf("_");
+
+ sb.append(" source=\"");
+ sb.append(path.substring(0, index) + ".source" + path.substring(index));
+ sb.append("\"");
+
+ sb.append(" />\n");
+ }
+
+ sb.append("</library>\n");
+ sb.append("</eclipse-userlibraries>\n");
+
+ Files.writeString(Paths.get(target, eclipseVersion + ".userlibraries"), sb.toString());
+ }
+}
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) {