diff options
6 files changed, 51 insertions, 17 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index 331fbde4..fe19decd 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -434,7 +434,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) { ConstructorDeclaration cd = HandleConstructor.createConstructor( - AccessLevel.PACKAGE, builderType, Collections.<EclipseNode>emptyList(), false, true, + AccessLevel.PACKAGE, builderType, Collections.<EclipseNode>emptyList(), false, annotationNode, Collections.<Annotation>emptyList()); if (cd != null) injectMethod(builderType, cd); } diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java index 3b7e95ca..04c3b2fe 100644 --- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java @@ -63,6 +63,7 @@ import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.ast.Wildcard; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; +import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; import org.eclipse.jdt.internal.compiler.lookup.MethodScope; import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; @@ -337,12 +338,6 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { return; } - // Create a simple constructor for the BuilderImpl class. - ConstructorDeclaration cd = HandleConstructor.createConstructor(AccessLevel.PRIVATE, builderImplType, Collections.<EclipseNode>emptyList(), false, annotationNode, Collections.<Annotation>emptyList()); - if (cd != null) { - injectMethod(builderImplType, cd); - } - // Create the self() and build() methods in the BuilderImpl. injectMethod(builderImplType, generateSelfMethod(builderImplType)); injectMethod(builderImplType, generateBuildMethod(tdParent, buildMethodName, returnType, ast)); @@ -383,6 +378,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { builder.superclass = copyType(superclassBuilderClass, source); + builder.createDefaultConstructor(false, true); + builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return injectType(tdParent, builder); } @@ -393,6 +390,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; builder.modifiers |= ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal; builder.name = builderImplClass.toCharArray(); + // Add type params if there are any. if (typeParams != null && typeParams.length > 0) { builder.typeParameters = copyTypeParams(typeParams, source); @@ -410,6 +408,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { typeArgs[typeArgs.length - 1] = createTypeReferenceWithTypeParameters(builderImplClass, typeParams); builder.superclass = new ParameterizedSingleTypeReference(builderAbstractClass.toCharArray(), typeArgs, 0, 0); } + + builder.createDefaultConstructor(false, true); + builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return injectType(tdParent, builder); } @@ -526,7 +527,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult); out.selector = SELF_METHOD.toCharArray(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; - out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected; + out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected | ExtraCompilerModifiers.AccSemicolonBody; if (override) { out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get())}; } @@ -550,7 +551,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; - out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; + out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody; out.selector = methodName.toCharArray(); out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; out.returnType = new SingleTypeReference(classGenericName.toCharArray(), 0); diff --git a/test/transform/resource/after-ecj/SuperBuilderBasic.java b/test/transform/resource/after-ecj/SuperBuilderBasic.java index 88ac7e70..11fd8498 100644 --- a/test/transform/resource/after-ecj/SuperBuilderBasic.java +++ b/test/transform/resource/after-ecj/SuperBuilderBasic.java @@ -4,6 +4,9 @@ public class SuperBuilderBasic { public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
private @java.lang.SuppressWarnings("all") int field1;
private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field1(final int field1) {
@@ -32,7 +35,7 @@ public class SuperBuilderBasic { }
}
private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends ParentBuilder<Parent, ParentBuilderImpl> {
- private @java.lang.SuppressWarnings("all") ParentBuilderImpl() {
+ private ParentBuilderImpl() {
super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ParentBuilderImpl self() {
@@ -67,6 +70,9 @@ public class SuperBuilderBasic { public static @lombok.experimental.SuperBuilder class Child extends Parent {
public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends Child, B extends ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field3(final double field3) {
@@ -78,7 +84,7 @@ public class SuperBuilderBasic { }
}
private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
- private @java.lang.SuppressWarnings("all") ChildBuilderImpl() {
+ private ChildBuilderImpl() {
super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ChildBuilderImpl self() {
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java index 119fb5bb..fe4938bf 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java @@ -4,6 +4,9 @@ public class SuperBuilderWithCustomBuilderMethod { public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends Parent<A>, B extends ParentBuilder<A, C, B>> {
private @java.lang.SuppressWarnings("all") A field1;
private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field1(final A field1) {
@@ -32,7 +35,8 @@ public class SuperBuilderWithCustomBuilderMethod { }
}
private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends ParentBuilder<A, Parent<A>, ParentBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ParentBuilderImpl() {
+ private ParentBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ParentBuilderImpl self() {
return this;
@@ -44,6 +48,7 @@ public class SuperBuilderWithCustomBuilderMethod { A field1;
@lombok.Singular List<String> items;
protected @java.lang.SuppressWarnings("all") Parent(final ParentBuilder<A, ?, ?> b) {
+ super();
this.field1 = b.field1;
java.util.List<String> items;
switch (((b.items == null) ? 0 : b.items.size())) {
@@ -65,6 +70,9 @@ public class SuperBuilderWithCustomBuilderMethod { public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends Child<A>, B extends ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field3(final double field3) {
@@ -76,7 +84,8 @@ public class SuperBuilderWithCustomBuilderMethod { }
}
private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends ChildBuilder<A, Child<A>, ChildBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ChildBuilderImpl() {
+ private ChildBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ChildBuilderImpl self() {
return this;
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java index cb717bcf..b82f25cb 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java @@ -4,6 +4,9 @@ public class SuperBuilderWithGenerics { public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends Parent<A>, B extends ParentBuilder<A, C, B>> {
private @java.lang.SuppressWarnings("all") A field1;
private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field1(final A field1) {
@@ -32,7 +35,8 @@ public class SuperBuilderWithGenerics { }
}
private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends ParentBuilder<A, Parent<A>, ParentBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ParentBuilderImpl() {
+ private ParentBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ParentBuilderImpl self() {
return this;
@@ -44,6 +48,7 @@ public class SuperBuilderWithGenerics { A field1;
@lombok.Singular List<String> items;
protected @java.lang.SuppressWarnings("all") Parent(final ParentBuilder<A, ?, ?> b) {
+ super();
this.field1 = b.field1;
java.util.List<String> items;
switch (((b.items == null) ? 0 : b.items.size())) {
@@ -65,6 +70,9 @@ public class SuperBuilderWithGenerics { public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends Child<A>, B extends ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field3(final double field3) {
@@ -76,7 +84,8 @@ public class SuperBuilderWithGenerics { }
}
private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends ChildBuilder<A, Child<A>, ChildBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ChildBuilderImpl() {
+ private ChildBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ChildBuilderImpl self() {
return this;
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java index 74cf376e..7db95ea0 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java @@ -4,6 +4,9 @@ public class SuperBuilderWithGenerics2 { public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends Parent<A>, B extends ParentBuilder<A, C, B>> {
private @java.lang.SuppressWarnings("all") A field1;
private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field1(final A field1) {
@@ -32,7 +35,8 @@ public class SuperBuilderWithGenerics2 { }
}
private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends ParentBuilder<A, Parent<A>, ParentBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ParentBuilderImpl() {
+ private ParentBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ParentBuilderImpl self() {
return this;
@@ -44,6 +48,7 @@ public class SuperBuilderWithGenerics2 { A field1;
@lombok.Singular List<String> items;
protected @java.lang.SuppressWarnings("all") Parent(final ParentBuilder<A, ?, ?> b) {
+ super();
this.field1 = b.field1;
java.util.List<String> items;
switch (((b.items == null) ? 0 : b.items.size())) {
@@ -65,6 +70,9 @@ public class SuperBuilderWithGenerics2 { public static @lombok.experimental.SuperBuilder(builderMethodName = "builder2") class Child<A> extends Parent<String> {
public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends Child<A>, B extends ChildBuilder<A, C, B>> extends Parent.ParentBuilder<String, C, B> {
private @java.lang.SuppressWarnings("all") A field3;
+ public ChildBuilder() {
+ super();
+ }
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
public @java.lang.SuppressWarnings("all") B field3(final A field3) {
@@ -76,7 +84,8 @@ public class SuperBuilderWithGenerics2 { }
}
private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends ChildBuilder<A, Child<A>, ChildBuilderImpl<A>> {
- private @java.lang.SuppressWarnings("all") ChildBuilderImpl() {
+ private ChildBuilderImpl() {
+ super();
}
protected @java.lang.Override @java.lang.SuppressWarnings("all") ChildBuilderImpl self() {
return this;
|