diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-08-13 15:04:43 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-08-22 22:42:48 +0200 |
commit | 15df143df6d35dd64459d717a451a039eb26d761 (patch) | |
tree | 70fc0be372fd02491f9c5e9d7d68ffe7901da6d8 /test | |
parent | ff1c01d9e9e66d898c30939b497490b04fe6163c (diff) | |
download | lombok-15df143df6d35dd64459d717a451a039eb26d761.tar.gz lombok-15df143df6d35dd64459d717a451a039eb26d761.tar.bz2 lombok-15df143df6d35dd64459d717a451a039eb26d761.zip |
[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.
Diffstat (limited to 'test')
20 files changed, 743 insertions, 4 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index fc05aea2..d223ae03 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -47,6 +47,7 @@ import lombok.core.configuration.ConfigurationKeysLoader; import lombok.core.configuration.ConfigurationResolver; import lombok.core.configuration.ConfigurationResolverFactory; import lombok.javac.CapturingDiagnosticListener.CompilerMessage; +import lombok.transform.TestLombokFilesIdempotent; public abstract class AbstractRunTests { private final File dumpActualFilesHere; @@ -74,6 +75,7 @@ public abstract class AbstractRunTests { if (expected.isIgnore()) return null; if (!expected.versionWithinLimit(params.getVersion())) return null; if (!expected.versionWithinLimit(version)) return null; + if (expected.isSkipIdempotent() && params instanceof TestLombokFilesIdempotent) return null; final LombokTestSource sourceDirectives_ = sourceDirectives; final AssertionError directiveFailure_ = directiveFailure; diff --git a/test/core/src/lombok/CompilerMessageMatcher.java b/test/core/src/lombok/CompilerMessageMatcher.java index 49c81b70..c00263f4 100644 --- a/test/core/src/lombok/CompilerMessageMatcher.java +++ b/test/core/src/lombok/CompilerMessageMatcher.java @@ -88,7 +88,7 @@ public class CompilerMessageMatcher { return out; } - private static final Pattern PATTERN = Pattern.compile("^(\\d+) (.*)$"); + private static final Pattern PATTERN = Pattern.compile("^(-?\\d+) (.*)$"); private static CompilerMessageMatcher read(String line) { line = line.trim(); diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java index 9410b4c7..ffadba8f 100644 --- a/test/core/src/lombok/DirectoryRunner.java +++ b/test/core/src/lombok/DirectoryRunner.java @@ -36,7 +36,8 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; public class DirectoryRunner extends Runner { - private static final String DEBUG_FOCUS_ON_FILE = null; + /** Fill in a file name (or multiple, space separated) to reduce the testset to just the named file(s). */ + private static final String DEBUG_FOCUS_ON_FILE = ""; public enum Compiler { DELOMBOK { @@ -79,7 +80,7 @@ public class DirectoryRunner extends Runner { private static final FileFilter JAVA_FILE_FILTER = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(".java") && - (DEBUG_FOCUS_ON_FILE == null || file.getName().equals(DEBUG_FOCUS_ON_FILE)); + (DEBUG_FOCUS_ON_FILE.isEmpty() || (" " + DEBUG_FOCUS_ON_FILE + " ").contains(" " + file.getName() + " ")); } }; diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index 31f7db3e..ba0aa972 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014-2015 The Project Lombok Authors. + * Copyright (C) 2014-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 @@ -52,6 +52,7 @@ public class LombokTestSource { private final Map<String, String> formatPreferences; private final boolean ignore; private final boolean skipCompareContent; + private final boolean skipIdempotent; private final boolean unchanged; private final int versionLowerLimit, versionUpperLimit; private final ConfigurationResolver configuration; @@ -92,6 +93,10 @@ public class LombokTestSource { return skipCompareContent; } + public boolean isSkipIdempotent() { + return skipIdempotent; + } + public String getSpecifiedEncoding() { return specifiedEncoding; } @@ -139,6 +144,7 @@ public class LombokTestSource { private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); private static final Pattern UNCHANGED_PATTERN = Pattern.compile("^\\s*unchanged\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?contents?\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); + private static final Pattern SKIP_IDEMPOTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?idempotent\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) { this.file = file; @@ -150,6 +156,7 @@ public class LombokTestSource { int versionUpper = Integer.MAX_VALUE; boolean ignore = false; boolean skipCompareContent = false; + boolean skipIdempotent = false; boolean unchanged = false; String encoding = null; Map<String, String> formats = new HashMap<String, String>(); @@ -173,6 +180,11 @@ public class LombokTestSource { continue; } + if (SKIP_IDEMPOTENT_PATTERN.matcher(directive).matches()) { + skipIdempotent = true; + continue; + } + if (lc.startsWith("platform ")) { String platformDesc = lc.substring("platform ".length()); int idx = platformDesc.indexOf(':'); @@ -223,6 +235,7 @@ public class LombokTestSource { this.versionUpperLimit = versionUpper; this.ignore = ignore; this.skipCompareContent = skipCompareContent; + this.skipIdempotent = skipIdempotent; this.unchanged = unchanged; this.platforms = platformLimit == null ? null : Arrays.asList(platformLimit); ConfigurationProblemReporter reporter = new ConfigurationProblemReporter() { 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<String> 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<String> 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<String> 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<String>(); + this.names.add(name); + return this; + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public CheckerFrameworkBuilderBuilder names(final java.util.Collection<? extends String> names) { + if (this.names == null) this.names = new java.util.ArrayList<String>(); + 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<String> 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<String>(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<String> names; + @java.lang.SuppressWarnings("all") + private static int $default$x() { + return 5; + } + @java.lang.SuppressWarnings("all") + public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> { + @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<String> 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<String>(); + this.names.add(name); + return self(); + } + @org.checkerframework.checker.builder.qual.ReturnsReceiver + @java.lang.SuppressWarnings("all") + public B names(final java.util.Collection<? extends String> names) { + if (this.names == null) this.names = new java.util.ArrayList<String>(); + 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<Parent, ParentBuilderImpl> { + @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<String> 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<String>(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<C extends Child, B extends ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> { + @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<Child, ChildBuilderImpl> { + @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<String> 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<String>(); + this.names.add(name); + return this; + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder names(final java.util.Collection<? extends String> names) { + if ((this.names == null)) + this.names = new java.util.ArrayList<String>(); + 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<String> 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<String>(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<String> 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<String> 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<C extends Parent, B extends ParentBuilder<C, B>> { + 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<String> 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<String>(); + this.names.add(name); + return self(); + } + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B names(final java.util.Collection<? extends String> names) { + if ((this.names == null)) + this.names = new java.util.ArrayList<String>(); + 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<Parent, ParentBuilderImpl> { + 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<String> 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<String> 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<String>(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<C extends Child, B extends ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> { + 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<Child, ChildBuilderImpl> { + 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<String> 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<String> 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 |