From 15df143df6d35dd64459d717a451a039eb26d761 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 13 Aug 2019 15:04:43 +0200 Subject: [checkerframework] A bit of a shadow feature because the checker framework folks need to do some work on their side. this update makes lombok generate a few checker framework annotations (if configured to do so) which let the checker framework add warnings and errors for example if you misuse builders, or ignore the return values of withers, etc. --- .../after-delombok/CheckerFrameworkBasic.java | 72 ++++++++ .../after-delombok/CheckerFrameworkBuilder.java | 106 +++++++++++ .../CheckerFrameworkSuperBuilder.java | 202 +++++++++++++++++++++ .../resource/after-ecj/CheckerFrameworkBasic.java | 59 ++++++ .../after-ecj/CheckerFrameworkBuilder.java | 79 ++++++++ .../after-ecj/CheckerFrameworkSuperBuilder.java | 142 +++++++++++++++ .../resource/before/CheckerFrameworkBasic.java | 11 ++ .../resource/before/CheckerFrameworkBuilder.java | 12 ++ .../before/CheckerFrameworkSuperBuilder.java | 19 ++ .../CheckerFrameworkBasic.java.messages | 4 + .../CheckerFrameworkBuilder.java.messages | 1 + .../CheckerFrameworkSuperBuilder.java.messages | 3 + .../CheckerFrameworkBasic.java.messages | 1 + .../CheckerFrameworkBuilder.java.messages | 1 + .../CheckerFrameworkSuperBuilder.java.messages | 1 + .../CheckerFrameworkBasic.java.messages | 10 + 16 files changed, 723 insertions(+) create mode 100644 test/transform/resource/after-delombok/CheckerFrameworkBasic.java create mode 100644 test/transform/resource/after-delombok/CheckerFrameworkBuilder.java create mode 100644 test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java create mode 100644 test/transform/resource/after-ecj/CheckerFrameworkBasic.java create mode 100644 test/transform/resource/after-ecj/CheckerFrameworkBuilder.java create mode 100644 test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java create mode 100644 test/transform/resource/before/CheckerFrameworkBasic.java create mode 100644 test/transform/resource/before/CheckerFrameworkBuilder.java create mode 100644 test/transform/resource/before/CheckerFrameworkSuperBuilder.java create mode 100644 test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages create mode 100644 test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages create mode 100644 test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages create mode 100644 test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages create mode 100644 test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages create mode 100644 test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages create mode 100644 test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages (limited to 'test/transform/resource') diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBasic.java b/test/transform/resource/after-delombok/CheckerFrameworkBasic.java new file mode 100644 index 00000000..b9d4e0fa --- /dev/null +++ b/test/transform/resource/after-delombok/CheckerFrameworkBasic.java @@ -0,0 +1,72 @@ +class CheckerFrameworkBasic { + private final int x; + private final int y; + private int z; + @org.checkerframework.common.aliasing.qual.Unique + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBasic(final int x, final int y) { + this.x = x; + this.y = y; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public int getX() { + return this.x; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public int getY() { + return this.y; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public int getZ() { + return this.z; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBasic setZ(final int z) { + this.z = z; + return this; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof CheckerFrameworkBasic)) return false; + final CheckerFrameworkBasic other = (CheckerFrameworkBasic) o; + if (!other.canEqual((java.lang.Object) this)) return false; + if (this.getX() != other.getX()) return false; + if (this.getY() != other.getY()) return false; + if (this.getZ() != other.getZ()) return false; + return true; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected boolean canEqual(final java.lang.Object other) { + return other instanceof CheckerFrameworkBasic; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getX(); + result = result * PRIME + this.getY(); + result = result * PRIME + this.getZ(); + return result; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "CheckerFrameworkBasic(x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + ")"; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBasic withX(final int x) { + return this.x == x ? this : new CheckerFrameworkBasic(x, this.y, this.z); + } +} diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java new file mode 100644 index 00000000..d21ad044 --- /dev/null +++ b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java @@ -0,0 +1,106 @@ +// skip-idempotent +import java.util.List; +class CheckerFrameworkBuilder { + int x; + int y; + int z; + List names; + @java.lang.SuppressWarnings("all") + private static int $default$x() { + return 5; + } + @org.checkerframework.common.aliasing.qual.Unique + @java.lang.SuppressWarnings("all") + CheckerFrameworkBuilder(final int x, final int y, final int z, final List names) { + this.x = x; + this.y = y; + this.z = z; + this.names = names; + } + @java.lang.SuppressWarnings("all") + public static class CheckerFrameworkBuilderBuilder { + @java.lang.SuppressWarnings("all") + private boolean x$set; + @java.lang.SuppressWarnings("all") + private int x$value; + @java.lang.SuppressWarnings("all") + private int y; + @java.lang.SuppressWarnings("all") + private int z; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList names; + @org.checkerframework.common.aliasing.qual.Unique + @java.lang.SuppressWarnings("all") + CheckerFrameworkBuilderBuilder() { + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder x(@org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkBuilderBuilder this, final int x) { + this.x$value = x; + x$set = true; + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder y(@org.checkerframework.checker.builder.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) { + this.y = y; + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder z(@org.checkerframework.checker.builder.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) { + this.z = z; + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder name(final String name) { + if (this.names == null) this.names = new java.util.ArrayList(); + this.names.add(name); + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder names(final java.util.Collection names) { + if (this.names == null) this.names = new java.util.ArrayList(); + this.names.addAll(names); + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder clearNames() { + if (this.names != null) this.names.clear(); + return this; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilder build(@org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) CheckerFrameworkBuilderBuilder this) { + java.util.List names; + switch (this.names == null ? 0 : this.names.size()) { + case 0: + names = java.util.Collections.emptyList(); + break; + case 1: + names = java.util.Collections.singletonList(this.names.get(0)); + break; + default: + names = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.names)); + } + int x$value = this.x$value; + if (!x$set) x$value = CheckerFrameworkBuilder.$default$x(); + return new CheckerFrameworkBuilder(x$value, y, z, names); + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder(x$value=" + this.x$value + ", y=" + this.y + ", z=" + this.z + ", names=" + this.names + ")"; + } + } + @org.checkerframework.common.aliasing.qual.Unique + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public static CheckerFrameworkBuilderBuilder builder() { + return new CheckerFrameworkBuilderBuilder(); + } +} diff --git a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java new file mode 100644 index 00000000..40876369 --- /dev/null +++ b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java @@ -0,0 +1,202 @@ +// skip-idempotent +import java.util.List; +class CheckerFrameworkSuperBuilder { + public static class Parent { + int x; + int y; + int z; + List names; + @java.lang.SuppressWarnings("all") + private static int $default$x() { + return 5; + } + @java.lang.SuppressWarnings("all") + public static abstract class ParentBuilder> { + @java.lang.SuppressWarnings("all") + private boolean x$set; + @java.lang.SuppressWarnings("all") + private int x$value; + @java.lang.SuppressWarnings("all") + private int y; + @java.lang.SuppressWarnings("all") + private int z; + @java.lang.SuppressWarnings("all") + private java.util.ArrayList names; + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected abstract B self(); + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public abstract C build(@org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) Parent this); + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B x(@org.checkerframework.checker.builder.qual.NotCalledMethods("x") ParentBuilder this, final int x) { + this.x$value = x; + x$set = true; + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B y(@org.checkerframework.checker.builder.qual.NotCalledMethods("y") ParentBuilder this, final int y) { + this.y = y; + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B z(@org.checkerframework.checker.builder.qual.NotCalledMethods("z") ParentBuilder this, final int z) { + this.z = z; + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B name(final String name) { + if (this.names == null) this.names = new java.util.ArrayList(); + this.names.add(name); + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B names(final java.util.Collection names) { + if (this.names == null) this.names = new java.util.ArrayList(); + this.names.addAll(names); + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B clearNames() { + if (this.names != null) this.names.clear(); + return self(); + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "CheckerFrameworkSuperBuilder.Parent.ParentBuilder(x$value=" + this.x$value + ", y=" + this.y + ", z=" + this.z + ", names=" + this.names + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class ParentBuilderImpl extends ParentBuilder { + @org.checkerframework.common.aliasing.qual.Unique + @java.lang.SuppressWarnings("all") + private ParentBuilderImpl() { + } + @java.lang.Override + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected ParentBuilderImpl self() { + return this; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public Parent build(@org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) ParentBuilderImpl this) { + return new Parent(this); + } + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected Parent(final ParentBuilder b) { + if (b.x$set) this.x = b.x$value; + else this.x = Parent.$default$x(); + this.y = b.y; + this.z = b.z; + java.util.List names; + switch (b.names == null ? 0 : b.names.size()) { + case 0: + names = java.util.Collections.emptyList(); + break; + case 1: + names = java.util.Collections.singletonList(b.names.get(0)); + break; + default: + names = java.util.Collections.unmodifiableList(new java.util.ArrayList(b.names)); + } + this.names = names; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public static ParentBuilder builder() { + return new ParentBuilderImpl(); + } + } + public static class Child extends Parent { + int a; + int b; + @java.lang.SuppressWarnings("all") + private static int $default$a() { + return 1; + } + @java.lang.SuppressWarnings("all") + public static abstract class ChildBuilder> extends Parent.ParentBuilder { + @java.lang.SuppressWarnings("all") + private boolean a$set; + @java.lang.SuppressWarnings("all") + private int a$value; + @java.lang.SuppressWarnings("all") + private int b; + @java.lang.Override + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected abstract B self(); + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public abstract C build(@org.checkerframework.checker.builder.qual.CalledMethods("b") Child this); + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B a(@org.checkerframework.checker.builder.qual.NotCalledMethods("a") ChildBuilder this, final int a) { + this.a$value = a; + a$set = true; + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B b(@org.checkerframework.checker.builder.qual.NotCalledMethods("b") ChildBuilder this, final int b) { + this.b = b; + return self(); + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "CheckerFrameworkSuperBuilder.Child.ChildBuilder(super=" + super.toString() + ", a$value=" + this.a$value + ", b=" + this.b + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class ChildBuilderImpl extends ChildBuilder { + @org.checkerframework.common.aliasing.qual.Unique + @java.lang.SuppressWarnings("all") + private ChildBuilderImpl() { + } + @java.lang.Override + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected ChildBuilderImpl self() { + return this; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public Child build(@org.checkerframework.checker.builder.qual.CalledMethods("b") ChildBuilderImpl this) { + return new Child(this); + } + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + protected Child(final ChildBuilder b) { + super(b); + if (b.a$set) this.a = b.a$value; + else this.a = Child.$default$a(); + this.b = b.b; + } + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public static ChildBuilder builder() { + return new ChildBuilderImpl(); + } + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java new file mode 100644 index 00000000..03313c6d --- /dev/null +++ b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java @@ -0,0 +1,59 @@ +import lombok.Data; +import lombok.experimental.Accessors; +import lombok.experimental.Wither; +@Data @Accessors(chain = true) class CheckerFrameworkBasic { + private final @Wither int x; + private final int y; + private int z; + public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBasic withX(final int x) { + return ((this.x == x) ? this : new CheckerFrameworkBasic(x, this.y, this.z)); + } + public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") int getX() { + return this.x; + } + public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") int getY() { + return this.y; + } + public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") int getZ() { + return this.z; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBasic setZ(final int z) { + this.z = z; + return this; + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof CheckerFrameworkBasic))) + return false; + final CheckerFrameworkBasic other = (CheckerFrameworkBasic) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((this.getX() != other.getX())) + return false; + if ((this.getY() != other.getY())) + return false; + if ((this.getZ() != other.getZ())) + return false; + return true; + } + protected @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + return (other instanceof CheckerFrameworkBasic); + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getX()); + result = ((result * PRIME) + this.getY()); + result = ((result * PRIME) + this.getZ()); + return result; + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("CheckerFrameworkBasic(x=" + this.getX()) + ", y=") + this.getY()) + ", z=") + this.getZ()) + ")"); + } + public @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkBasic(final int x, final int y) { + super(); + this.x = x; + this.y = y; + } +} diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java new file mode 100644 index 00000000..2baad9d9 --- /dev/null +++ b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java @@ -0,0 +1,79 @@ +import java.util.List; +import lombok.Builder; +import lombok.Singular; +@Builder class CheckerFrameworkBuilder { + public static @java.lang.SuppressWarnings("all") class CheckerFrameworkBuilderBuilder { + private @java.lang.SuppressWarnings("all") int x$value; + private @java.lang.SuppressWarnings("all") boolean x$set; + private @java.lang.SuppressWarnings("all") int y; + private @java.lang.SuppressWarnings("all") int z; + private @java.lang.SuppressWarnings("all") java.util.ArrayList names; + @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder() { + super(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder x(final @org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkBuilderBuilder this, final int x) { + this.x$value = x; + x$set = true; + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder y(final @org.checkerframework.checker.builder.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) { + this.y = y; + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder z(final @org.checkerframework.checker.builder.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) { + this.z = z; + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder name(final String name) { + if ((this.names == null)) + this.names = new java.util.ArrayList(); + this.names.add(name); + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder names(final java.util.Collection names) { + if ((this.names == null)) + this.names = new java.util.ArrayList(); + this.names.addAll(names); + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder clearNames() { + if ((this.names != null)) + this.names.clear(); + return this; + } + public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder build(final @org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) CheckerFrameworkBuilderBuilder this) { + java.util.List names; + switch (((this.names == null) ? 0 : this.names.size())) { + case 0 : + names = java.util.Collections.emptyList(); + break; + case 1 : + names = java.util.Collections.singletonList(this.names.get(0)); + break; + default : + names = java.util.Collections.unmodifiableList(new java.util.ArrayList(this.names)); + } + return new CheckerFrameworkBuilder((x$set ? x$value : CheckerFrameworkBuilder.$default$x()), y, z, names); + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder(x$value=" + this.x$value) + ", y=") + this.y) + ", z=") + this.z) + ", names=") + this.names) + ")"); + } + } + @Builder.Default int x; + int y; + int z; + @Singular List names; + private static @java.lang.SuppressWarnings("all") int $default$x() { + return 5; + } + @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder(final int x, final int y, final int z, final List names) { + super(); + this.x = x; + this.y = y; + this.z = z; + this.names = names; + } + public static @org.checkerframework.common.aliasing.qual.Unique @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder builder() { + return new CheckerFrameworkBuilderBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java new file mode 100644 index 00000000..3901bfce --- /dev/null +++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java @@ -0,0 +1,142 @@ +import java.util.List; +import lombok.Singular; +class CheckerFrameworkSuperBuilder { + public static @lombok.experimental.SuperBuilder class Parent { + public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder> { + private @java.lang.SuppressWarnings("all") int x$value; + private @java.lang.SuppressWarnings("all") boolean x$set; + private @java.lang.SuppressWarnings("all") int y; + private @java.lang.SuppressWarnings("all") int z; + private @java.lang.SuppressWarnings("all") java.util.ArrayList names; + public ParentBuilder() { + } + protected abstract @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") B self(); + public abstract @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) ParentBuilder this); + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B x(final @org.checkerframework.checker.builder.qual.NotCalledMethods("x") ParentBuilder this, final int x) { + this.x$value = x; + x$set = true; + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B y(final @org.checkerframework.checker.builder.qual.NotCalledMethods("y") ParentBuilder this, final int y) { + this.y = y; + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B z(final @org.checkerframework.checker.builder.qual.NotCalledMethods("z") ParentBuilder this, final int z) { + this.z = z; + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B name(final String name) { + if ((this.names == null)) + this.names = new java.util.ArrayList(); + this.names.add(name); + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B names(final java.util.Collection names) { + if ((this.names == null)) + this.names = new java.util.ArrayList(); + this.names.addAll(names); + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B clearNames() { + if ((this.names != null)) + this.names.clear(); + return self(); + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("CheckerFrameworkSuperBuilder.Parent.ParentBuilder(x$value=" + this.x$value) + ", y=") + this.y) + ", z=") + this.z) + ", names=") + this.names) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends ParentBuilder { + private ParentBuilderImpl() { + } + protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") ParentBuilderImpl self() { + return this; + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") Parent build(final @org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) ParentBuilderImpl this) { + return new Parent(this); + } + } + @lombok.Builder.Default int x; + int y; + int z; + @Singular List names; + private static @java.lang.SuppressWarnings("all") int $default$x() { + return 5; + } + protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") Parent(final ParentBuilder b) { + super(); + if (b.x$set) + this.x = b.x$value; + else + this.x = Parent.$default$x(); + this.y = b.y; + this.z = b.z; + java.util.List names; + switch (((b.names == null) ? 0 : b.names.size())) { + case 0 : + names = java.util.Collections.emptyList(); + break; + case 1 : + names = java.util.Collections.singletonList(b.names.get(0)); + break; + default : + names = java.util.Collections.unmodifiableList(new java.util.ArrayList(b.names)); + } + this.names = names; + } + public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") ParentBuilder builder() { + return new ParentBuilderImpl(); + } + } + public static @lombok.experimental.SuperBuilder class Child extends Parent { + public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder> extends Parent.ParentBuilder { + private @java.lang.SuppressWarnings("all") int a$value; + private @java.lang.SuppressWarnings("all") boolean a$set; + private @java.lang.SuppressWarnings("all") int b; + public ChildBuilder() { + } + protected abstract @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") B self(); + protected abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") ChildBuilder this); + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B a(final @org.checkerframework.checker.builder.qual.NotCalledMethods("a") ChildBuilder this, final int a) { + this.a$value = a; + a$set = true; + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B b(final @org.checkerframework.checker.builder.qual.NotCalledMethods("b") ChildBuilder this, final int b) { + this.b = b; + return self(); + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((("CheckerFrameworkSuperBuilder.Child.ChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends ChildBuilder { + private ChildBuilderImpl() { + } + protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") ChildBuilderImpl self() { + return this; + } + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") Child build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") ChildBuilderImpl this) { + return new Child(this); + } + } + @lombok.Builder.Default int a; + int b; + private static @java.lang.SuppressWarnings("all") int $default$a() { + return 1; + } + protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") Child(final ChildBuilder b) { + super(b); + if (b.a$set) + this.a = b.a$value; + else + this.a = Child.$default$a(); + this.b = b.b; + } + public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") ChildBuilder builder() { + return new ChildBuilderImpl(); + } + } + CheckerFrameworkSuperBuilder() { + } +} diff --git a/test/transform/resource/before/CheckerFrameworkBasic.java b/test/transform/resource/before/CheckerFrameworkBasic.java new file mode 100644 index 00000000..5b59165a --- /dev/null +++ b/test/transform/resource/before/CheckerFrameworkBasic.java @@ -0,0 +1,11 @@ +//CONF: checkerframework = 3.0 +import lombok.Data; +import lombok.experimental.Accessors; +import lombok.experimental.Wither; + +@Data @Accessors(chain = true) +class CheckerFrameworkBasic { + @Wither private final int x; + private final int y; + private int z; +} diff --git a/test/transform/resource/before/CheckerFrameworkBuilder.java b/test/transform/resource/before/CheckerFrameworkBuilder.java new file mode 100644 index 00000000..4b501ab8 --- /dev/null +++ b/test/transform/resource/before/CheckerFrameworkBuilder.java @@ -0,0 +1,12 @@ +//CONF: checkerframework = true +import java.util.List; +import lombok.Builder; +import lombok.Singular; + +@Builder +class CheckerFrameworkBuilder { + @Builder.Default int x = 5; + int y; + int z; + @Singular List names; +} diff --git a/test/transform/resource/before/CheckerFrameworkSuperBuilder.java b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java new file mode 100644 index 00000000..74d50ef1 --- /dev/null +++ b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java @@ -0,0 +1,19 @@ +//CONF: checkerframework = true +import java.util.List; +import lombok.Singular; + +class CheckerFrameworkSuperBuilder { + @lombok.experimental.SuperBuilder + public static class Parent { + @lombok.Builder.Default int x = 5; + int y; + int z; + @Singular List names; + } + + @lombok.experimental.SuperBuilder + public static class Child extends Parent { + @lombok.Builder.Default int a = 1; + int b; + } +} diff --git a/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages b/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages new file mode 100644 index 00000000..9ee959a4 --- /dev/null +++ b/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages @@ -0,0 +1,4 @@ +6 package org.checkerframework.common.aliasing.qual does not exist +8 package org.checkerframework.dataflow.qual does not exist +9 package org.checkerframework.dataflow.qual does not exist +10 package org.checkerframework.dataflow.qual does not exist diff --git a/test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages b/test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages new file mode 100644 index 00000000..8c736705 --- /dev/null +++ b/test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages @@ -0,0 +1 @@ +6 package org.checkerframework.common.aliasing.qual does not exist diff --git a/test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages b/test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages new file mode 100644 index 00000000..5dd6251a --- /dev/null +++ b/test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages @@ -0,0 +1,3 @@ +6 package org.checkerframework.dataflow.qual does not exist +-1 package org.checkerframework.checker.builder.qual does not exist +14 package org.checkerframework.dataflow.qual does not exist diff --git a/test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages b/test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages new file mode 100644 index 00000000..9bfcba0c --- /dev/null +++ b/test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages @@ -0,0 +1 @@ +8 org.checkerframework cannot be resolved to a type diff --git a/test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages b/test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages new file mode 100644 index 00000000..d385a95c --- /dev/null +++ b/test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages @@ -0,0 +1 @@ +6 org.checkerframework cannot be resolved to a type diff --git a/test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages b/test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages new file mode 100644 index 00000000..d385a95c --- /dev/null +++ b/test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages @@ -0,0 +1 @@ +6 org.checkerframework cannot be resolved to a type diff --git a/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages b/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages new file mode 100644 index 00000000..80694a06 --- /dev/null +++ b/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages @@ -0,0 +1,10 @@ +5 package org.checkerframework.common.aliasing.qual does not exist +11 package org.checkerframework.dataflow.qual does not exist +16 package org.checkerframework.dataflow.qual does not exist +21 package org.checkerframework.dataflow.qual does not exist +26 package org.checkerframework.checker.builder.qual does not exist +32 package org.checkerframework.dataflow.qual does not exist +45 package org.checkerframework.dataflow.qual does not exist +50 package org.checkerframework.dataflow.qual does not exist +61 package org.checkerframework.dataflow.qual does not exist +67 package org.checkerframework.dataflow.qual does not exist -- cgit From c11edbf032ce27e448faa00d37245665942095af Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 26 Aug 2019 21:41:10 +0200 Subject: [With] renaming lombok.experimental.Wither to lombok.experimental.With --- src/core/lombok/ConfigurationKeys.java | 12 +- src/core/lombok/With.java | 94 +++++++ src/core/lombok/core/LombokInternalAliasing.java | 3 +- src/core/lombok/core/handlers/HandlerUtil.java | 14 +- .../eclipse/handlers/EclipseHandlerUtil.java | 16 +- src/core/lombok/eclipse/handlers/HandleWith.java | 293 ++++++++++++++++++++ src/core/lombok/eclipse/handlers/HandleWither.java | 293 -------------------- src/core/lombok/experimental/Wither.java | 4 +- src/core/lombok/javac/handlers/HandleWith.java | 294 +++++++++++++++++++++ src/core/lombok/javac/handlers/HandleWither.java | 294 --------------------- .../lombok/javac/handlers/JavacHandlerUtil.java | 32 ++- .../after-delombok/SetterAndWithMethodJavadoc.java | 46 ++++ .../after-delombok/SetterAndWitherJavadoc.java | 46 ---- .../resource/after-delombok/WithAlreadyExists.java | 71 +++++ .../after-delombok/WithAndAllArgsConstructor.java | 22 ++ .../after-delombok/WithMethodAbstract.java | 5 + .../after-delombok/WithMethodMarkedDeprecated.java | 23 ++ .../resource/after-delombok/WithOnClass.java | 54 ++++ .../resource/after-delombok/WithOnStatic.java | 4 + .../resource/after-delombok/WithPlain.java | 16 ++ .../resource/after-delombok/WithWithDollar.java | 3 + .../resource/after-delombok/WithWithGenerics.java | 20 ++ .../resource/after-delombok/WithWithTypeAnnos.java | 21 ++ .../after-delombok/WitherAlreadyExists.java | 71 ----- .../WitherAndAllArgsConstructor.java | 22 -- .../resource/after-delombok/WitherDeprecated.java | 23 -- .../resource/after-delombok/WitherOnClass.java | 54 ---- .../resource/after-delombok/WitherOnStatic.java | 4 - .../resource/after-delombok/WitherPlain.java | 16 -- .../resource/after-delombok/WitherTypeAnnos.java | 21 -- .../after-delombok/WitherWithAbstract.java | 5 - .../resource/after-delombok/WitherWithDollar.java | 3 - .../after-delombok/WitherWithGenerics.java | 20 -- .../resource/after-ecj/CheckerFrameworkBasic.java | 4 +- .../after-ecj/SetterAndWithMethodJavadoc.java | 22 ++ .../resource/after-ecj/SetterAndWitherJavadoc.java | 22 -- .../resource/after-ecj/WithAlreadyExists.java | 78 ++++++ .../after-ecj/WithAndAllArgsConstructor.java | 20 ++ .../resource/after-ecj/WithMethodAbstract.java | 7 + .../after-ecj/WithMethodMarkedDeprecated.java | 14 + test/transform/resource/after-ecj/WithOnClass.java | 52 ++++ .../transform/resource/after-ecj/WithOnStatic.java | 9 + test/transform/resource/after-ecj/WithPlain.java | 16 ++ .../resource/after-ecj/WithWithDollar.java | 6 + .../resource/after-ecj/WithWithGenerics.java | 18 ++ .../resource/after-ecj/WithWithTypeAnnos.java | 18 ++ .../resource/after-ecj/WitherAlreadyExists.java | 78 ------ .../after-ecj/WitherAndAllArgsConstructor.java | 20 -- .../resource/after-ecj/WitherDeprecated.java | 14 - .../resource/after-ecj/WitherOnClass.java | 52 ---- .../resource/after-ecj/WitherOnStatic.java | 9 - test/transform/resource/after-ecj/WitherPlain.java | 16 -- .../resource/after-ecj/WitherTypeAnnos.java | 18 -- .../resource/after-ecj/WitherWithAbstract.java | 7 - .../resource/after-ecj/WitherWithDollar.java | 6 - .../resource/after-ecj/WitherWithGenerics.java | 18 -- .../resource/before/BuilderInvalidUse.java | 2 +- .../resource/before/CheckerFrameworkBasic.java | 4 +- test/transform/resource/before/FlagUsages.java | 3 +- .../before/SetterAndWithMethodJavadoc.java | 26 ++ .../resource/before/SetterAndWitherJavadoc.java | 26 -- .../resource/before/WithAlreadyExists.java | 89 +++++++ .../resource/before/WithAndAllArgsConstructor.java | 12 + .../resource/before/WithMethodAbstract.java | 3 + .../before/WithMethodMarkedDeprecated.java | 15 ++ test/transform/resource/before/WithOnClass.java | 45 ++++ test/transform/resource/before/WithOnStatic.java | 4 + test/transform/resource/before/WithPlain.java | 10 + test/transform/resource/before/WithWithDollar.java | 3 + .../resource/before/WithWithGenerics.java | 9 + .../resource/before/WithWithTypeAnnos.java | 18 ++ .../resource/before/WitherAlreadyExists.java | 89 ------- .../before/WitherAndAllArgsConstructor.java | 12 - .../resource/before/WitherDeprecated.java | 15 -- test/transform/resource/before/WitherOnClass.java | 45 ---- test/transform/resource/before/WitherOnStatic.java | 4 - test/transform/resource/before/WitherPlain.java | 10 - .../transform/resource/before/WitherTypeAnnos.java | 18 -- .../resource/before/WitherWithAbstract.java | 3 - .../resource/before/WitherWithDollar.java | 3 - .../resource/before/WitherWithGenerics.java | 9 - .../BuilderInvalidUse.java.messages | 2 +- .../messages-delombok/FlagUsages.java.messages | 4 +- .../WithAlreadyExists.java.messages | 7 + .../messages-delombok/WithOnStatic.java.messages | 2 + .../messages-delombok/WithWithDollar.java.messages | 1 + .../WitherAlreadyExists.java.messages | 7 - .../messages-delombok/WitherOnStatic.java.messages | 2 - .../WitherWithDollar.java.messages | 1 - .../messages-ecj/BuilderInvalidUse.java.messages | 2 +- .../resource/messages-ecj/FlagUsages.java.messages | 4 +- .../messages-ecj/WithAlreadyExists.java.messages | 7 + .../messages-ecj/WithOnStatic.java.messages | 2 + .../messages-ecj/WithWithDollar.java.messages | 1 + .../messages-ecj/WitherAccessLevel.java.messages | 1 + .../messages-ecj/WitherAlreadyExists.java.messages | 7 - .../messages-ecj/WitherOnStatic.java.messages | 2 - .../messages-ecj/WitherWithDollar.java.messages | 1 - 98 files changed, 1539 insertions(+), 1434 deletions(-) create mode 100644 src/core/lombok/With.java create mode 100644 src/core/lombok/eclipse/handlers/HandleWith.java delete mode 100644 src/core/lombok/eclipse/handlers/HandleWither.java create mode 100644 src/core/lombok/javac/handlers/HandleWith.java delete mode 100644 src/core/lombok/javac/handlers/HandleWither.java create mode 100644 test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java delete mode 100644 test/transform/resource/after-delombok/SetterAndWitherJavadoc.java create mode 100644 test/transform/resource/after-delombok/WithAlreadyExists.java create mode 100644 test/transform/resource/after-delombok/WithAndAllArgsConstructor.java create mode 100644 test/transform/resource/after-delombok/WithMethodAbstract.java create mode 100644 test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java create mode 100644 test/transform/resource/after-delombok/WithOnClass.java create mode 100644 test/transform/resource/after-delombok/WithOnStatic.java create mode 100644 test/transform/resource/after-delombok/WithPlain.java create mode 100644 test/transform/resource/after-delombok/WithWithDollar.java create mode 100644 test/transform/resource/after-delombok/WithWithGenerics.java create mode 100644 test/transform/resource/after-delombok/WithWithTypeAnnos.java delete mode 100644 test/transform/resource/after-delombok/WitherAlreadyExists.java delete mode 100644 test/transform/resource/after-delombok/WitherAndAllArgsConstructor.java delete mode 100644 test/transform/resource/after-delombok/WitherDeprecated.java delete mode 100644 test/transform/resource/after-delombok/WitherOnClass.java delete mode 100644 test/transform/resource/after-delombok/WitherOnStatic.java delete mode 100644 test/transform/resource/after-delombok/WitherPlain.java delete mode 100644 test/transform/resource/after-delombok/WitherTypeAnnos.java delete mode 100644 test/transform/resource/after-delombok/WitherWithAbstract.java delete mode 100644 test/transform/resource/after-delombok/WitherWithDollar.java delete mode 100644 test/transform/resource/after-delombok/WitherWithGenerics.java create mode 100644 test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java delete mode 100644 test/transform/resource/after-ecj/SetterAndWitherJavadoc.java create mode 100644 test/transform/resource/after-ecj/WithAlreadyExists.java create mode 100644 test/transform/resource/after-ecj/WithAndAllArgsConstructor.java create mode 100644 test/transform/resource/after-ecj/WithMethodAbstract.java create mode 100644 test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java create mode 100644 test/transform/resource/after-ecj/WithOnClass.java create mode 100644 test/transform/resource/after-ecj/WithOnStatic.java create mode 100644 test/transform/resource/after-ecj/WithPlain.java create mode 100644 test/transform/resource/after-ecj/WithWithDollar.java create mode 100644 test/transform/resource/after-ecj/WithWithGenerics.java create mode 100644 test/transform/resource/after-ecj/WithWithTypeAnnos.java delete mode 100644 test/transform/resource/after-ecj/WitherAlreadyExists.java delete mode 100644 test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java delete mode 100644 test/transform/resource/after-ecj/WitherDeprecated.java delete mode 100644 test/transform/resource/after-ecj/WitherOnClass.java delete mode 100644 test/transform/resource/after-ecj/WitherOnStatic.java delete mode 100644 test/transform/resource/after-ecj/WitherPlain.java delete mode 100644 test/transform/resource/after-ecj/WitherTypeAnnos.java delete mode 100644 test/transform/resource/after-ecj/WitherWithAbstract.java delete mode 100644 test/transform/resource/after-ecj/WitherWithDollar.java delete mode 100644 test/transform/resource/after-ecj/WitherWithGenerics.java create mode 100644 test/transform/resource/before/SetterAndWithMethodJavadoc.java delete mode 100644 test/transform/resource/before/SetterAndWitherJavadoc.java create mode 100644 test/transform/resource/before/WithAlreadyExists.java create mode 100644 test/transform/resource/before/WithAndAllArgsConstructor.java create mode 100644 test/transform/resource/before/WithMethodAbstract.java create mode 100644 test/transform/resource/before/WithMethodMarkedDeprecated.java create mode 100644 test/transform/resource/before/WithOnClass.java create mode 100644 test/transform/resource/before/WithOnStatic.java create mode 100644 test/transform/resource/before/WithPlain.java create mode 100644 test/transform/resource/before/WithWithDollar.java create mode 100644 test/transform/resource/before/WithWithGenerics.java create mode 100644 test/transform/resource/before/WithWithTypeAnnos.java delete mode 100644 test/transform/resource/before/WitherAlreadyExists.java delete mode 100644 test/transform/resource/before/WitherAndAllArgsConstructor.java delete mode 100644 test/transform/resource/before/WitherDeprecated.java delete mode 100644 test/transform/resource/before/WitherOnClass.java delete mode 100644 test/transform/resource/before/WitherOnStatic.java delete mode 100644 test/transform/resource/before/WitherPlain.java delete mode 100644 test/transform/resource/before/WitherTypeAnnos.java delete mode 100644 test/transform/resource/before/WitherWithAbstract.java delete mode 100644 test/transform/resource/before/WitherWithDollar.java delete mode 100644 test/transform/resource/before/WitherWithGenerics.java create mode 100644 test/transform/resource/messages-delombok/WithAlreadyExists.java.messages create mode 100644 test/transform/resource/messages-delombok/WithOnStatic.java.messages create mode 100644 test/transform/resource/messages-delombok/WithWithDollar.java.messages delete mode 100644 test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages delete mode 100644 test/transform/resource/messages-delombok/WitherOnStatic.java.messages delete mode 100644 test/transform/resource/messages-delombok/WitherWithDollar.java.messages create mode 100644 test/transform/resource/messages-ecj/WithAlreadyExists.java.messages create mode 100644 test/transform/resource/messages-ecj/WithOnStatic.java.messages create mode 100644 test/transform/resource/messages-ecj/WithWithDollar.java.messages create mode 100644 test/transform/resource/messages-ecj/WitherAccessLevel.java.messages delete mode 100644 test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages delete mode 100644 test/transform/resource/messages-ecj/WitherOnStatic.java.messages delete mode 100644 test/transform/resource/messages-ecj/WitherWithDollar.java.messages (limited to 'test/transform/resource') diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index d46889d6..0baf1f3b 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -593,14 +593,14 @@ public class ConfigurationKeys { */ public static final ConfigurationKey FIELD_NAME_CONSTANTS_UPPERCASE = new ConfigurationKey("lombok.fieldNameConstants.uppercase", "The default name of the constants inside the inner type generated by @FieldNameConstants follow the variable name precisely. If this config key is true, lombok will uppercase them as best it can. (default: false).") {}; - // ----- Wither ----- + // ----- With ----- /** - * lombok configuration: {@code lombok.wither.flagUsage} = {@code WARNING} | {@code ERROR}. + * lombok configuration: {@code lombok.with.flagUsage} = {@code WARNING} | {@code ERROR}. * - * If set, any usage of {@code @Wither} results in a warning / error. + * If set, any usage of {@code @With} results in a warning / error. */ - public static final ConfigurationKey WITHER_FLAG_USAGE = new ConfigurationKey("lombok.wither.flagUsage", "Emit a warning or error if @Wither is used.") {}; + public static final ConfigurationKey WITH_FLAG_USAGE = new ConfigurationKey("lombok.with.flagUsage", "Emit a warning or error if @With is used.") {}; // ----- SuperBuilder ----- @@ -625,9 +625,9 @@ public class ConfigurationKeys { /** * lombok configuration: {@code lombok.copyableAnnotations} += <TypeName: fully-qualified annotation class name>. * - * Copy these annotations to getters, setters, withers, builder-setters, etc. + * Copy these annotations to getters, setters, with methods, builder-setters, etc. */ - public static final ConfigurationKey> COPYABLE_ANNOTATIONS = new ConfigurationKey>("lombok.copyableAnnotations", "Copy these annotations to getters, setters, withers, builder-setters, etc.") {}; + public static final ConfigurationKey> COPYABLE_ANNOTATIONS = new ConfigurationKey>("lombok.copyableAnnotations", "Copy these annotations to getters, setters, with methods, builder-setters, etc.") {}; /** * lombok configuration: {@code checkerframework} = {@code true} | {@code false} | <String: MajorVer.MinorVer> (Default: false). diff --git a/src/core/lombok/With.java b/src/core/lombok/With.java new file mode 100644 index 00000000..141d1fa6 --- /dev/null +++ b/src/core/lombok/With.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2012-2019 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import lombok.AccessLevel; + +/** + * Put on any field to make lombok build a 'with' - a withX method which produces a clone of this object (except for 1 field which gets a new value). + *

+ * Complete documentation is found at the project lombok features page for @With. + *

+ * Example: + *

+ *     private @With final int foo;
+ * 
+ * + * will generate: + * + *
+ *     public SELF_TYPE withFoo(int foo) {
+ *         return this.foo == foo ? this : new SELF_TYPE(otherField1, otherField2, foo);
+ *     }
+ * 
+ *

+ * This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have + * a {@code With} annotation have the annotation. + */ +@Target({ElementType.FIELD, ElementType.TYPE}) +@Retention(RetentionPolicy.SOURCE) +public @interface With { + /** + * If you want your with method to be non-public, you can specify an alternate access level here. + * + * @return The method will be generated with this access modifier. + */ + AccessLevel value() default AccessLevel.PUBLIC; + + /** + * Any annotations listed here are put on the generated method. + * The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
+ * up to JDK7:
+ * {@code @With(onMethod=@__({@AnnotationsGoHere}))}
+ * from JDK8:
+ * {@code @With(onMethod_={@AnnotationsGohere})} // note the underscore after {@code onMethod}. + * + * @return List of annotations to apply to the generated method. + */ + AnyAnnotation[] onMethod() default {}; + + /** + * Any annotations listed here are put on the generated method's parameter. + * The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
+ * up to JDK7:
+ * {@code @With(onParam=@__({@AnnotationsGoHere}))}
+ * from JDK8:
+ * {@code @With(onParam_={@AnnotationsGohere})} // note the underscore after {@code onParam}. + * + * @return List of annotations to apply to the generated parameter in the method. + */ + AnyAnnotation[] onParam() default {}; + + /** + * Placeholder annotation to enable the placement of annotations on the generated code. + * @deprecated Don't use this annotation, ever - Read the documentation. + */ + @Deprecated + @Retention(RetentionPolicy.SOURCE) + @Target({}) + @interface AnyAnnotation {} +} diff --git a/src/core/lombok/core/LombokInternalAliasing.java b/src/core/lombok/core/LombokInternalAliasing.java index c1089580..0b92d3b9 100644 --- a/src/core/lombok/core/LombokInternalAliasing.java +++ b/src/core/lombok/core/LombokInternalAliasing.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2018 The Project Lombok Authors. + * Copyright (C) 2013-2019 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,6 +51,7 @@ public class LombokInternalAliasing { m2.put("lombok.experimental.Builder", "lombok.Builder"); m2.put("lombok.experimental.var", "lombok.var"); m2.put("lombok.Delegate", "lombok.experimental.Delegate"); + m2.put("lombok.experimental.Wither", "lombok.With"); ALIASES = Collections.unmodifiableMap(m2); } } diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 21a3a216..be32e101 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -38,6 +38,7 @@ import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; import lombok.Value; +import lombok.With; import lombok.core.AST; import lombok.core.AnnotationValues; import lombok.core.JavaIdentifiers; @@ -47,7 +48,6 @@ import lombok.core.configuration.ConfigurationKey; import lombok.core.configuration.FlagUsageType; import lombok.experimental.Accessors; import lombok.experimental.FieldDefaults; -import lombok.experimental.Wither; /** * Container for static utility methods useful for some of the standard lombok handlers, regardless of @@ -406,7 +406,7 @@ public class HandlerUtil { @SuppressWarnings({"all", "unchecked", "deprecation"}) public static final List INVALID_ON_BUILDERS = Collections.unmodifiableList( Arrays.asList( - Getter.class.getName(), Setter.class.getName(), Wither.class.getName(), + Getter.class.getName(), Setter.class.getName(), With.class.getName(), "lombok.experimental.Wither", ToString.class.getName(), EqualsAndHashCode.class.getName(), RequiredArgsConstructor.class.getName(), AllArgsConstructor.class.getName(), NoArgsConstructor.class.getName(), Data.class.getName(), Value.class.getName(), "lombok.experimental.Value", FieldDefaults.class.getName())); @@ -502,7 +502,7 @@ public class HandlerUtil { } /** - * Generates a wither name from a given field name. + * Generates a with name from a given field name. * * Strategy: *

    @@ -518,9 +518,9 @@ public class HandlerUtil { * @param accessors Accessors configuration. * @param fieldName the name of the field. * @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}. - * @return The wither name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name. + * @return The with name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name. */ - public static String toWitherName(AST ast, AnnotationValues accessors, CharSequence fieldName, boolean isBoolean) { + public static String toWithName(AST ast, AnnotationValues accessors, CharSequence fieldName, boolean isBoolean) { return toAccessorName(ast, accessors, fieldName, isBoolean, "with", "with", false); } @@ -582,7 +582,7 @@ public class HandlerUtil { } /** - * Returns all names of methods that would represent the wither for a field with the provided name. + * Returns all names of methods that would represent the with for a field with the provided name. * * For example if {@code isBoolean} is true, then a field named {@code isRunning} would produce:
    * {@code [withRunning, withIsRunning]} @@ -591,7 +591,7 @@ public class HandlerUtil { * @param fieldName the name of the field. * @param isBoolean if the field is of type 'boolean'. For fields of type 'java.lang.Boolean', you should provide {@code false}. */ - public static List toAllWitherNames(AST ast, AnnotationValues accessors, CharSequence fieldName, boolean isBoolean) { + public static List toAllWithNames(AST ast, AnnotationValues accessors, CharSequence fieldName, boolean isBoolean) { return toAllAccessorNames(ast, accessors, fieldName, isBoolean, "with", "with", false); } diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 6a6d4cca..0955dba6 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1417,20 +1417,20 @@ public class EclipseHandlerUtil { } /** - * Translates the given field into all possible wither names. - * Convenient wrapper around {@link TransformationsUtil#toAllWitherNames(lombok.core.AnnotationValues, CharSequence, boolean)}. + * Translates the given field into all possible with names. + * Convenient wrapper around {@link TransformationsUtil#toAllWithNames(lombok.core.AnnotationValues, CharSequence, boolean)}. */ - public static java.util.List toAllWitherNames(EclipseNode field, boolean isBoolean) { - return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean); + public static java.util.List toAllWithNames(EclipseNode field, boolean isBoolean) { + return HandlerUtil.toAllWithNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean); } /** - * @return the likely wither name for the stated field. (e.g. private boolean foo; to withFoo). + * @return the likely with name for the stated field. (e.g. private boolean foo; to withFoo). * - * Convenient wrapper around {@link TransformationsUtil#toWitherName(lombok.core.AnnotationValues, CharSequence, boolean)}. + * Convenient wrapper around {@link TransformationsUtil#toWithName(lombok.core.AnnotationValues, CharSequence, boolean)}. */ - public static String toWitherName(EclipseNode field, boolean isBoolean) { - return HandlerUtil.toWitherName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean); + public static String toWithName(EclipseNode field, boolean isBoolean) { + return HandlerUtil.toWithName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean); } /** diff --git a/src/core/lombok/eclipse/handlers/HandleWith.java b/src/core/lombok/eclipse/handlers/HandleWith.java new file mode 100644 index 00000000..8c8c3712 --- /dev/null +++ b/src/core/lombok/eclipse/handlers/HandleWith.java @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2012-2019 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.eclipse.handlers; + +import static lombok.core.handlers.HandlerUtil.*; +import static lombok.eclipse.Eclipse.*; +import static lombok.eclipse.handlers.EclipseHandlerUtil.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import lombok.AccessLevel; +import lombok.ConfigurationKeys; +import lombok.With; +import lombok.core.AST.Kind; +import lombok.core.configuration.CheckerFrameworkVersion; +import lombok.core.AnnotationValues; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; + +import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; +import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.Argument; +import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression; +import org.eclipse.jdt.internal.compiler.ast.EqualExpression; +import org.eclipse.jdt.internal.compiler.ast.Expression; +import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; +import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.OperatorIds; +import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; +import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; +import org.eclipse.jdt.internal.compiler.ast.Statement; +import org.eclipse.jdt.internal.compiler.ast.ThisReference; +import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; +import org.mangosdk.spi.ProviderFor; + +@ProviderFor(EclipseAnnotationHandler.class) +public class HandleWith extends EclipseAnnotationHandler { + public boolean generateWithForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWith) { + if (checkForTypeLevelWith) { + if (hasAnnotation(With.class, typeNode)) { + //The annotation will make it happen, so we can skip it. + return true; + } + } + + TypeDeclaration typeDecl = null; + if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get(); + int modifiers = typeDecl == null ? 0 : typeDecl.modifiers; + boolean notAClass = (modifiers & + (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0; + + if (typeDecl == null || notAClass) { + pos.addError("@With is only supported on a class or a field."); + return false; + } + + for (EclipseNode field : typeNode.down()) { + if (field.getKind() != Kind.FIELD) continue; + FieldDeclaration fieldDecl = (FieldDeclaration) field.get(); + if (!filterField(fieldDecl)) continue; + + //Skip final fields. + if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0 && fieldDecl.initialization != null) continue; + + generateWithForField(field, pos, level); + } + return true; + } + + + /** + * Generates a with on the stated field. + * + * Used by {@link HandleValue}. + * + * The difference between this call and the handle method is as follows: + * + * If there is a {@code lombok.With} annotation on the field, it is used and the + * same rules apply (e.g. warning if the method already exists, stated access level applies). + * If not, the with method is still generated if it isn't already there, though there will not + * be a warning if its already there. The default access level is used. + */ + public void generateWithForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) { + for (EclipseNode child : fieldNode.down()) { + if (child.getKind() == Kind.ANNOTATION) { + if (annotationTypeMatches(With.class, child)) { + //The annotation will make it happen, so we can skip it. + return; + } + } + } + + List empty = Collections.emptyList(); + createWithForField(level, fieldNode, sourceNode, false, empty, empty); + } + + @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { + handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITH_FLAG_USAGE, "@With"); + + EclipseNode node = annotationNode.up(); + AccessLevel level = annotation.getInstance().value(); + if (level == AccessLevel.NONE || node == null) return; + + List onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@With(onMethod", annotationNode); + List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@With(onParam", annotationNode); + + switch (node.getKind()) { + case FIELD: + createWithForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam); + break; + case TYPE: + if (!onMethod.isEmpty()) { + annotationNode.addError("'onMethod' is not supported for @With on a type."); + } + if (!onParam.isEmpty()) { + annotationNode.addError("'onParam' is not supported for @With on a type."); + } + generateWithForType(node, annotationNode, level, false); + break; + } + } + + public void createWithForFields(AccessLevel level, Collection fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List onMethod, List onParam) { + for (EclipseNode fieldNode : fieldNodes) { + createWithForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam); + } + } + + public void createWithForField( + AccessLevel level, EclipseNode fieldNode, EclipseNode sourceNode, + boolean whineIfExists, List onMethod, + List onParam) { + + ASTNode source = sourceNode.get(); + if (fieldNode.getKind() != Kind.FIELD) { + sourceNode.addError("@With is only supported on a class or a field."); + return; + } + + EclipseNode typeNode = fieldNode.up(); + boolean makeAbstract = typeNode != null && typeNode.getKind() == Kind.TYPE && (((TypeDeclaration) typeNode.get()).modifiers & ClassFileConstants.AccAbstract) != 0; + + FieldDeclaration field = (FieldDeclaration) fieldNode.get(); + TypeReference fieldType = copyType(field.type, source); + boolean isBoolean = isBoolean(fieldType); + String withName = toWithName(fieldNode, isBoolean); + + if (withName == null) { + fieldNode.addWarning("Not generating a with method for this field: It does not fit your @Accessors prefix list."); + return; + } + + if ((field.modifiers & ClassFileConstants.AccStatic) != 0) { + fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for static fields."); + return; + } + + if ((field.modifiers & ClassFileConstants.AccFinal) != 0 && field.initialization != null) { + fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for final, initialized fields."); + return; + } + + if (field.name != null && field.name.length > 0 && field.name[0] == '$') { + fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for fields starting with $."); + return; + } + + for (String altName : toAllWithNames(fieldNode, isBoolean)) { + switch (methodExists(altName, fieldNode, false, 1)) { + case EXISTS_BY_LOMBOK: + return; + case EXISTS_BY_USER: + if (whineIfExists) { + String altNameExpl = ""; + if (!altName.equals(withName)) altNameExpl = String.format(" (%s)", altName); + fieldNode.addWarning( + String.format("Not generating %s(): A method with that name already exists%s", withName, altNameExpl)); + } + return; + default: + case NOT_EXISTS: + //continue scanning the other alt names. + } + } + + int modifier = toEclipseModifier(level); + + MethodDeclaration method = createWith((TypeDeclaration) fieldNode.up().get(), fieldNode, withName, modifier, sourceNode, onMethod, onParam, makeAbstract); + injectMethod(fieldNode.up(), method); + } + + public MethodDeclaration createWith(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List onMethod, List onParam, boolean makeAbstract ) { + ASTNode source = sourceNode.get(); + if (name == null) return null; + FieldDeclaration field = (FieldDeclaration) fieldNode.get(); + int pS = source.sourceStart, pE = source.sourceEnd; + long p = (long) pS << 32 | pE; + MethodDeclaration method = new MethodDeclaration(parent.compilationResult); + if (makeAbstract) modifier = modifier | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody; + method.modifiers = modifier; + method.returnType = cloneSelfType(fieldNode, source); + if (method.returnType == null) return null; + + Annotation[] deprecated = null, checkerFramework = null; + if (isFieldDeprecated(fieldNode)) deprecated = new Annotation[] { generateDeprecatedAnnotation(source) }; + if (getCheckerFrameworkVersion(fieldNode).generateSideEffectFree()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) }; + + method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), checkerFramework, deprecated); + Argument param = new Argument(field.name, p, copyType(field.type, source), ClassFileConstants.AccFinal); + param.sourceStart = pS; param.sourceEnd = pE; + method.arguments = new Argument[] { param }; + method.selector = name.toCharArray(); + method.binding = null; + method.thrownExceptions = null; + method.typeParameters = null; + method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; + + Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode); + + if (!makeAbstract) { + List args = new ArrayList(); + for (EclipseNode child : fieldNode.up().down()) { + if (child.getKind() != Kind.FIELD) continue; + FieldDeclaration childDecl = (FieldDeclaration) child.get(); + // Skip fields that start with $ + if (childDecl.name != null && childDecl.name.length > 0 && childDecl.name[0] == '$') continue; + long fieldFlags = childDecl.modifiers; + // Skip static fields. + if ((fieldFlags & ClassFileConstants.AccStatic) != 0) continue; + // Skip initialized final fields. + if (((fieldFlags & ClassFileConstants.AccFinal) != 0) && childDecl.initialization != null) continue; + if (child.get() == fieldNode.get()) { + args.add(new SingleNameReference(field.name, p)); + } else { + args.add(createFieldAccessor(child, FieldAccess.ALWAYS_FIELD, source)); + } + } + + AllocationExpression constructorCall = new AllocationExpression(); + constructorCall.arguments = args.toArray(new Expression[0]); + constructorCall.type = cloneSelfType(fieldNode, source); + + Expression identityCheck = new EqualExpression( + createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source), + new SingleNameReference(field.name, p), + OperatorIds.EQUAL_EQUAL); + ThisReference thisRef = new ThisReference(pS, pE); + Expression conditional = new ConditionalExpression(identityCheck, thisRef, constructorCall); + Statement returnStatement = new ReturnStatement(conditional, pS, pE); + method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart; + method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd; + + List statements = new ArrayList(5); + if (hasNonNullAnnotations(fieldNode)) { + Statement nullCheck = generateNullCheck(field, sourceNode); + if (nullCheck != null) statements.add(nullCheck); + } + statements.add(returnStatement); + + method.statements = statements.toArray(new Statement[0]); + } + param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0])); + + method.traverse(new SetGeneratedByVisitor(source), parent.scope); + return method; + } +} diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java deleted file mode 100644 index 8be08cfe..00000000 --- a/src/core/lombok/eclipse/handlers/HandleWither.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (C) 2012-2019 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.eclipse.handlers; - -import static lombok.core.handlers.HandlerUtil.*; -import static lombok.eclipse.Eclipse.*; -import static lombok.eclipse.handlers.EclipseHandlerUtil.*; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import lombok.AccessLevel; -import lombok.ConfigurationKeys; -import lombok.core.AST.Kind; -import lombok.core.configuration.CheckerFrameworkVersion; -import lombok.core.AnnotationValues; -import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseNode; -import lombok.experimental.Wither; - -import org.eclipse.jdt.internal.compiler.ast.ASTNode; -import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; -import org.eclipse.jdt.internal.compiler.ast.Annotation; -import org.eclipse.jdt.internal.compiler.ast.Argument; -import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression; -import org.eclipse.jdt.internal.compiler.ast.EqualExpression; -import org.eclipse.jdt.internal.compiler.ast.Expression; -import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; -import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; -import org.eclipse.jdt.internal.compiler.ast.OperatorIds; -import org.eclipse.jdt.internal.compiler.ast.ReturnStatement; -import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; -import org.eclipse.jdt.internal.compiler.ast.Statement; -import org.eclipse.jdt.internal.compiler.ast.ThisReference; -import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; -import org.eclipse.jdt.internal.compiler.ast.TypeReference; -import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; -import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; -import org.mangosdk.spi.ProviderFor; - -@ProviderFor(EclipseAnnotationHandler.class) -public class HandleWither extends EclipseAnnotationHandler { - public boolean generateWitherForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWither) { - if (checkForTypeLevelWither) { - if (hasAnnotation(Wither.class, typeNode)) { - //The annotation will make it happen, so we can skip it. - return true; - } - } - - TypeDeclaration typeDecl = null; - if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get(); - int modifiers = typeDecl == null ? 0 : typeDecl.modifiers; - boolean notAClass = (modifiers & - (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0; - - if (typeDecl == null || notAClass) { - pos.addError("@Wither is only supported on a class or a field."); - return false; - } - - for (EclipseNode field : typeNode.down()) { - if (field.getKind() != Kind.FIELD) continue; - FieldDeclaration fieldDecl = (FieldDeclaration) field.get(); - if (!filterField(fieldDecl)) continue; - - //Skip final fields. - if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0 && fieldDecl.initialization != null) continue; - - generateWitherForField(field, pos, level); - } - return true; - } - - - /** - * Generates a wither on the stated field. - * - * Used by {@link HandleValue}. - * - * The difference between this call and the handle method is as follows: - * - * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the - * same rules apply (e.g. warning if the method already exists, stated access level applies). - * If not, the wither is still generated if it isn't already there, though there will not - * be a warning if its already there. The default access level is used. - */ - public void generateWitherForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) { - for (EclipseNode child : fieldNode.down()) { - if (child.getKind() == Kind.ANNOTATION) { - if (annotationTypeMatches(Wither.class, child)) { - //The annotation will make it happen, so we can skip it. - return; - } - } - } - - List empty = Collections.emptyList(); - createWitherForField(level, fieldNode, sourceNode, false, empty, empty); - } - - @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { - handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither"); - - EclipseNode node = annotationNode.up(); - AccessLevel level = annotation.getInstance().value(); - if (level == AccessLevel.NONE || node == null) return; - - List onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod", annotationNode); - List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam", annotationNode); - - switch (node.getKind()) { - case FIELD: - createWitherForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam); - break; - case TYPE: - if (!onMethod.isEmpty()) { - annotationNode.addError("'onMethod' is not supported for @Wither on a type."); - } - if (!onParam.isEmpty()) { - annotationNode.addError("'onParam' is not supported for @Wither on a type."); - } - generateWitherForType(node, annotationNode, level, false); - break; - } - } - - public void createWitherForFields(AccessLevel level, Collection fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List onMethod, List onParam) { - for (EclipseNode fieldNode : fieldNodes) { - createWitherForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam); - } - } - - public void createWitherForField( - AccessLevel level, EclipseNode fieldNode, EclipseNode sourceNode, - boolean whineIfExists, List onMethod, - List onParam) { - - ASTNode source = sourceNode.get(); - if (fieldNode.getKind() != Kind.FIELD) { - sourceNode.addError("@Wither is only supported on a class or a field."); - return; - } - - EclipseNode typeNode = fieldNode.up(); - boolean makeAbstract = typeNode != null && typeNode.getKind() == Kind.TYPE && (((TypeDeclaration) typeNode.get()).modifiers & ClassFileConstants.AccAbstract) != 0; - - FieldDeclaration field = (FieldDeclaration) fieldNode.get(); - TypeReference fieldType = copyType(field.type, source); - boolean isBoolean = isBoolean(fieldType); - String witherName = toWitherName(fieldNode, isBoolean); - - if (witherName == null) { - fieldNode.addWarning("Not generating wither for this field: It does not fit your @Accessors prefix list."); - return; - } - - if ((field.modifiers & ClassFileConstants.AccStatic) != 0) { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for static fields."); - return; - } - - if ((field.modifiers & ClassFileConstants.AccFinal) != 0 && field.initialization != null) { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for final, initialized fields."); - return; - } - - if (field.name != null && field.name.length > 0 && field.name[0] == '$') { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for fields starting with $."); - return; - } - - for (String altName : toAllWitherNames(fieldNode, isBoolean)) { - switch (methodExists(altName, fieldNode, false, 1)) { - case EXISTS_BY_LOMBOK: - return; - case EXISTS_BY_USER: - if (whineIfExists) { - String altNameExpl = ""; - if (!altName.equals(witherName)) altNameExpl = String.format(" (%s)", altName); - fieldNode.addWarning( - String.format("Not generating %s(): A method with that name already exists%s", witherName, altNameExpl)); - } - return; - default: - case NOT_EXISTS: - //continue scanning the other alt names. - } - } - - int modifier = toEclipseModifier(level); - - MethodDeclaration method = createWither((TypeDeclaration) fieldNode.up().get(), fieldNode, witherName, modifier, sourceNode, onMethod, onParam, makeAbstract); - injectMethod(fieldNode.up(), method); - } - - public MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List onMethod, List onParam, boolean makeAbstract ) { - ASTNode source = sourceNode.get(); - if (name == null) return null; - FieldDeclaration field = (FieldDeclaration) fieldNode.get(); - int pS = source.sourceStart, pE = source.sourceEnd; - long p = (long) pS << 32 | pE; - MethodDeclaration method = new MethodDeclaration(parent.compilationResult); - if (makeAbstract) modifier = modifier | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody; - method.modifiers = modifier; - method.returnType = cloneSelfType(fieldNode, source); - if (method.returnType == null) return null; - - Annotation[] deprecated = null, checkerFramework = null; - if (isFieldDeprecated(fieldNode)) deprecated = new Annotation[] { generateDeprecatedAnnotation(source) }; - if (getCheckerFrameworkVersion(fieldNode).generateSideEffectFree()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) }; - - method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), checkerFramework, deprecated); - Argument param = new Argument(field.name, p, copyType(field.type, source), ClassFileConstants.AccFinal); - param.sourceStart = pS; param.sourceEnd = pE; - method.arguments = new Argument[] { param }; - method.selector = name.toCharArray(); - method.binding = null; - method.thrownExceptions = null; - method.typeParameters = null; - method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; - - Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode); - - if (!makeAbstract) { - List args = new ArrayList(); - for (EclipseNode child : fieldNode.up().down()) { - if (child.getKind() != Kind.FIELD) continue; - FieldDeclaration childDecl = (FieldDeclaration) child.get(); - // Skip fields that start with $ - if (childDecl.name != null && childDecl.name.length > 0 && childDecl.name[0] == '$') continue; - long fieldFlags = childDecl.modifiers; - // Skip static fields. - if ((fieldFlags & ClassFileConstants.AccStatic) != 0) continue; - // Skip initialized final fields. - if (((fieldFlags & ClassFileConstants.AccFinal) != 0) && childDecl.initialization != null) continue; - if (child.get() == fieldNode.get()) { - args.add(new SingleNameReference(field.name, p)); - } else { - args.add(createFieldAccessor(child, FieldAccess.ALWAYS_FIELD, source)); - } - } - - AllocationExpression constructorCall = new AllocationExpression(); - constructorCall.arguments = args.toArray(new Expression[0]); - constructorCall.type = cloneSelfType(fieldNode, source); - - Expression identityCheck = new EqualExpression( - createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source), - new SingleNameReference(field.name, p), - OperatorIds.EQUAL_EQUAL); - ThisReference thisRef = new ThisReference(pS, pE); - Expression conditional = new ConditionalExpression(identityCheck, thisRef, constructorCall); - Statement returnStatement = new ReturnStatement(conditional, pS, pE); - method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart; - method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd; - - List statements = new ArrayList(5); - if (hasNonNullAnnotations(fieldNode)) { - Statement nullCheck = generateNullCheck(field, sourceNode); - if (nullCheck != null) statements.add(nullCheck); - } - statements.add(returnStatement); - - method.statements = statements.toArray(new Statement[0]); - } - param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0])); - - method.traverse(new SetGeneratedByVisitor(source), parent.scope); - return method; - } -} diff --git a/src/core/lombok/experimental/Wither.java b/src/core/lombok/experimental/Wither.java index 3df546d0..cf20c1eb 100644 --- a/src/core/lombok/experimental/Wither.java +++ b/src/core/lombok/experimental/Wither.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2017 The Project Lombok Authors. + * Copyright (C) 2012-2019 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -50,6 +50,8 @@ import lombok.AccessLevel; *

    * This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have * a {@code Wither} annotation have the annotation. + * + * @deprecated {@link lombok.With} has been promoted to the main package, so use that one instead. */ @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.SOURCE) diff --git a/src/core/lombok/javac/handlers/HandleWith.java b/src/core/lombok/javac/handlers/HandleWith.java new file mode 100644 index 00000000..fd14e06a --- /dev/null +++ b/src/core/lombok/javac/handlers/HandleWith.java @@ -0,0 +1,294 @@ +/* + * Copyright (C) 2012-2019 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.javac.handlers; + +import static lombok.core.handlers.HandlerUtil.*; +import static lombok.javac.Javac.*; +import static lombok.javac.handlers.JavacHandlerUtil.*; + +import java.util.Collection; + +import lombok.AccessLevel; +import lombok.ConfigurationKeys; +import lombok.With; +import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; +import lombok.core.configuration.CheckerFrameworkVersion; +import lombok.javac.JavacAnnotationHandler; +import lombok.javac.JavacNode; +import lombok.javac.JavacTreeMaker; +import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc; + +import org.mangosdk.spi.ProviderFor; + +import com.sun.tools.javac.code.Flags; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.tree.JCTree.JCAnnotation; +import com.sun.tools.javac.tree.JCTree.JCBlock; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCConditional; +import com.sun.tools.javac.tree.JCTree.JCExpression; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCNewClass; +import com.sun.tools.javac.tree.JCTree.JCReturn; +import com.sun.tools.javac.tree.JCTree.JCStatement; +import com.sun.tools.javac.tree.JCTree.JCTypeParameter; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Name; + +/** + * Handles the {@code lombok.With} annotation for javac. + */ +@ProviderFor(JavacAnnotationHandler.class) +public class HandleWith extends JavacAnnotationHandler { + public void generateWithForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelWith) { + if (checkForTypeLevelWith) { + if (hasAnnotation(With.class, typeNode)) { + //The annotation will make it happen, so we can skip it. + return; + } + } + + JCClassDecl typeDecl = null; + if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get(); + long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags; + boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0; + + if (typeDecl == null || notAClass) { + errorNode.addError("@With is only supported on a class or a field."); + return; + } + + for (JavacNode field : typeNode.down()) { + if (field.getKind() != Kind.FIELD) continue; + JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); + //Skip fields that start with $ + if (fieldDecl.name.toString().startsWith("$")) continue; + //Skip static fields. + if ((fieldDecl.mods.flags & Flags.STATIC) != 0) continue; + //Skip final initialized fields. + if ((fieldDecl.mods.flags & Flags.FINAL) != 0 && fieldDecl.init != null) continue; + + generateWithForField(field, errorNode.get(), level); + } + } + + /** + * Generates a with on the stated field. + * + * Used by {@link HandleValue}. + * + * The difference between this call and the handle method is as follows: + * + * If there is a {@code lombok.experimental.With} annotation on the field, it is used and the + * same rules apply (e.g. warning if the method already exists, stated access level applies). + * If not, the with is still generated if it isn't already there, though there will not + * be a warning if its already there. The default access level is used. + * + * @param fieldNode The node representing the field you want a with for. + * @param pos The node responsible for generating the with (the {@code @Value} or {@code @With} annotation). + */ + public void generateWithForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) { + if (hasAnnotation(With.class, fieldNode)) { + //The annotation will make it happen, so we can skip it. + return; + } + + createWithForField(level, fieldNode, fieldNode, false, List.nil(), List.nil()); + } + + @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + handleFlagUsage(annotationNode, ConfigurationKeys.WITH_FLAG_USAGE, "@With"); + + Collection fields = annotationNode.upFromAnnotationToFields(); + deleteAnnotationIfNeccessary(annotationNode, With.class, "lombok.experimental.Wither"); + deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); + JavacNode node = annotationNode.up(); + AccessLevel level = annotation.getInstance().value(); + + if (level == AccessLevel.NONE || node == null) return; + + List onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@With(onMethod", annotationNode); + List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@With(onParam", annotationNode); + + switch (node.getKind()) { + case FIELD: + createWithForFields(level, fields, annotationNode, true, onMethod, onParam); + break; + case TYPE: + if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @With on a type."); + if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @With on a type."); + generateWithForType(node, annotationNode, level, false); + break; + } + } + + public void createWithForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { + for (JavacNode fieldNode : fieldNodes) { + createWithForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); + } + } + + public void createWithForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean strictMode, List onMethod, List onParam) { + JavacNode typeNode = fieldNode.up(); + boolean makeAbstract = typeNode != null && typeNode.getKind() == Kind.TYPE && (((JCClassDecl) typeNode.get()).mods.flags & Flags.ABSTRACT) != 0; + + if (fieldNode.getKind() != Kind.FIELD) { + fieldNode.addError("@With is only supported on a class or a field."); + return; + } + + JCVariableDecl fieldDecl = (JCVariableDecl) fieldNode.get(); + String methodName = toWithName(fieldNode); + + if (methodName == null) { + fieldNode.addWarning("Not generating a withX method for this field: It does not fit your @Accessors prefix list."); + return; + } + + if ((fieldDecl.mods.flags & Flags.STATIC) != 0) { + if (strictMode) { + fieldNode.addWarning("Not generating " + methodName + " for this field: With methods cannot be generated for static fields."); + } + return; + } + + if ((fieldDecl.mods.flags & Flags.FINAL) != 0 && fieldDecl.init != null) { + if (strictMode) { + fieldNode.addWarning("Not generating " + methodName + " for this field: With methods cannot be generated for final, initialized fields."); + } + return; + } + + if (fieldDecl.name.toString().startsWith("$")) { + if (strictMode) { + fieldNode.addWarning("Not generating " + methodName + " for this field: With methods cannot be generated for fields starting with $."); + } + return; + } + + for (String altName : toAllWithNames(fieldNode)) { + switch (methodExists(altName, fieldNode, false, 1)) { + case EXISTS_BY_LOMBOK: + return; + case EXISTS_BY_USER: + if (strictMode) { + String altNameExpl = ""; + if (!altName.equals(methodName)) altNameExpl = String.format(" (%s)", altName); + fieldNode.addWarning( + String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl)); + } + return; + default: + case NOT_EXISTS: + //continue scanning the other alt names. + } + } + + long access = toJavacModifier(level); + + JCMethodDecl createdWith = createWith(access, fieldNode, fieldNode.getTreeMaker(), source, onMethod, onParam, makeAbstract); + ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym; + Type returnType = sym == null ? null : sym.type; + + injectMethod(typeNode, createdWith, List.of(getMirrorForFieldType(fieldNode)), returnType); + } + + public JCMethodDecl createWith(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List onMethod, List onParam, boolean makeAbstract) { + String withName = toWithName(field); + if (withName == null) return null; + + JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); + + List copyableAnnotations = findCopyableAnnotations(field); + + Name methodName = field.toName(withName); + + JCExpression returnType = cloneSelfType(field); + + JCBlock methodBody = null; + long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext()); + List annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations); + + JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null); + + if (!makeAbstract) { + ListBuffer statements = new ListBuffer(); + + JCExpression selfType = cloneSelfType(field); + if (selfType == null) return null; + + ListBuffer args = new ListBuffer(); + for (JavacNode child : field.up().down()) { + if (child.getKind() != Kind.FIELD) continue; + JCVariableDecl childDecl = (JCVariableDecl) child.get(); + // Skip fields that start with $ + if (childDecl.name.toString().startsWith("$")) continue; + long fieldFlags = childDecl.mods.flags; + // Skip static fields. + if ((fieldFlags & Flags.STATIC) != 0) continue; + // Skip initialized final fields. + if (((fieldFlags & Flags.FINAL) != 0) && childDecl.init != null) continue; + if (child.get() == field.get()) { + args.append(maker.Ident(fieldDecl.name)); + } else { + args.append(createFieldAccessor(maker, child, FieldAccess.ALWAYS_FIELD)); + } + } + + JCNewClass newClass = maker.NewClass(null, List.nil(), selfType, args.toList(), null); + JCExpression identityCheck = maker.Binary(CTC_EQUAL, createFieldAccessor(maker, field, FieldAccess.ALWAYS_FIELD), maker.Ident(fieldDecl.name)); + JCConditional conditional = maker.Conditional(identityCheck, maker.Ident(field.toName("this")), newClass); + JCReturn returnStatement = maker.Return(conditional); + + if (!hasNonNullAnnotations(field)) { + statements.append(returnStatement); + } else { + JCStatement nullCheck = generateNullCheck(maker, field, source); + if (nullCheck != null) statements.append(nullCheck); + statements.append(returnStatement); + } + + methodBody = maker.Block(0, statements.toList()); + } + List methodGenericParams = List.nil(); + List parameters = List.of(param); + List throwsClauses = List.nil(); + JCExpression annotationMethodDefaultValue = null; + + List annsOnMethod = copyAnnotations(onMethod); + CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(source); + if (checkerFramework.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.nil())); + + if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.nil())); + + if (makeAbstract) access = access | Flags.ABSTRACT; + JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType, + methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext()); + copyJavadoc(field, decl, CopyJavadoc.WITH); + return decl; + } +} diff --git a/src/core/lombok/javac/handlers/HandleWither.java b/src/core/lombok/javac/handlers/HandleWither.java deleted file mode 100644 index 9c95cb78..00000000 --- a/src/core/lombok/javac/handlers/HandleWither.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2012-2019 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.javac.handlers; - -import static lombok.core.handlers.HandlerUtil.*; -import static lombok.javac.Javac.*; -import static lombok.javac.handlers.JavacHandlerUtil.*; - -import java.util.Collection; - -import lombok.AccessLevel; -import lombok.ConfigurationKeys; -import lombok.core.AST.Kind; -import lombok.core.AnnotationValues; -import lombok.core.configuration.CheckerFrameworkVersion; -import lombok.experimental.Wither; -import lombok.javac.JavacAnnotationHandler; -import lombok.javac.JavacNode; -import lombok.javac.JavacTreeMaker; -import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc; - -import org.mangosdk.spi.ProviderFor; - -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.tree.JCTree.JCAnnotation; -import com.sun.tools.javac.tree.JCTree.JCBlock; -import com.sun.tools.javac.tree.JCTree.JCClassDecl; -import com.sun.tools.javac.tree.JCTree.JCConditional; -import com.sun.tools.javac.tree.JCTree.JCExpression; -import com.sun.tools.javac.tree.JCTree.JCMethodDecl; -import com.sun.tools.javac.tree.JCTree.JCNewClass; -import com.sun.tools.javac.tree.JCTree.JCReturn; -import com.sun.tools.javac.tree.JCTree.JCStatement; -import com.sun.tools.javac.tree.JCTree.JCTypeParameter; -import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; -import com.sun.tools.javac.util.List; -import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Name; - -/** - * Handles the {@code lombok.experimental.Wither} annotation for javac. - */ -@ProviderFor(JavacAnnotationHandler.class) -public class HandleWither extends JavacAnnotationHandler { - public void generateWitherForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelWither) { - if (checkForTypeLevelWither) { - if (hasAnnotation(Wither.class, typeNode)) { - //The annotation will make it happen, so we can skip it. - return; - } - } - - JCClassDecl typeDecl = null; - if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get(); - long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags; - boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0; - - if (typeDecl == null || notAClass) { - errorNode.addError("@Wither is only supported on a class or a field."); - return; - } - - for (JavacNode field : typeNode.down()) { - if (field.getKind() != Kind.FIELD) continue; - JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); - //Skip fields that start with $ - if (fieldDecl.name.toString().startsWith("$")) continue; - //Skip static fields. - if ((fieldDecl.mods.flags & Flags.STATIC) != 0) continue; - //Skip final initialized fields. - if ((fieldDecl.mods.flags & Flags.FINAL) != 0 && fieldDecl.init != null) continue; - - generateWitherForField(field, errorNode.get(), level); - } - } - - /** - * Generates a wither on the stated field. - * - * Used by {@link HandleValue}. - * - * The difference between this call and the handle method is as follows: - * - * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the - * same rules apply (e.g. warning if the method already exists, stated access level applies). - * If not, the wither is still generated if it isn't already there, though there will not - * be a warning if its already there. The default access level is used. - * - * @param fieldNode The node representing the field you want a wither for. - * @param pos The node responsible for generating the wither (the {@code @Value} or {@code @Wither} annotation). - */ - public void generateWitherForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) { - if (hasAnnotation(Wither.class, fieldNode)) { - //The annotation will make it happen, so we can skip it. - return; - } - - createWitherForField(level, fieldNode, fieldNode, false, List.nil(), List.nil()); - } - - @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither"); - - Collection fields = annotationNode.upFromAnnotationToFields(); - deleteAnnotationIfNeccessary(annotationNode, Wither.class); - deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel"); - JavacNode node = annotationNode.up(); - AccessLevel level = annotation.getInstance().value(); - - if (level == AccessLevel.NONE || node == null) return; - - List onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod", annotationNode); - List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam", annotationNode); - - switch (node.getKind()) { - case FIELD: - createWitherForFields(level, fields, annotationNode, true, onMethod, onParam); - break; - case TYPE: - if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Wither on a type."); - if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Wither on a type."); - generateWitherForType(node, annotationNode, level, false); - break; - } - } - - public void createWitherForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { - for (JavacNode fieldNode : fieldNodes) { - createWitherForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); - } - } - - public void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean strictMode, List onMethod, List onParam) { - JavacNode typeNode = fieldNode.up(); - boolean makeAbstract = typeNode != null && typeNode.getKind() == Kind.TYPE && (((JCClassDecl) typeNode.get()).mods.flags & Flags.ABSTRACT) != 0; - - if (fieldNode.getKind() != Kind.FIELD) { - fieldNode.addError("@Wither is only supported on a class or a field."); - return; - } - - JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get(); - String methodName = toWitherName(fieldNode); - - if (methodName == null) { - fieldNode.addWarning("Not generating wither for this field: It does not fit your @Accessors prefix list."); - return; - } - - if ((fieldDecl.mods.flags & Flags.STATIC) != 0) { - if (strictMode) { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for static fields."); - } - return; - } - - if ((fieldDecl.mods.flags & Flags.FINAL) != 0 && fieldDecl.init != null) { - if (strictMode) { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for final, initialized fields."); - } - return; - } - - if (fieldDecl.name.toString().startsWith("$")) { - if (strictMode) { - fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for fields starting with $."); - } - return; - } - - for (String altName : toAllWitherNames(fieldNode)) { - switch (methodExists(altName, fieldNode, false, 1)) { - case EXISTS_BY_LOMBOK: - return; - case EXISTS_BY_USER: - if (strictMode) { - String altNameExpl = ""; - if (!altName.equals(methodName)) altNameExpl = String.format(" (%s)", altName); - fieldNode.addWarning( - String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl)); - } - return; - default: - case NOT_EXISTS: - //continue scanning the other alt names. - } - } - - long access = toJavacModifier(level); - - JCMethodDecl createdWither = createWither(access, fieldNode, fieldNode.getTreeMaker(), source, onMethod, onParam, makeAbstract); - ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym; - Type returnType = sym == null ? null : sym.type; - - injectMethod(typeNode, createdWither, List.of(getMirrorForFieldType(fieldNode)), returnType); - } - - public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List onMethod, List onParam, boolean makeAbstract) { - String witherName = toWitherName(field); - if (witherName == null) return null; - - JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); - - List copyableAnnotations = findCopyableAnnotations(field); - - Name methodName = field.toName(witherName); - - JCExpression returnType = cloneSelfType(field); - - JCBlock methodBody = null; - long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext()); - List annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations); - - JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null); - - if (!makeAbstract) { - ListBuffer statements = new ListBuffer(); - - JCExpression selfType = cloneSelfType(field); - if (selfType == null) return null; - - ListBuffer args = new ListBuffer(); - for (JavacNode child : field.up().down()) { - if (child.getKind() != Kind.FIELD) continue; - JCVariableDecl childDecl = (JCVariableDecl) child.get(); - // Skip fields that start with $ - if (childDecl.name.toString().startsWith("$")) continue; - long fieldFlags = childDecl.mods.flags; - // Skip static fields. - if ((fieldFlags & Flags.STATIC) != 0) continue; - // Skip initialized final fields. - if (((fieldFlags & Flags.FINAL) != 0) && childDecl.init != null) continue; - if (child.get() == field.get()) { - args.append(maker.Ident(fieldDecl.name)); - } else { - args.append(createFieldAccessor(maker, child, FieldAccess.ALWAYS_FIELD)); - } - } - - JCNewClass newClass = maker.NewClass(null, List.nil(), selfType, args.toList(), null); - JCExpression identityCheck = maker.Binary(CTC_EQUAL, createFieldAccessor(maker, field, FieldAccess.ALWAYS_FIELD), maker.Ident(fieldDecl.name)); - JCConditional conditional = maker.Conditional(identityCheck, maker.Ident(field.toName("this")), newClass); - JCReturn returnStatement = maker.Return(conditional); - - if (!hasNonNullAnnotations(field)) { - statements.append(returnStatement); - } else { - JCStatement nullCheck = generateNullCheck(maker, field, source); - if (nullCheck != null) statements.append(nullCheck); - statements.append(returnStatement); - } - - methodBody = maker.Block(0, statements.toList()); - } - List methodGenericParams = List.nil(); - List parameters = List.of(param); - List throwsClauses = List.nil(); - JCExpression annotationMethodDefaultValue = null; - - List annsOnMethod = copyAnnotations(onMethod); - CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(source); - if (checkerFramework.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.nil())); - - if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.nil())); - - if (makeAbstract) access = access | Flags.ABSTRACT; - JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType, - methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext()); - copyJavadoc(field, decl, CopyJavadoc.WITHER); - return decl; - } -} diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index f23a894a..d12a980f 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -590,20 +590,20 @@ public class JavacHandlerUtil { } /** - * Translates the given field into all possible wither names. - * Convenient wrapper around {@link TransformationsUtil#toAllWitherNames(lombok.core.AnnotationValues, CharSequence, boolean)}. + * Translates the given field into all possible with names. + * Convenient wrapper around {@link TransformationsUtil#toAllWithNames(lombok.core.AnnotationValues, CharSequence, boolean)}. */ - public static java.util.List toAllWitherNames(JavacNode field) { - return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean(field)); + public static java.util.List toAllWithNames(JavacNode field) { + return HandlerUtil.toAllWithNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean(field)); } /** - * @return the likely wither name for the stated field. (e.g. private boolean foo; to withFoo). + * @return the likely with name for the stated field. (e.g. private boolean foo; to withFoo). * - * Convenient wrapper around {@link TransformationsUtil#toWitherName(lombok.core.AnnotationValues, CharSequence, boolean)}. + * Convenient wrapper around {@link TransformationsUtil#toWithName(lombok.core.AnnotationValues, CharSequence, boolean)}. */ - public static String toWitherName(JavacNode field) { - return HandlerUtil.toWitherName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean(field)); + public static String toWithName(JavacNode field) { + return HandlerUtil.toWithName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean(field)); } /** @@ -1883,7 +1883,7 @@ public class JavacHandlerUtil { return (JCExpression) in; } - private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITHER)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITH(?:ER)?)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); public static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) { Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); @@ -1898,12 +1898,18 @@ public class JavacHandlerUtil { return javadoc.substring(0, m.start()); } - public static String getJavadocSection(String javadoc, String sectionName) { + public static String getJavadocSection(String javadoc, String sectionNameSpec) { + String[] sectionNames = sectionNameSpec.split("\\|"); Matcher m = SECTION_FINDER.matcher(javadoc); int sectionStart = -1; int sectionEnd = -1; while (m.find()) { - if (m.group(1).equalsIgnoreCase(sectionName)) { + boolean found = false; + for (String sectionName : sectionNames) if (m.group(1).equalsIgnoreCase(sectionName)) { + found = true; + break; + } + if (found) { sectionStart = m.end() + 1; } else if (sectionStart != -1) { sectionEnd = m.start(); @@ -1953,9 +1959,9 @@ public class JavacHandlerUtil { return applySetter(cu, node, "SETTER"); } }, - WITHER { + WITH { @Override public String apply(final JCCompilationUnit cu, final JavacNode node) { - return applySetter(cu, node, "WITHER"); + return applySetter(cu, node, "WITH|WITHER"); } }; diff --git a/test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java b/test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java new file mode 100644 index 00000000..97524b9d --- /dev/null +++ b/test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java @@ -0,0 +1,46 @@ +class SetterAndWithMethodJavadoc { + /** + * Some value. + */ + int i; + /** + * Some other value. + */ + int j; + SetterAndWithMethodJavadoc(int i, int j) { + this.i = i; + this.j = j; + } + /** + * Some value. + * @param the new value + */ + @java.lang.SuppressWarnings("all") + public void setI(final int i) { + this.i = i; + } + /** + * Some value. + * @param the new value + */ + @java.lang.SuppressWarnings("all") + public SetterAndWithMethodJavadoc withI(final int i) { + return this.i == i ? this : new SetterAndWithMethodJavadoc(i, this.j); + } + /** + * Set some other value. + * @param the new other value + */ + @java.lang.SuppressWarnings("all") + public void setJ(final int j) { + this.j = j; + } + /** + * Reinstantiate with some other value. + * @param the other new other value + */ + @java.lang.SuppressWarnings("all") + public SetterAndWithMethodJavadoc withJ(final int j) { + return this.j == j ? this : new SetterAndWithMethodJavadoc(this.i, j); + } +} diff --git a/test/transform/resource/after-delombok/SetterAndWitherJavadoc.java b/test/transform/resource/after-delombok/SetterAndWitherJavadoc.java deleted file mode 100644 index 8c0505e7..00000000 --- a/test/transform/resource/after-delombok/SetterAndWitherJavadoc.java +++ /dev/null @@ -1,46 +0,0 @@ -class SetterAndWitherJavadoc { - /** - * Some value. - */ - int i; - /** - * Some other value. - */ - int j; - SetterAndWitherJavadoc(int i, int j) { - this.i = i; - this.j = j; - } - /** - * Some value. - * @param the new value - */ - @java.lang.SuppressWarnings("all") - public void setI(final int i) { - this.i = i; - } - /** - * Some value. - * @param the new value - */ - @java.lang.SuppressWarnings("all") - public SetterAndWitherJavadoc withI(final int i) { - return this.i == i ? this : new SetterAndWitherJavadoc(i, this.j); - } - /** - * Set some other value. - * @param the new other value - */ - @java.lang.SuppressWarnings("all") - public void setJ(final int j) { - this.j = j; - } - /** - * Reinstantiate with some other value. - * @param the other new other value - */ - @java.lang.SuppressWarnings("all") - public SetterAndWitherJavadoc withJ(final int j) { - return this.j == j ? this : new SetterAndWitherJavadoc(this.i, j); - } -} diff --git a/test/transform/resource/after-delombok/WithAlreadyExists.java b/test/transform/resource/after-delombok/WithAlreadyExists.java new file mode 100644 index 00000000..a9cb975d --- /dev/null +++ b/test/transform/resource/after-delombok/WithAlreadyExists.java @@ -0,0 +1,71 @@ +class With1 { + boolean foo; + void withFoo(boolean foo) { + } + With1(boolean foo) { + } +} +class With2 { + boolean foo; + void withFoo(String foo) { + } + With2(boolean foo) { + } +} +class With3 { + String foo; + void withFoo(boolean foo) { + } + With3(String foo) { + } +} +class With4 { + String foo; + void withFoo(String foo) { + } + With4(String foo) { + } +} +class With5 { + String foo; + void withFoo() { + } + With5(String foo) { + } + @java.lang.SuppressWarnings("all") + public With5 withFoo(final String foo) { + return this.foo == foo ? this : new With5(foo); + } +} +class With6 { + String foo; + void withFoo(String foo, int x) { + } + With6(String foo) { + } + @java.lang.SuppressWarnings("all") + public With6 withFoo(final String foo) { + return this.foo == foo ? this : new With6(foo); + } +} +class With7 { + String foo; + void withFoo(String foo, Object... x) { + } + With7(String foo) { + } +} +class With8 { + boolean isFoo; + void withIsFoo(boolean foo) { + } + With8(boolean foo) { + } +} +class With9 { + boolean isFoo; + void withFoo(boolean foo) { + } + With9(boolean foo) { + } +} diff --git a/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java b/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java new file mode 100644 index 00000000..131e792c --- /dev/null +++ b/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java @@ -0,0 +1,22 @@ +class WithAndAllArgsConstructor { + J test; + java.util.List test2; + final int x = 10; + int y = 20; + final int z; + @java.lang.SuppressWarnings("all") + public WithAndAllArgsConstructor(final J test, final java.util.List test2, final int y, final int z) { + this.test = test; + this.test2 = test2; + this.y = y; + this.z = z; + } + @java.lang.SuppressWarnings("all") + public WithAndAllArgsConstructor withTest(final J test) { + return this.test == test ? this : new WithAndAllArgsConstructor(test, this.test2, this.y, this.z); + } + @java.lang.SuppressWarnings("all") + public WithAndAllArgsConstructor withTest2(final java.util.List test2) { + return this.test2 == test2 ? this : new WithAndAllArgsConstructor(this.test, test2, this.y, this.z); + } +} diff --git a/test/transform/resource/after-delombok/WithMethodAbstract.java b/test/transform/resource/after-delombok/WithMethodAbstract.java new file mode 100644 index 00000000..16f6f060 --- /dev/null +++ b/test/transform/resource/after-delombok/WithMethodAbstract.java @@ -0,0 +1,5 @@ +abstract class WithMethodAbstract { + String foo; + @java.lang.SuppressWarnings("all") + public abstract WithMethodAbstract withFoo(final String foo); +} diff --git a/test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java b/test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java new file mode 100644 index 00000000..03b96d33 --- /dev/null +++ b/test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java @@ -0,0 +1,23 @@ +class WithMethodMarkedDeprecated { + @Deprecated + int annotation; + /** + * @deprecated + */ + int javadoc; + WithMethodMarkedDeprecated(int annotation, int javadoc) { + } + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public WithMethodMarkedDeprecated withAnnotation(final int annotation) { + return this.annotation == annotation ? this : new WithMethodMarkedDeprecated(annotation, this.javadoc); + } + /** + * @deprecated + */ + @java.lang.Deprecated + @java.lang.SuppressWarnings("all") + public WithMethodMarkedDeprecated withJavadoc(final int javadoc) { + return this.javadoc == javadoc ? this : new WithMethodMarkedDeprecated(this.annotation, javadoc); + } +} diff --git a/test/transform/resource/after-delombok/WithOnClass.java b/test/transform/resource/after-delombok/WithOnClass.java new file mode 100644 index 00000000..d6fb6fdf --- /dev/null +++ b/test/transform/resource/after-delombok/WithOnClass.java @@ -0,0 +1,54 @@ +class WithOnClass1 { + boolean isNone; + boolean isPublic; + WithOnClass1(boolean isNone, boolean isPublic) { + } + @java.lang.SuppressWarnings("all") + public WithOnClass1 withPublic(final boolean isPublic) { + return this.isPublic == isPublic ? this : new WithOnClass1(this.isNone, isPublic); + } +} +class WithOnClass2 { + boolean isNone; + boolean isProtected; + boolean isPackage; + WithOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { + } + @java.lang.SuppressWarnings("all") + protected WithOnClass2 withProtected(final boolean isProtected) { + return this.isProtected == isProtected ? this : new WithOnClass2(this.isNone, isProtected, this.isPackage); + } + @java.lang.SuppressWarnings("all") + WithOnClass2 withPackage(final boolean isPackage) { + return this.isPackage == isPackage ? this : new WithOnClass2(this.isNone, this.isProtected, isPackage); + } +} +class WithOnClass3 { + String couldBeNull; + @lombok.NonNull + String nonNull; + WithOnClass3(String couldBeNull, String nonNull) { + } + @java.lang.SuppressWarnings("all") + public WithOnClass3 withCouldBeNull(final String couldBeNull) { + return this.couldBeNull == couldBeNull ? this : new WithOnClass3(couldBeNull, this.nonNull); + } + @java.lang.SuppressWarnings("all") + public WithOnClass3 withNonNull(@lombok.NonNull final String nonNull) { + if (nonNull == null) { + throw new java.lang.NullPointerException("nonNull is marked non-null but is null"); + } + return this.nonNull == nonNull ? this : new WithOnClass3(this.couldBeNull, nonNull); + } +} +class WithOnClass4 { + final int fX = 10; + final int fY; + WithOnClass4(int y) { + this.fY = y; + } + @java.lang.SuppressWarnings("all") + public WithOnClass4 withY(final int fY) { + return this.fY == fY ? this : new WithOnClass4(fY); + } +} diff --git a/test/transform/resource/after-delombok/WithOnStatic.java b/test/transform/resource/after-delombok/WithOnStatic.java new file mode 100644 index 00000000..b234f0d6 --- /dev/null +++ b/test/transform/resource/after-delombok/WithOnStatic.java @@ -0,0 +1,4 @@ +class WithOnStatic { + static boolean foo; + static int bar; +} diff --git a/test/transform/resource/after-delombok/WithPlain.java b/test/transform/resource/after-delombok/WithPlain.java new file mode 100644 index 00000000..1a6ff22f --- /dev/null +++ b/test/transform/resource/after-delombok/WithPlain.java @@ -0,0 +1,16 @@ +class WithPlain { + int i; + final int foo; + WithPlain(int i, int foo) { + this.i = i; + this.foo = foo; + } + @java.lang.SuppressWarnings("all") + public WithPlain withI(final int i) { + return this.i == i ? this : new WithPlain(i, this.foo); + } + @java.lang.SuppressWarnings("all") + public WithPlain withFoo(final int foo) { + return this.foo == foo ? this : new WithPlain(this.i, foo); + } +} diff --git a/test/transform/resource/after-delombok/WithWithDollar.java b/test/transform/resource/after-delombok/WithWithDollar.java new file mode 100644 index 00000000..79abcc12 --- /dev/null +++ b/test/transform/resource/after-delombok/WithWithDollar.java @@ -0,0 +1,3 @@ +class WithWithDollar { + int $i; +} diff --git a/test/transform/resource/after-delombok/WithWithGenerics.java b/test/transform/resource/after-delombok/WithWithGenerics.java new file mode 100644 index 00000000..ac34f01a --- /dev/null +++ b/test/transform/resource/after-delombok/WithWithGenerics.java @@ -0,0 +1,20 @@ +class WithWithGenerics { + J test; + java.util.List test2; + java.util.List test3; + int $i; + public WithWithGenerics(J test, java.util.List test2, java.util.List test3) { + } + @java.lang.SuppressWarnings("all") + public WithWithGenerics withTest(final J test) { + return this.test == test ? this : new WithWithGenerics(test, this.test2, this.test3); + } + @java.lang.SuppressWarnings("all") + public WithWithGenerics withTest2(final java.util.List test2) { + return this.test2 == test2 ? this : new WithWithGenerics(this.test, test2, this.test3); + } + @java.lang.SuppressWarnings("all") + public WithWithGenerics withTest3(final java.util.List test3) { + return this.test3 == test3 ? this : new WithWithGenerics(this.test, this.test2, test3); + } +} diff --git a/test/transform/resource/after-delombok/WithWithTypeAnnos.java b/test/transform/resource/after-delombok/WithWithTypeAnnos.java new file mode 100644 index 00000000..bf7559ba --- /dev/null +++ b/test/transform/resource/after-delombok/WithWithTypeAnnos.java @@ -0,0 +1,21 @@ +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TB { +} +class WithWithTypeAnnos { + @TA + @TB + final List foo; + WithWithTypeAnnos(@TA @TB List foo) { + this.foo = foo; + } + @java.lang.SuppressWarnings("all") + public WithWithTypeAnnos withFoo(@TA final List foo) { + return this.foo == foo ? this : new WithWithTypeAnnos(foo); + } +} diff --git a/test/transform/resource/after-delombok/WitherAlreadyExists.java b/test/transform/resource/after-delombok/WitherAlreadyExists.java deleted file mode 100644 index d609bc7b..00000000 --- a/test/transform/resource/after-delombok/WitherAlreadyExists.java +++ /dev/null @@ -1,71 +0,0 @@ -class Wither1 { - boolean foo; - void withFoo(boolean foo) { - } - Wither1(boolean foo) { - } -} -class Wither2 { - boolean foo; - void withFoo(String foo) { - } - Wither2(boolean foo) { - } -} -class Wither3 { - String foo; - void withFoo(boolean foo) { - } - Wither3(String foo) { - } -} -class Wither4 { - String foo; - void withFoo(String foo) { - } - Wither4(String foo) { - } -} -class Wither5 { - String foo; - void withFoo() { - } - Wither5(String foo) { - } - @java.lang.SuppressWarnings("all") - public Wither5 withFoo(final String foo) { - return this.foo == foo ? this : new Wither5(foo); - } -} -class Wither6 { - String foo; - void withFoo(String foo, int x) { - } - Wither6(String foo) { - } - @java.lang.SuppressWarnings("all") - public Wither6 withFoo(final String foo) { - return this.foo == foo ? this : new Wither6(foo); - } -} -class Wither7 { - String foo; - void withFoo(String foo, Object... x) { - } - Wither7(String foo) { - } -} -class Wither8 { - boolean isFoo; - void withIsFoo(boolean foo) { - } - Wither8(boolean foo) { - } -} -class Wither9 { - boolean isFoo; - void withFoo(boolean foo) { - } - Wither9(boolean foo) { - } -} diff --git a/test/transform/resource/after-delombok/WitherAndAllArgsConstructor.java b/test/transform/resource/after-delombok/WitherAndAllArgsConstructor.java deleted file mode 100644 index ff4fe3e2..00000000 --- a/test/transform/resource/after-delombok/WitherAndAllArgsConstructor.java +++ /dev/null @@ -1,22 +0,0 @@ -class WitherAndAllArgsConstructor { - J test; - java.util.List test2; - final int x = 10; - int y = 20; - final int z; - @java.lang.SuppressWarnings("all") - public WitherAndAllArgsConstructor(final J test, final java.util.List test2, final int y, final int z) { - this.test = test; - this.test2 = test2; - this.y = y; - this.z = z; - } - @java.lang.SuppressWarnings("all") - public WitherAndAllArgsConstructor withTest(final J test) { - return this.test == test ? this : new WitherAndAllArgsConstructor(test, this.test2, this.y, this.z); - } - @java.lang.SuppressWarnings("all") - public WitherAndAllArgsConstructor withTest2(final java.util.List test2) { - return this.test2 == test2 ? this : new WitherAndAllArgsConstructor(this.test, test2, this.y, this.z); - } -} diff --git a/test/transform/resource/after-delombok/WitherDeprecated.java b/test/transform/resource/after-delombok/WitherDeprecated.java deleted file mode 100644 index b342a861..00000000 --- a/test/transform/resource/after-delombok/WitherDeprecated.java +++ /dev/null @@ -1,23 +0,0 @@ -class WitherDeprecated { - @Deprecated - int annotation; - /** - * @deprecated - */ - int javadoc; - WitherDeprecated(int annotation, int javadoc) { - } - @java.lang.Deprecated - @java.lang.SuppressWarnings("all") - public WitherDeprecated withAnnotation(final int annotation) { - return this.annotation == annotation ? this : new WitherDeprecated(annotation, this.javadoc); - } - /** - * @deprecated - */ - @java.lang.Deprecated - @java.lang.SuppressWarnings("all") - public WitherDeprecated withJavadoc(final int javadoc) { - return this.javadoc == javadoc ? this : new WitherDeprecated(this.annotation, javadoc); - } -} diff --git a/test/transform/resource/after-delombok/WitherOnClass.java b/test/transform/resource/after-delombok/WitherOnClass.java deleted file mode 100644 index abc93446..00000000 --- a/test/transform/resource/after-delombok/WitherOnClass.java +++ /dev/null @@ -1,54 +0,0 @@ -class WitherOnClass1 { - boolean isNone; - boolean isPublic; - WitherOnClass1(boolean isNone, boolean isPublic) { - } - @java.lang.SuppressWarnings("all") - public WitherOnClass1 withPublic(final boolean isPublic) { - return this.isPublic == isPublic ? this : new WitherOnClass1(this.isNone, isPublic); - } -} -class WitherOnClass2 { - boolean isNone; - boolean isProtected; - boolean isPackage; - WitherOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { - } - @java.lang.SuppressWarnings("all") - protected WitherOnClass2 withProtected(final boolean isProtected) { - return this.isProtected == isProtected ? this : new WitherOnClass2(this.isNone, isProtected, this.isPackage); - } - @java.lang.SuppressWarnings("all") - WitherOnClass2 withPackage(final boolean isPackage) { - return this.isPackage == isPackage ? this : new WitherOnClass2(this.isNone, this.isProtected, isPackage); - } -} -class WitherOnClass3 { - String couldBeNull; - @lombok.NonNull - String nonNull; - WitherOnClass3(String couldBeNull, String nonNull) { - } - @java.lang.SuppressWarnings("all") - public WitherOnClass3 withCouldBeNull(final String couldBeNull) { - return this.couldBeNull == couldBeNull ? this : new WitherOnClass3(couldBeNull, this.nonNull); - } - @java.lang.SuppressWarnings("all") - public WitherOnClass3 withNonNull(@lombok.NonNull final String nonNull) { - if (nonNull == null) { - throw new java.lang.NullPointerException("nonNull is marked non-null but is null"); - } - return this.nonNull == nonNull ? this : new WitherOnClass3(this.couldBeNull, nonNull); - } -} -class WitherOnClass4 { - final int fX = 10; - final int fY; - WitherOnClass4(int y) { - this.fY = y; - } - @java.lang.SuppressWarnings("all") - public WitherOnClass4 withY(final int fY) { - return this.fY == fY ? this : new WitherOnClass4(fY); - } -} diff --git a/test/transform/resource/after-delombok/WitherOnStatic.java b/test/transform/resource/after-delombok/WitherOnStatic.java deleted file mode 100644 index e481beb7..00000000 --- a/test/transform/resource/after-delombok/WitherOnStatic.java +++ /dev/null @@ -1,4 +0,0 @@ -class WitherOnStatic { - static boolean foo; - static int bar; -} diff --git a/test/transform/resource/after-delombok/WitherPlain.java b/test/transform/resource/after-delombok/WitherPlain.java deleted file mode 100644 index a2e947bd..00000000 --- a/test/transform/resource/after-delombok/WitherPlain.java +++ /dev/null @@ -1,16 +0,0 @@ -class WitherPlain { - int i; - final int foo; - WitherPlain(int i, int foo) { - this.i = i; - this.foo = foo; - } - @java.lang.SuppressWarnings("all") - public WitherPlain withI(final int i) { - return this.i == i ? this : new WitherPlain(i, this.foo); - } - @java.lang.SuppressWarnings("all") - public WitherPlain withFoo(final int foo) { - return this.foo == foo ? this : new WitherPlain(this.i, foo); - } -} diff --git a/test/transform/resource/after-delombok/WitherTypeAnnos.java b/test/transform/resource/after-delombok/WitherTypeAnnos.java deleted file mode 100644 index b57438af..00000000 --- a/test/transform/resource/after-delombok/WitherTypeAnnos.java +++ /dev/null @@ -1,21 +0,0 @@ -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; -import java.util.List; -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) -@interface TA { -} -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) -@interface TB { -} -class WitherTypeAnnos { - @TA - @TB - final List foo; - WitherTypeAnnos(@TA @TB List foo) { - this.foo = foo; - } - @java.lang.SuppressWarnings("all") - public WitherTypeAnnos withFoo(@TA final List foo) { - return this.foo == foo ? this : new WitherTypeAnnos(foo); - } -} diff --git a/test/transform/resource/after-delombok/WitherWithAbstract.java b/test/transform/resource/after-delombok/WitherWithAbstract.java deleted file mode 100644 index f9178e99..00000000 --- a/test/transform/resource/after-delombok/WitherWithAbstract.java +++ /dev/null @@ -1,5 +0,0 @@ -abstract class WitherWithAbstract { - String foo; - @java.lang.SuppressWarnings("all") - public abstract WitherWithAbstract withFoo(final String foo); -} diff --git a/test/transform/resource/after-delombok/WitherWithDollar.java b/test/transform/resource/after-delombok/WitherWithDollar.java deleted file mode 100644 index 066f3fb5..00000000 --- a/test/transform/resource/after-delombok/WitherWithDollar.java +++ /dev/null @@ -1,3 +0,0 @@ -class WitherWithDollar { - int $i; -} diff --git a/test/transform/resource/after-delombok/WitherWithGenerics.java b/test/transform/resource/after-delombok/WitherWithGenerics.java deleted file mode 100644 index 98bbd04d..00000000 --- a/test/transform/resource/after-delombok/WitherWithGenerics.java +++ /dev/null @@ -1,20 +0,0 @@ -class WitherWithGenerics { - J test; - java.util.List test2; - java.util.List test3; - int $i; - public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { - } - @java.lang.SuppressWarnings("all") - public WitherWithGenerics withTest(final J test) { - return this.test == test ? this : new WitherWithGenerics(test, this.test2, this.test3); - } - @java.lang.SuppressWarnings("all") - public WitherWithGenerics withTest2(final java.util.List test2) { - return this.test2 == test2 ? this : new WitherWithGenerics(this.test, test2, this.test3); - } - @java.lang.SuppressWarnings("all") - public WitherWithGenerics withTest3(final java.util.List test3) { - return this.test3 == test3 ? this : new WitherWithGenerics(this.test, this.test2, test3); - } -} diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java index 03313c6d..25b28c4b 100644 --- a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java +++ b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java @@ -1,8 +1,8 @@ import lombok.Data; import lombok.experimental.Accessors; -import lombok.experimental.Wither; +import lombok.With; @Data @Accessors(chain = true) class CheckerFrameworkBasic { - private final @Wither int x; + private final @With int x; private final int y; private int z; public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBasic withX(final int x) { diff --git a/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java new file mode 100644 index 00000000..dd64e358 --- /dev/null +++ b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java @@ -0,0 +1,22 @@ +import lombok.With; +class SetterAndWithMethodJavadoc { + @lombok.Setter @lombok.With int i; + @lombok.Setter @lombok.With int j; + SetterAndWithMethodJavadoc(int i, int j) { + super(); + this.i = i; + this.j = j; + } + public @java.lang.SuppressWarnings("all") void setI(final int i) { + this.i = i; + } + public @java.lang.SuppressWarnings("all") SetterAndWithMethodJavadoc withI(final int i) { + return ((this.i == i) ? this : new SetterAndWithMethodJavadoc(i, this.j)); + } + public @java.lang.SuppressWarnings("all") void setJ(final int j) { + this.j = j; + } + public @java.lang.SuppressWarnings("all") SetterAndWithMethodJavadoc withJ(final int j) { + return ((this.j == j) ? this : new SetterAndWithMethodJavadoc(this.i, j)); + } +} diff --git a/test/transform/resource/after-ecj/SetterAndWitherJavadoc.java b/test/transform/resource/after-ecj/SetterAndWitherJavadoc.java deleted file mode 100644 index 623277a0..00000000 --- a/test/transform/resource/after-ecj/SetterAndWitherJavadoc.java +++ /dev/null @@ -1,22 +0,0 @@ -import lombok.experimental.Wither; -class SetterAndWitherJavadoc { - @lombok.Setter @lombok.experimental.Wither int i; - @lombok.Setter @lombok.experimental.Wither int j; - SetterAndWitherJavadoc(int i, int j) { - super(); - this.i = i; - this.j = j; - } - public @java.lang.SuppressWarnings("all") void setI(final int i) { - this.i = i; - } - public @java.lang.SuppressWarnings("all") SetterAndWitherJavadoc withI(final int i) { - return ((this.i == i) ? this : new SetterAndWitherJavadoc(i, this.j)); - } - public @java.lang.SuppressWarnings("all") void setJ(final int j) { - this.j = j; - } - public @java.lang.SuppressWarnings("all") SetterAndWitherJavadoc withJ(final int j) { - return ((this.j == j) ? this : new SetterAndWitherJavadoc(this.i, j)); - } -} diff --git a/test/transform/resource/after-ecj/WithAlreadyExists.java b/test/transform/resource/after-ecj/WithAlreadyExists.java new file mode 100644 index 00000000..a868cde5 --- /dev/null +++ b/test/transform/resource/after-ecj/WithAlreadyExists.java @@ -0,0 +1,78 @@ +class With1 { + @lombok.With boolean foo; + void withFoo(boolean foo) { + } + With1(boolean foo) { + super(); + } +} +class With2 { + @lombok.With boolean foo; + void withFoo(String foo) { + } + With2(boolean foo) { + super(); + } +} +class With3 { + @lombok.With String foo; + void withFoo(boolean foo) { + } + With3(String foo) { + super(); + } +} +class With4 { + @lombok.With String foo; + void withFoo(String foo) { + } + With4(String foo) { + super(); + } +} +class With5 { + @lombok.With String foo; + void withFoo() { + } + With5(String foo) { + super(); + } + public @java.lang.SuppressWarnings("all") With5 withFoo(final String foo) { + return ((this.foo == foo) ? this : new With5(foo)); + } +} +class With6 { + @lombok.With String foo; + void withFoo(String foo, int x) { + } + With6(String foo) { + super(); + } + public @java.lang.SuppressWarnings("all") With6 withFoo(final String foo) { + return ((this.foo == foo) ? this : new With6(foo)); + } +} +class With7 { + @lombok.With String foo; + void withFoo(String foo, Object... x) { + } + With7(String foo) { + super(); + } +} +class With8 { + @lombok.With boolean isFoo; + void withIsFoo(boolean foo) { + } + With8(boolean foo) { + super(); + } +} +class With9 { + @lombok.With boolean isFoo; + void withFoo(boolean foo) { + } + With9(boolean foo) { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java b/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java new file mode 100644 index 00000000..d3fcded2 --- /dev/null +++ b/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java @@ -0,0 +1,20 @@ +@lombok.AllArgsConstructor class WithAndAllArgsConstructor { + @lombok.With J test; + @lombok.With java.util.List test2; + final int x = 10; + int y = 20; + final int z; + public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor withTest(final J test) { + return ((this.test == test) ? this : new WithAndAllArgsConstructor(test, this.test2, this.y, this.z)); + } + public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor withTest2(final java.util.List test2) { + return ((this.test2 == test2) ? this : new WithAndAllArgsConstructor(this.test, test2, this.y, this.z)); + } + public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor(final J test, final java.util.List test2, final int y, final int z) { + super(); + this.test = test; + this.test2 = test2; + this.y = y; + this.z = z; + } +} diff --git a/test/transform/resource/after-ecj/WithMethodAbstract.java b/test/transform/resource/after-ecj/WithMethodAbstract.java new file mode 100644 index 00000000..cb71357a --- /dev/null +++ b/test/transform/resource/after-ecj/WithMethodAbstract.java @@ -0,0 +1,7 @@ +abstract class WithMethodAbstract { + @lombok.With String foo; + WithMethodAbstract() { + super(); + } + public abstract @java.lang.SuppressWarnings("all") WithMethodAbstract withFoo(final String foo); +} diff --git a/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java b/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java new file mode 100644 index 00000000..cd123fe8 --- /dev/null +++ b/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java @@ -0,0 +1,14 @@ +import lombok.With; +class WithMethodMarkedDeprecated { + @Deprecated @With int annotation; + @With int javadoc; + WithMethodMarkedDeprecated(int annotation, int javadoc) { + super(); + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecated withAnnotation(final int annotation) { + return ((this.annotation == annotation) ? this : new WithMethodMarkedDeprecated(annotation, this.javadoc)); + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecated withJavadoc(final int javadoc) { + return ((this.javadoc == javadoc) ? this : new WithMethodMarkedDeprecated(this.annotation, javadoc)); + } +} diff --git a/test/transform/resource/after-ecj/WithOnClass.java b/test/transform/resource/after-ecj/WithOnClass.java new file mode 100644 index 00000000..ca3e8c6b --- /dev/null +++ b/test/transform/resource/after-ecj/WithOnClass.java @@ -0,0 +1,52 @@ +@lombok.With class WithOnClass1 { + @lombok.With(lombok.AccessLevel.NONE) boolean isNone; + boolean isPublic; + WithOnClass1(boolean isNone, boolean isPublic) { + super(); + } + public @java.lang.SuppressWarnings("all") WithOnClass1 withPublic(final boolean isPublic) { + return ((this.isPublic == isPublic) ? this : new WithOnClass1(this.isNone, isPublic)); + } +} +@lombok.With(lombok.AccessLevel.PROTECTED) class WithOnClass2 { + @lombok.With(lombok.AccessLevel.NONE) boolean isNone; + boolean isProtected; + @lombok.With(lombok.AccessLevel.PACKAGE) boolean isPackage; + WithOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { + super(); + } + @java.lang.SuppressWarnings("all") WithOnClass2 withPackage(final boolean isPackage) { + return ((this.isPackage == isPackage) ? this : new WithOnClass2(this.isNone, this.isProtected, isPackage)); + } + protected @java.lang.SuppressWarnings("all") WithOnClass2 withProtected(final boolean isProtected) { + return ((this.isProtected == isProtected) ? this : new WithOnClass2(this.isNone, isProtected, this.isPackage)); + } +} +@lombok.With class WithOnClass3 { + String couldBeNull; + @lombok.NonNull String nonNull; + WithOnClass3(String couldBeNull, String nonNull) { + super(); + } + public @java.lang.SuppressWarnings("all") WithOnClass3 withCouldBeNull(final String couldBeNull) { + return ((this.couldBeNull == couldBeNull) ? this : new WithOnClass3(couldBeNull, this.nonNull)); + } + public @java.lang.SuppressWarnings("all") WithOnClass3 withNonNull(final @lombok.NonNull String nonNull) { + if ((nonNull == null)) + { + throw new java.lang.NullPointerException("nonNull is marked non-null but is null"); + } + return ((this.nonNull == nonNull) ? this : new WithOnClass3(this.couldBeNull, nonNull)); + } +} +@lombok.With @lombok.experimental.Accessors(prefix = "f") class WithOnClass4 { + final int fX = 10; + final int fY; + WithOnClass4(int y) { + super(); + this.fY = y; + } + public @java.lang.SuppressWarnings("all") WithOnClass4 withY(final int fY) { + return ((this.fY == fY) ? this : new WithOnClass4(fY)); + } +} diff --git a/test/transform/resource/after-ecj/WithOnStatic.java b/test/transform/resource/after-ecj/WithOnStatic.java new file mode 100644 index 00000000..7094ae5e --- /dev/null +++ b/test/transform/resource/after-ecj/WithOnStatic.java @@ -0,0 +1,9 @@ +class WithOnStatic { + static @lombok.With boolean foo; + static @lombok.With int bar; + () { + } + WithOnStatic() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WithPlain.java b/test/transform/resource/after-ecj/WithPlain.java new file mode 100644 index 00000000..4203f540 --- /dev/null +++ b/test/transform/resource/after-ecj/WithPlain.java @@ -0,0 +1,16 @@ +import lombok.With; +class WithPlain { + @lombok.With int i; + final @With int foo; + WithPlain(int i, int foo) { + super(); + this.i = i; + this.foo = foo; + } + public @java.lang.SuppressWarnings("all") WithPlain withI(final int i) { + return ((this.i == i) ? this : new WithPlain(i, this.foo)); + } + public @java.lang.SuppressWarnings("all") WithPlain withFoo(final int foo) { + return ((this.foo == foo) ? this : new WithPlain(this.i, foo)); + } +} diff --git a/test/transform/resource/after-ecj/WithWithDollar.java b/test/transform/resource/after-ecj/WithWithDollar.java new file mode 100644 index 00000000..1fa830d4 --- /dev/null +++ b/test/transform/resource/after-ecj/WithWithDollar.java @@ -0,0 +1,6 @@ +class WithWithDollar { + @lombok.With int $i; + WithWithDollar() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WithWithGenerics.java b/test/transform/resource/after-ecj/WithWithGenerics.java new file mode 100644 index 00000000..b6985b99 --- /dev/null +++ b/test/transform/resource/after-ecj/WithWithGenerics.java @@ -0,0 +1,18 @@ +class WithWithGenerics { + @lombok.With J test; + @lombok.With java.util.List test2; + @lombok.With java.util.List test3; + int $i; + public WithWithGenerics(J test, java.util.List test2, java.util.List test3) { + super(); + } + public @java.lang.SuppressWarnings("all") WithWithGenerics withTest(final J test) { + return ((this.test == test) ? this : new WithWithGenerics(test, this.test2, this.test3)); + } + public @java.lang.SuppressWarnings("all") WithWithGenerics withTest2(final java.util.List test2) { + return ((this.test2 == test2) ? this : new WithWithGenerics(this.test, test2, this.test3)); + } + public @java.lang.SuppressWarnings("all") WithWithGenerics withTest3(final java.util.List test3) { + return ((this.test3 == test3) ? this : new WithWithGenerics(this.test, this.test2, test3)); + } +} diff --git a/test/transform/resource/after-ecj/WithWithTypeAnnos.java b/test/transform/resource/after-ecj/WithWithTypeAnnos.java new file mode 100644 index 00000000..ff73869b --- /dev/null +++ b/test/transform/resource/after-ecj/WithWithTypeAnnos.java @@ -0,0 +1,18 @@ +import lombok.With; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TB { +} +class WithWithTypeAnnos { + final @With @TA @TB List foo; + WithWithTypeAnnos(@TA @TB List foo) { + super(); + this.foo = foo; + } + public @java.lang.SuppressWarnings("all") WithWithTypeAnnos withFoo(final @TA List foo) { + return ((this.foo == foo) ? this : new WithWithTypeAnnos(foo)); + } +} diff --git a/test/transform/resource/after-ecj/WitherAlreadyExists.java b/test/transform/resource/after-ecj/WitherAlreadyExists.java deleted file mode 100644 index ded10755..00000000 --- a/test/transform/resource/after-ecj/WitherAlreadyExists.java +++ /dev/null @@ -1,78 +0,0 @@ -class Wither1 { - @lombok.experimental.Wither boolean foo; - void withFoo(boolean foo) { - } - Wither1(boolean foo) { - super(); - } -} -class Wither2 { - @lombok.experimental.Wither boolean foo; - void withFoo(String foo) { - } - Wither2(boolean foo) { - super(); - } -} -class Wither3 { - @lombok.experimental.Wither String foo; - void withFoo(boolean foo) { - } - Wither3(String foo) { - super(); - } -} -class Wither4 { - @lombok.experimental.Wither String foo; - void withFoo(String foo) { - } - Wither4(String foo) { - super(); - } -} -class Wither5 { - @lombok.experimental.Wither String foo; - void withFoo() { - } - Wither5(String foo) { - super(); - } - public @java.lang.SuppressWarnings("all") Wither5 withFoo(final String foo) { - return ((this.foo == foo) ? this : new Wither5(foo)); - } -} -class Wither6 { - @lombok.experimental.Wither String foo; - void withFoo(String foo, int x) { - } - Wither6(String foo) { - super(); - } - public @java.lang.SuppressWarnings("all") Wither6 withFoo(final String foo) { - return ((this.foo == foo) ? this : new Wither6(foo)); - } -} -class Wither7 { - @lombok.experimental.Wither String foo; - void withFoo(String foo, Object... x) { - } - Wither7(String foo) { - super(); - } -} -class Wither8 { - @lombok.experimental.Wither boolean isFoo; - void withIsFoo(boolean foo) { - } - Wither8(boolean foo) { - super(); - } -} -class Wither9 { - @lombok.experimental.Wither boolean isFoo; - void withFoo(boolean foo) { - } - Wither9(boolean foo) { - super(); - } -} diff --git a/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java b/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java deleted file mode 100644 index 10e993e1..00000000 --- a/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java +++ /dev/null @@ -1,20 +0,0 @@ -@lombok.AllArgsConstructor class WitherAndAllArgsConstructor { - @lombok.experimental.Wither J test; - @lombok.experimental.Wither java.util.List test2; - final int x = 10; - int y = 20; - final int z; - public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor withTest(final J test) { - return ((this.test == test) ? this : new WitherAndAllArgsConstructor(test, this.test2, this.y, this.z)); - } - public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor withTest2(final java.util.List test2) { - return ((this.test2 == test2) ? this : new WitherAndAllArgsConstructor(this.test, test2, this.y, this.z)); - } - public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor(final J test, final java.util.List test2, final int y, final int z) { - super(); - this.test = test; - this.test2 = test2; - this.y = y; - this.z = z; - } -} diff --git a/test/transform/resource/after-ecj/WitherDeprecated.java b/test/transform/resource/after-ecj/WitherDeprecated.java deleted file mode 100644 index b57d0d79..00000000 --- a/test/transform/resource/after-ecj/WitherDeprecated.java +++ /dev/null @@ -1,14 +0,0 @@ -import lombok.experimental.Wither; -class WitherDeprecated { - @Deprecated @Wither int annotation; - @Wither int javadoc; - WitherDeprecated(int annotation, int javadoc) { - super(); - } - public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WitherDeprecated withAnnotation(final int annotation) { - return ((this.annotation == annotation) ? this : new WitherDeprecated(annotation, this.javadoc)); - } - public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WitherDeprecated withJavadoc(final int javadoc) { - return ((this.javadoc == javadoc) ? this : new WitherDeprecated(this.annotation, javadoc)); - } -} diff --git a/test/transform/resource/after-ecj/WitherOnClass.java b/test/transform/resource/after-ecj/WitherOnClass.java deleted file mode 100644 index 166d1842..00000000 --- a/test/transform/resource/after-ecj/WitherOnClass.java +++ /dev/null @@ -1,52 +0,0 @@ -@lombok.experimental.Wither class WitherOnClass1 { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; - boolean isPublic; - WitherOnClass1(boolean isNone, boolean isPublic) { - super(); - } - public @java.lang.SuppressWarnings("all") WitherOnClass1 withPublic(final boolean isPublic) { - return ((this.isPublic == isPublic) ? this : new WitherOnClass1(this.isNone, isPublic)); - } -} -@lombok.experimental.Wither(lombok.AccessLevel.PROTECTED) class WitherOnClass2 { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; - boolean isProtected; - @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) boolean isPackage; - WitherOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { - super(); - } - @java.lang.SuppressWarnings("all") WitherOnClass2 withPackage(final boolean isPackage) { - return ((this.isPackage == isPackage) ? this : new WitherOnClass2(this.isNone, this.isProtected, isPackage)); - } - protected @java.lang.SuppressWarnings("all") WitherOnClass2 withProtected(final boolean isProtected) { - return ((this.isProtected == isProtected) ? this : new WitherOnClass2(this.isNone, isProtected, this.isPackage)); - } -} -@lombok.experimental.Wither class WitherOnClass3 { - String couldBeNull; - @lombok.NonNull String nonNull; - WitherOnClass3(String couldBeNull, String nonNull) { - super(); - } - public @java.lang.SuppressWarnings("all") WitherOnClass3 withCouldBeNull(final String couldBeNull) { - return ((this.couldBeNull == couldBeNull) ? this : new WitherOnClass3(couldBeNull, this.nonNull)); - } - public @java.lang.SuppressWarnings("all") WitherOnClass3 withNonNull(final @lombok.NonNull String nonNull) { - if ((nonNull == null)) - { - throw new java.lang.NullPointerException("nonNull is marked non-null but is null"); - } - return ((this.nonNull == nonNull) ? this : new WitherOnClass3(this.couldBeNull, nonNull)); - } -} -@lombok.experimental.Wither @lombok.experimental.Accessors(prefix = "f") class WitherOnClass4 { - final int fX = 10; - final int fY; - WitherOnClass4(int y) { - super(); - this.fY = y; - } - public @java.lang.SuppressWarnings("all") WitherOnClass4 withY(final int fY) { - return ((this.fY == fY) ? this : new WitherOnClass4(fY)); - } -} diff --git a/test/transform/resource/after-ecj/WitherOnStatic.java b/test/transform/resource/after-ecj/WitherOnStatic.java deleted file mode 100644 index 8f385e09..00000000 --- a/test/transform/resource/after-ecj/WitherOnStatic.java +++ /dev/null @@ -1,9 +0,0 @@ -class WitherOnStatic { - static @lombok.experimental.Wither boolean foo; - static @lombok.experimental.Wither int bar; - () { - } - WitherOnStatic() { - super(); - } -} diff --git a/test/transform/resource/after-ecj/WitherPlain.java b/test/transform/resource/after-ecj/WitherPlain.java deleted file mode 100644 index ae1988bc..00000000 --- a/test/transform/resource/after-ecj/WitherPlain.java +++ /dev/null @@ -1,16 +0,0 @@ -import lombok.experimental.Wither; -class WitherPlain { - @lombok.experimental.Wither int i; - final @Wither int foo; - WitherPlain(int i, int foo) { - super(); - this.i = i; - this.foo = foo; - } - public @java.lang.SuppressWarnings("all") WitherPlain withI(final int i) { - return ((this.i == i) ? this : new WitherPlain(i, this.foo)); - } - public @java.lang.SuppressWarnings("all") WitherPlain withFoo(final int foo) { - return ((this.foo == foo) ? this : new WitherPlain(this.i, foo)); - } -} diff --git a/test/transform/resource/after-ecj/WitherTypeAnnos.java b/test/transform/resource/after-ecj/WitherTypeAnnos.java deleted file mode 100644 index e41d9e13..00000000 --- a/test/transform/resource/after-ecj/WitherTypeAnnos.java +++ /dev/null @@ -1,18 +0,0 @@ -import lombok.experimental.Wither; -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; -import java.util.List; -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TA { -} -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TB { -} -class WitherTypeAnnos { - final @Wither @TA @TB List foo; - WitherTypeAnnos(@TA @TB List foo) { - super(); - this.foo = foo; - } - public @java.lang.SuppressWarnings("all") WitherTypeAnnos withFoo(final @TA List foo) { - return ((this.foo == foo) ? this : new WitherTypeAnnos(foo)); - } -} diff --git a/test/transform/resource/after-ecj/WitherWithAbstract.java b/test/transform/resource/after-ecj/WitherWithAbstract.java deleted file mode 100644 index ed71347e..00000000 --- a/test/transform/resource/after-ecj/WitherWithAbstract.java +++ /dev/null @@ -1,7 +0,0 @@ -abstract class WitherWithAbstract { - @lombok.experimental.Wither String foo; - WitherWithAbstract() { - super(); - } - public abstract @java.lang.SuppressWarnings("all") WitherWithAbstract withFoo(final String foo); -} diff --git a/test/transform/resource/after-ecj/WitherWithDollar.java b/test/transform/resource/after-ecj/WitherWithDollar.java deleted file mode 100644 index db46e259..00000000 --- a/test/transform/resource/after-ecj/WitherWithDollar.java +++ /dev/null @@ -1,6 +0,0 @@ -class WitherWithDollar { - @lombok.experimental.Wither int $i; - WitherWithDollar() { - super(); - } -} diff --git a/test/transform/resource/after-ecj/WitherWithGenerics.java b/test/transform/resource/after-ecj/WitherWithGenerics.java deleted file mode 100644 index ee73297c..00000000 --- a/test/transform/resource/after-ecj/WitherWithGenerics.java +++ /dev/null @@ -1,18 +0,0 @@ -class WitherWithGenerics { - @lombok.experimental.Wither J test; - @lombok.experimental.Wither java.util.List test2; - @lombok.experimental.Wither java.util.List test3; - int $i; - public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { - super(); - } - public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest(final J test) { - return ((this.test == test) ? this : new WitherWithGenerics(test, this.test2, this.test3)); - } - public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest2(final java.util.List test2) { - return ((this.test2 == test2) ? this : new WitherWithGenerics(this.test, test2, this.test3)); - } - public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest3(final java.util.List test3) { - return ((this.test3 == test3) ? this : new WitherWithGenerics(this.test, this.test2, test3)); - } -} diff --git a/test/transform/resource/before/BuilderInvalidUse.java b/test/transform/resource/before/BuilderInvalidUse.java index 1a5f2950..3945e64c 100644 --- a/test/transform/resource/before/BuilderInvalidUse.java +++ b/test/transform/resource/before/BuilderInvalidUse.java @@ -3,7 +3,7 @@ class BuilderInvalidUse { private int something; - @lombok.Getter @lombok.Setter @lombok.experimental.FieldDefaults(makeFinal = true) @lombok.experimental.Wither @lombok.Data @lombok.ToString @lombok.EqualsAndHashCode + @lombok.Getter @lombok.Setter @lombok.experimental.FieldDefaults(makeFinal = true) @lombok.With @lombok.Data @lombok.ToString @lombok.EqualsAndHashCode @lombok.AllArgsConstructor public static class BuilderInvalidUseBuilder { diff --git a/test/transform/resource/before/CheckerFrameworkBasic.java b/test/transform/resource/before/CheckerFrameworkBasic.java index 5b59165a..7dd40b54 100644 --- a/test/transform/resource/before/CheckerFrameworkBasic.java +++ b/test/transform/resource/before/CheckerFrameworkBasic.java @@ -1,11 +1,11 @@ //CONF: checkerframework = 3.0 import lombok.Data; import lombok.experimental.Accessors; -import lombok.experimental.Wither; +import lombok.With; @Data @Accessors(chain = true) class CheckerFrameworkBasic { - @Wither private final int x; + @With private final int x; private final int y; private int z; } diff --git a/test/transform/resource/before/FlagUsages.java b/test/transform/resource/before/FlagUsages.java index 6631224f..df3e8044 100644 --- a/test/transform/resource/before/FlagUsages.java +++ b/test/transform/resource/before/FlagUsages.java @@ -1,10 +1,11 @@ //skip compare content //CONF: lombok.Getter.flagUsage = WARNING //CONF: lombok.experimental.flagUsage = ERROR +@lombok.experimental.FieldNameConstants public class FlagUsages { @lombok.Getter String x; - @lombok.experimental.Wither String z; + String z; public FlagUsages(String x, String y) { } diff --git a/test/transform/resource/before/SetterAndWithMethodJavadoc.java b/test/transform/resource/before/SetterAndWithMethodJavadoc.java new file mode 100644 index 00000000..ba10b7f2 --- /dev/null +++ b/test/transform/resource/before/SetterAndWithMethodJavadoc.java @@ -0,0 +1,26 @@ +import lombok.With; +class SetterAndWithMethodJavadoc { + /** + * Some value. + * @param the new value + */ + @lombok.Setter @lombok.With int i; + + /** + * Some other value. + * + * --- SETTER --- + * Set some other value. + * @param the new other value + * + * --- WITH --- + * Reinstantiate with some other value. + * @param the other new other value + */ + @lombok.Setter @lombok.With int j; + + SetterAndWithMethodJavadoc(int i, int j) { + this.i = i; + this.j = j; + } +} diff --git a/test/transform/resource/before/SetterAndWitherJavadoc.java b/test/transform/resource/before/SetterAndWitherJavadoc.java deleted file mode 100644 index 6953eb39..00000000 --- a/test/transform/resource/before/SetterAndWitherJavadoc.java +++ /dev/null @@ -1,26 +0,0 @@ -import lombok.experimental.Wither; -class SetterAndWitherJavadoc { - /** - * Some value. - * @param the new value - */ - @lombok.Setter @lombok.experimental.Wither int i; - - /** - * Some other value. - * - * --- SETTER --- - * Set some other value. - * @param the new other value - * - * --- WITHER --- - * Reinstantiate with some other value. - * @param the other new other value - */ - @lombok.Setter @lombok.experimental.Wither int j; - - SetterAndWitherJavadoc(int i, int j) { - this.i = i; - this.j = j; - } -} diff --git a/test/transform/resource/before/WithAlreadyExists.java b/test/transform/resource/before/WithAlreadyExists.java new file mode 100644 index 00000000..ac1414b6 --- /dev/null +++ b/test/transform/resource/before/WithAlreadyExists.java @@ -0,0 +1,89 @@ +class With1 { + @lombok.With boolean foo; + + void withFoo(boolean foo) { + } + + With1(boolean foo) { + } +} + +class With2 { + @lombok.With boolean foo; + + void withFoo(String foo) { + } + + With2(boolean foo) { + } +} + +class With3 { + @lombok.With String foo; + + void withFoo(boolean foo) { + } + + With3(String foo) { + } +} + +class With4 { + @lombok.With String foo; + + void withFoo(String foo) { + } + + With4(String foo) { + } +} + +class With5 { + @lombok.With String foo; + + void withFoo() { + } + + With5(String foo) { + } +} + +class With6 { + @lombok.With String foo; + + void withFoo(String foo, int x) { + } + + With6(String foo) { + } +} + +class With7 { + @lombok.With String foo; + + void withFoo(String foo, Object... x) { + } + + With7(String foo) { + } +} + +class With8 { + @lombok.With boolean isFoo; + + void withIsFoo(boolean foo) { + } + + With8(boolean foo) { + } +} + +class With9 { + @lombok.With boolean isFoo; + + void withFoo(boolean foo) { + } + + With9(boolean foo) { + } +} diff --git a/test/transform/resource/before/WithAndAllArgsConstructor.java b/test/transform/resource/before/WithAndAllArgsConstructor.java new file mode 100644 index 00000000..d11d4faa --- /dev/null +++ b/test/transform/resource/before/WithAndAllArgsConstructor.java @@ -0,0 +1,12 @@ +@lombok.AllArgsConstructor +class WithAndAllArgsConstructor { + @lombok.With J test; + + @lombok.With java.util.List test2; + + final int x = 10; + + int y = 20; + + final int z; +} \ No newline at end of file diff --git a/test/transform/resource/before/WithMethodAbstract.java b/test/transform/resource/before/WithMethodAbstract.java new file mode 100644 index 00000000..fd6edbc9 --- /dev/null +++ b/test/transform/resource/before/WithMethodAbstract.java @@ -0,0 +1,3 @@ +abstract class WithMethodAbstract { + @lombok.With String foo; +} \ No newline at end of file diff --git a/test/transform/resource/before/WithMethodMarkedDeprecated.java b/test/transform/resource/before/WithMethodMarkedDeprecated.java new file mode 100644 index 00000000..7a6549e5 --- /dev/null +++ b/test/transform/resource/before/WithMethodMarkedDeprecated.java @@ -0,0 +1,15 @@ +import lombok.With; + +class WithMethodMarkedDeprecated { + + @Deprecated + @With int annotation; + + /** + * @deprecated + */ + @With int javadoc; + + WithMethodMarkedDeprecated(int annotation, int javadoc) { + } +} \ No newline at end of file diff --git a/test/transform/resource/before/WithOnClass.java b/test/transform/resource/before/WithOnClass.java new file mode 100644 index 00000000..a6215b54 --- /dev/null +++ b/test/transform/resource/before/WithOnClass.java @@ -0,0 +1,45 @@ +@lombok.With +class WithOnClass1 { + @lombok.With(lombok.AccessLevel.NONE) + boolean isNone; + + boolean isPublic; + + WithOnClass1(boolean isNone, boolean isPublic) { + } +} + +@lombok.With(lombok.AccessLevel.PROTECTED) +class WithOnClass2 { + @lombok.With(lombok.AccessLevel.NONE) + boolean isNone; + + boolean isProtected; + + @lombok.With(lombok.AccessLevel.PACKAGE) + boolean isPackage; + + WithOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { + } +} + +@lombok.With +class WithOnClass3 { + String couldBeNull; + + @lombok.NonNull String nonNull; + + WithOnClass3(String couldBeNull, String nonNull) { + } +} + +@lombok.With @lombok.experimental.Accessors(prefix="f") +class WithOnClass4 { + final int fX = 10; + + final int fY; + + WithOnClass4(int y) { + this.fY = y; + } +} diff --git a/test/transform/resource/before/WithOnStatic.java b/test/transform/resource/before/WithOnStatic.java new file mode 100644 index 00000000..f8105e0e --- /dev/null +++ b/test/transform/resource/before/WithOnStatic.java @@ -0,0 +1,4 @@ +class WithOnStatic { + @lombok.With static boolean foo; + @lombok.With static int bar; +} diff --git a/test/transform/resource/before/WithPlain.java b/test/transform/resource/before/WithPlain.java new file mode 100644 index 00000000..1b2a19c4 --- /dev/null +++ b/test/transform/resource/before/WithPlain.java @@ -0,0 +1,10 @@ +import lombok.With; +class WithPlain { + @lombok.With int i; + @With final int foo; + + WithPlain(int i, int foo) { + this.i = i; + this.foo = foo; + } +} diff --git a/test/transform/resource/before/WithWithDollar.java b/test/transform/resource/before/WithWithDollar.java new file mode 100644 index 00000000..1dd5d47d --- /dev/null +++ b/test/transform/resource/before/WithWithDollar.java @@ -0,0 +1,3 @@ +class WithWithDollar { + @lombok.With int $i; +} diff --git a/test/transform/resource/before/WithWithGenerics.java b/test/transform/resource/before/WithWithGenerics.java new file mode 100644 index 00000000..d94405d8 --- /dev/null +++ b/test/transform/resource/before/WithWithGenerics.java @@ -0,0 +1,9 @@ +class WithWithGenerics { + @lombok.With J test; + @lombok.With java.util.List test2; + @lombok.With java.util.List test3; + int $i; + + public WithWithGenerics(J test, java.util.List test2, java.util.List test3) { + } +} \ No newline at end of file diff --git a/test/transform/resource/before/WithWithTypeAnnos.java b/test/transform/resource/before/WithWithTypeAnnos.java new file mode 100644 index 00000000..ceef6d61 --- /dev/null +++ b/test/transform/resource/before/WithWithTypeAnnos.java @@ -0,0 +1,18 @@ +//CONF: lombok.copyableAnnotations += TA +import lombok.With; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.util.List; +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TA { +} +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@interface TB { +} +class WithWithTypeAnnos { + @With final @TA @TB List foo; + + WithWithTypeAnnos(@TA @TB List foo) { + this.foo = foo; + } +} diff --git a/test/transform/resource/before/WitherAlreadyExists.java b/test/transform/resource/before/WitherAlreadyExists.java deleted file mode 100644 index 7833173a..00000000 --- a/test/transform/resource/before/WitherAlreadyExists.java +++ /dev/null @@ -1,89 +0,0 @@ -class Wither1 { - @lombok.experimental.Wither boolean foo; - - void withFoo(boolean foo) { - } - - Wither1(boolean foo) { - } -} - -class Wither2 { - @lombok.experimental.Wither boolean foo; - - void withFoo(String foo) { - } - - Wither2(boolean foo) { - } -} - -class Wither3 { - @lombok.experimental.Wither String foo; - - void withFoo(boolean foo) { - } - - Wither3(String foo) { - } -} - -class Wither4 { - @lombok.experimental.Wither String foo; - - void withFoo(String foo) { - } - - Wither4(String foo) { - } -} - -class Wither5 { - @lombok.experimental.Wither String foo; - - void withFoo() { - } - - Wither5(String foo) { - } -} - -class Wither6 { - @lombok.experimental.Wither String foo; - - void withFoo(String foo, int x) { - } - - Wither6(String foo) { - } -} - -class Wither7 { - @lombok.experimental.Wither String foo; - - void withFoo(String foo, Object... x) { - } - - Wither7(String foo) { - } -} - -class Wither8 { - @lombok.experimental.Wither boolean isFoo; - - void withIsFoo(boolean foo) { - } - - Wither8(boolean foo) { - } -} - -class Wither9 { - @lombok.experimental.Wither boolean isFoo; - - void withFoo(boolean foo) { - } - - Wither9(boolean foo) { - } -} diff --git a/test/transform/resource/before/WitherAndAllArgsConstructor.java b/test/transform/resource/before/WitherAndAllArgsConstructor.java deleted file mode 100644 index d531b3f4..00000000 --- a/test/transform/resource/before/WitherAndAllArgsConstructor.java +++ /dev/null @@ -1,12 +0,0 @@ -@lombok.AllArgsConstructor -class WitherAndAllArgsConstructor { - @lombok.experimental.Wither J test; - - @lombok.experimental.Wither java.util.List test2; - - final int x = 10; - - int y = 20; - - final int z; -} \ No newline at end of file diff --git a/test/transform/resource/before/WitherDeprecated.java b/test/transform/resource/before/WitherDeprecated.java deleted file mode 100644 index efd1af43..00000000 --- a/test/transform/resource/before/WitherDeprecated.java +++ /dev/null @@ -1,15 +0,0 @@ -import lombok.experimental.Wither; - -class WitherDeprecated { - - @Deprecated - @Wither int annotation; - - /** - * @deprecated - */ - @Wither int javadoc; - - WitherDeprecated(int annotation, int javadoc) { - } -} \ No newline at end of file diff --git a/test/transform/resource/before/WitherOnClass.java b/test/transform/resource/before/WitherOnClass.java deleted file mode 100644 index d6a3d3c8..00000000 --- a/test/transform/resource/before/WitherOnClass.java +++ /dev/null @@ -1,45 +0,0 @@ -@lombok.experimental.Wither -class WitherOnClass1 { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) - boolean isNone; - - boolean isPublic; - - WitherOnClass1(boolean isNone, boolean isPublic) { - } -} - -@lombok.experimental.Wither(lombok.AccessLevel.PROTECTED) -class WitherOnClass2 { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) - boolean isNone; - - boolean isProtected; - - @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) - boolean isPackage; - - WitherOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { - } -} - -@lombok.experimental.Wither -class WitherOnClass3 { - String couldBeNull; - - @lombok.NonNull String nonNull; - - WitherOnClass3(String couldBeNull, String nonNull) { - } -} - -@lombok.experimental.Wither @lombok.experimental.Accessors(prefix="f") -class WitherOnClass4 { - final int fX = 10; - - final int fY; - - WitherOnClass4(int y) { - this.fY = y; - } -} diff --git a/test/transform/resource/before/WitherOnStatic.java b/test/transform/resource/before/WitherOnStatic.java deleted file mode 100644 index 566c8154..00000000 --- a/test/transform/resource/before/WitherOnStatic.java +++ /dev/null @@ -1,4 +0,0 @@ -class WitherOnStatic { - @lombok.experimental.Wither static boolean foo; - @lombok.experimental.Wither static int bar; -} diff --git a/test/transform/resource/before/WitherPlain.java b/test/transform/resource/before/WitherPlain.java deleted file mode 100644 index 436e6f3b..00000000 --- a/test/transform/resource/before/WitherPlain.java +++ /dev/null @@ -1,10 +0,0 @@ -import lombok.experimental.Wither; -class WitherPlain { - @lombok.experimental.Wither int i; - @Wither final int foo; - - WitherPlain(int i, int foo) { - this.i = i; - this.foo = foo; - } -} diff --git a/test/transform/resource/before/WitherTypeAnnos.java b/test/transform/resource/before/WitherTypeAnnos.java deleted file mode 100644 index 97cd3d9f..00000000 --- a/test/transform/resource/before/WitherTypeAnnos.java +++ /dev/null @@ -1,18 +0,0 @@ -//CONF: lombok.copyableAnnotations += TA -import lombok.experimental.Wither; -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; -import java.util.List; -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) -@interface TA { -} -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) -@interface TB { -} -class WitherTypeAnnos { - @Wither final @TA @TB List foo; - - WitherTypeAnnos(@TA @TB List foo) { - this.foo = foo; - } -} diff --git a/test/transform/resource/before/WitherWithAbstract.java b/test/transform/resource/before/WitherWithAbstract.java deleted file mode 100644 index acc9094b..00000000 --- a/test/transform/resource/before/WitherWithAbstract.java +++ /dev/null @@ -1,3 +0,0 @@ -abstract class WitherWithAbstract { - @lombok.experimental.Wither String foo; -} \ No newline at end of file diff --git a/test/transform/resource/before/WitherWithDollar.java b/test/transform/resource/before/WitherWithDollar.java deleted file mode 100644 index 8dd2572f..00000000 --- a/test/transform/resource/before/WitherWithDollar.java +++ /dev/null @@ -1,3 +0,0 @@ -class WitherWithDollar { - @lombok.experimental.Wither int $i; -} diff --git a/test/transform/resource/before/WitherWithGenerics.java b/test/transform/resource/before/WitherWithGenerics.java deleted file mode 100644 index 0b0fdd46..00000000 --- a/test/transform/resource/before/WitherWithGenerics.java +++ /dev/null @@ -1,9 +0,0 @@ -class WitherWithGenerics { - @lombok.experimental.Wither J test; - @lombok.experimental.Wither java.util.List test2; - @lombok.experimental.Wither java.util.List test3; - int $i; - - public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { - } -} \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages index 506a3426..62387ec3 100644 --- a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -2 @Getter, @Setter, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +2 @Getter, @Setter, @With, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. 13 @Value is not allowed on builder classes. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/FlagUsages.java.messages b/test/transform/resource/messages-delombok/FlagUsages.java.messages index 13a148b1..795ff584 100644 --- a/test/transform/resource/messages-delombok/FlagUsages.java.messages +++ b/test/transform/resource/messages-delombok/FlagUsages.java.messages @@ -1,2 +1,2 @@ -5 Use of @Getter is flagged according to lombok configuration. -7 Use of any lombok.experimental feature is flagged according to lombok configuration. +4 Use of any lombok.experimental feature is flagged according to lombok configuration. +6 Use of @Getter is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-delombok/WithAlreadyExists.java.messages b/test/transform/resource/messages-delombok/WithAlreadyExists.java.messages new file mode 100644 index 00000000..d5e30e28 --- /dev/null +++ b/test/transform/resource/messages-delombok/WithAlreadyExists.java.messages @@ -0,0 +1,7 @@ +2 Not generating withFoo(): A method with that name already exists +12 Not generating withFoo(): A method with that name already exists +22 Not generating withFoo(): A method with that name already exists +32 Not generating withFoo(): A method with that name already exists +62 Not generating withFoo(): A method with that name already exists +72 Not generating withFoo(): A method with that name already exists (withIsFoo) +82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-delombok/WithOnStatic.java.messages b/test/transform/resource/messages-delombok/WithOnStatic.java.messages new file mode 100644 index 00000000..4637cfb4 --- /dev/null +++ b/test/transform/resource/messages-delombok/WithOnStatic.java.messages @@ -0,0 +1,2 @@ +2 Not generating withFoo for this field: With methods cannot be generated for static fields. +3 Not generating withBar for this field: With methods cannot be generated for static fields. diff --git a/test/transform/resource/messages-delombok/WithWithDollar.java.messages b/test/transform/resource/messages-delombok/WithWithDollar.java.messages new file mode 100644 index 00000000..b2368131 --- /dev/null +++ b/test/transform/resource/messages-delombok/WithWithDollar.java.messages @@ -0,0 +1 @@ +2 Not generating with$i for this field: With methods cannot be generated for fields starting with $. diff --git a/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages b/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages deleted file mode 100644 index d5e30e28..00000000 --- a/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages +++ /dev/null @@ -1,7 +0,0 @@ -2 Not generating withFoo(): A method with that name already exists -12 Not generating withFoo(): A method with that name already exists -22 Not generating withFoo(): A method with that name already exists -32 Not generating withFoo(): A method with that name already exists -62 Not generating withFoo(): A method with that name already exists -72 Not generating withFoo(): A method with that name already exists (withIsFoo) -82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-delombok/WitherOnStatic.java.messages b/test/transform/resource/messages-delombok/WitherOnStatic.java.messages deleted file mode 100644 index 3af59fa1..00000000 --- a/test/transform/resource/messages-delombok/WitherOnStatic.java.messages +++ /dev/null @@ -1,2 +0,0 @@ -2 Not generating wither for this field: Withers cannot be generated for static fields. -3 Not generating wither for this field: Withers cannot be generated for static fields. diff --git a/test/transform/resource/messages-delombok/WitherWithDollar.java.messages b/test/transform/resource/messages-delombok/WitherWithDollar.java.messages deleted file mode 100644 index 84603868..00000000 --- a/test/transform/resource/messages-delombok/WitherWithDollar.java.messages +++ /dev/null @@ -1 +0,0 @@ -2 Not generating wither for this field: Withers cannot be generated for fields starting with $. diff --git a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages index c5571b92..8969b48a 100644 --- a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -2 @Getter, @Setter, @FieldDefaults, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +2 @Getter, @Setter, @FieldDefaults, @With, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. 13 @Value is not allowed on builder classes. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/FlagUsages.java.messages b/test/transform/resource/messages-ecj/FlagUsages.java.messages index 13a148b1..795ff584 100644 --- a/test/transform/resource/messages-ecj/FlagUsages.java.messages +++ b/test/transform/resource/messages-ecj/FlagUsages.java.messages @@ -1,2 +1,2 @@ -5 Use of @Getter is flagged according to lombok configuration. -7 Use of any lombok.experimental feature is flagged according to lombok configuration. +4 Use of any lombok.experimental feature is flagged according to lombok configuration. +6 Use of @Getter is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-ecj/WithAlreadyExists.java.messages b/test/transform/resource/messages-ecj/WithAlreadyExists.java.messages new file mode 100644 index 00000000..d5e30e28 --- /dev/null +++ b/test/transform/resource/messages-ecj/WithAlreadyExists.java.messages @@ -0,0 +1,7 @@ +2 Not generating withFoo(): A method with that name already exists +12 Not generating withFoo(): A method with that name already exists +22 Not generating withFoo(): A method with that name already exists +32 Not generating withFoo(): A method with that name already exists +62 Not generating withFoo(): A method with that name already exists +72 Not generating withFoo(): A method with that name already exists (withIsFoo) +82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/WithOnStatic.java.messages b/test/transform/resource/messages-ecj/WithOnStatic.java.messages new file mode 100644 index 00000000..4637cfb4 --- /dev/null +++ b/test/transform/resource/messages-ecj/WithOnStatic.java.messages @@ -0,0 +1,2 @@ +2 Not generating withFoo for this field: With methods cannot be generated for static fields. +3 Not generating withBar for this field: With methods cannot be generated for static fields. diff --git a/test/transform/resource/messages-ecj/WithWithDollar.java.messages b/test/transform/resource/messages-ecj/WithWithDollar.java.messages new file mode 100644 index 00000000..b2368131 --- /dev/null +++ b/test/transform/resource/messages-ecj/WithWithDollar.java.messages @@ -0,0 +1 @@ +2 Not generating with$i for this field: With methods cannot be generated for fields starting with $. diff --git a/test/transform/resource/messages-ecj/WitherAccessLevel.java.messages b/test/transform/resource/messages-ecj/WitherAccessLevel.java.messages new file mode 100644 index 00000000..4ba55bb8 --- /dev/null +++ b/test/transform/resource/messages-ecj/WitherAccessLevel.java.messages @@ -0,0 +1 @@ +4 The type Wither is deprecated diff --git a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages b/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages deleted file mode 100644 index d5e30e28..00000000 --- a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages +++ /dev/null @@ -1,7 +0,0 @@ -2 Not generating withFoo(): A method with that name already exists -12 Not generating withFoo(): A method with that name already exists -22 Not generating withFoo(): A method with that name already exists -32 Not generating withFoo(): A method with that name already exists -62 Not generating withFoo(): A method with that name already exists -72 Not generating withFoo(): A method with that name already exists (withIsFoo) -82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/WitherOnStatic.java.messages b/test/transform/resource/messages-ecj/WitherOnStatic.java.messages deleted file mode 100644 index 3af59fa1..00000000 --- a/test/transform/resource/messages-ecj/WitherOnStatic.java.messages +++ /dev/null @@ -1,2 +0,0 @@ -2 Not generating wither for this field: Withers cannot be generated for static fields. -3 Not generating wither for this field: Withers cannot be generated for static fields. diff --git a/test/transform/resource/messages-ecj/WitherWithDollar.java.messages b/test/transform/resource/messages-ecj/WitherWithDollar.java.messages deleted file mode 100644 index 84603868..00000000 --- a/test/transform/resource/messages-ecj/WitherWithDollar.java.messages +++ /dev/null @@ -1 +0,0 @@ -2 Not generating wither for this field: Withers cannot be generated for fields starting with $. -- cgit From 461b5541da3fc8c43439f032e2f1d37574a1a658 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 26 Aug 2019 22:22:05 +0200 Subject: [tests] fixing an error in a superbuilder/checkerframework test --- test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/transform/resource') diff --git a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java index 3901bfce..ffbcf44e 100644 --- a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java @@ -96,7 +96,7 @@ class CheckerFrameworkSuperBuilder { public ChildBuilder() { } protected abstract @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") B self(); - protected abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") ChildBuilder this); + public abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") ChildBuilder this); public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B a(final @org.checkerframework.checker.builder.qual.NotCalledMethods("a") ChildBuilder this, final int a) { this.a$value = a; a$set = true; -- cgit