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') 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