aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java2
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderInitializer.java74
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderInitializer.java54
-rw-r--r--test/transform/resource/before/SuperBuilderInitializer.java16
4 files changed, 146 insertions, 0 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index e08fc334..d9c8946f 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -50,6 +50,7 @@ import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
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.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
@@ -1102,6 +1103,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// 3. Add used type names.
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]));
diff --git a/test/transform/resource/after-delombok/SuperBuilderInitializer.java b/test/transform/resource/after-delombok/SuperBuilderInitializer.java
new file mode 100644
index 00000000..95943aa9
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderInitializer.java
@@ -0,0 +1,74 @@
+class SuperBuilderInitializer {
+
+ public static class One {
+ private String world;
+
+ {
+ world = "Hello";
+ }
+
+ private static final String world2;
+
+ static {
+ world2 = "Hello";
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ public static abstract class OneBuilder<C extends SuperBuilderInitializer.One, B extends SuperBuilderInitializer.One.OneBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private String world;
+
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B world(final String world) {
+ this.world = world;
+ return self();
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderInitializer.One.OneBuilder(world=" + this.world + ")";
+ }
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ private static final class OneBuilderImpl extends SuperBuilderInitializer.One.OneBuilder<SuperBuilderInitializer.One, SuperBuilderInitializer.One.OneBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private OneBuilderImpl() {
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderInitializer.One.OneBuilderImpl self() {
+ return this;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderInitializer.One build() {
+ return new SuperBuilderInitializer.One(this);
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected One(final SuperBuilderInitializer.One.OneBuilder<?, ?> b) {
+ this.world = b.world;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderInitializer.One.OneBuilder<?, ?> builder() {
+ return new SuperBuilderInitializer.One.OneBuilderImpl();
+ }
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderInitializer.java b/test/transform/resource/after-ecj/SuperBuilderInitializer.java
new file mode 100644
index 00000000..0425fb89
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderInitializer.java
@@ -0,0 +1,54 @@
+import lombok.experimental.SuperBuilder;
+class SuperBuilderInitializer {
+ public static @SuperBuilder class One {
+ public static abstract @java.lang.SuppressWarnings("all") class OneBuilder<C extends SuperBuilderInitializer.One, B extends SuperBuilderInitializer.One.OneBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") String world;
+ public OneBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B world(final String world) {
+ this.world = world;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderInitializer.One.OneBuilder(world=" + this.world) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class OneBuilderImpl extends SuperBuilderInitializer.One.OneBuilder<SuperBuilderInitializer.One, SuperBuilderInitializer.One.OneBuilderImpl> {
+ private OneBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One.OneBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One build() {
+ return new SuperBuilderInitializer.One(this);
+ }
+ }
+ private String world;
+ {
+ world = "Hello";
+ }
+ private static final String world2;
+ static {
+ world2 = "Hello";
+ }
+ <clinit>() {
+ }
+ protected @java.lang.SuppressWarnings("all") One(final SuperBuilderInitializer.One.OneBuilder<?, ?> b) {
+ super();
+ this.world = b.world;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One.OneBuilder<?, ?> builder() {
+ return new SuperBuilderInitializer.One.OneBuilderImpl();
+ }
+ }
+ SuperBuilderInitializer() {
+ super();
+ }
+}
diff --git a/test/transform/resource/before/SuperBuilderInitializer.java b/test/transform/resource/before/SuperBuilderInitializer.java
new file mode 100644
index 00000000..966a4daf
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderInitializer.java
@@ -0,0 +1,16 @@
+import lombok.experimental.SuperBuilder;
+
+class SuperBuilderInitializer {
+ @SuperBuilder
+ public static class One {
+ private String world;
+ {
+ world = "Hello";
+ }
+
+ private static final String world2;
+ static {
+ world2 = "Hello";
+ }
+ }
+}