aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Brinkman <cbrinkman@sonatype.com>2019-09-11 09:17:02 -0500
committerCaleb Brinkman <cbrinkman@sonatype.com>2019-09-11 09:17:02 -0500
commitdc56309dada0ae0fba2c939d3fc300d6abac145c (patch)
treef79b31cb086a368aa467f359b84923bca1ecaa6b
parent4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7 (diff)
parent8c32769f18361ed626ebd06962d924c288950d26 (diff)
downloadlombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.tar.gz
lombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.tar.bz2
lombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.zip
Merge branch 'master' of github.com:rzwitserloot/lombok into feature/builder-setter-prefixes
-rwxr-xr-xAUTHORS2
-rw-r--r--build.xml14
-rw-r--r--buildScripts/website.ant.xml5
-rw-r--r--doc/changelog.markdown10
-rw-r--r--docker/ant/Dockerfile10
-rw-r--r--docker/ant/files/jdk-11/build.xml35
-rw-r--r--docker/ant/files/jdk-12/build.xml35
-rw-r--r--docker/ant/readme.md11
-rw-r--r--docker/bazel/Dockerfile10
-rw-r--r--docker/bazel/readme.md13
-rw-r--r--docker/gradle/Dockerfile10
-rw-r--r--docker/gradle/readme.md13
-rw-r--r--docker/maven/Dockerfile10
-rw-r--r--docker/maven/files/jdk-12/pom.xml53
-rw-r--r--docker/maven/readme.md13
-rwxr-xr-xdocker/provision/ant/ant-1.10.1.sh2
-rw-r--r--docker/provision/ant/ant-1.10.6.sh4
-rw-r--r--docker/provision/bazel/bazel-0.28.1.sh4
-rw-r--r--docker/provision/gradle/gradle-5.6.sh4
-rwxr-xr-xdocker/provision/jdk/java-10.sh4
-rw-r--r--docker/provision/jdk/java-11.sh4
-rw-r--r--docker/provision/jdk/java-12.sh4
-rwxr-xr-xdocker/provision/jdk/java-8.sh10
-rwxr-xr-xdocker/provision/jdk/java-9.sh4
-rw-r--r--docker/provision/maven/maven-3.6.1.sh4
-rw-r--r--docker/readme.md5
-rw-r--r--src/core/lombok/ConfigurationKeys.java32
-rw-r--r--src/core/lombok/With.java94
-rw-r--r--src/core/lombok/core/LombokInternalAliasing.java24
-rw-r--r--src/core/lombok/core/TypeLibrary.java23
-rw-r--r--src/core/lombok/core/TypeResolver.java4
-rw-r--r--src/core/lombok/core/Version.java2
-rw-r--r--src/core/lombok/core/configuration/CheckerFrameworkVersion.java86
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java14
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java58
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java17
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java110
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java17
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java18
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java13
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java9
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleSuperBuilder.java106
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWith.java (renamed from src/core/lombok/eclipse/handlers/HandleWither.java)85
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java21
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java23
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java23
-rw-r--r--src/core/lombok/experimental/Wither.java4
-rw-r--r--src/core/lombok/javac/apt/LombokProcessor.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java79
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java22
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java95
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleWith.java (renamed from src/core/lombok/javac/handlers/HandleWither.java)98
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java40
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java40
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java5
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java5
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java5
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java6
-rw-r--r--src/launch/lombok/launch/ShadowClassLoader.java4
-rw-r--r--test/core/src/lombok/AbstractRunTests.java2
-rw-r--r--test/core/src/lombok/CompilerMessageMatcher.java2
-rw-r--r--test/core/src/lombok/DirectoryRunner.java5
-rw-r--r--test/core/src/lombok/LombokTestSource.java15
-rw-r--r--test/manual/knownIssue-1976_2138-valPlusDelegateVsEclipseErrors/about.txt35
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkBasic.java72
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkBuilder.java106
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java202
-rw-r--r--test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java (renamed from test/transform/resource/after-delombok/SetterAndWitherJavadoc.java)12
-rw-r--r--test/transform/resource/after-delombok/WithAlreadyExists.java71
-rw-r--r--test/transform/resource/after-delombok/WithAndAllArgsConstructor.java22
-rw-r--r--test/transform/resource/after-delombok/WithMethodAbstract.java5
-rw-r--r--test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java23
-rw-r--r--test/transform/resource/after-delombok/WithOnClass.java54
-rw-r--r--test/transform/resource/after-delombok/WithOnStatic.java (renamed from test/transform/resource/after-delombok/WitherOnStatic.java)2
-rw-r--r--test/transform/resource/after-delombok/WithPlain.java16
-rw-r--r--test/transform/resource/after-delombok/WithWithDollar.java3
-rw-r--r--test/transform/resource/after-delombok/WithWithGenerics.java20
-rw-r--r--test/transform/resource/after-delombok/WithWithTypeAnnos.java (renamed from test/transform/resource/after-delombok/WitherTypeAnnos.java)8
-rw-r--r--test/transform/resource/after-delombok/WitherAlreadyExists.java71
-rw-r--r--test/transform/resource/after-delombok/WitherAndAllArgsConstructor.java22
-rw-r--r--test/transform/resource/after-delombok/WitherDeprecated.java23
-rw-r--r--test/transform/resource/after-delombok/WitherOnClass.java54
-rw-r--r--test/transform/resource/after-delombok/WitherPlain.java16
-rw-r--r--test/transform/resource/after-delombok/WitherWithAbstract.java5
-rw-r--r--test/transform/resource/after-delombok/WitherWithDollar.java3
-rw-r--r--test/transform/resource/after-delombok/WitherWithGenerics.java20
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkBasic.java59
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkBuilder.java79
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java142
-rw-r--r--test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java22
-rw-r--r--test/transform/resource/after-ecj/SetterAndWitherJavadoc.java22
-rw-r--r--test/transform/resource/after-ecj/WithAlreadyExists.java78
-rw-r--r--test/transform/resource/after-ecj/WithAndAllArgsConstructor.java20
-rw-r--r--test/transform/resource/after-ecj/WithMethodAbstract.java7
-rw-r--r--test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java14
-rw-r--r--test/transform/resource/after-ecj/WithOnClass.java52
-rw-r--r--test/transform/resource/after-ecj/WithOnStatic.java9
-rw-r--r--test/transform/resource/after-ecj/WithPlain.java16
-rw-r--r--test/transform/resource/after-ecj/WithWithDollar.java6
-rw-r--r--test/transform/resource/after-ecj/WithWithGenerics.java18
-rw-r--r--test/transform/resource/after-ecj/WithWithTypeAnnos.java (renamed from test/transform/resource/after-ecj/WitherTypeAnnos.java)12
-rw-r--r--test/transform/resource/after-ecj/WitherAlreadyExists.java78
-rw-r--r--test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java20
-rw-r--r--test/transform/resource/after-ecj/WitherDeprecated.java14
-rw-r--r--test/transform/resource/after-ecj/WitherOnClass.java52
-rw-r--r--test/transform/resource/after-ecj/WitherOnStatic.java9
-rw-r--r--test/transform/resource/after-ecj/WitherPlain.java16
-rw-r--r--test/transform/resource/after-ecj/WitherWithAbstract.java7
-rw-r--r--test/transform/resource/after-ecj/WitherWithDollar.java6
-rw-r--r--test/transform/resource/after-ecj/WitherWithGenerics.java18
-rw-r--r--test/transform/resource/before/BuilderInvalidUse.java2
-rw-r--r--test/transform/resource/before/CheckerFrameworkBasic.java11
-rw-r--r--test/transform/resource/before/CheckerFrameworkBuilder.java12
-rw-r--r--test/transform/resource/before/CheckerFrameworkSuperBuilder.java19
-rw-r--r--test/transform/resource/before/FlagUsages.java3
-rw-r--r--test/transform/resource/before/SetterAndWithMethodJavadoc.java (renamed from test/transform/resource/before/SetterAndWitherJavadoc.java)12
-rw-r--r--test/transform/resource/before/WithAlreadyExists.java89
-rw-r--r--test/transform/resource/before/WithAndAllArgsConstructor.java12
-rw-r--r--test/transform/resource/before/WithMethodAbstract.java3
-rw-r--r--test/transform/resource/before/WithMethodMarkedDeprecated.java15
-rw-r--r--test/transform/resource/before/WithOnClass.java45
-rw-r--r--test/transform/resource/before/WithOnStatic.java4
-rw-r--r--test/transform/resource/before/WithPlain.java10
-rw-r--r--test/transform/resource/before/WithWithDollar.java3
-rw-r--r--test/transform/resource/before/WithWithGenerics.java9
-rw-r--r--test/transform/resource/before/WithWithTypeAnnos.java (renamed from test/transform/resource/before/WitherTypeAnnos.java)8
-rw-r--r--test/transform/resource/before/WitherAlreadyExists.java89
-rw-r--r--test/transform/resource/before/WitherAndAllArgsConstructor.java12
-rw-r--r--test/transform/resource/before/WitherDeprecated.java15
-rw-r--r--test/transform/resource/before/WitherOnClass.java45
-rw-r--r--test/transform/resource/before/WitherOnStatic.java4
-rw-r--r--test/transform/resource/before/WitherPlain.java10
-rw-r--r--test/transform/resource/before/WitherWithAbstract.java3
-rw-r--r--test/transform/resource/before/WitherWithDollar.java3
-rw-r--r--test/transform/resource/before/WitherWithGenerics.java9
-rw-r--r--test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages4
-rw-r--r--test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages3
-rw-r--r--test/transform/resource/messages-delombok/FlagUsages.java.messages4
-rw-r--r--test/transform/resource/messages-delombok/WithAlreadyExists.java.messages (renamed from test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages)0
-rw-r--r--test/transform/resource/messages-delombok/WithOnStatic.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/WithWithDollar.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/WitherOnStatic.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/WitherWithDollar.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/FlagUsages.java.messages4
-rw-r--r--test/transform/resource/messages-ecj/WithAlreadyExists.java.messages (renamed from test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages)0
-rw-r--r--test/transform/resource/messages-ecj/WithOnStatic.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/WithWithDollar.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/WitherAccessLevel.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/WitherOnStatic.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/WitherWithDollar.java.messages1
-rw-r--r--test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages10
-rw-r--r--website/extra/htaccess5
-rw-r--r--website/templates/features/With.html53
-rw-r--r--website/templates/features/experimental/Wither.html66
-rw-r--r--website/templates/setup/gradle.html2
-rw-r--r--website/usageExamples/WithExample_post.jpage21
-rw-r--r--website/usageExamples/WithExample_pre.jpage14
-rw-r--r--website/usageExamples/experimental/WitherExample_post.jpage21
-rw-r--r--website/usageExamples/experimental/WitherExample_pre.jpage14
170 files changed, 2682 insertions, 1214 deletions
diff --git a/AUTHORS b/AUTHORS
index 0bee77cd..91ef1793 100755
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,6 +9,8 @@ Dave Brosius <dbrosius@mebigfatguy.com>
Dawid Rusin <dawidrusin90@gmail.com>
Emil Lundberg <emil@yubico.com>
Enrique da Costa Cambio <enrique.dacostacambio@gmail.com>
+Jacob Middag <jacob@gaddim.nl>
+Jan Matèrne <jhm@apache.org>
Jan Rieke <it@janrieke.de>
Jappe van der Hel <jappe.vanderhel@gmail.com>
Kevin Chirls <kchirls@users.noreply.github.com>
diff --git a/build.xml b/build.xml
index 1bb4e0c0..f66191db 100644
--- a/build.xml
+++ b/build.xml
@@ -171,6 +171,15 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
</target>
<target name="compile" depends="version, ensureBuildDeps, -unpackLibs, -ensureJdk9" description="Compiles the code.">
+ <fail>
+For compiling with Java9 'modulepath' an Ant version 1.9.7+ or 1.10.0+ is required.
+Your current version is:
+ ${ant.version}
+ <condition>
+ <not><antversion atleast="1.9.8"/></not>
+ </condition>
+ </fail>
+
<!-- ant includes the destination dir on the classpath (and there are good reasons to do this), but that also means
the bleeding edge lombok from the previous build is run, which means if there are bugs in it, you can't compile
anymore until you 'ant clean'. That's very much not desired, so we kill the processor, which stops lombok from running.
@@ -764,12 +773,15 @@ You can also create your own by writing a 'testenvironment.properties' file. The
</target>
<target name="utils-javadoc" depends="compile">
+ <tstamp>
+ <format property="javadoc.year" pattern="yyyy"/>
+ </tstamp>
<mkdir dir="build/utils-api" />
<javadoc sourcepath="src/utils" defaultexcludes="yes" destdir="build/utils-api" windowtitle="Lombok Utils">
<classpath refid="build.path" />
<link href="http://download.oracle.com/javase/6/docs/api/" />
<header><![CDATA[<a href='https://projectlombok.org/' target='_blank'>Lombok</a> - ]]>v${lombok.version}</header>
- <bottom><![CDATA[<i>Copyright &copy; 2011-2015 The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
+ <bottom><![CDATA[<i>Copyright &copy; 2011-${javadoc.year} The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
</javadoc>
<!-- bugfix for boneheaded javadoc bug where ?is-external=true is inserted before an anchor ref, breaking the anchor ref.
is-external=true doesn't actually do anything, so, we'll just get rid of it. -->
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index 62cb9a44..b14ee89e 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -285,6 +285,9 @@ such as applying the templates to produce the website, converting the changelog
check the <a href="lombok/package-summary.html">lombok</a> package.&nbsp;If you're trying to extend lombok or
write your own plugins, the other packages are what you're looking for.</body></html>
]]></echo>
+ <tstamp>
+ <format property="javadoc.year" pattern="yyyy"/>
+ </tstamp>
<javadoc sourcepath="src/core" defaultexcludes="yes" destdir="build/api" windowtitle="Lombok" source="1.8" Overview="${javadoc.overview.html}">
<package name="lombok" />
<package name="lombok.experimental" />
@@ -292,7 +295,7 @@ such as applying the templates to produce the website, converting the changelog
<classpath refid="build.path" />
<classpath location="build/lombok" />
<header><![CDATA[<a href='https://projectlombok.org/' target='_blank'>Lombok</a> - ]]>v${lombok.version}</header>
- <bottom><![CDATA[<i>Copyright &copy; 2009-2019 The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
+ <bottom><![CDATA[<i>Copyright &copy; 2009-${javadoc.year} The Project Lombok Authors, licensed under the <a href='http://www.opensource.org/licenses/mit-license.php' target='_blank'>MIT licence</a>.]]></bottom>
</javadoc>
<!-- bugfix for boneheaded javadoc bug where ?is-external=true is inserted before an anchor ref, breaking the anchor ref.
is-external=true doesn't actually do anything except mess with titles, so, we'll just get rid of it. -->
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 0e489dd3..818ced1a 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -2,15 +2,23 @@ Lombok Changelog
----------------
### v1.18.9 "Edgy Guinea Pig"
+* No changes yet.
+
+### v1.18.10 (September 10th, 2019)
+* PROMOTION: `@Wither` has been promoted to the main package, renamed to `@With`. Otherwise, no changes have been made to the annotation. The old experimental annotation will remain for a few versions as a deprecated annotation. If you had `lombok.config` configuration for this annotation, the configuration keys for this feature have been renamed.
* FEATURE: You can now configure a custom logger framework using the new `@CustomLog` annotation in combination with the `lombok.log.custom.declaration` configuration key. See the [log documentation](https://projectlombok.org/features/Log) for more information. [Pullrequest #2086](https://github.com/rzwitserloot/lombok/pull/2086) with thanks to Adam Juraszek.
* ENHANCEMENT: Thanks to Mark Haynes, the `staticConstructor` will now also be generated if a (private) constructor already exists. [Issue #2100](https://github.com/rzwitserloot/lombok/issues/2100)
-* ENHANCEMENT: `val` is now capable of decoding the type of convoluted expressions (particularly if the right hand side involves lambdas and conditional (ternary) expressions). [Pull Request #2109](https://github.com/rzwitserloot/lombok/pull/2109) and [Pull Request #2138](https://github.com/rzwitserloot/lombok/pull/2138) with thanks to Alexander Bulgakov.
+* ENHANCEMENT: `val` is now capable of decoding the type of convoluted expressions (particularly if the right hand side involves lambdas and conditional (ternary) expressions). [Pull Request #2109](https://github.com/rzwitserloot/lombok/pull/2109) with thanks to Alexander Bulgakov.
* ENHANCEMENT: You can now configure the generated builder class name via the config system, using key `lombok.builder.className`. See the [Builder documentation](https://projectlombok.org/features/Builder) and [SuperBuilder documentation](https://projectlombok.org/features/experimental/SuperBuilder)
* ENHANCEMENT: If you mix up eclipse's non-null support, such as `@NonNullByDefault`, with lombok's `@NonNull`, you get a bunch of warnings about dead code that are inappropriate. These warnings are now suppressed, thanks to a contribution from Till Brychcy! [Pull Request #2155](https://github.com/rzwitserloot/lombok/pull/2155)
* ENHANCEMENT: `@NonNull` can now also generate checks using jdk's `Objects.requireNonNull` or Guava's `Preconditions.checkNotNull`. [Issue #1197](https://github.com/rzwitserloot/lombok/issues/1197)
+* EXPERIMENT: Lombok is working together with [checkerframework](https://checkerframework.org/) to enable detection of improper builder use (such as forgetting to set a mandatory property prior to calling `build()`). This experiment can be turned on by adding `checkerframework = true` to your `lombok.config` file.
+* BUGFIX: Using `@JsonProperty` or `@JsonValue` on a field in combination with `@Setter` or `@Data` would sometimes throw a ClassCastException during compilation. [Issue #2156](https://github.com/rzwitserloot/lombok/issues/2156)
* BUGFIX: Delombok would turn something like `List<byte[]>...` in a method parameter to `List<byte...>...` [Issue #2140](https://github.com/rzwitserloot/lombok/issues/2140)
* BUGFIX: Javac would generate the wrong equals and hashCode if a type-use annotation was put on an array type field [Issue #2165](https://github.com/rzwitserloot/lombok/issues/2165)
* BUGFIX: Eclipse 2019-06 + JDK-12 compatibility + an `@Singular` builder entry would produce a cascade of error dialogs. [Issue #2169](https://github.com/rzwitserloot/lombok/issues/2169)
+* BUGFIX: Javac would throw a NullPointerException if the package-info.java did not contain a package declaration. [Issue #2184](https://github.com/rzwitserloot/lombok/issues/2184)
+* BUGFIX: Javac sets incorrect annotated type on constructor, getter and setter. [Issue #2189](https://github.com/rzwitserloot/lombok/issues/2189)
* IMPROBABLE BREAKING CHANGE: Stricter validation of configuration keys dealing with identifiers and types (`lombok.log.fieldName`, `lombok.fieldNameConstants.innerTypeName`, `lombok.copyableAnnotations`).
* IMPROBABLE BREAKING CHANGE: The fields generated inside builders for fields with defaults (with `@Builder` on a class with fields marked `@Default`) now have `$value` as the name; direct manipulation of these fields is not advised because there is an associated `$set` variable that also needs to be taken into account. [Issue #2115](https://github.com/rzwitserloot/lombok/issues/2115)
diff --git a/docker/ant/Dockerfile b/docker/ant/Dockerfile
index 7358183e..69b465e8 100644
--- a/docker/ant/Dockerfile
+++ b/docker/ant/Dockerfile
@@ -1,14 +1,14 @@
-FROM ubuntu:16.04 as downloader
+FROM ubuntu:18.04 as downloader
-ARG jdk=11
+ARG jdk=12
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
-ARG ant=1.10.1
+ARG ant=1.10.6
ADD provision/ant/ant-${ant}.sh provision/ant/ant-${ant}.sh
RUN provision/ant/ant-${ant}.sh
-FROM ubuntu:16.04
+FROM ubuntu:18.04
COPY --from=downloader /usr/local/apache-ant/ /usr/local/apache-ant/
COPY --from=downloader /opt/jdk/ /opt/jdk/
@@ -19,7 +19,7 @@ WORKDIR workspace
ADD shared/ ./
-ARG jdk=11
+ARG jdk=12
ADD ant/files/jdk-${jdk} ./
ARG lombokjar=lombok.jar
diff --git a/docker/ant/files/jdk-11/build.xml b/docker/ant/files/jdk-11/build.xml
new file mode 100644
index 00000000..3f181ed9
--- /dev/null
+++ b/docker/ant/files/jdk-11/build.xml
@@ -0,0 +1,35 @@
+<project name="example" default="dist" basedir=".">
+ <property name="src" location="src/main/java"/>
+ <property name="build" location="build"/>
+ <property name="dist" location="dist"/>
+ <property name="build.sysclasspath" value="ignore"/>
+
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init" description="compile the source">
+ <javac classpath="lombok.jar" srcdir="${src}" destdir="${build}" fork="true">
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/>
+ </javac>
+ </target>
+
+ <target name="dist" depends="compile" description="generate the distribution">
+ <mkdir dir="${dist}/lib"/>
+ <jar jarfile="${dist}/lib/example-${DSTAMP}.jar" basedir="${build}"/>
+ </target>
+
+ <target name="clean" description="clean up">
+ <delete dir="${build}"/>
+ <delete dir="${dist}"/>
+ </target>
+</project> \ No newline at end of file
diff --git a/docker/ant/files/jdk-12/build.xml b/docker/ant/files/jdk-12/build.xml
new file mode 100644
index 00000000..3f181ed9
--- /dev/null
+++ b/docker/ant/files/jdk-12/build.xml
@@ -0,0 +1,35 @@
+<project name="example" default="dist" basedir=".">
+ <property name="src" location="src/main/java"/>
+ <property name="build" location="build"/>
+ <property name="dist" location="dist"/>
+ <property name="build.sysclasspath" value="ignore"/>
+
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init" description="compile the source">
+ <javac classpath="lombok.jar" srcdir="${src}" destdir="${build}" fork="true">
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"/>
+ <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/>
+ </javac>
+ </target>
+
+ <target name="dist" depends="compile" description="generate the distribution">
+ <mkdir dir="${dist}/lib"/>
+ <jar jarfile="${dist}/lib/example-${DSTAMP}.jar" basedir="${build}"/>
+ </target>
+
+ <target name="clean" description="clean up">
+ <delete dir="${build}"/>
+ <delete dir="${dist}"/>
+ </target>
+</project> \ No newline at end of file
diff --git a/docker/ant/readme.md b/docker/ant/readme.md
index 6618cd03..8983213e 100644
--- a/docker/ant/readme.md
+++ b/docker/ant/readme.md
@@ -2,10 +2,11 @@
[_(general configuration and options)_](../readme.md)
-### `ARG ant=1.10.1`
+### `ARG ant=1.10.6`
The ant version to be used. Supported values:
+- `1.10.6` (default)
- `1.10.1` (default)
## Example build commands:
@@ -13,17 +14,17 @@ The ant version to be used. Supported values:
(To be executed from the `<lombokhome>/docker` directory)
```
-docker build -t lombok-ant-jdk10 -f ant/Dockerfile .
+docker build -t lombok-ant-jdk12 -f ant/Dockerfile .
-docker build -t lombok-ant-jdk10 --build-arg lombokjar=lombok-1.16.20.jar -f ant/Dockerfile .
+docker build -t lombok-ant-jdk12 --build-arg lombokjar=lombok-1.16.20.jar -f ant/Dockerfile .
```
## Example run commands:
```
-docker run -it lombok-ant-jdk10
+docker run -it lombok-ant-jdk12
-docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-ant-jdk10
+docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-ant-jdk12
```
## Example container commands:
diff --git a/docker/bazel/Dockerfile b/docker/bazel/Dockerfile
index 007b7a5b..dd69273c 100644
--- a/docker/bazel/Dockerfile
+++ b/docker/bazel/Dockerfile
@@ -1,14 +1,14 @@
-FROM ubuntu:16.04 as downloader
+FROM ubuntu:18.04 as downloader
-ARG jdk=11
+ARG jdk=12
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
-ARG bazel=0.13.0
+ARG bazel=0.28.1
ADD provision/bazel/bazel-${bazel}.sh provision/bazel/bazel-${bazel}.sh
RUN provision/bazel/bazel-${bazel}.sh
-FROM ubuntu:16.04
+FROM ubuntu:18.04
COPY --from=downloader /opt/bazel/ /opt/bazel/
COPY --from=downloader /opt/jdk/ /opt/jdk/
@@ -23,7 +23,7 @@ ADD bazel/files/ ./
ARG lombokjar=lombok.jar
ADD https://projectlombok.org/downloads/${lombokjar} lombok.jar
-ARG jdk=11
+ARG jdk=12
ENV JDK_VERSION=${jdk}
ENV JAVA_HOME=/opt/jdk
ENV BAZEL_HOME=/opt/bazel
diff --git a/docker/bazel/readme.md b/docker/bazel/readme.md
index 2bed86f1..916b8718 100644
--- a/docker/bazel/readme.md
+++ b/docker/bazel/readme.md
@@ -2,28 +2,29 @@
[_(general configuration and options)_](../readme.md)
-### `ARG bazel=0.13.0`
+### `ARG bazel=0.28.1`
The bazel version to be used. Supported values:
-- `0.13.0` (default)
+- `0.28.1` (default)
+- `0.13.0`
## Example build commands:
(To be executed from the `<lombokhome>/docker` directory)
```
-docker build -t lombok-bazel-jdk10 -f bazel/Dockerfile .
+docker build -t lombok-bazel-jdk12 -f bazel/Dockerfile .
-docker build -t lombok-bazel-jdk10 --build-arg lombokjar=lombok-1.16.20.jar -f bazel/Dockerfile .
+docker build -t lombok-bazel-jdk12 --build-arg lombokjar=lombok-1.16.20.jar -f bazel/Dockerfile .
```
## Example run commands:
```
-docker run -it lombok-bazel-jdk10
+docker run -it lombok-bazel-jdk12
-docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-bazel-jdk10
+docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-bazel-jdk12
```
## Example container commands:
diff --git a/docker/gradle/Dockerfile b/docker/gradle/Dockerfile
index 0b6f8d4c..2721f9b2 100644
--- a/docker/gradle/Dockerfile
+++ b/docker/gradle/Dockerfile
@@ -1,14 +1,14 @@
-FROM ubuntu:16.04 as downloader
+FROM ubuntu:18.04 as downloader
-ARG jdk=11
+ARG jdk=12
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
-ARG gradle=5.1.1
+ARG gradle=5.6
ADD provision/gradle/gradle-${gradle}.sh provision/gradle/gradle-${gradle}.sh
RUN provision/gradle/gradle-${gradle}.sh
-FROM ubuntu:16.04
+FROM ubuntu:18.04
COPY --from=downloader /opt/gradle/ /opt/gradle/
COPY --from=downloader /opt/jdk/ /opt/jdk/
@@ -22,7 +22,7 @@ ADD gradle/files/ ./
ARG lombokjar=lombok.jar
ADD https://projectlombok.org/downloads/${lombokjar} lombok.jar
-ARG jdk=11
+ARG jdk=12
ENV JDK_VERSION=${jdk}
ENV JAVA_HOME=/opt/jdk
ENV GRADLE_HOME=/opt/gradle/gradle
diff --git a/docker/gradle/readme.md b/docker/gradle/readme.md
index a106b569..81f147d8 100644
--- a/docker/gradle/readme.md
+++ b/docker/gradle/readme.md
@@ -2,11 +2,12 @@
[_(general configuration and options)_](../readme.md)
-### `ARG gradle=5.1.1`
+### `ARG gradle=5.6`
The gradle version to be used. Supported values:
-- `5.1.1` (default)
+- `5.6` (default)
+- `5.1.1`
- `4.10.2`
- `4.7`
- `4.2.1`
@@ -16,17 +17,17 @@ The gradle version to be used. Supported values:
(To be executed from the `<lombokhome>/docker` directory)
```
-docker build -t lombok-gradle-jdk11 -f gradle/Dockerfile .
+docker build -t lombok-gradle-jdk12 -f gradle/Dockerfile .
-docker build -t lombok-gradle-jdk11 --build-arg lombokjar=lombok-1.16.20.jar -f gradle/Dockerfile .
+docker build -t lombok-gradle-jdk12 --build-arg lombokjar=lombok-1.16.20.jar -f gradle/Dockerfile .
```
## Example run commands:
```
-docker run -it lombok-gradle-jdk11
+docker run -it lombok-gradle-jdk12
-docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-gradle-jdk11
+docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-gradle-jdk12
```
## Example container commands:
diff --git a/docker/maven/Dockerfile b/docker/maven/Dockerfile
index f5433882..e5269ba2 100644
--- a/docker/maven/Dockerfile
+++ b/docker/maven/Dockerfile
@@ -1,14 +1,14 @@
-FROM ubuntu:16.04 as downloader
+FROM ubuntu:18.04 as downloader
-ARG jdk=11
+ARG jdk=12
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
-ARG maven=3.6.0
+ARG maven=3.6.1
ADD provision/maven/maven-${maven}.sh provision/maven/maven-${maven}.sh
RUN provision/maven/maven-${maven}.sh
-FROM ubuntu:16.04
+FROM ubuntu:18.04
COPY --from=downloader /usr/local/apache-maven/ /usr/local/apache-maven/
COPY --from=downloader /opt/jdk/ /opt/jdk/
@@ -19,7 +19,7 @@ WORKDIR workspace
ADD shared/ ./
-ARG jdk=11
+ARG jdk=12
ADD maven/files/jdk-${jdk} ./
ARG lombokjar=lombok.jar
diff --git a/docker/maven/files/jdk-12/pom.xml b/docker/maven/files/jdk-12/pom.xml
new file mode 100644
index 00000000..cdbab371
--- /dev/null
+++ b/docker/maven/files/jdk-12/pom.xml
@@ -0,0 +1,53 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.example</groupId>
+ <artifactId>lombok-jdk-${env.JDK_VERSION}</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java.version>12</java.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <fork>true</fork>
+ <compilerargs>
+ <arg>-Werror</arg>
+ <arg>-Xlint:all</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
+ <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
+ </compilerargs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.2.3</version>
+ <scope>system</scope>
+ <systemPath>/workspace/lombok.jar</systemPath>
+ </dependency>
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/docker/maven/readme.md b/docker/maven/readme.md
index 8a784eb8..2d0f0604 100644
--- a/docker/maven/readme.md
+++ b/docker/maven/readme.md
@@ -2,11 +2,12 @@
[_(general configuration and options)_](../readme.md)
-### `ARG maven=3.6.0`
+### `ARG maven=3.6.1`
The maven version to be used. Supported values:
-- `3.6.0` (default)
+- `3.6.1` (default)
+- `3.6.0`
- `3.5.0`
## Example build commands:
@@ -14,17 +15,17 @@ The maven version to be used. Supported values:
(To be executed from the `<lombokhome>/docker` directory)
```
-docker build -t lombok-maven-jdk11 -f maven/Dockerfile .
+docker build -t lombok-maven-jdk12 -f maven/Dockerfile .
-docker build -t lombok-maven-jdk11 --build-arg lombokjar=lombok-1.16.20.jar -f maven/Dockerfile .
+docker build -t lombok-maven-jdk12 --build-arg lombokjar=lombok-1.16.20.jar -f maven/Dockerfile .
```
## Example run commands:
```
-docker run -it lombok-maven-jdk11
+docker run -it lombok-maven-jdk12
-docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-maven-jdk11
+docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-maven-jdk12
```
## Example container commands:
diff --git a/docker/provision/ant/ant-1.10.1.sh b/docker/provision/ant/ant-1.10.1.sh
index 3de7f3d0..9105f400 100755
--- a/docker/provision/ant/ant-1.10.1.sh
+++ b/docker/provision/ant/ant-1.10.1.sh
@@ -1,4 +1,4 @@
apt-get update && apt-get install -y wget
wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz -O ant.tar.gz
mkdir /usr/local/apache-ant/ && tar xvf ant.tar.gz -C /usr/local/apache-ant/
-mv /usr/local/apache-ant/apache-ant-1.10.1 /usr/local/apache-ant/apache-ant
+mv /usr/local/apache-ant/apache-ant-1.10.1 /usr/local/apache-ant/apache-ant \ No newline at end of file
diff --git a/docker/provision/ant/ant-1.10.6.sh b/docker/provision/ant/ant-1.10.6.sh
new file mode 100644
index 00000000..66cfe9e4
--- /dev/null
+++ b/docker/provision/ant/ant-1.10.6.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget
+wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.6-bin.tar.gz -O ant.tar.gz
+mkdir /usr/local/apache-ant/ && tar xvf ant.tar.gz -C /usr/local/apache-ant/
+mv /usr/local/apache-ant/apache-ant-1.10.6 /usr/local/apache-ant/apache-ant \ No newline at end of file
diff --git a/docker/provision/bazel/bazel-0.28.1.sh b/docker/provision/bazel/bazel-0.28.1.sh
new file mode 100644
index 00000000..054915d3
--- /dev/null
+++ b/docker/provision/bazel/bazel-0.28.1.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget pkg-config zip g++ zlib1g-dev unzip python
+wget https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel-0.28.1-installer-linux-x86_64.sh -O bazel-installer.sh
+chmod +x bazel-installer.sh
+./bazel-installer.sh --prefix=/opt/bazel \ No newline at end of file
diff --git a/docker/provision/gradle/gradle-5.6.sh b/docker/provision/gradle/gradle-5.6.sh
new file mode 100644
index 00000000..ab34da42
--- /dev/null
+++ b/docker/provision/gradle/gradle-5.6.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget unzip
+wget https://services.gradle.org/distributions/gradle-5.6-bin.zip -O gradle.zip
+mkdir /opt/gradle && unzip -d /opt/gradle gradle.zip
+mv /opt/gradle/gradle-5.6 /opt/gradle/gradle
diff --git a/docker/provision/jdk/java-10.sh b/docker/provision/jdk/java-10.sh
index 4cf75f60..51aebd25 100755
--- a/docker/provision/jdk/java-10.sh
+++ b/docker/provision/jdk/java-10.sh
@@ -1,4 +1,4 @@
apt-get update && apt-get install -y wget
-wget https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_linux-x64_bin.tar.gz -O jdk.tar.gz
+wget https://github.com/AdoptOpenJDK/openjdk10-releases/releases/download/jdk-10.0.2%2B13/OpenJDK10_x64_Linux_jdk-10.0.2%2B13.tar.gz -O jdk.tar.gz
tar -xzf jdk.tar.gz -C /opt/
-mv /opt/jdk-10.0.2 /opt/jdk
+mv /opt/jdk-10.0.2+13 /opt/jdk
diff --git a/docker/provision/jdk/java-11.sh b/docker/provision/jdk/java-11.sh
index 6252c2ae..21f4e949 100644
--- a/docker/provision/jdk/java-11.sh
+++ b/docker/provision/jdk/java-11.sh
@@ -1,4 +1,4 @@
apt-get update && apt-get install -y wget
-wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O jdk.tar.gz
+wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.4%2B11/OpenJDK11U-jdk_x64_linux_hotspot_11.0.4_11.tar.gz -O jdk.tar.gz
tar -xzf jdk.tar.gz -C /opt/
-mv /opt/jdk-11.0.2 /opt/jdk \ No newline at end of file
+mv /opt/jdk-11.0.4+11 /opt/jdk \ No newline at end of file
diff --git a/docker/provision/jdk/java-12.sh b/docker/provision/jdk/java-12.sh
new file mode 100644
index 00000000..6598d56c
--- /dev/null
+++ b/docker/provision/jdk/java-12.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget
+wget https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_linux_hotspot_12.0.2_10.tar.gz -O jdk.tar.gz
+tar -xzf jdk.tar.gz -C /opt/
+mv /opt/jdk-12.0.2+10 /opt/jdk \ No newline at end of file
diff --git a/docker/provision/jdk/java-8.sh b/docker/provision/jdk/java-8.sh
index 44795c6c..7875ef2c 100755
--- a/docker/provision/jdk/java-8.sh
+++ b/docker/provision/jdk/java-8.sh
@@ -1,6 +1,4 @@
-apt-get update && apt-get install -y software-properties-common
-echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
-add-apt-repository -y ppa:webupd8team/java
-apt-get update && apt-get install -y oracle-java8-installer
-
-mv /usr/lib/jvm/java-8-oracle /opt/jdk
+apt-get update && apt-get install -y wget
+wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_x64_linux_hotspot_8u222b10.tar.gz -O jdk.tar.gz
+tar -xzf jdk.tar.gz -C /opt/
+mv /opt/jdk8u222-b10 /opt/jdk \ No newline at end of file
diff --git a/docker/provision/jdk/java-9.sh b/docker/provision/jdk/java-9.sh
index 483c1a28..4b4bac90 100755
--- a/docker/provision/jdk/java-9.sh
+++ b/docker/provision/jdk/java-9.sh
@@ -1,4 +1,4 @@
apt-get update && apt-get install -y wget
-wget https://download.java.net/java/GA/jdk9/9.0.4/binaries/openjdk-9.0.4_linux-x64_bin.tar.gz -O jdk.tar.gz
+wget https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk-9.0.4%2B11/OpenJDK9U-jdk_x64_linux_hotspot_9.0.4_11.tar.gz -O jdk.tar.gz
tar -xzf jdk.tar.gz -C /opt/
-mv /opt/jdk-9.0.4 /opt/jdk
+mv /opt/jdk-9.0.4+11 /opt/jdk
diff --git a/docker/provision/maven/maven-3.6.1.sh b/docker/provision/maven/maven-3.6.1.sh
new file mode 100644
index 00000000..d8a8be64
--- /dev/null
+++ b/docker/provision/maven/maven-3.6.1.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget
+wget https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.tar.gz -O maven.tar.gz
+mkdir /usr/local/apache-maven/ && tar xvf maven.tar.gz -C /usr/local/apache-maven/
+mv /usr/local/apache-maven/apache-maven-3.6.1 /usr/local/apache-maven/apache-maven
diff --git a/docker/readme.md b/docker/readme.md
index 81e500b3..3500a6ef 100644
--- a/docker/readme.md
+++ b/docker/readme.md
@@ -10,11 +10,12 @@ Each docker image contains a `/workspace` where all relevant files are located.
When building the image, a lombok.jar will be downloaded to `/workspace`. By default, this is the latest released version. You
can download a specific version by adding `--build-arg lombokjar=lombok-<major.minor.build>.jar`
-### `ARG jdk=11`
+### `ARG jdk=12`
The jdk version to be used. Supported values:
-- `11` (default)
+- `12` (default)
+- `11`
- `10`
- `9`
- `8`
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index dda0b54b..ef433d8d 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -24,6 +24,7 @@ package lombok;
import java.util.List;
import lombok.core.configuration.CallSuperType;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.configuration.ConfigurationKey;
import lombok.core.configuration.LogDeclaration;
import lombok.core.configuration.FlagUsageType;
@@ -353,6 +354,15 @@ public class ConfigurationKeys {
public static final ConfigurationKey<FlagUsageType> VAL_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.val.flagUsage", "Emit a warning or error if 'val' is used.") {};
public static final ConfigurationKey<FlagUsageType> VAR_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.var.flagUsage", "Emit a warning or error if 'var' is used.") {};
+ // ----- With -----
+
+ /**
+ * lombok configuration: {@code lombok.with.flagUsage} = {@code WARNING} | {@code ERROR}.
+ *
+ * If set, <em>any</em> usage of {@code @With} results in a warning / error.
+ */
+ public static final ConfigurationKey<FlagUsageType> WITH_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.with.flagUsage", "Emit a warning or error if @With is used.") {};
+
// ##### Extern #####
// ----- Logging -----
@@ -592,15 +602,6 @@ public class ConfigurationKeys {
*/
public static final ConfigurationKey<Boolean> FIELD_NAME_CONSTANTS_UPPERCASE = new ConfigurationKey<Boolean>("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 -----
-
- /**
- * lombok configuration: {@code lombok.wither.flagUsage} = {@code WARNING} | {@code ERROR}.
- *
- * If set, <em>any</em> usage of {@code @Wither} results in a warning / error.
- */
- public static final ConfigurationKey<FlagUsageType> WITHER_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.wither.flagUsage", "Emit a warning or error if @Wither is used.") {};
-
// ----- SuperBuilder -----
/**
@@ -624,8 +625,17 @@ public class ConfigurationKeys {
/**
* lombok configuration: {@code lombok.copyableAnnotations} += &lt;TypeName: fully-qualified annotation class name&gt;.
*
- * 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<List<TypeName>> COPYABLE_ANNOTATIONS = new ConfigurationKey<List<TypeName>>("lombok.copyableAnnotations", "Copy these annotations to getters, setters, with methods, builder-setters, etc.") {};
+
+ /**
+ * lombok configuration: {@code checkerframework} = {@code true} | {@code false} | &lt;String: MajorVer.MinorVer&gt; (Default: false).
+ *
+ * If set, lombok will generate appropriate annotations from checkerframework.org on generated code. If set to {@code true}, all relevant annotations from the most recent version of
+ * checkerframework.org that lombok supports will be generated. If set to a specific major/minor version number, only checkerframework annotations introduced on or before the stated
+ * checkerframework.org version will be generated.
*/
- public static final ConfigurationKey<List<TypeName>> COPYABLE_ANNOTATIONS = new ConfigurationKey<List<TypeName>>("lombok.copyableAnnotations", "Copy these annotations to getters, setters, withers, builder-setters, etc.") {};
+ public static final ConfigurationKey<CheckerFrameworkVersion> CHECKER_FRAMEWORK = new ConfigurationKey<CheckerFrameworkVersion>("checkerframework", "If set with the version of checkerframework.org (in major.minor, or just 'true' for the latest supported version), create relevant checkerframework.org annotations for code lombok generates (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).
+ * <p>
+ * Complete documentation is found at <a href="https://projectlombok.org/features/With">the project lombok features page for &#64;With</a>.
+ * <p>
+ * Example:
+ * <pre>
+ * private &#64;With final int foo;
+ * </pre>
+ *
+ * will generate:
+ *
+ * <pre>
+ * public SELF_TYPE withFoo(int foo) {
+ * return this.foo == foo ? this : new SELF_TYPE(otherField1, otherField2, foo);
+ * }
+ * </pre>
+ * <p>
+ * 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).<br>
+ * up to JDK7:<br>
+ * {@code @With(onMethod=@__({@AnnotationsGoHere}))}<br>
+ * from JDK8:<br>
+ * {@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).<br>
+ * up to JDK7:<br>
+ * {@code @With(onParam=@__({@AnnotationsGoHere}))}<br>
+ * from JDK8:<br>
+ * {@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..68ced84f 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
@@ -21,6 +21,7 @@
*/
package lombok.core;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -30,6 +31,7 @@ public class LombokInternalAliasing {
/** Maps a package name to a space separated list of packages. If the key package is star-imported, assume all packages in the 'value' part of the MapEntry are too. */
public static final Map<String, Collection<String>> IMPLIED_EXTRA_STAR_IMPORTS;
public static final Map<String, String> ALIASES;
+ public static final Map<String, Collection<String>> REVERSE_ALIASES;
/**
* Provide a fully qualified name (FQN), and the canonical version of this is returned.
@@ -51,6 +53,26 @@ 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);
+
+ Map<String, Collection<String>> m3 = new HashMap<String, Collection<String>>();
+ for (Map.Entry<String, String> e : m2.entrySet()) {
+ Collection<String> c = m3.get(e.getValue());
+ if (c == null) {
+ m3.put(e.getValue(), Collections.singleton(e.getKey()));
+ } else if (c.size() == 1) {
+ Collection<String> newC = new ArrayList<String>(2);
+ newC.addAll(c);
+ m3.put(e.getValue(), c);
+ } else {
+ c.add(e.getKey());
+ }
+ }
+ for (Map.Entry<String, Collection<String>> e : m3.entrySet()) {
+ Collection<String> c = e.getValue();
+ if (c.size() > 1) e.setValue(Collections.unmodifiableList((ArrayList<String>) c));
+ }
+ REVERSE_ALIASES = Collections.unmodifiableMap(m3);
}
}
diff --git a/src/core/lombok/core/TypeLibrary.java b/src/core/lombok/core/TypeLibrary.java
index ceaf5f90..113ce67e 100644
--- a/src/core/lombok/core/TypeLibrary.java
+++ b/src/core/lombok/core/TypeLibrary.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -21,6 +21,7 @@
*/
package lombok.core;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -75,6 +76,14 @@ public class TypeLibrary {
}
public static TypeLibrary createLibraryForSingleType(String fqnSingleton) {
+ if (LombokInternalAliasing.REVERSE_ALIASES.containsKey(fqnSingleton)) {
+ // Internal aliasing is a little too complex to handle with the map-less 'efficient' implementation.
+ TypeLibrary tl = new TypeLibrary();
+ tl.addType(fqnSingleton);
+ tl.lock();
+ return tl;
+ }
+
return new TypeLibrary(fqnSingleton);
}
@@ -89,7 +98,7 @@ public class TypeLibrary {
if (locked) throw new IllegalStateException("locked");
int idx = fullyQualifiedTypeName.lastIndexOf('.');
if (idx == -1) throw new IllegalArgumentException(
- "Only fully qualified types are allowed (and stuff in the default package is not palatable to us either!)");
+ "Only fully qualified types are allowed (types in the default package cannot be added here either)");
String unqualified = fullyQualifiedTypeName.substring(idx + 1);
if (unqualifiedToQualifiedMap == null) throw new IllegalStateException("SingleType library");
@@ -97,8 +106,11 @@ public class TypeLibrary {
unqualifiedToQualifiedMap.put(unqualified, dotBased);
unqualifiedToQualifiedMap.put(fullyQualifiedTypeName, dotBased);
unqualifiedToQualifiedMap.put(dotBased, dotBased);
- for (Map.Entry<String, String> e : LombokInternalAliasing.ALIASES.entrySet()) {
- if (fullyQualifiedTypeName.equals(e.getValue())) unqualifiedToQualifiedMap.put(e.getKey(), dotBased);
+ Collection<String> oldNames = LombokInternalAliasing.REVERSE_ALIASES.get(fullyQualifiedTypeName);
+ if (oldNames != null) for (String oldName : oldNames) {
+ unqualifiedToQualifiedMap.put(oldName, dotBased);
+ int li = oldName.lastIndexOf('.');
+ if (li != -1) unqualifiedToQualifiedMap.put(oldName.substring(li + 1), dotBased);
}
int idx2 = fullyQualifiedTypeName.indexOf('$', idx + 1);
@@ -119,9 +131,6 @@ public class TypeLibrary {
public String toQualified(String typeReference) {
if (unqualifiedToQualifiedMap == null) {
if (typeReference.equals(unqualified) || typeReference.equals(qualified)) return qualified;
- for (Map.Entry<String, String> e : LombokInternalAliasing.ALIASES.entrySet()) {
- if (e.getKey().equals(typeReference)) return e.getValue();
- }
return null;
}
return unqualifiedToQualifiedMap.get(typeReference);
diff --git a/src/core/lombok/core/TypeResolver.java b/src/core/lombok/core/TypeResolver.java
index 60ac6b6a..06c91138 100644
--- a/src/core/lombok/core/TypeResolver.java
+++ b/src/core/lombok/core/TypeResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -45,7 +45,7 @@ public class TypeResolver {
public String typeRefToFullyQualifiedName(LombokNode<?, ?, ?> context, TypeLibrary library, String typeRef) {
typeRef = LombokInternalAliasing.processAliases(typeRef);
- // When asking if 'Foo' could possibly be referring to 'bar.Baz', the answer is obviously no.
+ // When asking if 'Foo' could possibly be referring to 'bar.Baz', the answer is obviously no.
String qualified = library.toQualified(typeRef);
if (qualified == null) return null;
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java
index 0a4f7e3d..28c79ac2 100644
--- a/src/core/lombok/core/Version.java
+++ b/src/core/lombok/core/Version.java
@@ -30,7 +30,7 @@ public class Version {
// ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries).
// Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example.
// Official builds always end in an even number. (Since 0.10.2).
- private static final String VERSION = "1.18.9";
+ private static final String VERSION = "1.18.11";
private static final String RELEASE_NAME = "Edgy Guinea Pig";
// private static final String RELEASE_NAME = "Envious Ferret";
diff --git a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
new file mode 100644
index 00000000..68fc05a7
--- /dev/null
+++ b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 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.core.configuration;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class CheckerFrameworkVersion implements ConfigurationValueType {
+ private final int version;
+ private static final int MAX_SUPPORTED = 3000;
+
+ public static final String NAME__SIDE_EFFECT_FREE = "org.checkerframework.dataflow.qual.SideEffectFree";
+ public static final String NAME__UNIQUE = "org.checkerframework.common.aliasing.qual.Unique";
+ public static final String NAME__RETURNS_RECEIVER = "org.checkerframework.checker.builder.qual.ReturnsReceiver";
+ public static final String NAME__NOT_CALLED = "org.checkerframework.checker.builder.qual.NotCalledMethods";
+ public static final String NAME__CALLED = "org.checkerframework.checker.builder.qual.CalledMethods";
+
+ public static final CheckerFrameworkVersion NONE = new CheckerFrameworkVersion(0);
+
+ private CheckerFrameworkVersion(int v) {
+ this.version = v;
+ }
+
+ private static final Pattern VERSION = Pattern.compile("^(\\d+)(?:\\.(\\d+))?(?:\\.\\d+)*$");
+
+ public boolean generateSideEffectFree() {
+ return version > 0;
+ }
+
+ public boolean generateUnique() {
+ return version > 0;
+ }
+
+ public boolean generateReturnsReceiver() {
+ return version > 2999;
+ }
+
+ public boolean generateCalledMethods() {
+ return version > 2999;
+ }
+
+ public static CheckerFrameworkVersion valueOf(String versionString) {
+ if (versionString != null) versionString = versionString.trim();
+ if (versionString == null || versionString.equalsIgnoreCase("false") || versionString.equals("0")) return new CheckerFrameworkVersion(0);
+ if (versionString.equalsIgnoreCase("true")) return new CheckerFrameworkVersion(MAX_SUPPORTED);
+ Matcher m = VERSION.matcher(versionString);
+ if (!m.matches()) throw new IllegalArgumentException("Expected 'true' or 'false' or a major/minor version, such as '2.9'");
+ int major = Integer.parseInt(m.group(1));
+ int minor = (m.group(2) != null && !m.group(2).isEmpty()) ? Integer.parseInt(m.group(2)) : 0;
+ if (minor > 999) throw new IllegalArgumentException("Minor version must be between 0 and 999");
+ int v = major * 1000 + minor;
+ if (v > MAX_SUPPORTED) {
+ String s = (v / 1000) + "." + (v % 1000);
+ throw new IllegalArgumentException("Lombok supports at most v" + s + "; reduce the value of key 'checkerframework' to " + s);
+ }
+ return new CheckerFrameworkVersion(v);
+ }
+
+ public static String description() {
+ return "checkerframework-version";
+ }
+
+ public static String exampleValue() {
+ String s = (MAX_SUPPORTED / 1000) + "." + (MAX_SUPPORTED % 1000);
+ return "major.minor (example: 2.9 - and no higher than " + s + ") or true or false";
+ }
+}
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<String> INVALID_ON_BUILDERS = Collections.unmodifiableList(
Arrays.<String>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:
* <ul>
@@ -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> accessors, CharSequence fieldName, boolean isBoolean) {
+ public static String toWithName(AST<?, ?, ?> ast, AnnotationValues<Accessors> 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:<br />
* {@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<String> toAllWitherNames(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean) {
+ public static List<String> toAllWithNames(AST<?, ?, ?> ast, AnnotationValues<Accessors> 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 11a2b9bd..0955dba6 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -111,6 +111,7 @@ import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
import lombok.core.LombokImmutableList;
import lombok.core.TypeResolver;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.configuration.NullCheckExceptionType;
import lombok.core.configuration.TypeName;
import lombok.core.debug.ProblemReporter;
@@ -184,6 +185,23 @@ public class EclipseHandlerUtil {
return ma;
}
+ public static MarkerAnnotation generateNamedAnnotation(ASTNode source, String typeName) {
+ char[][] cc = fromQualifiedName(typeName);
+ QualifiedTypeReference qtr = new QualifiedTypeReference(cc, poss(source, cc.length));
+ setGeneratedBy(qtr, source);
+ MarkerAnnotation ma = new MarkerAnnotation(qtr, source.sourceStart);
+ // No matter what value you input for sourceEnd, the AST->DOM converter of eclipse will reparse to find the end, and will fail as
+ // it can't find code that isn't really there. This results in the end position being set to 2 or 0 or some weird magic value, and thus,
+ // length, as calculated by end-start, is all screwed up, resulting in IllegalArgumentException during a setSourceRange call MUCH later in the process.
+ // We solve it by going with a voodoo magic source start value such that the calculated length so happens to exactly be 0. 0 lengths are accepted
+ // by eclipse. For some reason.
+ // TL;DR: Don't change 1. 1 is sacred. Trust the 1.
+ // issue: #408.
+ ma.sourceStart = 1;
+ setGeneratedBy(ma, source);
+ return ma;
+ }
+
public static boolean isFieldDeprecated(EclipseNode fieldNode) {
if (!(fieldNode.get() instanceof FieldDeclaration)) return false;
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
@@ -199,6 +217,11 @@ public class EclipseHandlerUtil {
return false;
}
+ public static CheckerFrameworkVersion getCheckerFrameworkVersion(EclipseNode node) {
+ CheckerFrameworkVersion cfv = node.getAst().readConfiguration(ConfigurationKeys.CHECKER_FRAMEWORK);
+ return cfv != null ? cfv : CheckerFrameworkVersion.NONE;
+ }
+
/**
* Checks if the given TypeReference node is likely to be a reference to the provided class.
*
@@ -652,15 +675,6 @@ public class EclipseHandlerUtil {
return result == null ? null : result.toArray(new Annotation[0]);
}
- public static Annotation[] mergeAnnotations(Annotation[] a, Annotation[] b) {
- if (a == null || a.length == 0) return (b == null || b.length == 0) ? null : b;
- if (b == null || b.length == 0) return a.length == 0 ? null : a;
- Annotation[] c = new Annotation[a.length + b.length];
- System.arraycopy(a, 0, c, 0, a.length);
- System.arraycopy(b, 0, c, a.length, b.length);
- return c;
- }
-
public static boolean hasAnnotation(Class<? extends java.lang.annotation.Annotation> type, EclipseNode node) {
if (node == null) return false;
if (type == null) return false;
@@ -1403,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<String> toAllWitherNames(EclipseNode field, boolean isBoolean) {
- return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
+ public static java.util.List<String> 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);
}
/**
@@ -1908,11 +1922,13 @@ public class EclipseHandlerUtil {
* Create an annotation of the given name, and is marked as being generated by the given source.
*/
public static MarkerAnnotation makeMarkerAnnotation(char[][] name, ASTNode source) {
- long pos = (long)source.sourceStart << 32 | source.sourceEnd;
- TypeReference typeRef = new QualifiedTypeReference(name, new long[] {pos, pos, pos});
+ long pos = (long) source.sourceStart << 32 | source.sourceEnd;
+ long[] poss = new long[name.length];
+ Arrays.fill(poss, pos);
+ TypeReference typeRef = new QualifiedTypeReference(name, poss);
setGeneratedBy(typeRef, source);
- MarkerAnnotation ann = new MarkerAnnotation(typeRef, (int)(pos >> 32));
- ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = (int)pos;
+ MarkerAnnotation ann = new MarkerAnnotation(typeRef, (int) (pos >> 32));
+ ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = (int) pos;
setGeneratedBy(ann, source);
return ann;
}
diff --git a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
index a8a780d6..da0bf471 100755
--- a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
+++ b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
@@ -33,6 +33,7 @@ import java.util.Map;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
import org.eclipse.jdt.internal.compiler.ast.Expression;
@@ -62,6 +63,7 @@ import lombok.AccessLevel;
import lombok.core.LombokImmutableList;
import lombok.core.SpiLoadUtil;
import lombok.core.TypeLibrary;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.eclipse.EclipseNode;
public class EclipseSingularsRecipes {
@@ -235,7 +237,7 @@ public class EclipseSingularsRecipes {
* If you need more control over the return type and value, use
* {@link #generateMethods(SingularData, boolean, EclipseNode, boolean, TypeReferenceMaker, StatementMaker)}.
*/
- public void generateMethods(SingularData data, boolean deprecate, final EclipseNode builderType, boolean fluent, final boolean chain, AccessLevel access) {
+ public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, final EclipseNode builderType, boolean fluent, final boolean chain, AccessLevel access) {
TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() {
@Override public TypeReference make() {
return chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
@@ -248,14 +250,14 @@ public class EclipseSingularsRecipes {
}
};
- generateMethods(data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
+ generateMethods(cfv, data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
}
/**
* Generates the singular, plural, and clear methods for the given {@link SingularData}.
* Uses the given {@code returnTypeMaker} and {@code returnStatementMaker} for the generated methods.
*/
- public abstract void generateMethods(SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
+ public abstract void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
public abstract void appendBuildCode(SingularData data, EclipseNode builderType, List<Statement> statements, char[] targetVariableName, String builderVariable);
@@ -272,6 +274,15 @@ public class EclipseSingularsRecipes {
// -- Utility methods --
+ protected Annotation[] generateSelfReturnAnnotations(boolean deprecate, CheckerFrameworkVersion cfv, ASTNode source) {
+ Annotation deprecated = deprecate ? generateDeprecatedAnnotation(source) : null;
+ Annotation returnsReceiver = cfv.generateReturnsReceiver() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) : null;
+ if (deprecated == null && returnsReceiver == null) return null;
+ if (deprecated == null) return new Annotation[] {returnsReceiver};
+ if (returnsReceiver == null) return new Annotation[] {deprecated};
+ return new Annotation[] {deprecated, returnsReceiver};
+ }
+
/**
* Adds the requested number of type arguments to the provided type, copying each argument in {@code typeArgs}. If typeArgs is too long, the extra elements are ignored.
* If {@code typeArgs} is null or too short, {@code java.lang.Object} will be substituted for each missing type argument.
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 5a4d5bff..375bd164 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -38,6 +38,7 @@ import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
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.ArrayInitializer;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
@@ -58,9 +59,11 @@ import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedThisReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
+import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.Statement;
+import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
@@ -85,6 +88,7 @@ import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -156,6 +160,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
@Override public void handle(AnnotationValues<Builder> annotation, Annotation ast, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder");
+ CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode);
long p = (long) ast.sourceStart << 32 | ast.sourceEnd;
@@ -488,14 +493,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
for (BuilderFieldData bfd : builderFields) {
- makePrefixedSetterMethodsForBuilder(builderType, bfd, annotationNode, fluent, chain, accessForInners, bfd.originalFieldNode, builderInstance.setterPrefix());
+ makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, bfd.originalFieldNode, builderInstance.setterPrefix());
}
{
MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1);
if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0);
if (methodExists == MemberExistsResult.NOT_EXISTS) {
- MethodDeclaration md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfStaticBuilderMethod, returnType, builderFields, builderType, thrownExceptions, addCleaning, ast, accessForInners);
+ MethodDeclaration md = generateBuildMethod(cfv, tdParent, isStatic, buildMethodName, nameOfStaticBuilderMethod, returnType, builderFields, builderType, thrownExceptions, addCleaning, ast, accessForInners);
if (md != null) injectMethod(builderType, md);
}
}
@@ -518,7 +523,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- MethodDeclaration md = generateBuilderMethod(isStatic, builderMethodName, builderClassName, tdParent, typeParams, ast, accessForOuters);
+ MethodDeclaration md = generateBuilderMethod(cfv, isStatic, builderMethodName, builderClassName, tdParent, typeParams, ast, accessForOuters);
if (md != null) injectMethod(tdParent, md);
}
@@ -535,7 +540,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
tps[i].name = typeArgsForToBuilder.get(i);
}
}
- MethodDeclaration md = generateToBuilderMethod(toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters);
+ MethodDeclaration md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters);
if (md != null) injectMethod(tdParent, md);
}
@@ -548,7 +553,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
private static final char[] BUILDER_TEMP_VAR = {'b', 'u', 'i', 'l', 'd', 'e', 'r'};
- private MethodDeclaration generateToBuilderMethod(String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source, AccessLevel access) {
+ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source, AccessLevel access) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -624,6 +629,10 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
out.statements = new Statement[] {new ReturnStatement(receiver, pS, pE)};
}
+ if (cfv.generateUnique()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
+
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
@@ -651,7 +660,35 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return decl;
}
- public MethodDeclaration generateBuildMethod(EclipseNode tdParent, boolean isStatic, String name, char[] staticName, TypeReference returnType, List<BuilderFieldData> builderFields, EclipseNode type, TypeReference[] thrownExceptions, boolean addCleaning, ASTNode source, AccessLevel access) {
+ static Argument[] generateBuildArgs(CheckerFrameworkVersion cfv, EclipseNode type, List<BuilderFieldData> builderFields, ASTNode source) {
+ if (!cfv.generateCalledMethods()) return null;
+
+ List<char[]> mandatories = new ArrayList<char[]>();
+ for (BuilderFieldData bfd : builderFields) {
+ if (bfd.singularData == null && bfd.nameOfSetFlag == null) mandatories.add(bfd.name);
+ }
+
+ if (mandatories.size() == 0) return null;
+ char[][] nameCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__CALLED);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameCalled, poss(source, nameCalled.length)), source.sourceStart);
+ if (mandatories.size() == 1) {
+ ann.memberValue = new StringLiteral(mandatories.get(0), 0, 0, 0);
+ } else {
+ ArrayInitializer arr = new ArrayInitializer();
+ arr.sourceStart = source.sourceStart;
+ arr.sourceEnd = source.sourceEnd;
+ arr.expressions = new Expression[mandatories.size()];
+ for (int i = 0; i < arr.expressions.length; i++) {
+ arr.expressions[i] = new StringLiteral(mandatories.get(i), source.sourceStart, source.sourceEnd, 0);
+ }
+ ann.memberValue = arr;
+ }
+ Argument arg = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(type.getName().toCharArray(), source.sourceStart), Modifier.FINAL);
+ arg.annotations = new Annotation[] {ann};
+ return new Argument[] {arg};
+ }
+
+ public MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, EclipseNode tdParent, boolean isStatic, String name, char[] staticName, TypeReference returnType, List<BuilderFieldData> builderFields, EclipseNode type, TypeReference[] thrownExceptions, boolean addCleaning, ASTNode source, AccessLevel access) {
MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
List<Statement> statements = new ArrayList<Statement>();
@@ -724,6 +761,10 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
}
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
+ if (cfv.generateSideEffectFree()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
+ }
+ out.arguments = generateBuildArgs(cfv, type, builderFields, source);
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return out;
}
@@ -755,7 +796,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return out;
}
- public MethodDeclaration generateBuilderMethod(boolean isStatic, String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source, AccessLevel access) {
+ public MethodDeclaration generateBuilderMethod(CheckerFrameworkVersion cfv, boolean isStatic, String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source, AccessLevel access) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -769,7 +810,15 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
AllocationExpression invoke = new AllocationExpression();
invoke.type = namePlusTypeParamsToTypeReference(builderClassName.toCharArray(), typeParams, p);
out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
-
+ Annotation uniqueAnn = cfv.generateUnique() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE) : null;
+ Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) : null;
+ if (uniqueAnn != null && sefAnn != null) {
+ out.annotations = new Annotation[] {uniqueAnn, sefAnn};
+ } else if (uniqueAnn != null) {
+ out.annotations = new Annotation[] {uniqueAnn};
+ } else if (sefAnn != null) {
+ out.annotations = new Annotation[] {sefAnn};
+ }
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -814,18 +863,19 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
private static final AbstractMethodDeclaration[] EMPTY = {};
- public void makeSetterMethodsForBuilder(EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode) {
+ public void makeSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- makeSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode);
+ makeSimpleSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode);
} else {
- bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, fluent, chain, access);
+ bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, fluent, chain, access);
}
}
- private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations, AccessLevel access, EclipseNode originalFieldNode) {
+ private void makeSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations, AccessLevel access, EclipseNode originalFieldNode) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
+ ASTNode source = sourceNode.get();
if (existing == null) existing = EMPTY;
int len = existing.length;
FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
@@ -839,24 +889,35 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
String setterName = fluent ? new String(paramName) : HandlerUtil.buildAccessorName("set", new String(paramName));
- List<Annotation> methodAnnsList = Collections.<Annotation>emptyList();
+ List<Annotation> methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode));
Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
if (methodAnns != null && methodAnns.length > 0) methodAnnsList = Arrays.asList(methodAnns);
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, chain, toEclipseModifier(access),
sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annotations)) : Collections.<Annotation>emptyList());
+ if (cfv.generateCalledMethods()) {
+ Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments;
+ Argument[] newArr = new Argument[arr.length + 1];
+ System.arraycopy(arr, 0, newArr, 1, arr.length);
+ newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(builderType.getName().toCharArray(), 0), Modifier.FINAL);
+ char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart);
+ ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
+ newArr[0].annotations = new Annotation[] {ann};
+ setter.arguments = newArr;
+ }
injectMethod(builderType, setter);
}
- public void makePrefixedSetterMethodsForBuilder(EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode, String prefix) {
+ public void makePrefixedSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode, String prefix) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- makePrefixedSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode, prefix);
+ makePrefixedSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode, prefix);
} else {
- bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, fluent, chain, access);
+ bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, fluent, chain, access);
}
}
- private void makePrefixedSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations, AccessLevel access, EclipseNode originalFieldNode, String prefix) {
+ private void makePrefixedSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations, AccessLevel access, EclipseNode originalFieldNode, String prefix) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY;
@@ -881,8 +942,21 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
List<Annotation> methodAnnsList = Collections.<Annotation>emptyList();
Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
if (methodAnns != null && methodAnns.length > 0) methodAnnsList = Arrays.asList(methodAnns);
+ ASTNode source = sourceNode.get();
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, chain, toEclipseModifier(access),
- sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annotations)) : Collections.<Annotation>emptyList());
+ sourceNode, methodAnnsList, annotations != null ? Arrays.asList(copyAnnotations(source, annotations)) : Collections.<Annotation>emptyList());
+ if (cfv.generateCalledMethods()) {
+ Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments;
+ Argument[] newArr = new Argument[arr.length + 1];
+ System.arraycopy(arr, 0, newArr, 1, arr.length);
+ newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(builderType.getName().toCharArray(), 0), Modifier.FINAL);
+ char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(
+ source, nameNotCalled.length)), source.sourceStart);
+ ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
+ newArr[0].annotations = new Annotation[] {ann};
+ setter.arguments = newArr;
+ }
injectMethod(builderType, setter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index c6b51042..8f981c1a 100755
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2018 The Project Lombok Authors.
+ * Copyright (C) 2010-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
@@ -39,6 +39,7 @@ import lombok.ConfigurationKeys;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -456,14 +457,14 @@ public class HandleConstructor {
constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[0]);
/* Generate annotations that must be put on the generated method, and attach them. */ {
- Annotation[] constructorProperties = null;
- if (addConstructorProperties && !isLocalType(type)) {
- constructorProperties = createConstructorProperties(source, fieldsToParam);
- }
+ Annotation[] constructorProperties = null, checkerFramework = null;
+ if (addConstructorProperties && !isLocalType(type)) constructorProperties = createConstructorProperties(source, fieldsToParam);
+ if (getCheckerFrameworkVersion(type).generateUnique()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE) };
constructor.annotations = copyAnnotations(source,
onConstructor.toArray(new Annotation[0]),
- constructorProperties);
+ constructorProperties,
+ checkerFramework);
}
constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
@@ -551,7 +552,9 @@ public class HandleConstructor {
assigns.add(nameRef);
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
- parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode));
+ Annotation[] checkerFramework = null;
+ if (getCheckerFrameworkVersion(fieldNode).generateUnique()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE) };
+ parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode), checkerFramework);
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 046b197f..1bca4767 100755
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -42,6 +42,7 @@ import lombok.core.handlers.InclusionExclusionUtils;
import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.core.AnnotationValues;
import lombok.core.configuration.CallSuperType;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -235,7 +236,12 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
method.modifiers = toEclipseModifier(AccessLevel.PUBLIC);
method.returnType = TypeReference.baseTypeReference(TypeIds.T_int, 0);
setGeneratedBy(method.returnType, source);
- method.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source)};
+ Annotation overrideAnnotation = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
+ if (getCheckerFrameworkVersion(type).generateSideEffectFree()) {
+ method.annotations = new Annotation[] { overrideAnnotation, generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
+ } else {
+ method.annotations = new Annotation[] { overrideAnnotation };
+ }
method.selector = "hashCode".toCharArray();
method.thrownExceptions = null;
method.typeParameters = null;
@@ -508,7 +514,12 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
method.returnType = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
setGeneratedBy(method.returnType, source);
- method.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source)};
+ Annotation overrideAnnotation = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
+ if (getCheckerFrameworkVersion(type).generateSideEffectFree()) {
+ method.annotations = new Annotation[] { overrideAnnotation, generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
+ } else {
+ method.annotations = new Annotation[] { overrideAnnotation };
+ }
method.selector = "equals".toCharArray();
method.thrownExceptions = null;
method.typeParameters = null;
@@ -785,6 +796,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
setGeneratedBy(returnStatement, source);
method.statements = new Statement[] {returnStatement};
+ if (getCheckerFrameworkVersion(type).generateSideEffectFree()) method.annotations = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
return method;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index 7d3fe62f..7ba84cdc 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -38,6 +38,7 @@ import lombok.experimental.Delegate;
import lombok.Getter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.agent.PatchDelegate;
@@ -262,16 +263,16 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
EclipseHandlerUtil.registerCreatedLazyGetter((FieldDeclaration) fieldNode.get(), method.selector, returnType);
- /* Generate annotations that must be put on the generated method, and attach them. */ {
- Annotation[] deprecated = null;
- if (isFieldDeprecated(fieldNode)) {
- deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
- }
+ /* Generate annotations that must be put on the generated method, and attach them. */ {
+ 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]),
findCopyableAnnotations(fieldNode),
findDelegatesAndMarkAsHandled(fieldNode),
+ checkerFramework,
deprecated);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index bb704ead..8180c3fa 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -36,6 +36,7 @@ import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.Setter;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -200,7 +201,11 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
returnThis = new ReturnStatement(thisRef, pS, pE);
}
- return createSetter(parent, deprecate, fieldNode, name, paramName, booleanFieldToSet, returnType, returnThis, modifier, sourceNode, onMethod, onParam);
+ MethodDeclaration d = createSetter(parent, deprecate, fieldNode, name, paramName, booleanFieldToSet, returnType, returnThis, modifier, sourceNode, onMethod, onParam);
+ if (shouldReturnThis && getCheckerFrameworkVersion(sourceNode).generateReturnsReceiver()) {
+ d.annotations = copyAnnotations(source, d.annotations, new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) });
+ }
+ return d;
}
static MethodDeclaration createSetter(TypeDeclaration parent, boolean deprecate, EclipseNode fieldNode, String name, char[] paramName, char[] booleanFieldToSet, TypeReference returnType, Statement returnStatement, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam) {
@@ -221,7 +226,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
if (isFieldDeprecated(fieldNode) || deprecate) {
deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
}
- method.annotations = mergeAnnotations(copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated), findCopyableToSetterAnnotations(fieldNode));
+ method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated, findCopyableToSetterAnnotations(fieldNode));
Argument param = new Argument(paramName, p, copyType(field.type, source), Modifier.FINAL);
param.sourceStart = pS; param.sourceEnd = pE;
method.arguments = new Argument[] { param };
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 88479911..8f0ef338 100755
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -57,9 +57,11 @@ import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
+import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.Statement;
+import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.SuperReference;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
@@ -81,6 +83,7 @@ import lombok.ConfigurationKeys;
import lombok.Singular;
import lombok.ToString;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.core.AnnotationValues;
@@ -119,6 +122,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
@Override
public void handle(AnnotationValues<SuperBuilder> annotation, Annotation ast, EclipseNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.SUPERBUILDER_FLAG_USAGE, "@SuperBuilder");
+ CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode);
long p = (long) ast.sourceStart << 32 | ast.sourceEnd;
@@ -269,7 +273,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// If there is no superclass, superclassBuilderClassExpression is still == null at this point.
// You can use it to check whether to inherit or not.
- generateBuilderBasedConstructor(tdParent, typeParams, builderFields, annotationNode, builderClassName,
+ generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
superclassBuilderClass != null);
// Create the abstract builder class, or reuse an existing one.
@@ -334,12 +338,12 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
// Generate abstract self() and build() methods in the abstract builder.
- injectMethod(builderType, generateAbstractSelfMethod(tdParent, superclassBuilderClass != null, builderGenericName));
- injectMethod(builderType, generateAbstractBuildMethod(tdParent, buildMethodName, superclassBuilderClass != null, classGenericName, ast));
+ injectMethod(builderType, generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClass != null, builderGenericName));
+ injectMethod(builderType, generateAbstractBuildMethod(cfv, builderType, buildMethodName, builderFields, superclassBuilderClass != null, classGenericName, ast));
// Create the setter methods in the abstract builder.
for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(builderType, bfd, annotationNode, builderGenericName);
+ generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName);
}
// Create the toString() method for the abstract builder.
@@ -386,22 +390,22 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
break;
case NOT_EXISTS:
- injectMethod(tdParent, generateToBuilderMethod(builderClassName, builderImplClassName, tdParent, typeParams, ast));
+ injectMethod(tdParent, generateToBuilderMethod(cfv, builderClassName, builderImplClassName, tdParent, typeParams, ast));
default:
// Should not happen.
}
}
// Create the self() and build() methods in the BuilderImpl.
- injectMethod(builderImplType, generateSelfMethod(builderImplType, typeParams, p));
+ injectMethod(builderImplType, generateSelfMethod(cfv, builderImplType, typeParams, p));
if (methodExists(buildMethodName, builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
- injectMethod(builderImplType, generateBuildMethod(tdParent, buildMethodName, returnType, ast));
+ injectMethod(builderImplType, generateBuildMethod(cfv, builderImplType, buildMethodName, returnType, builderFields, ast));
}
// Add the builder() method to the annotated class.
if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- MethodDeclaration md = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, tdParent, typeParams, ast);
+ MethodDeclaration md = generateBuilderMethod(cfv, builderMethodName, builderClassName, builderImplClassName, tdParent, typeParams, ast);
if (md != null) injectMethod(tdParent, md);
}
@@ -483,6 +487,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* the type (with the {@code @Builder} annotation) for which a
* constructor should be generated.
* @param typeParams
+ * @param cfv Settings for generating checker framework annotations
* @param builderFields a list of fields in the builder which should be assigned to new instances.
* @param source the annotation (used for setting source code locations for the generated code).
* @param callBuilderBasedSuperConstructor
@@ -490,7 +495,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* constructor with the builder as argument. Requires
* {@code builderClassAsParameter != null}.
*/
- private void generateBuilderBasedConstructor(EclipseNode typeNode, TypeParameter[] typeParams, List<BuilderFieldData> builderFields,
+ private void generateBuilderBasedConstructor(CheckerFrameworkVersion cfv, EclipseNode typeNode, TypeParameter[] typeParams, List<BuilderFieldData> builderFields,
EclipseNode sourceNode, String builderClassName, boolean callBuilderBasedSuperConstructor) {
ASTNode source = sourceNode.get();
@@ -501,6 +506,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) typeNode.top().get()).compilationResult);
constructor.modifiers = toEclipseModifier(AccessLevel.PROTECTED);
+ if (cfv.generateUnique()) constructor.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
constructor.selector = typeDeclaration.name;
if (callBuilderBasedSuperConstructor) {
constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.Super);
@@ -572,7 +578,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
injectMethod(typeNode, constructor);
}
- private MethodDeclaration generateBuilderMethod(String builderMethodName, String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
+ private MethodDeclaration generateBuilderMethod(CheckerFrameworkVersion cfv, String builderMethodName, String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -591,6 +597,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
invoke.type = namePlusTypeParamsToTypeReference(builderImplClassName.toCharArray(), typeParams, p);
out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
+ if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -603,7 +611,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* }
* </pre>
*/
- private MethodDeclaration generateToBuilderMethod(String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
+ private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -623,6 +631,8 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
invokeFillMethod.arguments = new Expression[] {new ThisReference(0, 0)};
out.statements = new Statement[] {new ReturnStatement(invokeFillMethod, pS, pE)};
+ if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -755,44 +765,64 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
return ms;
}
- private MethodDeclaration generateAbstractSelfMethod(EclipseNode tdParent, boolean override, String builderGenericName) {
+ private MethodDeclaration generateAbstractSelfMethod(CheckerFrameworkVersion cfv, EclipseNode tdParent, boolean override, String builderGenericName) {
MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
out.selector = SELF_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected | ExtraCompilerModifiers.AccSemicolonBody;
- if (override) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get())};
+ Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get()) : null;
+ Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(tdParent.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER): null;
+ Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(tdParent.get(), CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ if (overrideAnn != null && rrAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn, sefAnn};
+ else if (overrideAnn != null && rrAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn};
+ else if (overrideAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
+ else if (overrideAnn != null) out.annotations = new Annotation[] {overrideAnn};
+ else if (rrAnn != null && sefAnn != null) out.annotations = new Annotation[] {rrAnn, sefAnn};
+ else if (rrAnn != null) out.annotations = new Annotation[] {rrAnn};
+ else if (sefAnn != null) out.annotations = new Annotation[] {sefAnn};
out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0);
return out;
}
- private MethodDeclaration generateSelfMethod(EclipseNode builderImplType, TypeParameter[] typeParams, long p) {
+ private MethodDeclaration generateSelfMethod(CheckerFrameworkVersion cfv, EclipseNode builderImplType, TypeParameter[] typeParams, long p) {
MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderImplType.top().get()).compilationResult);
out.selector = SELF_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccProtected;
- out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get())};
+ Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get());
+ Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER): null;
+ Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ if (rrAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn, sefAnn};
+ else if (rrAnn != null) out.annotations = new Annotation[] {overrideAnn, rrAnn};
+ else if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
+ else out.annotations = new Annotation[] {overrideAnn};
out.returnType = namePlusTypeParamsToTypeReference(builderImplType.getName().toCharArray(), typeParams, p);
out.statements = new Statement[] {new ReturnStatement(new ThisReference(0, 0), 0, 0)};
return out;
}
- private MethodDeclaration generateAbstractBuildMethod(EclipseNode tdParent, String methodName, boolean override,
+ private MethodDeclaration generateAbstractBuildMethod(CheckerFrameworkVersion cfv, EclipseNode builderType, String methodName, List<BuilderFieldData> builderFields, boolean override,
String classGenericName, ASTNode source) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
+ MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody;
out.selector = methodName.toCharArray();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.returnType = new SingleTypeReference(classGenericName.toCharArray(), 0);
- if (override) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source)};
+ Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source) : null;
+ Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ if (overrideAnn != null && sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
+ else if (overrideAnn != null) out.annotations = new Annotation[] {overrideAnn};
+ else if (sefAnn != null) out.annotations = new Annotation[] {sefAnn};
+ out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return out;
}
- private MethodDeclaration generateBuildMethod(EclipseNode tdParent, String name, TypeReference returnType, ASTNode source) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
+ private MethodDeclaration generateBuildMethod(CheckerFrameworkVersion cfv, EclipseNode builderType, String name, TypeReference returnType, List<BuilderFieldData> builderFields, ASTNode source) {
+ MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
List<Statement> statements = new ArrayList<Statement>();
@@ -800,7 +830,10 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
out.selector = name.toCharArray();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.returnType = returnType;
- out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source)};
+ Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
+ Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
+ else out.annotations = new Annotation[] {overrideAnn};
AllocationExpression allocationStatement = new AllocationExpression();
allocationStatement.type = copyType(out.returnType);
@@ -809,6 +842,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
statements.add(new ReturnStatement(allocationStatement, 0, 0));
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
return out;
}
@@ -872,7 +906,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
}
- private void generateSetterMethodsForBuilder(EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, final String builderGenericName) {
+ private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, final String builderGenericName) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() {
@@ -891,14 +925,15 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
};
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, true, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations, bfd.originalFieldNode);
+ generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, true, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations, bfd.originalFieldNode);
} else {
- bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
+ bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
- private void generateSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, boolean fluent, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam, EclipseNode originalFieldNode) {
+ private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, boolean fluent, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam, EclipseNode originalFieldNode) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
+ ASTNode source = sourceNode.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY_METHODS;
int len = existing.length;
@@ -913,11 +948,24 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
String setterName = fluent ? new String(paramName) : HandlerUtil.buildAccessorName("set", new String(paramName));
- List<Annotation> methodAnnsList = Collections.<Annotation>emptyList();
- Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
- if (methodAnns != null && methodAnns.length > 0) methodAnnsList = Arrays.asList(methodAnns);
+ List<Annotation> methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode));
+ if (cfv.generateReturnsReceiver()) {
+ methodAnnsList = new ArrayList<Annotation>(methodAnnsList);
+ methodAnnsList.add(generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER));
+ }
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, paramName, nameOfSetFlag, returnType, returnStatement, ClassFileConstants.AccPublic,
- sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annosOnParam)) : Collections.<Annotation>emptyList());
+ sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(source, annosOnParam)) : Collections.<Annotation>emptyList());
+ if (cfv.generateCalledMethods()) {
+ Argument[] arr = setter.arguments == null ? new Argument[0] : setter.arguments;
+ Argument[] newArr = new Argument[arr.length + 1];
+ System.arraycopy(arr, 0, newArr, 1, arr.length);
+ newArr[0] = new Argument(new char[] { 't', 'h', 'i', 's' }, 0, new SingleTypeReference(builderType.getName().toCharArray(), 0), Modifier.FINAL);
+ char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(source, nameNotCalled.length)), source.sourceStart);
+ ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
+ newArr[0].annotations = new Annotation[] {ann};
+ setter.arguments = newArr;
+ }
injectMethod(builderType, setter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java
index bb52feb5..39fd5937 100644
--- a/src/core/lombok/eclipse/handlers/HandleToString.java
+++ b/src/core/lombok/eclipse/handlers/HandleToString.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -60,6 +60,7 @@ import lombok.ToString;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.configuration.CallSuperType;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil.FieldAccess;
import lombok.core.handlers.InclusionExclusionUtils;
import lombok.core.handlers.InclusionExclusionUtils.Included;
@@ -300,7 +301,12 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
method.modifiers = toEclipseModifier(AccessLevel.PUBLIC);
method.returnType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_STRING, new long[] {p, p, p});
setGeneratedBy(method.returnType, source);
- method.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source)};
+ Annotation overrideAnnotation = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
+ if (getCheckerFrameworkVersion(type).generateSideEffectFree()) {
+ method.annotations = new Annotation[] { overrideAnnotation, generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
+ } else {
+ method.annotations = new Annotation[] { overrideAnnotation };
+ }
method.arguments = null;
method.selector = "toString".toCharArray();
method.thrownExceptions = null;
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWith.java
index a99789a6..8c8c3712 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWith.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 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
@@ -32,11 +32,12 @@ 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 lombok.experimental.Wither;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
@@ -59,10 +60,10 @@ import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.mangosdk.spi.ProviderFor;
@ProviderFor(EclipseAnnotationHandler.class)
-public class HandleWither extends EclipseAnnotationHandler<Wither> {
- public boolean generateWitherForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWither) {
- if (checkForTypeLevelWither) {
- if (hasAnnotation(Wither.class, typeNode)) {
+public class HandleWith extends EclipseAnnotationHandler<With> {
+ 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;
}
@@ -75,7 +76,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
(ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0;
if (typeDecl == null || notAClass) {
- pos.addError("@Wither is only supported on a class or a field.");
+ pos.addError("@With is only supported on a class or a field.");
return false;
}
@@ -87,28 +88,28 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
//Skip final fields.
if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0 && fieldDecl.initialization != null) continue;
- generateWitherForField(field, pos, level);
+ generateWithForField(field, pos, level);
}
return true;
}
/**
- * Generates a wither on the stated field.
+ * 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.Wither} annotation on the field, it is used and the
+ * 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 wither is still generated if it isn't already there, though there will not
+ * 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 generateWitherForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) {
+ public void generateWithForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) {
for (EclipseNode child : fieldNode.down()) {
if (child.getKind() == Kind.ANNOTATION) {
- if (annotationTypeMatches(Wither.class, child)) {
+ if (annotationTypeMatches(With.class, child)) {
//The annotation will make it happen, so we can skip it.
return;
}
@@ -116,49 +117,49 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
}
List<Annotation> empty = Collections.emptyList();
- createWitherForField(level, fieldNode, sourceNode, false, empty, empty);
+ createWithForField(level, fieldNode, sourceNode, false, empty, empty);
}
- @Override public void handle(AnnotationValues<Wither> annotation, Annotation ast, EclipseNode annotationNode) {
- handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
+ @Override public void handle(AnnotationValues<With> 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<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod", annotationNode);
- List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam", annotationNode);
+ List<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@With(onMethod", annotationNode);
+ List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@With(onParam", annotationNode);
switch (node.getKind()) {
case FIELD:
- createWitherForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam);
+ createWithForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam);
break;
case TYPE:
if (!onMethod.isEmpty()) {
- annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
+ annotationNode.addError("'onMethod' is not supported for @With on a type.");
}
if (!onParam.isEmpty()) {
- annotationNode.addError("'onParam' is not supported for @Wither on a type.");
+ annotationNode.addError("'onParam' is not supported for @With on a type.");
}
- generateWitherForType(node, annotationNode, level, false);
+ generateWithForType(node, annotationNode, level, false);
break;
}
}
- public void createWitherForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) {
+ public void createWithForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) {
for (EclipseNode fieldNode : fieldNodes) {
- createWitherForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam);
+ createWithForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam);
}
}
- public void createWitherForField(
+ public void createWithForField(
AccessLevel level, EclipseNode fieldNode, EclipseNode sourceNode,
boolean whineIfExists, List<Annotation> onMethod,
List<Annotation> onParam) {
ASTNode source = sourceNode.get();
if (fieldNode.getKind() != Kind.FIELD) {
- sourceNode.addError("@Wither is only supported on a class or a field.");
+ sourceNode.addError("@With is only supported on a class or a field.");
return;
}
@@ -168,38 +169,38 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
TypeReference fieldType = copyType(field.type, source);
boolean isBoolean = isBoolean(fieldType);
- String witherName = toWitherName(fieldNode, isBoolean);
+ String withName = toWithName(fieldNode, isBoolean);
- if (witherName == null) {
- fieldNode.addWarning("Not generating wither for this field: It does not fit your @Accessors prefix list.");
+ 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 wither for this field: Withers cannot be generated for static fields.");
+ 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 wither for this field: Withers cannot be generated for final, initialized fields.");
+ 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 wither for this field: Withers cannot be generated for fields starting with $.");
+ fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for fields starting with $.");
return;
}
- for (String altName : toAllWitherNames(fieldNode, isBoolean)) {
+ 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(witherName)) altNameExpl = String.format(" (%s)", altName);
+ if (!altName.equals(withName)) altNameExpl = String.format(" (%s)", altName);
fieldNode.addWarning(
- String.format("Not generating %s(): A method with that name already exists%s", witherName, altNameExpl));
+ String.format("Not generating %s(): A method with that name already exists%s", withName, altNameExpl));
}
return;
default:
@@ -210,11 +211,11 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
int modifier = toEclipseModifier(level);
- MethodDeclaration method = createWither((TypeDeclaration) fieldNode.up().get(), fieldNode, witherName, modifier, sourceNode, onMethod, onParam, makeAbstract);
+ MethodDeclaration method = createWith((TypeDeclaration) fieldNode.up().get(), fieldNode, withName, modifier, sourceNode, onMethod, onParam, makeAbstract);
injectMethod(fieldNode.up(), method);
}
- public MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam, boolean makeAbstract ) {
+ public MethodDeclaration createWith(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam, boolean makeAbstract ) {
ASTNode source = sourceNode.get();
if (name == null) return null;
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
@@ -226,11 +227,11 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.returnType = cloneSelfType(fieldNode, source);
if (method.returnType == null) return null;
- Annotation[] deprecated = null;
- if (isFieldDeprecated(fieldNode)) {
- deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
- }
- method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
+ 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 };
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index 642ba9b7..338f5eab 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -31,6 +31,7 @@ import java.util.List;
import lombok.AccessLevel;
import lombok.core.GuavaTypeMap;
import lombok.core.LombokImmutableList;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.HandleNonNull;
@@ -111,13 +112,13 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
- generateSingularMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generatePluralMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generateClearMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ generateSingularMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generatePluralMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generateClearMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
}
- void generateClearMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
+ void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -128,13 +129,13 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
md.statements = returnStatement != null ? new Statement[] {a, returnStatement} : new Statement[] {a};
md.returnType = returnType;
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
- void generateSingularMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
LombokImmutableList<String> suffixes = getArgumentSuffixes();
char[][] names = new char[suffixes.size()][];
for (int i = 0; i < suffixes.size(); i++) {
@@ -172,13 +173,13 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
}
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
- void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -204,7 +205,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName(getAddMethodName() + "All", new String(data.getPluralName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
index 73d6fe9b..53ea15a6 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
@@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.List;
import lombok.AccessLevel;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.HandleNonNull;
@@ -91,18 +92,18 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
if (useGuavaInstead(builderType)) {
- guavaListSetSingularizer.generateMethods(data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
+ guavaListSetSingularizer.generateMethods(cfv, data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
return;
}
- generateSingularMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generatePluralMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generateClearMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
+ generateSingularMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generatePluralMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generateClearMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
}
- private void generateClearMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
+ private void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -118,13 +119,13 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
- void generateSingularMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -150,13 +151,13 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
- void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -181,7 +182,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index b642522f..8684987f 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -54,6 +54,7 @@ import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.core.LombokImmutableList;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
@@ -150,18 +151,18 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
return Arrays.asList(keyFieldNode, valueFieldNode);
}
- @Override public void generateMethods(SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, EclipseNode builderType, boolean fluent, TypeReferenceMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
if (useGuavaInstead(builderType)) {
- guavaMapSingularizer.generateMethods(data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
+ guavaMapSingularizer.generateMethods(cfv, data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
return;
}
- generateSingularMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generatePluralMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
- generateClearMethod(deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
+ generateSingularMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generatePluralMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, fluent, access);
+ generateClearMethod(cfv, deprecate, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, access);
}
- private void generateClearMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
+ private void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -188,13 +189,13 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsgs, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
- private void generateSingularMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -245,13 +246,13 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.arguments = new Argument[] {keyParam, valueParam};
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("put", new String(data.getSingularName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
- private void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
+ private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
md.modifiers = toEclipseModifier(access);
@@ -309,7 +310,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("putAll", new String(data.getPluralName())).toCharArray();
- md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
+ md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
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;
* <p>
* 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/apt/LombokProcessor.java b/src/core/lombok/javac/apt/LombokProcessor.java
index 79db5dec..c32e09d5 100644
--- a/src/core/lombok/javac/apt/LombokProcessor.java
+++ b/src/core/lombok/javac/apt/LombokProcessor.java
@@ -389,7 +389,16 @@ public class LombokProcessor extends AbstractProcessor {
}
private JCCompilationUnit toUnit(Element element) {
- TreePath path = trees == null ? null : trees.getPath(element);
+ TreePath path = null;
+ if (trees != null) {
+ try {
+ path = trees.getPath(element);
+ } catch (NullPointerException ignore) {
+ // Happens if a package-info.java dowsn't conatin a package declaration.
+ // https://github.com/rzwitserloot/lombok/issues/2184
+ // We can safely ignore those, since they do not need any processing
+ }
+ }
if (path == null) return null;
return (JCCompilationUnit) path.getCompilationUnit();
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index e447ace7..da40692e 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -58,6 +58,7 @@ import lombok.ToString;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.experimental.NonFinal;
@@ -102,7 +103,8 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
@Override public void handle(AnnotationValues<Builder> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder");
-
+ CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode);
+
Builder builderInstance = annotation.getInstance();
AccessLevel accessForOuters = builderInstance.access();
if (accessForOuters == null) accessForOuters = AccessLevel.PUBLIC;
@@ -434,14 +436,14 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
for (BuilderFieldData bfd : builderFields) {
- makePrefixedSetterMethodsForBuilder(builderType, bfd, annotationNode, fluent, chain, accessForInners, builderInstance.setterPrefix());
+ makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, builderInstance.setterPrefix());
}
{
MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1);
if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0);
if (methodExists == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl md = generateBuildMethod(tdParent, isStatic, buildMethodName, nameOfBuilderMethod, returnType, builderFields, builderType, thrownExceptions, ast, addCleaning, accessForInners);
+ JCMethodDecl md = generateBuildMethod(cfv, tdParent, isStatic, buildMethodName, nameOfBuilderMethod, returnType, builderFields, builderType, thrownExceptions, ast, addCleaning, accessForInners);
if (md != null) {
injectMethod(builderType, md);
recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
@@ -465,7 +467,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- JCMethodDecl md = generateBuilderMethod(isStatic, builderMethodName, builderClassName, annotationNode, tdParent, typeParams, accessForOuters);
+ JCMethodDecl md = generateBuilderMethod(cfv, isStatic, builderMethodName, builderClassName, annotationNode, tdParent, typeParams, accessForOuters);
recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
if (md != null) injectMethod(tdParent, md);
}
@@ -485,7 +487,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
tps = lb.toList();
}
- JCMethodDecl md = generateToBuilderMethod(toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters);
+ JCMethodDecl md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters);
if (md != null) {
recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
injectMethod(tdParent, md);
@@ -534,7 +536,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
private static final String BUILDER_TEMP_VAR = "builder";
- private JCMethodDecl generateToBuilderMethod(String toBuilderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, boolean fluent, JCAnnotation ast, AccessLevel access) {
+ private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String toBuilderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, boolean fluent, JCAnnotation ast, AccessLevel access) {
// return new ThingieBuilder<A, B>().setA(this.a).setB(this.b);
JavacTreeMaker maker = type.getTreeMaker();
@@ -585,7 +587,8 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
statements.append(maker.Return(invoke));
}
JCBlock body = maker.Block(0, statements.toList());
- return maker.MethodDef(maker.Modifiers(toJavacModifier(access)), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ return maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
@@ -617,7 +620,30 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
*/
}
- private JCMethodDecl generateBuildMethod(JavacNode tdParent, boolean isStatic, String buildName, Name builderName, JCExpression returnType, java.util.List<BuilderFieldData> builderFields, JavacNode type, List<JCExpression> thrownExceptions, JCTree source, boolean addCleaning, AccessLevel access) {
+ static List<JCVariableDecl> generateBuildArgs(CheckerFrameworkVersion cfv, JavacNode type, java.util.List<BuilderFieldData> builderFields) {
+ if (!cfv.generateCalledMethods()) return List.<JCVariableDecl>nil();
+
+ ArrayList<String> mandatories = new ArrayList<String>();
+ for (BuilderFieldData bfd : builderFields) {
+ if (bfd.singularData == null && bfd.nameOfSetFlag == null) mandatories.add(bfd.name.toString());
+ }
+
+ JCExpression arg;
+ JavacTreeMaker maker = type.getTreeMaker();
+ if (mandatories.size() == 0) return List.<JCVariableDecl>nil();
+ if (mandatories.size() == 1) arg = maker.Literal(mandatories.get(0));
+ else {
+ List<JCExpression> elems = List.nil();
+ for (int i = mandatories.size() - 1; i >= 0; i--) elems = elems.prepend(maker.Literal(mandatories.get(i)));
+ arg = maker.NewArray(null, List.<JCExpression>nil(), elems);
+ }
+ JCAnnotation recvAnno = maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__CALLED), List.of(arg));
+ JCClassDecl builderTypeNode = (JCClassDecl) type.get();
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>of(recvAnno)), type.toName("this"), maker.Ident(builderTypeNode.name), null);
+ return List.of(recv);
+ }
+
+ private JCMethodDecl generateBuildMethod(CheckerFrameworkVersion cfv, JavacNode tdParent, boolean isStatic, String buildName, Name builderName, JCExpression returnType, java.util.List<BuilderFieldData> builderFields, JavacNode type, List<JCExpression> thrownExceptions, JCTree source, boolean addCleaning, AccessLevel access) {
JavacTreeMaker maker = type.getTreeMaker();
JCExpression call;
@@ -670,7 +696,9 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCBlock body = maker.Block(0, statements.toList());
- return maker.MethodDef(maker.Modifiers(toJavacModifier(access)), type.toName(buildName), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ List<JCAnnotation> annsOnMethod = cfv.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ List<JCVariableDecl> params = generateBuildArgs(cfv, type, builderFields);
+ return maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(buildName), returnType, List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
}
public static JCMethodDecl generateDefaultProvider(Name methodName, JavacNode fieldNode, List<JCTypeParameter> params) {
@@ -685,7 +713,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
return maker.MethodDef(maker.Modifiers(modifiers), methodName, cloneType(maker, field.vartype, field, fieldNode.getContext()), copyTypeParams(fieldNode, params), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- public JCMethodDecl generateBuilderMethod(boolean isStatic, String builderMethodName, String builderClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams, AccessLevel access) {
+ public JCMethodDecl generateBuilderMethod(CheckerFrameworkVersion cfv, boolean isStatic, String builderMethodName, String builderClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams, AccessLevel access) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
@@ -699,7 +727,14 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
int modifiers = toJavacModifier(access);
if (isStatic) modifiers |= Flags.STATIC;
- return maker.MethodDef(maker.Modifiers(modifiers), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ JCAnnotation annUnique = cfv.generateUnique() ? maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()) : null;
+ JCAnnotation annSef = cfv.generateSideEffectFree() ? maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()) : null;
+ List<JCAnnotation> annsOnMethod;
+ if (annUnique != null && annSef != null) annsOnMethod = List.of(annUnique, annSef);
+ else if (annUnique != null) annsOnMethod = List.of(annUnique);
+ else if (annSef != null) annsOnMethod = List.of(annSef);
+ else annsOnMethod = List.nil();
+ return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
@@ -741,16 +776,16 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
}
- public void makeSetterMethodsForBuilder(JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, boolean fluent, boolean chain, AccessLevel access) {
+ public void makeSetterMethodsForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, boolean fluent, boolean chain, AccessLevel access) {
boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode);
if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) {
- makeSimpleSetterMethodForBuilder(builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access);
+ makeSimpleSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access);
} else {
- fieldNode.singularData.getSingularizer().generateMethods(fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access);
+ fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access);
}
}
- private void makeSimpleSetterMethodForBuilder(JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, AccessLevel access) {
+ private void makeSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, AccessLevel access) {
Name fieldName = ((JCVariableDecl) fieldNode.get()).name;
for (JavacNode child : builderType.down()) {
@@ -772,17 +807,17 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
injectMethod(builderType, newMethod);
}
- public void makePrefixedSetterMethodsForBuilder(JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, boolean fluent, boolean chain, AccessLevel access, String prefix) {
+ public void makePrefixedSetterMethodsForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, boolean fluent, boolean chain, AccessLevel access, String prefix) {
boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode);
if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) {
- makePrefixedSetterMethodForBuilder(builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access, prefix);
+ makePrefixedSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access, prefix);
} else {
// TODO prefixed version
- fieldNode.singularData.getSingularizer().generateMethods(fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access);
+ fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access);
}
}
- private void makePrefixedSetterMethodForBuilder(JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, AccessLevel access, String prefix) {
+ private void makePrefixedSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, boolean chain, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, AccessLevel access, String prefix) {
Name fieldName = ((JCVariableDecl) fieldNode.get()).name;
for (JavacNode child : builderType.down()) {
@@ -804,6 +839,12 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
JCMethodDecl newMethod = HandleSetter.createSetter(toJavacModifier(access), deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, chain, source, methodAnns, annosOnParam);
+ if (cfv.generateCalledMethods()) {
+ JCAnnotation ncAnno = maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(newMethod.getName().toString())));
+ JCClassDecl builderTypeNode = (JCClassDecl) builderType.get();
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>of(ncAnno)), builderType.toName("this"), maker.Ident(builderTypeNode.name), null);
+ newMethod.params = List.of(recv, newMethod.params.get(0));
+ }
recursiveSetGeneratedBy(newMethod, source.get(), builderType.getContext());
copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER);
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java
index 096963f4..4d7c61ad 100644
--- a/src/core/lombok/javac/handlers/HandleConstructor.java
+++ b/src/core/lombok/javac/handlers/HandleConstructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2018 The Project Lombok Authors.
+ * Copyright (C) 2010-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
@@ -56,6 +56,7 @@ import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.LombokNode;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.delombok.LombokOptionsFactory;
import lombok.javac.Javac;
import lombok.javac.JavacAST;
@@ -222,7 +223,6 @@ public class HandleConstructor {
boolean staticConstrRequired = staticName != null && !staticName.equals("");
if (skipIfConstructorExists != SkipIfConstructorExists.NO) {
-
for (JavacNode child : typeNode.down()) {
if (child.getKind() == Kind.ANNOTATION) {
boolean skipGeneration = annotationTypeMatches(NoArgsConstructor.class, child) ||
@@ -247,7 +247,7 @@ public class HandleConstructor {
}
if (noArgs && noArgsConstructorExists(typeNode)) return;
-
+
ListBuffer<Type> argTypes = new ListBuffer<Type>();
for (JavacNode fieldNode : fields) {
Type mirror = getMirrorForFieldType(fieldNode);
@@ -339,7 +339,8 @@ public class HandleConstructor {
Name rawName = field.name;
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
- JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, field.vartype, null);
+ JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source.get(), source.getContext());
+ JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
params.append(param);
if (hasNonNullAnnotations(fieldNode)) {
JCStatement nullCheck = generateNullCheck(maker, param, source);
@@ -373,7 +374,7 @@ public class HandleConstructor {
addConstructorProperties(mods, typeNode, fieldsToParam);
}
if (onConstructor != null) mods.annotations = mods.annotations.appendList(copyAnnotations(onConstructor));
-
+ if (getCheckerFrameworkVersion(source).generateUnique()) mods.annotations = mods.annotations.prepend(maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("<init>"),
null, List.<JCTypeParameter>nil(), params.toList(), List.<JCExpression>nil(),
maker.Block(0L, nullChecks.appendList(assigns).toList()), null), source.get(), typeNode.getContext());
@@ -452,6 +453,7 @@ public class HandleConstructor {
JCClassDecl type = (JCClassDecl) typeNode.get();
JCModifiers mods = maker.Modifiers(Flags.STATIC | toJavacModifier(level));
+ if (getCheckerFrameworkVersion(typeNode).generateUnique()) mods.annotations = mods.annotations.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
JCExpression returnType, constructorType;
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index e4d7fa7f..2981bfa7 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -59,6 +59,7 @@ import lombok.EqualsAndHashCode;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.configuration.CallSuperType;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.HandlerUtil.FieldAccess;
import lombok.core.handlers.InclusionExclusionUtils;
@@ -203,7 +204,10 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
JavacTreeMaker maker = typeNode.getTreeMaker();
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil());
- JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation));
+ List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation);
+ CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(typeNode);
+ if (checkerFramework.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ JCModifiers mods = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
JCExpression returnType = maker.TypeIdent(CTC_INT);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
@@ -378,7 +382,12 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
Name thisName = typeNode.toName("this");
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil());
- JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation));
+ List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation);
+ CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(typeNode);
+ if (checkerFramework.generateSideEffectFree()) {
+ annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ }
+ JCModifiers mods = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
JCExpression objectType = genJavaLangTypeRef(typeNode, "Object");
JCExpression returnType = maker.TypeIdent(CTC_BOOLEAN);
@@ -497,7 +506,12 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
*/
JavacTreeMaker maker = typeNode.getTreeMaker();
- JCModifiers mods = maker.Modifiers(Flags.PROTECTED, List.<JCAnnotation>nil());
+ List<JCAnnotation> annsOnMethod = List.nil();
+ CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(typeNode);
+ if (checkerFramework.generateSideEffectFree()) {
+ annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ }
+ JCModifiers mods = maker.Modifiers(Flags.PROTECTED, annsOnMethod);
JCExpression returnType = maker.TypeIdent(CTC_BOOLEAN);
Name canEqualName = typeNode.toName("canEqual");
JCExpression objectType = genJavaLangTypeRef(typeNode, "Object");
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java
index 7a178f66..681865df 100644
--- a/src/core/lombok/javac/handlers/HandleGetter.java
+++ b/src/core/lombok/javac/handlers/HandleGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2017 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -37,6 +37,7 @@ import lombok.experimental.Delegate;
import lombok.Getter;
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;
@@ -167,6 +168,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
public void createGetterForField(AccessLevel level,
JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) {
+
if (fieldNode.getKind() != Kind.FIELD) {
source.addError("@Getter is only supported on a class or a field.");
return;
@@ -223,7 +225,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
JCVariableDecl fieldNode = (JCVariableDecl) field.get();
// Remember the type; lazy will change it
- JCExpression methodType = copyType(treeMaker, fieldNode);
+ JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source, field.getContext());
// Generate the methodName; lazy will change the field type
Name methodName = field.toName(toGetterName(field));
@@ -246,9 +248,8 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(field);
List<JCAnnotation> delegates = findDelegatesAndRemoveFromField(field);
List<JCAnnotation> annsOnMethod = copyAnnotations(onMethod).appendList(copyableAnnotations);
- if (isFieldDeprecated(field)) {
- annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
- }
+ if (getCheckerFrameworkVersion(field).generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genTypeRef(field, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext());
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index cd8b5d1c..926e94d9 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -32,6 +32,7 @@ import lombok.ConfigurationKeys;
import lombok.Setter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
@@ -214,7 +215,15 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
returnStatement = treeMaker.Return(treeMaker.Ident(field.toName("this")));
}
- return createSetter(access, deprecate, field, treeMaker, setterName, paramName, booleanFieldToSet, returnType, returnStatement, source, onMethod, onParam);
+ JCMethodDecl d = createSetter(access, deprecate, field, treeMaker, setterName, paramName, booleanFieldToSet, returnType, returnStatement, source, onMethod, onParam);
+ if (shouldReturnThis && getCheckerFrameworkVersion(source).generateReturnsReceiver()) {
+ List<JCAnnotation> annotations = d.mods.annotations;
+ if (annotations == null) annotations = List.nil();
+ JCAnnotation anno = treeMaker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
+ recursiveSetGeneratedBy(anno, source.get(), field.getContext());
+ d.mods.annotations = annotations.prepend(anno);
+ }
+ return d;
}
public static JCMethodDecl createSetter(long access, boolean deprecate, JavacNode field, JavacTreeMaker treeMaker, String setterName, Name paramName, Name booleanFieldToSet, JCExpression methodType, JCStatement returnStatement, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
@@ -233,7 +242,8 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
- JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, fieldDecl.vartype, null);
+ JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source.get(), source.getContext());
+ JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, pType, null);
if (!hasNonNullAnnotations(field) && !hasNonNullAnnotations(field, onParam)) {
statements.append(treeMaker.Exec(assign));
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index a5c492a1..0f809571 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -62,6 +62,7 @@ import lombok.ConfigurationKeys;
import lombok.Singular;
import lombok.ToString;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
import lombok.core.handlers.HandlerUtil;
@@ -93,7 +94,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
@Override
public void handle(AnnotationValues<SuperBuilder> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.SUPERBUILDER_FLAG_USAGE, "@SuperBuilder");
-
+ CheckerFrameworkVersion cfv = getCheckerFrameworkVersion(annotationNode);
SuperBuilder superbuilderAnnotation = annotation.getInstance();
deleteAnnotationIfNeccessary(annotationNode, SuperBuilder.class);
@@ -284,16 +285,16 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
// Generate abstract self() and build() methods in the abstract builder.
- JCMethodDecl asm = generateAbstractSelfMethod(tdParent, superclassBuilderClassExpression != null, builderGenericName);
+ JCMethodDecl asm = generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClassExpression != null, builderGenericName);
recursiveSetGeneratedBy(asm, ast, annotationNode.getContext());
injectMethod(builderType, asm);
- JCMethodDecl abm = generateAbstractBuildMethod(tdParent, buildMethodName, superclassBuilderClassExpression != null, classGenericName);
+ JCMethodDecl abm = generateAbstractBuildMethod(cfv, tdParent, buildMethodName, builderFields, superclassBuilderClassExpression != null, classGenericName);
recursiveSetGeneratedBy(abm, ast, annotationNode.getContext());
injectMethod(builderType, abm);
// Create the setter methods in the abstract builder.
for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(builderType, bfd, annotationNode, builderGenericName);
+ generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName);
}
// Create the toString() method for the abstract builder.
@@ -339,18 +340,18 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (cd != null) injectMethod(builderImplType, cd);
// Create the self() and build() methods in the BuilderImpl.
- JCMethodDecl selfMethod = generateSelfMethod(builderImplType, typeParams);
+ JCMethodDecl selfMethod = generateSelfMethod(cfv, builderImplType, typeParams);
recursiveSetGeneratedBy(selfMethod, ast, annotationNode.getContext());
injectMethod(builderImplType, selfMethod);
if (methodExists(buildMethodName, builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl buildMethod = generateBuildMethod(buildMethodName, tdParent, builderImplType, thrownExceptions);
+ JCMethodDecl buildMethod = generateBuildMethod(cfv, buildMethodName, tdParent, builderImplType, builderFields, thrownExceptions);
recursiveSetGeneratedBy(buildMethod, ast, annotationNode.getContext());
injectMethod(builderImplType, buildMethod);
}
}
// Generate a constructor in the annotated class that takes a builder as argument.
- generateBuilderBasedConstructor(tdParent, typeParams, builderFields, annotationNode, builderClassName,
+ generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
superclassBuilderClassExpression != null);
if (isAbstract) {
@@ -362,7 +363,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Allow users to specify their own builder() methods, e.g., to provide default values.
if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- JCMethodDecl builderMethod = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
+ JCMethodDecl builderMethod = generateBuilderMethod(cfv, builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext());
if (builderMethod != null) injectMethod(tdParent, builderMethod);
}
@@ -374,7 +375,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
return;
case NOT_EXISTS:
- JCMethodDecl md = generateToBuilderMethod(builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
+ JCMethodDecl md = generateToBuilderMethod(cfv, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
if (md != null) {
recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
injectMethod(tdParent, md);
@@ -483,7 +484,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* constructor with the builder as argument. Requires
* {@code builderClassAsParameter != null}.
*/
- private void generateBuilderBasedConstructor(JavacNode typeNode, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, JavacNode source, String builderClassName, boolean callBuilderBasedSuperConstructor) {
+ private void generateBuilderBasedConstructor(CheckerFrameworkVersion cfv, JavacNode typeNode, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, JavacNode source, String builderClassName, boolean callBuilderBasedSuperConstructor) {
JavacTreeMaker maker = typeNode.getTreeMaker();
AccessLevel level = AccessLevel.PROTECTED;
@@ -519,7 +520,8 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
}
- JCModifiers mods = maker.Modifiers(toJavacModifier(level), List.<JCAnnotation>nil());
+ List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ JCModifiers mods = maker.Modifiers(toJavacModifier(level), annsOnMethod);
// Create a constructor that has just the builder as parameter.
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
@@ -551,7 +553,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
injectMethod(typeNode, constr, null, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
}
- private JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, String builderImplClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams) {
+ private JCMethodDecl generateBuilderMethod(CheckerFrameworkVersion cfv, String builderMethodName, String builderClassName, String builderImplClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
@@ -573,7 +575,8 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
typeParameterNames.add(wildcard);
JCTypeApply returnType = maker.TypeApply(maker.Ident(type.toName(builderClassName)), typeParameterNames.toList());
- return maker.MethodDef(maker.Modifiers(modifiers), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
/**
@@ -584,7 +587,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* }
* </pre>
*/
- private JCMethodDecl generateToBuilderMethod(String builderClassName, String builderImplClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams) {
+ private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String builderClassName, String builderImplClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
@@ -607,7 +610,8 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
typeParameterNames.add(wildcard);
JCTypeApply returnType = maker.TypeApply(maker.Ident(type.toName(builderClassName)), typeParameterNames.toList());
- return maker.MethodDef(maker.Modifiers(modifiers), type.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ return maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
/**
@@ -737,25 +741,34 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return exec;
}
- private JCMethodDecl generateAbstractSelfMethod(JavacNode type, boolean override, String builderGenericName) {
+ private JCMethodDecl generateAbstractSelfMethod(CheckerFrameworkVersion cfv, JavacNode type, boolean override, String builderGenericName) {
JavacTreeMaker maker = type.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
- if (override) {
- JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
- annotations = List.of(overrideAnnotation);
- }
+ JCAnnotation overrideAnnotation = override ? maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil()) : null;
+ JCAnnotation rrAnnotation = cfv.generateReturnsReceiver() ? maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
+ JCAnnotation sefAnnotation = cfv.generateSideEffectFree() ? maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()) : null;
+ if (sefAnnotation != null) annotations = annotations.prepend(sefAnnotation);
+ if (rrAnnotation != null) annotations = annotations.prepend(rrAnnotation);
+ if (overrideAnnotation != null) annotations = annotations.prepend(overrideAnnotation);
JCModifiers modifiers = maker.Modifiers(Flags.PROTECTED | Flags.ABSTRACT, annotations);
Name name = type.toName(SELF_METHOD);
JCExpression returnType = maker.Ident(type.toName(builderGenericName));
-
+
return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
}
- private JCMethodDecl generateSelfMethod(JavacNode builderImplType, List<JCTypeParameter> typeParams) {
+ private JCMethodDecl generateSelfMethod(CheckerFrameworkVersion cfv, JavacNode builderImplType, List<JCTypeParameter> typeParams) {
JavacTreeMaker maker = builderImplType.getTreeMaker();
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(builderImplType, "Override"), List.<JCExpression>nil());
- JCModifiers modifiers = maker.Modifiers(Flags.PROTECTED, List.of(overrideAnnotation));
+ JCAnnotation rrAnnotation = cfv.generateReturnsReceiver() ? maker.Annotation(genTypeRef(builderImplType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
+ JCAnnotation sefAnnotation = cfv.generateSideEffectFree() ? maker.Annotation(genTypeRef(builderImplType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()) : null;
+ List<JCAnnotation> annsOnMethod = List.nil();
+ if (sefAnnotation != null) annsOnMethod = annsOnMethod.prepend(sefAnnotation);
+ if (rrAnnotation != null) annsOnMethod = annsOnMethod.prepend(rrAnnotation);
+ annsOnMethod = annsOnMethod.prepend(overrideAnnotation);
+
+ JCModifiers modifiers = maker.Modifiers(Flags.PROTECTED, annsOnMethod);
Name name = builderImplType.toName(SELF_METHOD);
JCExpression returnType = namePlusTypeParamsToTypeReference(maker, builderImplType.toName(builderImplType.getName()), typeParams);
@@ -765,21 +778,23 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- private JCMethodDecl generateAbstractBuildMethod(JavacNode type, String methodName, boolean override, String classGenericName) {
+ private JCMethodDecl generateAbstractBuildMethod(CheckerFrameworkVersion cfv, JavacNode type, String methodName, java.util.List<BuilderFieldData> builderFields, boolean override, String classGenericName) {
JavacTreeMaker maker = type.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
if (override) {
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
annotations = List.of(overrideAnnotation);
}
+ if (cfv.generateSideEffectFree()) annotations = annotations.prepend(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
JCModifiers modifiers = maker.Modifiers(Flags.PUBLIC | Flags.ABSTRACT, annotations);
Name name = type.toName(methodName);
JCExpression returnType = maker.Ident(type.toName(classGenericName));
- return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
+ List<JCVariableDecl> params = HandleBuilder.generateBuildArgs(cfv, type, builderFields);
+ return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), null, null);
}
- private JCMethodDecl generateBuildMethod(String buildName, JavacNode returnType, JavacNode type, List<JCExpression> thrownExceptions) {
+ private JCMethodDecl generateBuildMethod(CheckerFrameworkVersion cfv, String buildName, JavacNode returnType, JavacNode type, java.util.List<BuilderFieldData> builderFields, List<JCExpression> thrownExceptions) {
JavacTreeMaker maker = type.getTreeMaker();
JCExpression call;
@@ -793,9 +808,12 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JCBlock body = maker.Block(0, statements.toList());
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
- JCModifiers modifiers = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation));
+ List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation);
+ if (cfv.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ JCModifiers modifiers = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
- return maker.MethodDef(modifiers, type.toName(buildName), cloneSelfType(returnType), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ List<JCVariableDecl> params = HandleBuilder.generateBuildArgs(cfv, type, builderFields);
+ return maker.MethodDef(modifiers, type.toName(buildName), cloneSelfType(returnType), List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
}
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
@@ -852,7 +870,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
}
- private void generateSetterMethodsForBuilder(final JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, final String builderGenericName) {
+ private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, final JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, final String builderGenericName) {
boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode);
final JavacTreeMaker maker = builderType.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
@@ -864,13 +882,13 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}};
if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, true, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode);
+ generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, true, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode);
} else {
- fieldNode.singularData.getSingularizer().generateMethods(fieldNode.singularData, deprecate, builderType, source.get(), true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
+ fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
- private void generateSimpleSetterMethodForBuilder(JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode) {
+ private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, boolean fluent, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode) {
Name fieldName = ((JCVariableDecl) fieldNode.get()).name;
for (JavacNode child : builderType.down()) {
@@ -886,6 +904,19 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
JCMethodDecl newMethod = HandleSetter.createSetter(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, source, methodAnns, annosOnParam);
+ if (cfv.generateCalledMethods()) {
+ JCAnnotation ncAnno = maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(newMethod.getName().toString())));
+ JCClassDecl builderTypeNode = (JCClassDecl) builderType.get();
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>of(ncAnno)), builderType.toName("this"), maker.Ident(builderTypeNode.name), null);
+ newMethod.params = List.of(recv, newMethod.params.get(0));
+ }
+ if (cfv.generateReturnsReceiver()) {
+ List<JCAnnotation> annotations = newMethod.mods.annotations;
+ if (annotations == null) annotations = List.nil();
+ JCAnnotation anno = maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
+ recursiveSetGeneratedBy(anno, source.get(), builderType.getContext());
+ newMethod.mods.annotations = annotations.prepend(anno);
+ }
injectMethod(builderType, newMethod);
}
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java
index 3780da79..d0d36e06 100644
--- a/src/core/lombok/javac/handlers/HandleToString.java
+++ b/src/core/lombok/javac/handlers/HandleToString.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -31,6 +31,7 @@ import lombok.ConfigurationKeys;
import lombok.ToString;
import lombok.core.AnnotationValues;
import lombok.core.configuration.CallSuperType;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AST.Kind;
import lombok.core.handlers.InclusionExclusionUtils;
import lombok.core.handlers.InclusionExclusionUtils.Included;
@@ -93,7 +94,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
boolean includeFieldNames = true;
try {
Boolean configuration = typeNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_INCLUDE_FIELD_NAMES);
- includeFieldNames = configuration != null ? configuration : ((Boolean)ToString.class.getMethod("includeFieldNames").getDefaultValue()).booleanValue();
+ includeFieldNames = configuration != null ? configuration : ((Boolean) ToString.class.getMethod("includeFieldNames").getDefaultValue()).booleanValue();
} catch (Exception ignore) {}
Boolean doNotUseGettersConfiguration = typeNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_DO_NOT_USE_GETTERS);
@@ -160,7 +161,9 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
JavacTreeMaker maker = typeNode.getTreeMaker();
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil());
- JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.of(overrideAnnotation));
+ List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation);
+ if (getCheckerFrameworkVersion(typeNode).generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ JCModifiers mods = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
JCExpression returnType = genJavaLangTypeRef(typeNode, "String");
boolean first = true;
diff --git a/src/core/lombok/javac/handlers/HandleWither.java b/src/core/lombok/javac/handlers/HandleWith.java
index 33c4dec2..7b2417da 100644
--- a/src/core/lombok/javac/handlers/HandleWither.java
+++ b/src/core/lombok/javac/handlers/HandleWith.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 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
@@ -29,9 +29,10 @@ import java.util.Collection;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
+import lombok.With;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.experimental.Wither;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -59,13 +60,13 @@ import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
/**
- * Handles the {@code lombok.experimental.Wither} annotation for javac.
+ * Handles the {@code lombok.With} annotation for javac.
*/
@ProviderFor(JavacAnnotationHandler.class)
-public class HandleWither extends JavacAnnotationHandler<Wither> {
- public void generateWitherForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelWither) {
- if (checkForTypeLevelWither) {
- if (hasAnnotation(Wither.class, typeNode)) {
+public class HandleWith extends JavacAnnotationHandler<With> {
+ 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;
}
@@ -77,7 +78,7 @@ public class HandleWither extends JavacAnnotationHandler<Wither> {
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.");
+ errorNode.addError("@With is only supported on a class or a field.");
return;
}
@@ -91,105 +92,105 @@ public class HandleWither extends JavacAnnotationHandler<Wither> {
//Skip final initialized fields.
if ((fieldDecl.mods.flags & Flags.FINAL) != 0 && fieldDecl.init != null) continue;
- generateWitherForField(field, errorNode.get(), level);
+ generateWithForField(field, errorNode.get(), level);
}
}
/**
- * Generates a wither on the stated field.
+ * 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.Wither} annotation on the field, it is used and the
+ * 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 wither is still generated if it isn't already there, though there will not
+ * 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 wither for.
- * @param pos The node responsible for generating the wither (the {@code @Value} or {@code @Wither} annotation).
+ * @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 generateWitherForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) {
- if (hasAnnotation(Wither.class, fieldNode)) {
+ 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;
}
- createWitherForField(level, fieldNode, fieldNode, false, List.<JCAnnotation>nil(), List.<JCAnnotation>nil());
+ createWithForField(level, fieldNode, fieldNode, false, List.<JCAnnotation>nil(), List.<JCAnnotation>nil());
}
- @Override public void handle(AnnotationValues<Wither> annotation, JCAnnotation ast, JavacNode annotationNode) {
- handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
+ @Override public void handle(AnnotationValues<With> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ handleFlagUsage(annotationNode, ConfigurationKeys.WITH_FLAG_USAGE, "@With");
Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
- deleteAnnotationIfNeccessary(annotationNode, Wither.class);
+ 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<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod", annotationNode);
- List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam", annotationNode);
+ List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@With(onMethod", annotationNode);
+ List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@With(onParam", annotationNode);
switch (node.getKind()) {
case FIELD:
- createWitherForFields(level, fields, annotationNode, true, onMethod, onParam);
+ createWithForFields(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);
+ 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 createWitherForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
+ public void createWithForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
for (JavacNode fieldNode : fieldNodes) {
- createWitherForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam);
+ createWithForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam);
}
}
- public void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean strictMode, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
+ public void createWithForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean strictMode, List<JCAnnotation> onMethod, List<JCAnnotation> 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.");
+ fieldNode.addError("@With is only supported on a class or a field.");
return;
}
- JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get();
- String methodName = toWitherName(fieldNode);
+ JCVariableDecl fieldDecl = (JCVariableDecl) fieldNode.get();
+ String methodName = toWithName(fieldNode);
if (methodName == null) {
- fieldNode.addWarning("Not generating wither for this field: It does not fit your @Accessors prefix list.");
+ 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 wither for this field: Withers cannot be generated for static fields.");
+ 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 wither for this field: Withers cannot be generated for final, initialized fields.");
+ 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 wither for this field: Withers cannot be generated for fields starting with $.");
+ fieldNode.addWarning("Not generating " + methodName + " for this field: With methods cannot be generated for fields starting with $.");
}
return;
}
- for (String altName : toAllWitherNames(fieldNode)) {
+ for (String altName : toAllWithNames(fieldNode)) {
switch (methodExists(altName, fieldNode, false, 1)) {
case EXISTS_BY_LOMBOK:
return;
@@ -209,22 +210,22 @@ public class HandleWither extends JavacAnnotationHandler<Wither> {
long access = toJavacModifier(level);
- JCMethodDecl createdWither = createWither(access, fieldNode, fieldNode.getTreeMaker(), source, onMethod, onParam, makeAbstract);
+ 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, createdWither, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
+ injectMethod(typeNode, createdWith, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
}
- public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam, boolean makeAbstract) {
- String witherName = toWitherName(field);
- if (witherName == null) return null;
+ public JCMethodDecl createWith(long access, JavacNode field, JavacTreeMaker maker, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam, boolean makeAbstract) {
+ String withName = toWithName(field);
+ if (withName == null) return null;
JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(field);
- Name methodName = field.toName(witherName);
+ Name methodName = field.toName(withName);
JCExpression returnType = cloneSelfType(field);
@@ -279,14 +280,15 @@ public class HandleWither extends JavacAnnotationHandler<Wither> {
JCExpression annotationMethodDefaultValue = null;
List<JCAnnotation> annsOnMethod = copyAnnotations(onMethod);
+ CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(source);
+ if (checkerFramework.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+
+ if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
- if (isFieldDeprecated(field)) {
- annsOnMethod = annsOnMethod.prepend(maker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>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);
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
+ copyJavadoc(field, decl, CopyJavadoc.WITH);
return decl;
}
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 5f0f39b0..d12a980f 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -93,6 +93,7 @@ import lombok.core.AnnotationValues.AnnotationValue;
import lombok.core.CleanupTask;
import lombok.core.LombokImmutableList;
import lombok.core.TypeResolver;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.configuration.NullCheckExceptionType;
import lombok.core.configuration.TypeName;
import lombok.core.handlers.HandlerUtil;
@@ -330,6 +331,11 @@ public class JavacHandlerUtil {
return false;
}
+ public static CheckerFrameworkVersion getCheckerFrameworkVersion(JavacNode node) {
+ CheckerFrameworkVersion cfv = node.getAst().readConfiguration(ConfigurationKeys.CHECKER_FRAMEWORK);
+ return cfv == null ? CheckerFrameworkVersion.NONE : cfv;
+ }
+
/**
* Returns if a node is marked deprecated (as picked up on by the parser).
* @param node the node to check (type, method, or field decl).
@@ -584,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<String> toAllWitherNames(JavacNode field) {
- return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean(field));
+ public static java.util.List<String> 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));
}
/**
@@ -1266,7 +1272,7 @@ public class JavacHandlerUtil {
}
}
- private static void addAnnotation(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context, String annotationTypeFqn, JCExpression arg) {
+ public static void addAnnotation(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context, String annotationTypeFqn, JCExpression arg) {
boolean isJavaLangBased;
String simpleName; {
int idx = annotationTypeFqn.lastIndexOf('.');
@@ -1877,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);
@@ -1892,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();
@@ -1947,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/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index a5895951..341d44df 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -37,6 +37,7 @@ import lombok.ConfigurationKeys;
import lombok.core.LombokImmutableList;
import lombok.core.SpiLoadUtil;
import lombok.core.TypeLibrary;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -163,9 +164,12 @@ public class JavacSingularsRecipes {
return this;
}
- protected JCModifiers makeMods(JavacTreeMaker maker, JavacNode node, boolean deprecate, AccessLevel access) {
- if (deprecate) return maker.Modifiers(toJavacModifier(access), List.<JCAnnotation>of(maker.Annotation(genJavaLangTypeRef(node, "Deprecated"), List.<JCExpression>nil())));
- return maker.Modifiers(toJavacModifier(access));
+ protected JCModifiers makeMods(JavacTreeMaker maker, CheckerFrameworkVersion cfv, JavacNode node, boolean deprecate, AccessLevel access) {
+ JCAnnotation deprecateAnn = deprecate ? maker.Annotation(genJavaLangTypeRef(node, "Deprecated"), List.<JCExpression>nil()) : null;
+ JCAnnotation rrAnn = cfv.generateReturnsReceiver() ? maker.Annotation(genTypeRef(node, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
+
+ List<JCAnnotation> annsOnMethod = (deprecateAnn != null && rrAnn != null) ? List.of(deprecateAnn, rrAnn) : deprecateAnn != null ? List.of(deprecateAnn) : rrAnn != null ? List.of(rrAnn) : List.<JCAnnotation>nil();
+ return maker.Modifiers(toJavacModifier(access), annsOnMethod);
}
/** Checks if any of the to-be-generated nodes (fields, methods) already exist. If so, errors on these (singulars don't support manually writing some of it, and returns true). */
@@ -220,7 +224,7 @@ public class JavacSingularsRecipes {
* If you need more control over the return type and value, use
* {@link #generateMethods(SingularData, boolean, JavacNode, JCTree, boolean, ExpressionMaker, StatementMaker)}.
*/
- public void generateMethods(SingularData data, boolean deprecate, final JavacNode builderType, JCTree source, boolean fluent, final boolean chain, AccessLevel access) {
+ public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, final JavacNode builderType, JCTree source, boolean fluent, final boolean chain, AccessLevel access) {
final JavacTreeMaker maker = builderType.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
@@ -233,26 +237,26 @@ public class JavacSingularsRecipes {
return chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
}};
- generateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
+ generateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
/**
* Generates the singular, plural, and clear methods for the given {@link SingularData}.
* Uses the given {@code returnTypeMaker} and {@code returnStatementMaker} for the generated methods.
*/
- public abstract void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
+ public abstract void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
- protected void doGenerateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ protected void doGenerateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
JavacTreeMaker maker = builderType.getTreeMaker();
- generateSingularMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
- generatePluralMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
- generateClearMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, access);
+ generateSingularMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
+ generatePluralMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
+ generateClearMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, access);
}
- private void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, AccessLevel access) {
+ private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, AccessLevel access) {
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
- JCModifiers mods = makeMods(maker, builderType, deprecate, access);
+ JCModifiers mods = makeMods(maker, cfv, builderType, deprecate, access);
List<JCTypeParameter> typeParams = List.nil();
List<JCExpression> thrown = List.nil();
JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, jcVariableDecls, thrown, body, null);
@@ -260,25 +264,25 @@ public class JavacSingularsRecipes {
injectMethod(builderType, method);
}
- private void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, AccessLevel access) {
+ private void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, AccessLevel access) {
JCStatement clearStatement = generateClearStatements(maker, data, builderType);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.add(clearStatement);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
- finishAndInjectMethod(maker, returnType, returnStatement, data, builderType, source, deprecate, statements, methodName, List.<JCVariableDecl>nil(), access);
+ finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, methodName, List.<JCVariableDecl>nil(), access);
}
protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType);
- private void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
+ private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
ListBuffer<JCStatement> statements = generateSingularMethodStatements(maker, data, builderType, source);
List<JCVariableDecl> params = generateSingularMethodParameters(maker, data, builderType, source);
Name name = data.getSingularName();
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName(), name.toString()));
statements.prepend(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
- finishAndInjectMethod(maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, access);
+ finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, access);
}
protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, Name name) {
@@ -300,7 +304,7 @@ public class JavacSingularsRecipes {
protected abstract List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
- private void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
+ private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
ListBuffer<JCStatement> statements = generatePluralMethodStatements(maker, data, builderType, source);
Name name = data.getPluralName();
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", name.toString()));
@@ -309,7 +313,7 @@ public class JavacSingularsRecipes {
long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
statements.prepend(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
- finishAndInjectMethod(maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), access);
+ finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), access);
}
protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index 5b022206..546dc66e 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -29,6 +29,7 @@ import java.util.Collections;
import lombok.AccessLevel;
import lombok.core.GuavaTypeMap;
import lombok.core.LombokImmutableList;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil;
@@ -71,8 +72,8 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
- doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@Override
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 9d24f5d5..634a086d 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -27,6 +27,7 @@ import static lombok.javac.handlers.JavacHandlerUtil.*;
import java.util.Collections;
import lombok.AccessLevel;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil;
@@ -66,8 +67,8 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
- doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@Override
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 3e498cac..8dc7ecff 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -28,6 +28,7 @@ import java.util.Arrays;
import lombok.AccessLevel;
import lombok.core.LombokImmutableList;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil;
@@ -97,8 +98,8 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return Arrays.asList(keyFieldNode, valueFieldNode);
}
- @Override public void generateMethods(SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
- doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@Override
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 0c66bb31..5c31e87a 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -366,10 +366,6 @@ public class PatchVal {
}
private static TypeBinding resolveForExpression(Expression collection, BlockScope scope) {
- CompilationUnitDeclaration referenceContext = scope.compilationUnitScope().referenceContext;
- ProblemReporter oldProblemReporter = referenceContext.problemReporter;
- referenceContext.problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.exitOnFirstError(),
- oldProblemReporter.options, oldProblemReporter.problemFactory);
try {
return collection.resolveType(scope);
} catch (ArrayIndexOutOfBoundsException e) {
@@ -413,8 +409,6 @@ public class PatchVal {
}
}
throw e;
- } finally {
- referenceContext.problemReporter = oldProblemReporter;
}
}
diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java
index 5489f3ea..f2a21a4e 100644
--- a/src/launch/lombok/launch/ShadowClassLoader.java
+++ b/src/launch/lombok/launch/ShadowClassLoader.java
@@ -436,14 +436,14 @@ class ShadowClassLoader extends ClassLoader {
Enumeration<URL> sec = super.getResources(name);
while (sec.hasMoreElements()) {
URL item = sec.nextElement();
- if (!partOfShadow(item.toString(), name)) vector.add(item);
+ if (isPartOfShadowSuffix(item.toString(), name, sclSuffix)) vector.add(item);
}
if (altName != null) {
Enumeration<URL> tern = super.getResources(altName);
while (tern.hasMoreElements()) {
URL item = tern.nextElement();
- if (!partOfShadow(item.toString(), altName)) vector.add(item);
+ if (isPartOfShadowSuffix(item.toString(), altName, sclSuffix)) vector.add(item);
}
}
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/manual/knownIssue-1976_2138-valPlusDelegateVsEclipseErrors/about.txt b/test/manual/knownIssue-1976_2138-valPlusDelegateVsEclipseErrors/about.txt
new file mode 100644
index 00000000..58b3df3b
--- /dev/null
+++ b/test/manual/knownIssue-1976_2138-valPlusDelegateVsEclipseErrors/about.txt
@@ -0,0 +1,35 @@
+PullRequest https://github.com/rzwitserloot/lombok/pull/2114 tries to fix issue https://github.com/rzwitserloot/lombok/issues/1976 but causes problems.
+
+The problem is that the fail-fast resolver applied by PR 2114 causes the following issue:
+
+Given:
+
+A.java:
+
+ public class A {
+ interface Inner {
+ default void example() {
+ lombok.val v = doesNotExist();
+ }
+ }
+ B b = new B();
+ }
+
+B.java:
+
+ import com.foo.pkg.A.Inner;
+
+ public class B implements Inner {
+ void foo() {
+ lombok.val v = doesNotExist();
+ }
+ }
+
+will cause A.java to be parsed such that nothing in it exists, in turn causing B to consider A.Inner to not exist at all,
+even though the error on the 'implements Inner' line offers 'import Inner' as a quickfix. This quickfix won't, obviously, fix it.
+
+In addition, enough 'A refers to B refers to A' loops with errors like this and eclipse 2019-06 will eventually run out of heap and crash.
+
+The key commit that attempts to fix 1976 but causes the above issue is commit 089f2ec5f45567c8c12e9d13bf9be8fa5c107c18.
+
+The commit that undoes this, re-introducing 1976 but avoiding the problem above, is commit 877a169727a4c8078c43a4465929247c3390c897.
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-delombok/SetterAndWitherJavadoc.java b/test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java
index 8c0505e7..97524b9d 100644
--- a/test/transform/resource/after-delombok/SetterAndWitherJavadoc.java
+++ b/test/transform/resource/after-delombok/SetterAndWithMethodJavadoc.java
@@ -1,4 +1,4 @@
-class SetterAndWitherJavadoc {
+class SetterAndWithMethodJavadoc {
/**
* Some value.
*/
@@ -7,7 +7,7 @@ class SetterAndWitherJavadoc {
* Some other value.
*/
int j;
- SetterAndWitherJavadoc(int i, int j) {
+ SetterAndWithMethodJavadoc(int i, int j) {
this.i = i;
this.j = j;
}
@@ -24,8 +24,8 @@ class SetterAndWitherJavadoc {
* @param the new value
*/
@java.lang.SuppressWarnings("all")
- public SetterAndWitherJavadoc withI(final int i) {
- return this.i == i ? this : new SetterAndWitherJavadoc(i, this.j);
+ public SetterAndWithMethodJavadoc withI(final int i) {
+ return this.i == i ? this : new SetterAndWithMethodJavadoc(i, this.j);
}
/**
* Set some other value.
@@ -40,7 +40,7 @@ class SetterAndWitherJavadoc {
* @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);
+ public SetterAndWithMethodJavadoc withJ(final int j) {
+ return this.j == j ? this : new SetterAndWithMethodJavadoc(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<T, J extends T, L extends java.lang.Number> {
+ J test;
+ java.util.List<L> test2;
+ final int x = 10;
+ int y = 20;
+ final int z;
+ @java.lang.SuppressWarnings("all")
+ public WithAndAllArgsConstructor(final J test, final java.util.List<L> 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<T, J, L> withTest(final J test) {
+ return this.test == test ? this : new WithAndAllArgsConstructor<T, J, L>(test, this.test2, this.y, this.z);
+ }
+ @java.lang.SuppressWarnings("all")
+ public WithAndAllArgsConstructor<T, J, L> withTest2(final java.util.List<L> test2) {
+ return this.test2 == test2 ? this : new WithAndAllArgsConstructor<T, J, L>(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/WitherOnStatic.java b/test/transform/resource/after-delombok/WithOnStatic.java
index e481beb7..b234f0d6 100644
--- a/test/transform/resource/after-delombok/WitherOnStatic.java
+++ b/test/transform/resource/after-delombok/WithOnStatic.java
@@ -1,4 +1,4 @@
-class WitherOnStatic {
+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<T, J extends T, L extends java.lang.Number> {
+ J test;
+ java.util.List<L> test2;
+ java.util.List<? extends L> test3;
+ int $i;
+ public WithWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
+ }
+ @java.lang.SuppressWarnings("all")
+ public WithWithGenerics<T, J, L> withTest(final J test) {
+ return this.test == test ? this : new WithWithGenerics<T, J, L>(test, this.test2, this.test3);
+ }
+ @java.lang.SuppressWarnings("all")
+ public WithWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
+ return this.test2 == test2 ? this : new WithWithGenerics<T, J, L>(this.test, test2, this.test3);
+ }
+ @java.lang.SuppressWarnings("all")
+ public WithWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
+ return this.test3 == test3 ? this : new WithWithGenerics<T, J, L>(this.test, this.test2, test3);
+ }
+}
diff --git a/test/transform/resource/after-delombok/WitherTypeAnnos.java b/test/transform/resource/after-delombok/WithWithTypeAnnos.java
index b57438af..bf7559ba 100644
--- a/test/transform/resource/after-delombok/WitherTypeAnnos.java
+++ b/test/transform/resource/after-delombok/WithWithTypeAnnos.java
@@ -7,15 +7,15 @@ import java.util.List;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@interface TB {
}
-class WitherTypeAnnos {
+class WithWithTypeAnnos {
@TA
@TB
final List<String> foo;
- WitherTypeAnnos(@TA @TB List<String> foo) {
+ WithWithTypeAnnos(@TA @TB List<String> foo) {
this.foo = foo;
}
@java.lang.SuppressWarnings("all")
- public WitherTypeAnnos withFoo(@TA final List<String> foo) {
- return this.foo == foo ? this : new WitherTypeAnnos(foo);
+ public WithWithTypeAnnos withFoo(@TA final List<String> 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<T, J extends T, L extends java.lang.Number> {
- J test;
- java.util.List<L> test2;
- final int x = 10;
- int y = 20;
- final int z;
- @java.lang.SuppressWarnings("all")
- public WitherAndAllArgsConstructor(final J test, final java.util.List<L> 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<T, J, L> withTest(final J test) {
- return this.test == test ? this : new WitherAndAllArgsConstructor<T, J, L>(test, this.test2, this.y, this.z);
- }
- @java.lang.SuppressWarnings("all")
- public WitherAndAllArgsConstructor<T, J, L> withTest2(final java.util.List<L> test2) {
- return this.test2 == test2 ? this : new WitherAndAllArgsConstructor<T, J, L>(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/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/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<T, J extends T, L extends java.lang.Number> {
- J test;
- java.util.List<L> test2;
- java.util.List<? extends L> test3;
- int $i;
- public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
- }
- @java.lang.SuppressWarnings("all")
- public WitherWithGenerics<T, J, L> withTest(final J test) {
- return this.test == test ? this : new WitherWithGenerics<T, J, L>(test, this.test2, this.test3);
- }
- @java.lang.SuppressWarnings("all")
- public WitherWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
- return this.test2 == test2 ? this : new WitherWithGenerics<T, J, L>(this.test, test2, this.test3);
- }
- @java.lang.SuppressWarnings("all")
- public WitherWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
- return this.test3 == test3 ? this : new WitherWithGenerics<T, J, L>(this.test, this.test2, test3);
- }
-}
diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java
new file mode 100644
index 00000000..25b28c4b
--- /dev/null
+++ b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java
@@ -0,0 +1,59 @@
+import lombok.Data;
+import lombok.experimental.Accessors;
+import lombok.With;
+@Data @Accessors(chain = true) class CheckerFrameworkBasic {
+ 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) {
+ 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..ffbcf44e
--- /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();
+ 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;
+ 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/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<T, J extends T, L extends java.lang.Number> {
+ @lombok.With J test;
+ @lombok.With java.util.List<L> test2;
+ final int x = 10;
+ int y = 20;
+ final int z;
+ public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor<T, J, L> withTest(final J test) {
+ return ((this.test == test) ? this : new WithAndAllArgsConstructor<T, J, L>(test, this.test2, this.y, this.z));
+ }
+ public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor<T, J, L> withTest2(final java.util.List<L> test2) {
+ return ((this.test2 == test2) ? this : new WithAndAllArgsConstructor<T, J, L>(this.test, test2, this.y, this.z));
+ }
+ public @java.lang.SuppressWarnings("all") WithAndAllArgsConstructor(final J test, final java.util.List<L> 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;
+ <clinit>() {
+ }
+ 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<T, J extends T, L extends java.lang.Number> {
+ @lombok.With J test;
+ @lombok.With java.util.List<L> test2;
+ @lombok.With java.util.List<? extends L> test3;
+ int $i;
+ public WithWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") WithWithGenerics<T, J, L> withTest(final J test) {
+ return ((this.test == test) ? this : new WithWithGenerics<T, J, L>(test, this.test2, this.test3));
+ }
+ public @java.lang.SuppressWarnings("all") WithWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
+ return ((this.test2 == test2) ? this : new WithWithGenerics<T, J, L>(this.test, test2, this.test3));
+ }
+ public @java.lang.SuppressWarnings("all") WithWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
+ return ((this.test3 == test3) ? this : new WithWithGenerics<T, J, L>(this.test, this.test2, test3));
+ }
+}
diff --git a/test/transform/resource/after-ecj/WitherTypeAnnos.java b/test/transform/resource/after-ecj/WithWithTypeAnnos.java
index e41d9e13..ff73869b 100644
--- a/test/transform/resource/after-ecj/WitherTypeAnnos.java
+++ b/test/transform/resource/after-ecj/WithWithTypeAnnos.java
@@ -1,4 +1,4 @@
-import lombok.experimental.Wither;
+import lombok.With;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
@@ -6,13 +6,13 @@ import java.util.List;
}
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @interface TB {
}
-class WitherTypeAnnos {
- final @Wither @TA @TB List<String> foo;
- WitherTypeAnnos(@TA @TB List<String> foo) {
+class WithWithTypeAnnos {
+ final @With @TA @TB List<String> foo;
+ WithWithTypeAnnos(@TA @TB List<String> foo) {
super();
this.foo = foo;
}
- public @java.lang.SuppressWarnings("all") WitherTypeAnnos withFoo(final @TA List<String> foo) {
- return ((this.foo == foo) ? this : new WitherTypeAnnos(foo));
+ public @java.lang.SuppressWarnings("all") WithWithTypeAnnos withFoo(final @TA List<String> 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<T, J extends T, L extends java.lang.Number> {
- @lombok.experimental.Wither J test;
- @lombok.experimental.Wither java.util.List<L> test2;
- final int x = 10;
- int y = 20;
- final int z;
- public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor<T, J, L> withTest(final J test) {
- return ((this.test == test) ? this : new WitherAndAllArgsConstructor<T, J, L>(test, this.test2, this.y, this.z));
- }
- public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor<T, J, L> withTest2(final java.util.List<L> test2) {
- return ((this.test2 == test2) ? this : new WitherAndAllArgsConstructor<T, J, L>(this.test, test2, this.y, this.z));
- }
- public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor(final J test, final java.util.List<L> 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;
- <clinit>() {
- }
- 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/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<T, J extends T, L extends java.lang.Number> {
- @lombok.experimental.Wither J test;
- @lombok.experimental.Wither java.util.List<L> test2;
- @lombok.experimental.Wither java.util.List<? extends L> test3;
- int $i;
- public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
- super();
- }
- public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest(final J test) {
- return ((this.test == test) ? this : new WitherWithGenerics<T, J, L>(test, this.test2, this.test3));
- }
- public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
- return ((this.test2 == test2) ? this : new WitherWithGenerics<T, J, L>(this.test, test2, this.test3));
- }
- public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
- return ((this.test3 == test3) ? this : new WitherWithGenerics<T, J, L>(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
new file mode 100644
index 00000000..7dd40b54
--- /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.With;
+
+@Data @Accessors(chain = true)
+class CheckerFrameworkBasic {
+ @With 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/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/SetterAndWitherJavadoc.java b/test/transform/resource/before/SetterAndWithMethodJavadoc.java
index 6953eb39..ba10b7f2 100644
--- a/test/transform/resource/before/SetterAndWitherJavadoc.java
+++ b/test/transform/resource/before/SetterAndWithMethodJavadoc.java
@@ -1,10 +1,10 @@
-import lombok.experimental.Wither;
-class SetterAndWitherJavadoc {
+import lombok.With;
+class SetterAndWithMethodJavadoc {
/**
* Some value.
* @param the new value
*/
- @lombok.Setter @lombok.experimental.Wither int i;
+ @lombok.Setter @lombok.With int i;
/**
* Some other value.
@@ -13,13 +13,13 @@ class SetterAndWitherJavadoc {
* Set some other value.
* @param the new other value
*
- * --- WITHER ---
+ * --- WITH ---
* Reinstantiate with some other value.
* @param the other new other value
*/
- @lombok.Setter @lombok.experimental.Wither int j;
+ @lombok.Setter @lombok.With int j;
- SetterAndWitherJavadoc(int i, int j) {
+ SetterAndWithMethodJavadoc(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<T, J extends T, L extends java.lang.Number> {
+ @lombok.With J test;
+
+ @lombok.With java.util.List<L> 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<T, J extends T, L extends java.lang.Number> {
+ @lombok.With J test;
+ @lombok.With java.util.List<L> test2;
+ @lombok.With java.util.List<? extends L> test3;
+ int $i;
+
+ public WithWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/WitherTypeAnnos.java b/test/transform/resource/before/WithWithTypeAnnos.java
index 97cd3d9f..ceef6d61 100644
--- a/test/transform/resource/before/WitherTypeAnnos.java
+++ b/test/transform/resource/before/WithWithTypeAnnos.java
@@ -1,5 +1,5 @@
//CONF: lombok.copyableAnnotations += TA
-import lombok.experimental.Wither;
+import lombok.With;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
@@ -9,10 +9,10 @@ import java.util.List;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@interface TB {
}
-class WitherTypeAnnos {
- @Wither final @TA @TB List<String> foo;
+class WithWithTypeAnnos {
+ @With final @TA @TB List<String> foo;
- WitherTypeAnnos(@TA @TB List<String> foo) {
+ WithWithTypeAnnos(@TA @TB List<String> 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<T, J extends T, L extends java.lang.Number> {
- @lombok.experimental.Wither J test;
-
- @lombok.experimental.Wither java.util.List<L> 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/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<T, J extends T, L extends java.lang.Number> {
- @lombok.experimental.Wither J test;
- @lombok.experimental.Wither java.util.List<L> test2;
- @lombok.experimental.Wither java.util.List<? extends L> test3;
- int $i;
-
- public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> 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/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-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/WitherAlreadyExists.java.messages b/test/transform/resource/messages-delombok/WithAlreadyExists.java.messages
index d5e30e28..d5e30e28 100644
--- a/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages
+++ b/test/transform/resource/messages-delombok/WithAlreadyExists.java.messages
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/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/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-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/WitherAlreadyExists.java.messages b/test/transform/resource/messages-ecj/WithAlreadyExists.java.messages
index d5e30e28..d5e30e28 100644
--- a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages
+++ b/test/transform/resource/messages-ecj/WithAlreadyExists.java.messages
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/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 $.
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
diff --git a/website/extra/htaccess b/website/extra/htaccess
index d2c7a292..3539950f 100644
--- a/website/extra/htaccess
+++ b/website/extra/htaccess
@@ -4,6 +4,7 @@ RewriteRule ^$ /main.html [L,END]
RewriteRule ^(index|home)(\.html)?$ / [NC,R=301]
RewriteRule ^setup/overview$ /setup/main.html [L,END]
+RewriteRule ^setup/overview(\.html)?/?$ /setup/overview [NC,R=301]
RewriteRule ^setup/main(\.html)?/?$ /setup/overview [NC,R=301]
RewriteRule ^setup/index(\.html)?/?$ /setup/overview [NC,R=301]
RewriteRule ^setup(/(overview/?)?)?$ /setup/overview [NC,R=301]
@@ -58,6 +59,7 @@ RewriteRule ^features/${pg?no_esc}(\.html)?/?$ /features/${pg?no_esc} [NC,R=301]
RewriteRule ^features/experimental/Builder(\.html)?/?$ /features/Builder [NC,R=301]
RewriteRule ^features/experimental/Value(\.html)?/?$ /features/Value [NC,R=301]
RewriteRule ^features/experimental/var(\.html)?/?$ /features/var [NC,R=301]
+RewriteRule ^features/experimental/Wither(\.html)?/?$ /features/With [NC,R=301]
RewriteRule ^features/experimental/all$ /features/experimental/index.html [L,END]
RewriteRule ^features/experimental(/all)?/?$ /features/experimental/all [NC,R=301]
@@ -71,3 +73,6 @@ RewriteRule ^features/experimental/${pg?no_esc}(\.html)?/?$ /features/experiment
RewriteRule ^presentations/7lessons$ /presentations/7lessons.html [L,END]
RewriteRule ^presentations/7lessons(\.html)?/?$ /presentations/7lessons [NC,R=301]
RewriteRule ^presentations/7mistakes(\.html)?/?$ /presentations/7lessons [NC,R=301]
+
+RewriteRule ^tidelift$ /tidelift.html [L,END]
+RewriteRule ^tidelift(\.html)?/?$ /tidelift [NC,R=301]
diff --git a/website/templates/features/With.html b/website/templates/features/With.html
new file mode 100644
index 00000000..35c52dab
--- /dev/null
+++ b/website/templates/features/With.html
@@ -0,0 +1,53 @@
+<#import "_features.html" as f>
+
+<@f.scaffold title="@With" logline="Immutable 'setters' - methods that create a clone but with one changed field.">
+ <@f.history>
+ <p>
+ <code>@Wither</code> was introduced as experimental feature in lombok v0.11.4.
+ </p><p>
+ <code>@Wither</code> was renamed to <code>@With</code>, and moved out of experimental and into the core package, in lombok v1.18.10.
+ </@f.history>
+
+ <@f.overview>
+ <p>
+ The next best alternative to a setter for an immutable property is to construct a clone of the object, but with a new value for this one field. A method to generate this clone is precisely what <code>@With</code> generates: a <code>withFieldName(newValue)</code> method which produces a clone except for the new value for the associated field.
+ </p><p>
+ For example, if you create <code>public class Point { private final int x, y; }</code>, setters make no sense because the fields are final. <code>@With</code> can generate a <code>withX(int newXValue)</code> method for you which will return a new point with the supplied value for <code>x</code> and the same value for <code>y</code>.
+ </p><p>
+ Like <a href="/features/GetterSetter"><code>@Setter</code></a>, you can specify an access level in case you want the generated with method to be something other than <code>public</code>:<br /> <code>@With(level = AccessLevel.PROTECTED)</code>. Also like <a href="/features/GetterSetter"><code>@Setter</code></a>, you can also put a <code>@With</code> annotation on a type, which means a <code>with</code> method is generated for each field (even non-final fields).
+ </p><p>
+ To put annotations on the generated method, you can use <code>onMethod=@__({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="/features/experimental/onX">onX</a> feature.
+ </p><p>
+ javadoc on the field will be copied to generated with methods. Normally, all text is copied, and <code>@param</code> is <em>moved</em> to the with method, whilst <code>@return</code> lines are stripped from the with method's javadoc. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for the with method's javadoc. To do that, you create a 'section' named <code>WITH</code>. A section is a line in your javadoc containing 2 or more dashes, then the text 'WITH', followed by 2 or more dashes, and nothing else on the line. If you use sections, <code>@return</code> and <code>@param</code> stripping / copying for that section is no longer done (move the <code>@param</code> line into the section).
+ </p><p>
+ If you have a hierarchical immutable data structure, the <a href="/features/experimental/WithBy"><code>@WithBy</code></a> feature might be more suitable than <code>@With</code>
+ </@f.overview>
+
+ <@f.snippets name="With" />
+
+ <@f.confKeys>
+ <dt>
+ <code>lombok.with.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
+ </dt><dd>
+ Lombok will flag any usage of <code>@With</code> as a warning or error if configured.
+ </dd>
+ </@f.confKeys>
+
+ <@f.smallPrint>
+ <p>
+ With methods cannot be generated for static fields because that makes no sense.
+ </p><p>
+ With methods can be generated for abstract classes, but this generates an abstract method with the appropriate signature.
+ </p><p>
+ When applying <code>@With</code> to a type, static fields and fields whose name start with a $ are skipped.
+ </p><p>
+ For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified. Then, <code>with</code> is prefixed.
+ </p><p>
+ No method is generated if any method already exists with the same name (case insensitive) and same parameter count. For example, <code>withX(int x)</code> will not be generated if there's already a method <code>withX(String... x)</code> even though it is technically possible to make the method. This caveat exists to prevent confusion. If the generation of a method is skipped for this reason, a warning is emitted instead. Varargs count as 0 to N parameters.
+ </p><p>
+ For <code>boolean</code> fields that start with <code>is</code> immediately followed by a title-case letter, nothing is prefixed to generate the wither name.
+ </p><p>
+ Various well known annotations about nullity cause null checks to be inserted and will be copied to the parameter. See <a href="/features/GetterSetter">Getter/Setter</a> documentation's small print for more information.
+ </p>
+ </@f.smallPrint>
+</@f.scaffold>
diff --git a/website/templates/features/experimental/Wither.html b/website/templates/features/experimental/Wither.html
deleted file mode 100644
index 00dc10b1..00000000
--- a/website/templates/features/experimental/Wither.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<#import "../_features.html" as f>
-
-<@f.scaffold title="@Wither" logline="Immutable 'setters' - methods that create a clone but with one changed field.">
- <@f.history>
- <p>
- @Wither was introduced as experimental feature in lombok v0.11.4.
- </p>
- </@f.history>
-
- <@f.experimental>
- <ul>
- <li>
- Still not sure that <code>@Wither</code> is an appropriate name for this feature.
- </li><li>
- Should there be an option to supply a way of cloning the input somehow?
- </li><li>
- Should the way that the clone is created by configurable?
- </li><li>
- Should we replace @Wither entirely with a builder class?
- </li>
- </ul>
- Current status: <em>neutral</em> - More feedback requires on the items in the above list before promotion to the main package is warranted.
- </@f.experimental>
-
- <@f.overview>
- <p>
- The next best alternative to a setter for an immutable property is to construct a clone of the object, but with a new value for this one field. A method to generate this clone is precisely what <code>@Wither</code> generates: a <code>withFieldName(newValue)</code> method which produces a clone except for the new value for the associated field.
- </p><p>
- For example, if you create <code>public class Point { private final int x, y; }</code>, setters make no sense because the fields are final. <code>@Wither</code> can generate a <code>withX(int newXValue)</code> method for you which will return a new point with the supplied value for <code>x</code> and the same value for <code>y</code>.
- </p><p>
- Like <a href="/features/GetterSetter"><code>@Setter</code></a>, you can specify an access level in case you want the generated wither to be something other than <code>public</code>:<br /> <code>@Wither(level = AccessLevel.PROTECTED)</code>. Also like <a href="/features/GetterSetter"><code>@Setter</code></a>, you can also put a <code>@Wither</code> annotation on a type, which means a 'wither' is generated for each field (even non-final fields).
- </p><p>
- To put annotations on the generated method, you can use <code>onMethod=@__({@AnnotationsHere})</code>; to put annotations on the only parameter of a generated wither method, you can use <code>onParam=@__({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="/features/experimental/onX">onX</a> feature.
- </p><p>
- <em>NEW in lombok v1.12.0:</em> javadoc on the field will now be copied to generated withers. Normally, all text is copied, and <code>@param</code> is <em>moved</em> to the wither, whilst <code>@return</code> lines are stripped from the wither's javadoc. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for the wither's javadoc. To do that, you create a 'section' named <code>WITHER</code>. A section is a line in your javadoc containing 2 or more dashes, then the text 'WITHER', followed by 2 or more dashes, and nothing else on the line. If you use sections, <code>@return</code> and <code>@param</code> stripping / copying for that section is no longer done (move the <code>@param</code> line into the section).
- </p>
- </@f.overview>
-
- <@f.snippets name="experimental/Wither" />
-
- <@f.confKeys>
- <dt>
- <code>lombok.wither.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
- </dt><dd>
- Lombok will flag any usage of <code>@Wither</code> as a warning or error if configured.
- </dd>
- </@f.confKeys>
-
- <@f.smallPrint>
- <p>
- Withers cannot be generated for static fields because that makes no sense.
- </p><p>
- Withers can be generated for abstract classes, but this generates an abstract method with the appropriate signature.
- </p><p>
- When applying <code>@Wither</code> to a type, static fields and fields whose name start with a $ are skipped.
- </p><p>
- For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified. Then, <code>with</code> is prefixed.
- </p><p>
- No method is generated if any method already exists with the same name (case insensitive) and same parameter count. For example, <code>withX(int x)</code> will not be generated if there's already a method <code>withX(String... x)</code> even though it is technically possible to make the method. This caveat exists to prevent confusion. If the generation of a method is skipped for this reason, a warning is emitted instead. Varargs count as 0 to N parameters.
- </p><p>
- For <code>boolean</code> fields that start with <code>is</code> immediately followed by a title-case letter, nothing is prefixed to generate the wither name.
- </p><p>
- Various well known annotations about nullity cause null checks to be inserted and will be copied to the parameter. See <a href="/features/GetterSetter">Getter/Setter</a> documentation's small print for more information.
- </p>
- </@f.smallPrint>
-</@f.scaffold>
diff --git a/website/templates/setup/gradle.html b/website/templates/setup/gradle.html
index 53f45a71..148f20f8 100644
--- a/website/templates/setup/gradle.html
+++ b/website/templates/setup/gradle.html
@@ -11,7 +11,7 @@
<@s.section title="The Lombok Gradle Plugin">
<p>
- There is a plugin for gradle that we recommend you use; it makes deployment a breeze, works around shortcomings of gradle prior to v2.12, and makes it easy to do additional tasks, such as running the lombok eclipse installer or delomboking. The plugin is open source. Read more <a href="https://plugins.gradle.org/plugin/io.freefair.lombok">about the gradle-lombok plugin</a>.
+ There is a plugin for gradle that we recommend you use; it makes deployment a breeze, and makes it easy to do additional tasks, such as delomboking. The plugin is open source. Read more <a href="https://plugins.gradle.org/plugin/io.freefair.lombok">about the gradle-lombok plugin</a>.
</p>
</@s.section>
diff --git a/website/usageExamples/WithExample_post.jpage b/website/usageExamples/WithExample_post.jpage
new file mode 100644
index 00000000..a881ed8d
--- /dev/null
+++ b/website/usageExamples/WithExample_post.jpage
@@ -0,0 +1,21 @@
+import lombok.NonNull;
+
+public class WithExample {
+ private final int age;
+ private @NonNull final String name;
+
+ public WithExample(String name, int age) {
+ if (name == null) throw new NullPointerException();
+ this.name = name;
+ this.age = age;
+ }
+
+ public WithExample withAge(int age) {
+ return this.age == age ? this : new WithExample(name, age);
+ }
+
+ protected WithExample withName(@NonNull String name) {
+ if (name == null) throw new java.lang.NullPointerException("name");
+ return this.name == name ? this : new WithExample(name, age);
+ }
+}
diff --git a/website/usageExamples/WithExample_pre.jpage b/website/usageExamples/WithExample_pre.jpage
new file mode 100644
index 00000000..3c76204e
--- /dev/null
+++ b/website/usageExamples/WithExample_pre.jpage
@@ -0,0 +1,14 @@
+import lombok.AccessLevel;
+import lombok.NonNull;
+import lombok.With;
+
+public class WithExample {
+ @With private final int age;
+ @With(AccessLevel.PROTECTED) @NonNull private final String name;
+
+ public WithExample(String name, int age) {
+ if (name == null) throw new NullPointerException();
+ this.name = name;
+ this.age = age;
+ }
+}
diff --git a/website/usageExamples/experimental/WitherExample_post.jpage b/website/usageExamples/experimental/WitherExample_post.jpage
deleted file mode 100644
index 3447192a..00000000
--- a/website/usageExamples/experimental/WitherExample_post.jpage
+++ /dev/null
@@ -1,21 +0,0 @@
-import lombok.NonNull;
-
-public class WitherExample {
- private final int age;
- private @NonNull final String name;
-
- public WitherExample(String name, int age) {
- if (name == null) throw new NullPointerException();
- this.name = name;
- this.age = age;
- }
-
- public WitherExample withAge(int age) {
- return this.age == age ? this : new WitherExample(name, age);
- }
-
- protected WitherExample withName(@NonNull String name) {
- if (name == null) throw new java.lang.NullPointerException("name");
- return this.name == name ? this : new WitherExample(name, age);
- }
-} \ No newline at end of file
diff --git a/website/usageExamples/experimental/WitherExample_pre.jpage b/website/usageExamples/experimental/WitherExample_pre.jpage
deleted file mode 100644
index 5db799fc..00000000
--- a/website/usageExamples/experimental/WitherExample_pre.jpage
+++ /dev/null
@@ -1,14 +0,0 @@
-import lombok.AccessLevel;
-import lombok.NonNull;
-import lombok.experimental.Wither;
-
-public class WitherExample {
- @Wither private final int age;
- @Wither(AccessLevel.PROTECTED) @NonNull private final String name;
-
- public WitherExample(String name, int age) {
- if (name == null) throw new NullPointerException();
- this.name = name;
- this.age = age;
- }
-}