mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 16:08:05 +00:00
@Builder on a compact record constructor (record R(...) { @Builder R {} }) failed in the
editor: ECJ has not filled in a compact constructor's implicit parameters when Lombok
runs, so the builder got no fields and builder() was undefined. A patch to Lombok's
Eclipse HandleBuilder takes the parameters from the record components in that case.
The bundled agent is now lombok-1.18.48-openidea.3, built from v1.18.48 with #4059,
#4089 and java/lombok/patches/builder-compact-constructor.patch through the documented
Ant build; only HandleBuilder differs from openidea.2. The new agent path gives JDT LS a
fresh workspace. java/lombok/tests/verify.py compiles and runs the regression cases with
javac and with ECJ plus the agent.
Co-authored-by: egasa21 <44431625+egasa21@users.noreply.github.com>
22 lines
1.3 KiB
Diff
22 lines
1.3 KiB
Diff
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
|
|
index 64a3fa9..6ebaaaf 100755
|
|
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
|
|
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
|
|
@@ -493,10 +493,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
|
if (!checkBuilderClassNameAnnotationConflict("Builder", "lombok.Builder", job.builderClassName, ast, annotationNode)) return;
|
|
|
|
if (fillParametersFrom != null) {
|
|
- for (EclipseNode param : fillParametersFrom.down()) {
|
|
- if (param.getKind() != Kind.ARGUMENT) continue;
|
|
+ // ECJ has not populated the implicit arguments of a compact record constructor yet.
|
|
+ boolean compactConstructor = parent.get() instanceof ConstructorDeclaration
|
|
+ && isRecord(job.parentType) && (parent.get().bits & IsCanonicalConstructor) != 0;
|
|
+ for (EclipseNode param : (compactConstructor ? job.parentType : fillParametersFrom).down()) {
|
|
+ if (compactConstructor ? !isRecordField(param) : param.getKind() != Kind.ARGUMENT) continue;
|
|
BuilderFieldData bfd = new BuilderFieldData();
|
|
- Argument arg = (Argument) param.get();
|
|
+ AbstractVariableDeclaration arg = (AbstractVariableDeclaration) param.get();
|
|
|
|
Annotation[] copyableAnnotations = findCopyableAnnotations(param);
|
|
|