дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
fix(java): support Lombok builders on compact record constructors (#950)
@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 <[email protected]>
Цей коміт міститься в:
1 джерело
37f0897eb7
коміт
ba8d224a46
11 files changed
+261
-24
No files matched your search
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
|
||||
Reference in new issue
Заблокувати користувача