aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xAUTHORS6
-rw-r--r--buildScripts/build-support.ant.xml2
-rw-r--r--buildScripts/compile.ant.xml148
-rw-r--r--buildScripts/create-eclipse-project.ant.xml21
-rw-r--r--buildScripts/create-intellij-project.ant.xml15
-rw-r--r--buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.38.xml (renamed from buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.32.xml)4
-rw-r--r--buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.40.xml (renamed from buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.34.xml)4
-rw-r--r--buildScripts/ivy.xml15
-rw-r--r--buildScripts/mapstructBinding.ant.xml46
-rw-r--r--buildScripts/maven.ant.xml2
-rw-r--r--buildScripts/setup.ant.xml38
-rw-r--r--buildScripts/tests.ant.xml85
-rw-r--r--buildScripts/vm-finder.ant.xml5
-rw-r--r--buildScripts/website.ant.xml4
-rw-r--r--doc/changelog.markdown38
-rw-r--r--docker/ant/Dockerfile4
-rw-r--r--docker/ant/files/jdk-16/classpath/build.xml35
-rw-r--r--docker/ant/files/jdk-16/modules/build.xml35
-rw-r--r--docker/ant/readme.md9
-rw-r--r--docker/bazel/Dockerfile4
-rw-r--r--docker/gradle/Dockerfile4
-rw-r--r--docker/maven/Dockerfile4
-rw-r--r--docker/provision/jdk/java-16.sh4
-rw-r--r--src/ant/lombok/ant/SimpleTestFormatter.java63
-rw-r--r--src/core/lombok/ConfigurationKeys.java2
-rw-r--r--src/core/lombok/EqualsAndHashCode.java23
-rw-r--r--src/core/lombok/bytecode/PoolConstantsApp.java8
-rw-r--r--src/core/lombok/bytecode/PostCompilerApp.java7
-rw-r--r--src/core/lombok/bytecode/PreventNullAnalysisRemover.java6
-rw-r--r--src/core/lombok/bytecode/SneakyThrowsRemover.java6
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java63
-rw-r--r--src/core/lombok/core/Main.java8
-rw-r--r--src/core/lombok/core/PostCompiler.java10
-rw-r--r--src/core/lombok/core/PublicApiCreatorApp.java7
-rw-r--r--src/core/lombok/core/Version.java4
-rw-r--r--src/core/lombok/core/configuration/CheckerFrameworkVersion.java6
-rw-r--r--src/core/lombok/core/configuration/ConfigurationApp.java7
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java89
-rw-r--r--src/core/lombok/core/handlers/SneakyThrowsAndCleanupDependencyInfo.java7
-rw-r--r--src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java7
-rw-r--r--src/core/lombok/eclipse/EcjAugments.java (renamed from src/core/lombok/eclipse/EclipseAugments.java)20
-rw-r--r--src/core/lombok/eclipse/EclipseAST.java36
-rw-r--r--src/core/lombok/eclipse/EclipseNode.java2
-rw-r--r--src/core/lombok/eclipse/HandlerLibrary.java2
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java293
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java21
-rw-r--r--src/core/lombok/eclipse/handlers/HandleAccessors.java6
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java613
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilderDefault.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleCleanup.java6
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java25
-rw-r--r--src/core/lombok/eclipse/handlers/HandleData.java8
-rw-r--r--src/core/lombok/eclipse/handlers/HandleDelegate.java6
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java163
-rw-r--r--src/core/lombok/eclipse/handlers/HandleExtensionMethod.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldDefaults.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java13
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleHelper.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleJacksonized.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java45
-rw-r--r--src/core/lombok/eclipse/handlers/HandleNonNull.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandlePrintAST.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java13
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSneakyThrows.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java542
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSynchronized.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleUtilityClass.java27
-rw-r--r--src/core/lombok/eclipse/handlers/HandleVal.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleValue.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWith.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWithBy.java7
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseGuavaMapSingularizer.java7
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSetListSingularizer.java7
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java4
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseGuavaTableSingularizer.java7
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java10
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java7
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java10
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java6
-rw-r--r--src/core/lombok/javac/CompilerMessageSuppressor.java6
-rw-r--r--src/core/lombok/javac/HandlerLibrary.java2
-rw-r--r--src/core/lombok/javac/Javac6BasedLombokOptions.java2
-rw-r--r--src/core/lombok/javac/JavacAST.java126
-rw-r--r--src/core/lombok/javac/JavacASTVisitor.java26
-rw-r--r--src/core/lombok/javac/JavacNode.java2
-rw-r--r--src/core/lombok/javac/JavacResolution.java41
-rw-r--r--src/core/lombok/javac/apt/InterceptingJavaFileObject.java15
-rw-r--r--src/core/lombok/javac/apt/LombokProcessor.java178
-rw-r--r--src/core/lombok/javac/apt/Processor.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleAccessors.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java606
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilderDefault.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilderDefaultRemove.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilderRemove.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleCleanup.java13
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java33
-rw-r--r--src/core/lombok/javac/handlers/HandleData.java10
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java136
-rw-r--r--src/core/lombok/javac/handlers/HandleExtensionMethod.java41
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldDefaults.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldNameConstants.java19
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java37
-rwxr-xr-xsrc/core/lombok/javac/handlers/HandleHelper.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleJacksonized.java18
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java42
-rw-r--r--src/core/lombok/javac/handlers/HandleNonNull.java26
-rw-r--r--src/core/lombok/javac/handlers/HandlePrintAST.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java52
-rw-r--r--src/core/lombok/javac/handlers/HandleSneakyThrows.java20
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java715
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilderRemove.java9
-rw-r--r--src/core/lombok/javac/handlers/HandleSynchronized.java15
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleUtilityClass.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleValue.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleWith.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleWithBy.java17
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java266
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java81
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaMapSingularizer.java7
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSetListSingularizer.java7
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java15
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaTableSingularizer.java7
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java11
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java14
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java22
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java10
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java15
-rw-r--r--src/core9/module-info.java3
-rwxr-xr-xsrc/delombok/lombok/delombok/Delombok.java40
-rw-r--r--src/delombok/lombok/delombok/DelombokApp.java13
-rw-r--r--src/delombok/lombok/delombok/DocCommentIntegrator.java6
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java30
-rw-r--r--src/delombok/lombok/delombok/ant/DelombokTask.java14
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipseLoaderPatcher.java6
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java366
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/ExtensionMethodCompletionProposal.java76
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java226
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchDelegatePortal.java58
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java148
-rwxr-xr-xsrc/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java41
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java103
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java138
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java29
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java209
-rw-r--r--src/installer/lombok/installer/Installer.java11
-rw-r--r--src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/EclipseLocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/JbdsLocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/MyEclipseLocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/RhcrLocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/RhdsLocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/STS4LocationProvider.java7
-rw-r--r--src/installer/lombok/installer/eclipse/STSLocationProvider.java7
-rw-r--r--src/launch/lombok/launch/Main.java5
-rw-r--r--src/launch/lombok/launch/ShadowClassLoader.java37
-rw-r--r--src/spiProcessor/lombok/spi/Provides.java33
-rw-r--r--src/spiProcessor/lombok/spi/SpiProcessor.java254
-rw-r--r--src/spiProcessor/lombok/spi/SpiProcessorCollector.java107
-rw-r--r--src/spiProcessor/lombok/spi/SpiProcessorPersistence.java148
-rw-r--r--src/spiProcessor/lombok/spi/SpiProcessorService.java83
-rw-r--r--src/stubs/com/sun/tools/javac/code/Symbol.java2
-rw-r--r--src/stubs/com/sun/tools/javac/main/Arguments.java3
-rw-r--r--src/stubs/com/sun/tools/javac/parser/JavaTokenizer.java17
-rw-r--r--src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java8
-rw-r--r--src/utils/lombok/core/FieldAugment.java53
-rw-r--r--src/utils/lombok/eclipse/Eclipse.java27
-rw-r--r--src/utils/lombok/javac/Javac.java26
-rw-r--r--src/utils/lombok/javac/JavacTreeMaker.java127
-rw-r--r--src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java27
-rw-r--r--src/utils/lombok/javac/java8/CommentCollectingTokenizer.java50
-rw-r--r--src/utils/lombok/permit/Permit.java190
-rw-r--r--src/utils/lombok/permit/dummy/Child.java9
-rw-r--r--src/utils/lombok/permit/dummy/GrandChild.java19
-rw-r--r--src/utils/lombok/permit/dummy/Parent.java12
-rw-r--r--src/utils/lombok/permit/dummy/package-info.java8
-rw-r--r--test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java26
-rw-r--r--test/configuration/src/lombok/core/configuration/TestConfiguration.java4
-rw-r--r--test/core/src/lombok/AbstractRunTests.java7
-rw-r--r--test/core/src/lombok/DirectoryRunner.java13
-rw-r--r--test/core/src/lombok/LombokTestSource.java28
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java157
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java191
-rw-r--r--test/pretty/resource/after/TryWithResourcesVarRef.java (renamed from test/pretty/resource/after/tryWithResourcesVarRef.java)0
-rw-r--r--test/pretty/resource/before/ThisParameter.java1
-rw-r--r--test/stubs/org/checkerframework/checker/calledmethods/qual/CalledMethods.java17
-rw-r--r--test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java17
-rw-r--r--test/stubs/org/checkerframework/common/aliasing/qual/Unique.java12
-rw-r--r--test/stubs/org/checkerframework/common/returnsreceiver/qual/This.java12
-rw-r--r--test/stubs/org/checkerframework/dataflow/qual/Pure.java12
-rw-r--r--test/stubs/org/checkerframework/dataflow/qual/SideEffectFree.java12
-rw-r--r--test/transform/resource/after-delombok/Accessors.java12
-rw-r--r--test/transform/resource/after-delombok/AccessorsConfiguration.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderAccessWithGetter.java49
-rw-r--r--test/transform/resource/after-delombok/BuilderComplex.java12
-rw-r--r--test/transform/resource/after-delombok/BuilderCustomName.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaults.java9
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaultsGenerics.java9
-rw-r--r--test/transform/resource/after-delombok/BuilderDefaultsWarnings.java9
-rw-r--r--test/transform/resource/after-delombok/BuilderGenericMethod.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderInstanceMethod.java12
-rw-r--r--test/transform/resource/after-delombok/BuilderJavadoc.java2
-rw-r--r--test/transform/resource/after-delombok/BuilderSimple.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularNoAuto.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularNullBehavior1.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderSingularNullBehavior2.java1
-rw-r--r--test/transform/resource/after-delombok/BuilderTypeAnnos.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderWithAccessors.java12
-rw-r--r--test/transform/resource/after-delombok/BuilderWithBadNames.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderWithDeprecated.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderWithDeprecatedAnnOnly.java107
-rw-r--r--test/transform/resource/after-delombok/BuilderWithExistingBuilderClass.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderWithNoBuilderMethod.java3
-rw-r--r--test/transform/resource/after-delombok/BuilderWithNonNull.java4
-rw-r--r--test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java4
-rw-r--r--test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java6
-rw-r--r--test/transform/resource/after-delombok/BuilderWithToBuilder.java68
-rw-r--r--test/transform/resource/after-delombok/BuilderWithTolerate.java3
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkBasic.java21
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkBuilder.java35
-rw-r--r--test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java65
-rw-r--r--test/transform/resource/after-delombok/ConstructorsWithAccessors.java1
-rw-r--r--test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java6
-rw-r--r--test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java9
-rw-r--r--test/transform/resource/after-delombok/DataOnLocalClass.java1
-rw-r--r--test/transform/resource/after-delombok/DataWithOverrideEqualsAndHashCode.java25
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java1
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCodeCache.java167
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodAutoboxing.java20
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodChain.java15
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodFunctional.java42
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodGeneric.java33
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodNames.java27
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodSuppress.java33
-rw-r--r--test/transform/resource/after-delombok/ExtensionMethodVarargs.java19
-rw-r--r--test/transform/resource/after-delombok/GetterLazyArguments.java1
-rw-r--r--test/transform/resource/after-delombok/GetterOnClass.java1
-rw-r--r--test/transform/resource/after-delombok/I2335_BuilderMultipleObtainVia.java6
-rw-r--r--test/transform/resource/after-delombok/JacksonBuilderSingular.java1
-rw-r--r--test/transform/resource/after-delombok/JacksonJsonProperty.java4
-rw-r--r--test/transform/resource/after-delombok/JacksonizedBuilderComplex.java13
-rw-r--r--test/transform/resource/after-delombok/JacksonizedBuilderSimple.java7
-rw-r--r--test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java114
-rw-r--r--test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java4
-rw-r--r--test/transform/resource/after-delombok/JavadocMultiline.java51
-rw-r--r--test/transform/resource/after-delombok/LoggerLog4j2.java1
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4j.java5
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4jInvalidTopic.java5
-rw-r--r--test/transform/resource/after-delombok/NonNullOnParameter.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullOnParameterAbstract.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullPlain.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullTypeUse.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullWithAlternateException.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullWithAssertion.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullWithGuava.java1
-rw-r--r--test/transform/resource/after-delombok/NonNullWithJdk.java2
-rw-r--r--test/transform/resource/after-delombok/NonNullWithSneakyThrows.java1
-rw-r--r--test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java237
-rw-r--r--test/transform/resource/after-delombok/NullLibrary1.java4
-rw-r--r--test/transform/resource/after-delombok/NullLibrary2.java4
-rw-r--r--test/transform/resource/after-delombok/SetterOnClass.java1
-rw-r--r--test/transform/resource/after-delombok/StaticConstructor.java1
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderAbstract.java267
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java345
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderBasic.java278
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java417
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderCustomized.java203
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java100
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderInitializer.java74
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderNameClashes.java251
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java82
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java1
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java77
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java277
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithDefaults.java277
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java39
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithGenerics.java278
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java278
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java6
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java370
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithNonNull.java253
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java6
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java417
-rw-r--r--test/transform/resource/after-delombok/Tolerate.java21
-rw-r--r--test/transform/resource/after-delombok/TypeUseAnnotations.java1
-rw-r--r--test/transform/resource/after-delombok/ValDelegateMethodReference.java1
-rw-r--r--test/transform/resource/after-delombok/ValWeirdTypes.java1
-rw-r--r--test/transform/resource/after-delombok/WithAlreadyExists.java6
-rw-r--r--test/transform/resource/after-delombok/WithAndAllArgsConstructor.java6
-rw-r--r--test/transform/resource/after-delombok/WithByNullAnnos.java1
-rw-r--r--test/transform/resource/after-delombok/WithByTypes.java1
-rw-r--r--test/transform/resource/after-delombok/WithMethodAbstract.java3
-rw-r--r--test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java3
-rw-r--r--test/transform/resource/after-delombok/WithMethodMarkedDeprecatedAnnOnly.java14
-rw-r--r--test/transform/resource/after-delombok/WithNested.java3
-rw-r--r--test/transform/resource/after-delombok/WithOnClass.java19
-rw-r--r--test/transform/resource/after-delombok/WithPlain.java7
-rw-r--r--test/transform/resource/after-delombok/WithWithGenerics.java9
-rw-r--r--test/transform/resource/after-delombok/WithWithTypeAnnos.java3
-rw-r--r--test/transform/resource/after-delombok/WitherAccessLevel.java15
-rw-r--r--test/transform/resource/after-delombok/WitherLegacyStar.java3
-rw-r--r--test/transform/resource/after-ecj/Accessors.java12
-rw-r--r--test/transform/resource/after-ecj/AccessorsConfiguration.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderAccessWithGetter.java35
-rw-r--r--test/transform/resource/after-ecj/BuilderComplex.java12
-rw-r--r--test/transform/resource/after-ecj/BuilderConstructorJavadoc.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderCustomName.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaults.java9
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaultsGenerics.java9
-rw-r--r--test/transform/resource/after-ecj/BuilderDefaultsWarnings.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderGenericMethod.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderInstanceMethod.java12
-rw-r--r--test/transform/resource/after-ecj/BuilderJavadoc.java24
-rw-r--r--test/transform/resource/after-ecj/BuilderSimple.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderSingularNullBehavior2.java1
-rw-r--r--test/transform/resource/after-ecj/BuilderTypeAnnos.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderWithAccessors.java12
-rw-r--r--test/transform/resource/after-ecj/BuilderWithBadNames.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderWithDeprecated.java7
-rw-r--r--test/transform/resource/after-ecj/BuilderWithDeprecatedAnnOnly.java91
-rw-r--r--test/transform/resource/after-ecj/BuilderWithExistingBuilderClass.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderWithNoBuilderMethod.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderWithNonNull.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java3
-rw-r--r--test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java6
-rw-r--r--test/transform/resource/after-ecj/BuilderWithToBuilder.java53
-rw-r--r--test/transform/resource/after-ecj/BuilderWithTolerate.java3
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkBasic.java16
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkBuilder.java29
-rw-r--r--test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java55
-rw-r--r--test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java6
-rw-r--r--test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java9
-rw-r--r--test/transform/resource/after-ecj/DataWithOverrideEqualsAndHashCode.java25
-rw-r--r--test/transform/resource/after-ecj/EqualsAndHashCodeCache.java189
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodAutoboxing.java25
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodChain.java19
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodFunctional.java42
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodGeneric.java35
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodNames.java32
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodNonStaticAccess.java22
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodSuppress.java41
-rw-r--r--test/transform/resource/after-ecj/ExtensionMethodVarargs.java24
-rw-r--r--test/transform/resource/after-ecj/GetterDeprecated.java3
-rw-r--r--test/transform/resource/after-ecj/GetterSetterJavadoc.java48
-rw-r--r--test/transform/resource/after-ecj/I2335_BuilderMultipleObtainVia.java6
-rw-r--r--test/transform/resource/after-ecj/JacksonJsonProperty.java3
-rw-r--r--test/transform/resource/after-ecj/JacksonizedBuilderComplex.java12
-rw-r--r--test/transform/resource/after-ecj/JacksonizedBuilderSimple.java6
-rw-r--r--test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java3
-rw-r--r--test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java3
-rw-r--r--test/transform/resource/after-ecj/JavadocMultiline.java40
-rw-r--r--test/transform/resource/after-ecj/LoggerSlf4j.java8
-rw-r--r--test/transform/resource/after-ecj/LoggerSlf4jInvalidTopic.java9
-rw-r--r--test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java166
-rw-r--r--test/transform/resource/after-ecj/NullLibrary1.java3
-rw-r--r--test/transform/resource/after-ecj/NullLibrary2.java3
-rw-r--r--test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java18
-rw-r--r--test/transform/resource/after-ecj/SetterDeprecated.java3
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderAbstract.java213
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java271
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderBasic.java238
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java351
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderCustomized.java179
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java90
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderInitializer.java54
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderNameClashes.java3
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java72
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java70
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java238
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithDefaults.java233
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java32
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithGenerics.java238
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java238
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java6
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java318
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithNonNull.java216
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java6
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java351
-rw-r--r--test/transform/resource/after-ecj/Tolerate.java3
-rw-r--r--test/transform/resource/after-ecj/ValueCallSuper.java64
-rw-r--r--test/transform/resource/after-ecj/WithAlreadyExists.java6
-rw-r--r--test/transform/resource/after-ecj/WithAndAllArgsConstructor.java6
-rw-r--r--test/transform/resource/after-ecj/WithMethodAbstract.java3
-rw-r--r--test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java7
-rw-r--r--test/transform/resource/after-ecj/WithMethodMarkedDeprecatedAnnOnly.java14
-rw-r--r--test/transform/resource/after-ecj/WithNested.java3
-rw-r--r--test/transform/resource/after-ecj/WithOnClass.java18
-rw-r--r--test/transform/resource/after-ecj/WithPlain.java6
-rw-r--r--test/transform/resource/after-ecj/WithWithGenerics.java9
-rw-r--r--test/transform/resource/after-ecj/WithWithTypeAnnos.java3
-rw-r--r--test/transform/resource/after-ecj/WitherAccessLevel.java15
-rw-r--r--test/transform/resource/after-ecj/WitherLegacyStar.java3
-rw-r--r--test/transform/resource/before/BuilderAccessWithGetter.java10
-rw-r--r--test/transform/resource/before/BuilderSingularNullBehavior1.java1
-rw-r--r--test/transform/resource/before/BuilderSingularNullBehavior2.java1
-rw-r--r--test/transform/resource/before/BuilderWithDeprecatedAnnOnly.java10
-rw-r--r--test/transform/resource/before/BuilderWithNonNull.java1
-rw-r--r--test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java1
-rw-r--r--test/transform/resource/before/BuilderWithToBuilder.java13
-rw-r--r--test/transform/resource/before/CheckerFrameworkBasic.java4
-rw-r--r--test/transform/resource/before/CheckerFrameworkBuilder.java1
-rw-r--r--test/transform/resource/before/CheckerFrameworkSuperBuilder.java1
-rw-r--r--test/transform/resource/before/ConstructorsWithAccessors.java2
-rw-r--r--test/transform/resource/before/DataOnLocalClass.java1
-rw-r--r--test/transform/resource/before/DataWithOverrideEqualsAndHashCode.java18
-rw-r--r--test/transform/resource/before/DelegateAlreadyImplemented.java1
-rw-r--r--test/transform/resource/before/DelegateFlagUsage.java1
-rw-r--r--test/transform/resource/before/DelegateGenerics.java1
-rw-r--r--test/transform/resource/before/DelegateOnGetter.java1
-rw-r--r--test/transform/resource/before/DelegateOnGetterNone.java1
-rw-r--r--test/transform/resource/before/DelegateOnLocalClass.java19
-rw-r--r--test/transform/resource/before/DelegateOnMethods.java1
-rw-r--r--test/transform/resource/before/DelegateOnStatic.java1
-rw-r--r--test/transform/resource/before/DelegateRecursion.java1
-rw-r--r--test/transform/resource/before/DelegateTypesAndExcludes.java1
-rw-r--r--test/transform/resource/before/DelegateWithDeprecated.java1
-rw-r--r--test/transform/resource/before/DelegateWithVarargs.java1
-rw-r--r--test/transform/resource/before/DelegateWithVarargs2.java1
-rw-r--r--test/transform/resource/before/EqualsAndHashCodeAnnotated.java2
-rw-r--r--test/transform/resource/before/EqualsAndHashCodeCache.java29
-rw-r--r--test/transform/resource/before/ExtensionMethodAutoboxing.java23
-rw-r--r--test/transform/resource/before/ExtensionMethodChain.java17
-rw-r--r--test/transform/resource/before/ExtensionMethodFunctional.java47
-rw-r--r--test/transform/resource/before/ExtensionMethodGeneric.java34
-rw-r--r--test/transform/resource/before/ExtensionMethodNames.java33
-rw-r--r--test/transform/resource/before/ExtensionMethodNonStaticAccess.java18
-rw-r--r--test/transform/resource/before/ExtensionMethodSuppress.java43
-rw-r--r--test/transform/resource/before/ExtensionMethodVarargs.java23
-rw-r--r--test/transform/resource/before/GetterDeprecated.java2
-rw-r--r--test/transform/resource/before/GetterOnClass.java1
-rw-r--r--test/transform/resource/before/JacksonBuilderSingular.java1
-rw-r--r--test/transform/resource/before/JacksonJsonProperty.java1
-rw-r--r--test/transform/resource/before/JacksonizedBuilderComplex.java21
-rw-r--r--test/transform/resource/before/JacksonizedBuilderSimple.java1
-rw-r--r--test/transform/resource/before/JacksonizedSuperBuilderSimple.java1
-rw-r--r--test/transform/resource/before/JacksonizedSuperBuilderWithJsonDeserialize.java1
-rw-r--r--test/transform/resource/before/JavadocMultiline.java22
-rw-r--r--test/transform/resource/before/LoggerLog4j2.java1
-rw-r--r--test/transform/resource/before/LoggerSlf4j.java4
-rw-r--r--test/transform/resource/before/LoggerSlf4jInvalidTopic.java5
-rw-r--r--test/transform/resource/before/NonNullOnParameter.java1
-rw-r--r--test/transform/resource/before/NonNullOnParameterAbstract.java1
-rw-r--r--test/transform/resource/before/NonNullPlain.java1
-rw-r--r--test/transform/resource/before/NonNullWithAlternateException.java1
-rw-r--r--test/transform/resource/before/NonNullWithAssertion.java1
-rw-r--r--test/transform/resource/before/NonNullWithGuava.java1
-rw-r--r--test/transform/resource/before/NonNullWithJdk.java2
-rw-r--r--test/transform/resource/before/NonNullWithSneakyThrows.java1
-rw-r--r--test/transform/resource/before/NullAnnotatedCheckerFrameworkSuperBuilder.java20
-rw-r--r--test/transform/resource/before/NullLibrary1.java1
-rw-r--r--test/transform/resource/before/NullLibrary2.java1
-rw-r--r--test/transform/resource/before/OnXJava7StyleOn8.java2
-rw-r--r--test/transform/resource/before/OnXJava8StyleOn7.java2
-rw-r--r--test/transform/resource/before/SetterDeprecated.java2
-rw-r--r--test/transform/resource/before/SetterOnClass.java1
-rw-r--r--test/transform/resource/before/StaticConstructor.java1
-rw-r--r--test/transform/resource/before/SuperBuilderBasicToBuilder.java2
-rw-r--r--test/transform/resource/before/SuperBuilderCustomized.java1
-rw-r--r--test/transform/resource/before/SuperBuilderInitializer.java16
-rw-r--r--test/transform/resource/before/SuperBuilderSingularAnnotatedTypes.java2
-rw-r--r--test/transform/resource/before/SuperBuilderSingularCustomized.java9
-rw-r--r--test/transform/resource/before/SuperBuilderWithCustomBuilderMethod.java1
-rw-r--r--test/transform/resource/before/SuperBuilderWithExistingConstructor.java5
-rw-r--r--test/transform/resource/before/SuperBuilderWithNonNull.java1
-rw-r--r--test/transform/resource/before/ValDelegateMethodReference.java3
-rw-r--r--test/transform/resource/before/ValWeirdTypes.java1
-rw-r--r--test/transform/resource/before/ValueCallSuper.java14
-rw-r--r--test/transform/resource/before/WithByNullAnnos.java1
-rw-r--r--test/transform/resource/before/WithByTypes.java1
-rw-r--r--test/transform/resource/before/WithMethodMarkedDeprecatedAnnOnly.java10
-rw-r--r--test/transform/resource/before/WithOnClass.java2
-rw-r--r--test/transform/resource/before/WithPlain.java1
-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/ExtensionMethodVarargs.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/LoggerSlf4jInvalidTopic.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/UtilityClassErrors.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/ExtensionMethodNonStaticAccess.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/ExtensionMethodSuppress.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/LoggerSlf4jInvalidTopic.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/UtilityClassErrors.java.messages2
-rw-r--r--test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages10
-rw-r--r--test/transform/resource/messages-idempotent/ExtensionMethodVarargs.java.messages1
-rw-r--r--test/transform/resource/messages-idempotent/LoggerSlf4jInvalidTopic.java.messages1
-rw-r--r--test/transform/src/lombok/transform/TestLombokFilesIdempotent.java6
-rw-r--r--test/transform/src/lombok/transform/TestSourceFiles.java6
-rw-r--r--test/transform/src/lombok/transform/TestWithDelombok.java6
-rw-r--r--test/transform/src/lombok/transform/TestWithEcj.java6
-rw-r--r--website/resources/css/custom.css2
-rw-r--r--website/resources/js/order-license.js2
-rw-r--r--website/templates/features/EqualsAndHashCode.html2
-rw-r--r--website/templates/features/configuration.html2
-rw-r--r--website/templates/features/experimental/Accessors.html9
-rw-r--r--website/templates/order-license.html8
-rw-r--r--website/templates/setup/intellij.html4
513 files changed, 13434 insertions, 6774 deletions
diff --git a/.gitignore b/.gitignore
index 824ae9c2..2417108c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@
/out
/website/lombokSupporters
/pom.xml
+/jvm.locations
diff --git a/AUTHORS b/AUTHORS
index 9adf2005..f152f0c7 100755
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,9 +2,11 @@ Lombok contributors in alphabetical order:
Adam Juraszek <juriad@gmail.com>
Aleksandr Zhelezniak <lekan1992@gmail.com>
+Andre Brait <andrebrait@gmail.com>
Bulgakov Alexander <buls@yandex.ru>
Caleb Brinkman <floralvikings@gmail.com>
Christian Nüssgens <christian@nuessgens.com>
+Christian Schlichtherle <christian-schlichtherle@users.noreply.github.com>
Christian Sterzl <christian.sterzl@gmail.com>
DaveLaw <project.lombok@apconsult.de>
Dave Brosius <dbrosius@mebigfatguy.com>
@@ -23,6 +25,8 @@ Maarten Mulders <mthmulders@users.noreply.github.com>
Mark Haynes <markhaynes.work@gmail.com>
Mart Hagenaars <marthagenaars@gmail.com>
Mateusz Matela <mateusz.matela@gmail.com>
+Michael Dardis <git@md-5.net>
+Michael Ernst <mernst@alum.mit.edu>
Michiel Verheul <cheelio@gmail.com>
Pascal Bihler <pascal@qfs.de>
Peter Grant <petercgrant@users.noreply.github.com>
@@ -46,4 +50,4 @@ Till Brychcy <till.brychcy@mercateo.com>
Victor Williams Stafusa da Silva <victorwssilva@gmail.com>
Yun Zhi Lin <yun@yunspace.com>
-By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok.
+By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok in relation to all commits you add to Project Lombok, and you certify that you have the right to do so.
diff --git a/buildScripts/build-support.ant.xml b/buildScripts/build-support.ant.xml
index 107f5f47..d6439cb0 100644
--- a/buildScripts/build-support.ant.xml
+++ b/buildScripts/build-support.ant.xml
@@ -50,7 +50,7 @@ None of these tasks are normally needed, unless modifying how the build works, s
<input addproperty="target.jdk">You need to specify the JDK9+ jdk whose jdk.compiler and java.compiler modules are to be converted. Run ant with -Dtarget.jdk=/full/path/here to automate this, or type the path in now (for example: /Library/JavaVirtualMachines/jdk-14.jdk/Contents/Home):</input>
</target>
- <target name="make.javac-patch-jar" depends="-ask.target-jdk" description="to test javac13 on JDK14, for example, you need a jar (not a jmod), to use with --patch-modules. This task makes those.">
+ <target name="make.javac-patch-jar" depends="-ask.target-jdk, -setup.build" description="to test javac13 on JDK14, for example, you need a jar (not a jmod), to use with --patch-modules. This task makes those.">
<exec executable="${target.jdk}/bin/java${executable.suffix}" outputproperty="target.javac.version.full" errorproperty="target.javac.version.err">
<arg value="--version" />
</exec>
diff --git a/buildScripts/compile.ant.xml b/buildScripts/compile.ant.xml
index 5baf50c3..23a8a63c 100644
--- a/buildScripts/compile.ant.xml
+++ b/buildScripts/compile.ant.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2020 The Project Lombok Authors.
+ Copyright (C) 2020-2021 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
@@ -24,19 +24,18 @@
This buildfile is part of projectlombok.org. It takes care of compiling and building lombok itself.
</description>
- <property name="mapstruct-binding.version" value="0.1.0" />
+ <property name="mapstruct-binding.version" value="0.2.0" />
<!-- compiles just 'version.java' and runs the produced class file, setting up the various version properties -->
- <target name="version" depends="ipp.setup, deps.jdk-runtime" description="Shows the version number" unless="lombok.version">
- <mkdir dir="build/lombok" />
- <ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true" nowarn="true">
+ <target name="version" depends="ipp.setup, deps.jdk-runtime, -setup.build" description="Shows the version number" unless="lombok.version">
+ <ivy:compile destdir="build/lombok-version" source="1.5" target="1.5" ecj="true" nowarn="true">
<bootclasspath path="${jdk6-rt.loc}" />
<src path="src/core" />
<include name="lombok/core/Version.java" />
</ivy:compile>
<java
classname="lombok.core.Version"
- classpath="build/lombok"
+ classpath="build/lombok-version"
failonerror="true"
output="build/version.txt">
<arg value="full" />
@@ -44,28 +43,50 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil
<ivy:loadversion property="lombok.fullversion" file="build/version.txt" />
<java
classname="lombok.core.Version"
- classpath="build/lombok"
+ classpath="build/lombok-version"
failonerror="true"
output="build/version.txt" />
<ivy:loadversion property="lombok.version" file="build/version.txt" />
<echo level="info">Lombok version: ${lombok.version} (${lombok.fullversion})</echo>
</target>
- <target name="compile" depends="version, deps" description="Compiles the code">
+ <property name="packing.basedirs" value="build/lombok-transplants,build/lombok-utils,build/lombok-utils6,build/lombok-main,build/lombok-main8,build/lombok-deps" />
+ <loadresource property="packing.basedirs.colon">
+ <propertyresource name="packing.basedirs" />
+ <filterchain><tokenfilter>
+ <filetokenizer/>
+ <replacestring from="," to=":" />
+ </tokenfilter></filterchain>
+ </loadresource>
+ <path id="packing.basedirs.path">
+ <pathelement path="${packing.basedirs.colon}" />
+ </path>
+
+ <target name="create.spiProcessor" depends="version, -setup.build" description="Compiles the services file generating processor">
+ <ivy:compile destdir="build/spiProcessor" source="1.8" target="1.8" ecj="true">
+ <src path="src/spiProcessor" />
+ <classpath location="build/spiProcessor" />
+ </ivy:compile>
+ <mkdir dir="build/spiProcessor/META-INF/services" />
+ <echo file="build/spiProcessor/META-INF/services/javax.annotation.processing.Processor">lombok.spi.SpiProcessor</echo>
+ <jar destfile="dist/spiProcessor.jar">
+ <fileset dir="build/spiProcessor" />
+ </jar>
+ </target>
+
+ <target name="compile" depends="version, deps, -setup.build, create.spiProcessor" description="Compiles the code">
<!--
1. Compile stubs.
- 2. Compile lombok-utils.
- 3. Compile transplants.
- 4. Compile lombok.
- 5. Run SPI processor.
- 6. Create other manifest entries. -->
+ 2. Compile transplants.
+ 3. Compile lombok-utils.
+ 4. Compile lombok. -->
<!--
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 (as lombok is an annotation processor), which means if
there are bugs in it, you can't compile anymore until you 'ant clean'. That's very undesirable. so we kill the processor,
which stops lombok from running. We re-create the file at the end of this target. -->
- <delete file="build/lombok/META-INF/services/javax.annotation.processing.Processor" quiet="true" />
+ <delete file="build/lombok-main/META-INF/services/javax.annotation.processing.Processor" quiet="true" />
<!--
first, compile stubs. Lombok needs to produce class files that run in a wide variety of JDK, javac, and ecj/eclipse versions.
@@ -106,40 +127,40 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil
</filterchain>
</copy>
- <ivy:compile destdir="build/lombok" source="1.4" target="1.4" ecj="true">
+ <ivy:compile destdir="build/lombok-transplants" source="1.4" target="1.4" ecj="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="build/transformedSources" />
</ivy:compile>
- <ivy:compile destdir="build/lombok/Class50" source="1.4" target="1.6" ecj="true">
+ <ivy:compile destdir="build/lombok-transplants/Class50" source="1.4" target="1.6" ecj="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="build/transformedSources" />
</ivy:compile>
- <ivy:compile destdir="build/lombok" source="1.5" target="1.5" ecj="true">
+ <ivy:compile destdir="build/lombok-utils" source="1.5" target="1.5" ecj="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="src/utils" />
<exclude name="lombok/javac/**" />
- <classpath path="build/lombok" />
+ <classpath location="build/lombok-utils" />
<classpath refid="cp.javac6" />
<classpath refid="cp.ecj8" />
</ivy:compile>
- <ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true">
+ <ivy:compile destdir="build/lombok-utils6" source="1.6" target="1.6" ecj="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="src/utils" />
<include name="lombok/javac/**" />
- <classpath location="build/lombok" />
<classpath refid="cp.javac6" />
+ <classpath path="build/lombok-utils:build/lombok-utils6" />
</ivy:compile>
<!--
compile lombok proper. We target java 1.6 to be as compatible with older releases as we can, using a JDK6 boot rt to ensure we don't
use API that didn't exist in those versions yet. -->
- <ivy:compile destdir="build/lombok" source="1.6" target="1.6" ecj="true" nowarn="true">
+ <ivy:compile destdir="build/lombok-main" source="1.6" target="1.6" ecj="true" nowarn="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="src/launch" />
@@ -148,89 +169,61 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil
<src path="src/eclipseAgent" />
<src path="src/delombok" />
<exclude name="**/*Transplants.java" />
- <classpath location="build/lombok" />
<classpath refid="cp.build" />
<classpath refid="cp.eclipse-oxygen" />
<classpath refid="cp.javac6" />
+ <classpath path="build/lombok-utils:build/lombok-utils6:build/lombok-main:dist/spiProcessor.jar" />
+ <annotationProcessor jar="dist/spiProcessor.jar" processor="lombok.spi.SpiProcessor" />
</ivy:compile>
<!-- This is really part of the eclipse agent, but references lombok, so that had to be compiled first -->
- <ivy:compile destdir="build/lombok/Class50" source="1.5" target="1.6" ecj="true">
+ <ivy:compile destdir="build/lombok-main/Class50" source="1.5" target="1.6" ecj="true">
<bootclasspath location="build/stubs" />
<bootclasspath path="${jdk6-rt.loc}" />
<src path="src/eclipseAgent" />
<include name="lombok/launch/PatchFixesHider.java" />
- <classpath location="build/lombok" />
<classpath refid="cp.build" />
<classpath refid="cp.eclipse-oxygen" />
+ <classpath path="build/lombok-utils:build/lombok-utils6:build/lombok-main" />
</ivy:compile>
<!--
a couple of classes to cater to the bits of javac8+ that require j8 language constructs/API types; the main lombok
compile refers to these via reflection -->
- <ivy:compile destdir="build/lombok" source="1.8" target="1.8" ecj="true" nowarn="true" includesystembootclasspath="true">
+ <ivy:compile destdir="build/lombok-main8" source="1.8" target="1.8" ecj="true" nowarn="true" includesystembootclasspath="true">
<bootclasspath location="build/stubs" />
<src path="src/core8" />
- <classpath location="build/lombok" />
<classpath refid="cp.javac8" />
+ <classpath path="build/lombok-main:build/lombok-main8:build" />
</ivy:compile>
<!--
We also act as a jigsaw module so that module-based compile runs can use module-style dependency management. Obviously,
that bit we can only compile with jdk9+. -->
- <ivy:compile destdir="build/lombok" release="9">
+ <ivy:compile destdir="build/lombok-main" release="9">
<src path="src/core9" />
<compilerarg value="-Xlint:none" />
- <classpath location="build/lombok" />
- <classpath refid="cp.build" />
- </ivy:compile>
-
- <!-- Run the SPI processor to create the services files listing all lombok handlers -->
- <delete dir="build/lombok-proc-result" quiet="true" />
- <ivy:compile destdir="build/lombok-proc-result" release="9" nowarn="true">
- <classpath location="build/stubs" />
- <compilerarg value="-proc:only" />
- <compilerarg value="-processor" />
- <compilerarg value="org.mangosdk.spi.processor.SpiProcessor" />
- <src path="src/core" />
- <src path="src/installer" />
- <src path="src/eclipseAgent" />
- <src path="src/delombok" />
- <classpath location="build/lombok" />
<classpath refid="cp.build" />
- <classpath refid="cp.javac6" />
- <classpath refid="cp.eclipse-oxygen" />
</ivy:compile>
- <copy todir="build/lombok">
- <fileset dir="build/lombok-proc-result">
- <include name="META-INF/services/*" />
- </fileset>
- </copy>
-
- <mkdir dir="build/lombok/META-INF" />
- <mkdir dir="build/lombok/META-INF/services" />
- <echo file="build/lombok/META-INF/services/javax.annotation.processing.Processor">lombok.launch.AnnotationProcessorHider$AnnotationProcessor
+ <mkdir dir="build/lombok-main/META-INF/services" />
+ <echo file="build/lombok-main/META-INF/services/javax.annotation.processing.Processor">lombok.launch.AnnotationProcessorHider$AnnotationProcessor
lombok.launch.AnnotationProcessorHider$ClaimingProcessor</echo>
- <mkdir dir="build/lombok/META-INF/gradle" />
- <echo file="build/lombok/META-INF/gradle/incremental.annotation.processors">lombok.launch.AnnotationProcessorHider$AnnotationProcessor,isolating
+ <mkdir dir="build/lombok-main/META-INF/gradle" />
+ <echo file="build/lombok-main/META-INF/gradle/incremental.annotation.processors">lombok.launch.AnnotationProcessorHider$AnnotationProcessor,isolating
lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
</target>
<!-- compiles the bit of API from mapstruct that lombok compiles against. -->
- <target name="mapstruct.compile">
+ <target name="mapstruct.compile" depends="-setup.build">
<mkdir dir="build/mapstruct" />
- <ivy:compile destdir="build/mapstruct" release="9">
+ <ivy:compile destdir="build/mapstruct" release="8">
<src path="src/j9stubs" />
</ivy:compile>
- <mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
- <move
- file="build/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class"
- tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />
</target>
<target name="-deps.unpack" depends="deps">
- <ivy:cachedunjar dest="build/lombok" marker="build/unpackDeps.marker">
+ <ivy:cachedunjar dest="build/lombok-deps" marker="build/unpackDeps.marker">
<path refid="cp.stripe" />
</ivy:cachedunjar>
</target>
@@ -252,7 +245,7 @@ lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
lombok classes served up in autocomplete dialogs, amongst other reasons.
Thus, we list here only the few class files that serve as 'entry points'. -->
- <fileset dir="build/lombok">
+ <patternset id="packing.entrypoints">
<include name="module-info.class" />
<include name="lombok/*.class" />
<include name="lombok/experimental/**" />
@@ -261,21 +254,19 @@ lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
<include name="lombok/delombok/ant/Tasks*" />
<include name="lombok/javac/apt/Processor.class" />
<include name="lombok/META-INF/**" />
- </fileset>
+ </patternset>
+
+ <fileset dir="build/lombok-main"><patternset refid="packing.entrypoints" /></fileset>
- <!-- now include everything else but renamed for the shadowloader system, to make these clsases invisible to other projects. -->
+ <!-- now include everything else but renamed for the shadowloader system, to make these classes invisible to other projects. -->
+ <patternset id="packing.shadowed">
+ <exclude name="com/sun/tools/javac/**" />
+ <invert><patternset refid="packing.entrypoints" /></invert>
+ </patternset>
<mappedresources>
- <fileset dir="build/lombok">
- <exclude name="com/sun/tools/javac/**" />
- <exclude name="module-info.class" />
- <exclude name="lombok/*.class" />
- <exclude name="lombok/experimental/**" />
- <exclude name="lombok/extern/**" />
- <exclude name="lombok/launch/**" />
- <exclude name="lombok/delombok/ant/Tasks*" />
- <exclude name="lombok/javac/apt/Processor.class" />
- <exclude name="lombok/META-INF/**" />
- </fileset>
+ <multirootfileset basedirs="${packing.basedirs}">
+ <patternset refid="packing.shadowed" />
+ </multirootfileset>
<firstmatchmapper>
<globmapper from="*.class" to="*.SCL.lombok" />
<identitymapper />
@@ -291,6 +282,7 @@ lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
<attribute name="Can-Redefine-Classes" value="true" />
<attribute name="Main-Class" value="lombok.launch.Main" />
<attribute name="Lombok-Version" value="${lombok.version}" />
+ <attribute name="Automatic-Module-Name" value="lombok" />
</manifest>
</jar>
<delete file="release-timestamp.txt" />
@@ -298,7 +290,7 @@ lombok.launch.AnnotationProcessorHider$ClaimingProcessor,isolating</echo>
<property name="lombok.dist.built" value="true" />
</target>
- <target name="compile.support" depends="ipp.setup, deps" description="Compiles code that is used solely by the build, such as website and IDE project creation">
+ <target name="compile.support" depends="ipp.setup, deps, -setup.build" description="Compiles code that is used solely by the build, such as website and IDE project creation">
<ivy:compile includeDestClasses="false" includeantruntime="false" destdir="build/support" debug="on" source="1.8" target="1.8">
<compilerarg value="-proc:none" />
<compilerarg value="-Xlint:-options" />
diff --git a/buildScripts/create-eclipse-project.ant.xml b/buildScripts/create-eclipse-project.ant.xml
index 513ffe8f..a9b1a5dc 100644
--- a/buildScripts/create-eclipse-project.ant.xml
+++ b/buildScripts/create-eclipse-project.ant.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2010-2020 The Project Lombok Authors.
+ Copyright (C) 2010-2021 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
@@ -24,10 +24,11 @@
This buildfile is part of projectlombok.org. It creates the infrastructure needed to develop lombok on eclipse.
</description>
- <target name="eclipse" depends="eclipse.projectfiles, eclipse.testtarget.default" description="Downloads dependencies, create eclipse project files, as well as debug/run test targets. Open this directory as project in eclipse (via import... existing projects)" />
+ <target name="eclipse" depends="create.spiProcessor, eclipse.projectfiles, eclipse.testtarget.default" description="Downloads dependencies, create eclipse project files, as well as debug/run test targets. Open this directory as project in eclipse (via import... existing projects)" />
<target name="eclipse.projectfiles" depends="deps">
- <ivy:eclipsegen source="1.6">
+ <ivy:eclipsegen source="1.6" srcout="bin/main">
+ <srcdir dir="src/spiProcessor" />
<srcdir dir="src/core" />
<srcdir dir="src/core8" />
<srcdir dir="src/launch" />
@@ -35,7 +36,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede
<srcdir dir="src/eclipseAgent" />
<srcdir dir="src/installer" />
<srcdir dir="src/delombok" />
- <srcdir dir="src/stubs" />
+ <srcdir dir="src/stubs" srcout="bin/stubs" />
<srcdir dir="src/support" />
<srcdir dir="experimental/src" />
<srcdir dir="test/transform/src" />
@@ -52,7 +53,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede
<settings>
<url url="https://projectlombok.org/downloads/lombok.eclipse.settings" />
</settings>
- <apt location="lib/build/projectlombok.org-spi.jar" />
+ <apt location="dist/spiProcessor.jar" />
</ivy:eclipsegen>
</target>
@@ -96,7 +97,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede
<path refid="cp.buildtools" />
<pathelement location="build/support" />
</classpath>
- <arg value="name=Lombok-test Javac14" />
+ <arg value="name=Lombok-test Javac 14" />
<arg value="testType=lombok.TestJavac" />
<arg value="jvmTarget=14" />
<arg value="conf.test=${cp.test}" />
@@ -116,7 +117,7 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede
<condition property="inputs.jvmtarget" value="1.6"><equals arg1="${inputs.jvmtarget.raw}" arg2="6" /></condition>
<condition property="inputs.jvmtarget" value="1.8"><equals arg1="${inputs.jvmtarget.raw}" arg2="8" /></condition>
- <property name="inputs" value="${inputs.jvmtarget.raw}" />
+ <property name="inputs.jvmtarget" value="${inputs.jvmtarget.raw}" />
<condition property="inputs.bootpath" value="${jdk6-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="6" /></condition>
<condition property="inputs.bootpath" value="${jdk8-rt.loc}"><equals arg1="${inputs.jvmtarget.raw}" arg2="8" /></condition>
@@ -127,6 +128,12 @@ This buildfile is part of projectlombok.org. It creates the infrastructure neede
<target name="eclipse.testtarget.javac" depends="compile.support" description="Makes an eclipse launch target for running the tests for javac">
<eclipse.testtarget.conf.jvmtarget question="Which javac do you want to target? Enter a version, such as '11'." validargs="8,11,13,14,15" />
+ <local name="inputs.confcp" />
+ <condition property="inputs.confcp" value="NONE">
+ <not><equals arg1="8" arg2="${inputs.jvmtarget.raw}" /></not>
+ </condition>
+ <property name="inputs.confcp" refid="cp.javac8" />
+
<java classname="lombok.eclipseCreate.CreateEclipseDebugTarget" failonerror="true">
<classpath>
<path refid="cp.buildtools" />
diff --git a/buildScripts/create-intellij-project.ant.xml b/buildScripts/create-intellij-project.ant.xml
index 865e8971..33c1e449 100644
--- a/buildScripts/create-intellij-project.ant.xml
+++ b/buildScripts/create-intellij-project.ant.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2010-2020 The Project Lombok Authors.
+ Copyright (C) 2010-2021 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
@@ -24,15 +24,22 @@
This buildfile is part of projectlombok.org. It creates the infrastructure needed to develop lombok on intellij.
</description>
- <target name="intellij" depends="deps" description="Creates intellij project files and downloads all dependencies. Open this directory as a project in IntelliJ after running this target">
+ <target name="intellij" depends="create.spiProcessor, deps" description="Creates intellij project files and downloads all dependencies. Open this directory as a project in IntelliJ after running this target">
<echo> ** WARNING ** The core lombok contributors all use eclipse to develop lombok. This script will attempt to set up your lombok directory up as intellij project; whether can be used in a modern intellij is currently unknown. Please do continue, but be aware that trying to work on lombok from intellij may run into problems. If you want to adopt 'work on lombok via intellij' as a task, we're open to it!</echo>
<echo>NOT IMPLEMENTED: The project should optimally be configured as a java1.6, using the rt.jar in lib/openjdk6_rt.jar as boot basis, to ensure lombok remains 1.6 compatible.</echo>
<echo>NOT IMPLEMENTED: Ability to run tests targeted at a specific jvm/javac/ecj/eclipse release; the relevant entrypoint test classes are lombok.RunBaseAndJavacTests and lombok.RunEclipseTests - you can run the eclipse tests even on intellij; an eclipse installation is not required.</echo>
+ <echo>NOT SURE: The annotation processor system that automatically generates the services files has been changed. This AP is now internal to the project,
+ the source files for it are in `src/spiProcessor`, and a build of this is now in `dist/spiProcessor.jar` - you may have to manually add it, though I'm not
+ sure if you actually need it - the files generated by this processor are relevant only when running lombok itself, and if intellij accomplishes this by
+ invoking ant, all will be well.</echo>
<input>Press return to continue</input>
<ivy:intellijgen>
- <conf name="build" sources="contrib" />
- <conf name="test" sources="contrib" />
+ <conf name="build" sources="sources" />
+ <conf name="javac6" sources="sources" />
+ <conf name="test" sources="sources" />
+ <conf name="buildTools" sources="sources" />
<module name="lombok" depends="build, test">
+ <srcdir dir="src/spiProcessor" />
<srcdir dir="src/core" />
<srcdir dir="src/core8" />
<srcdir dir="src/launch" />
diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.32.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.38.xml
index 858ddfec..1ca9c743 100644
--- a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.32.xml
+++ b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.38.xml
@@ -1,5 +1,5 @@
<ivy-module version="2.0">
- <info organisation="org.projectlombok" module="lombok.patcher" revision="0.32" publication="20190110114000">
+ <info organisation="org.projectlombok" module="lombok.patcher" revision="0.38" publication="20201008193000">
<license name="MIT License" url="https://www.opensource.org/licenses/mit-license.php" />
<ivyauthor name="rzwitserloot" url="https://github.com/rzwitserloot" />
<ivyauthor name="rspilker" url="https://github.com/rspilker" />
@@ -9,6 +9,6 @@
<conf name="default" />
</configurations>
<publications>
- <artifact conf="default" url="https://projectlombok.org/downloads/lombok.patcher-0.32.jar" />
+ <artifact conf="default" url="https://projectlombok.org/downloads/lombok.patcher-0.38.jar" />
</publications>
</ivy-module>
diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.34.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.40.xml
index 778462cf..11302b2b 100644
--- a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.34.xml
+++ b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.40.xml
@@ -1,5 +1,5 @@
<ivy-module version="2.0">
- <info organisation="org.projectlombok" module="lombok.patcher" revision="0.34" publication="20190925010000">
+ <info organisation="org.projectlombok" module="lombok.patcher" revision="0.40" publication="20201015232000">
<license name="MIT License" url="https://www.opensource.org/licenses/mit-license.php" />
<ivyauthor name="rzwitserloot" url="https://github.com/rzwitserloot" />
<ivyauthor name="rspilker" url="https://github.com/rspilker" />
@@ -9,6 +9,6 @@
<conf name="default" />
</configurations>
<publications>
- <artifact conf="default" url="https://projectlombok.org/downloads/lombok.patcher-0.34.jar" />
+ <artifact conf="default" url="https://projectlombok.org/downloads/lombok.patcher-0.40.jar" />
</publications>
</ivy-module>
diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml
index 3dfbde7e..12dd2c5b 100644
--- a/buildScripts/ivy.xml
+++ b/buildScripts/ivy.xml
@@ -10,7 +10,7 @@
<!-- test: base dependencies required to run the tests. Does not include javac or ecj. -->
<conf name="test" />
- <!-- stripe: dependencies that need to be on the classpath during builds -->
+ <!-- build: dependencies that need to be on the classpath during builds -->
<conf name="build" />
<!-- stripe: dependencies that need to be striped into lombok.jar itself, and are required for both build and test/run purposes -->
@@ -36,10 +36,10 @@
</configurations>
<dependencies>
- <dependency org="org.projectlombok" name="lombok.patcher" rev="0.36" conf="build,stripe->default" />
+ <dependency org="org.projectlombok" name="lombok.patcher" rev="0.40" conf="build,stripe->default" />
<dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="build,stripe->runtime" />
- <dependency org="projectlombok.org" name="spi" rev="0.2.7" conf="build" />
<dependency org="org.apache.ant" name="ant" rev="1.10.5" conf="build->default" />
+ <dependency org="org.apache.ant" name="ant-junit" rev="1.10.5" conf="build->default" />
<!-- test deps -->
<dependency org="junit" name="junit" rev="4.8.2" conf="test->default; sources" />
@@ -52,6 +52,9 @@
<dependency org="com.google.flogger" name="flogger" rev="0.2" conf="test->default; sources" />
<dependency org="com.google.guava" name="guava" rev="18.0" conf="test->default; sources" />
<dependency org="com.google.code.findbugs" name="findbugs" rev="3.0.1" conf="test->master" />
+ <dependency org="org.springframework" name="spring-core" rev="5.3.4" conf="test->master" />
+ <dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.10.0" conf="test->master" />
+ <dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.10.0" conf="test->master" />
<!-- build tooling -->
<dependency org="com.hierynomus" name="sshj" rev="0.26.0" conf="buildtools->default" />
@@ -85,7 +88,10 @@
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.13.102" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.13.100" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.9.0" conf="eclipse-oxygen->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.equinox.registry" rev="3.7.0" conf="eclipse-oxygen->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.equinox.app" rev="1.3.400" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.12.0" conf="eclipse-oxygen->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.core.contenttype" rev="3.6.0" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.9.0" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.12.100" conf="eclipse-oxygen->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.text" rev="3.6.100" conf="eclipse-oxygen->default" transitive="false" />
@@ -95,7 +101,10 @@
<dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.21.100" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.12.0" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.equinox.preferences" rev="3.8.0" conf="eclipse-202006->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.equinox.registry" rev="3.8.700" conf="eclipse-202006->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.equinox.app" rev="1.4.400" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.13.700" conf="eclipse-202006->default" transitive="false" />
+ <dependency org="org.eclipse.platform" name="org.eclipse.core.contenttype" rev="3.7.600" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.10.800" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.15.300" conf="eclipse-202006->default" transitive="false" />
<dependency org="org.eclipse.platform" name="org.eclipse.text" rev="3.10.200" conf="eclipse-202006->default" transitive="false" />
diff --git a/buildScripts/mapstructBinding.ant.xml b/buildScripts/mapstructBinding.ant.xml
index c59b84da..d7c52dc3 100644
--- a/buildScripts/mapstructBinding.ant.xml
+++ b/buildScripts/mapstructBinding.ant.xml
@@ -26,14 +26,11 @@ version on mavencentral is the last version that is ever needed; the code itself
exists as a separate dependency solely because it is itself dependent on both lombok and mapstruct.
</description>
- <target name="-mapstructBinding.compile">
+ <target name="-mapstructBinding.compile" depends="-setup.build">
<mkdir dir="build/mapstruct" />
- <javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct">
+ <javac includeAntRuntime="false" source="1.8" target="1.8" destdir="build/mapstruct">
<src path="src/j9stubs" />
- <!-- This includes org.mapstruct.ap.spi.AstModifyingAnnotationProcessor; putting this on the classpath doesn't work (needs to be internal or a module) so we just add it and then delete the class file for convenience. -->
</javac>
- <mkdir dir="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi" />
- <move file="build/mapstruct/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.class" tofile="build/lombok/secondaryLoading.SCL.lombok/org/mapstruct/ap/spi/AstModifyingAnnotationProcessor.SCL.lombok" />
</target>
<target name="-mapstructBinding.prepare" depends="-mapstructBinding.compile">
@@ -76,12 +73,18 @@ exists as a separate dependency solely because it is itself dependent on both lo
<jar destfile="dist/lombok-mapstruct-binding-${mapstruct-binding.version}-javadoc.jar" basedir="build/mapstruct-binding/api" includes="**" />
</target>
- <target name="-mapstructBinding.jar" depends="dist,-mapstructBinding.prepare">
+ <target name="-mapstructBinding.jar" depends="dist, -mapstructBinding.prepare">
<mkdir dir="build/mapstruct-binding/classes" />
<echo file="build/mapstruct-binding/classes/META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor">lombok.mapstruct.NotifierHider$AstModificationNotifier</echo>
+ <javac includeAntRuntime="false" source="1.8" target="1.8" destdir="build/mapstruct-binding/classes">
+ <src path="src/bindings/mapstruct" />
+ <exclude name="module-info.java" />
+ <classpath location="build/mapstruct" />
+ </javac>
<javac includeAntRuntime="false" source="1.9" target="1.9" destdir="build/mapstruct-binding/classes" modulepath="build/mapstruct-module-path">
<src path="src/bindings/mapstruct" />
+ <include name="module-info.java" />
</javac>
<jar destfile="dist/lombok-mapstruct-binding-${mapstruct-binding.version}.jar" basedir="build/mapstruct-binding/classes" includes="**" />
</target>
@@ -93,6 +96,37 @@ exists as a separate dependency solely because it is itself dependent on both lo
<target name="mapstructBinding.pack" depends="dist,-mapstructBinding.jar,-mapstructBinding.doc,-mapstructBinding.src">
</target>
+ <target name="mapstructBinding.publish" depends="mapstructBinding.pack, setup.ssh">
+ <tar destfile="dist/mavenPublish-mapstructBinding.tar.bz2" compression="bzip2">
+ <tarfileset dir="dist">
+ <include name="lombok-mapstruct-binding-${mapstruct-binding.version}.jar" />
+ <include name="lombok-mapstruct-binding-${mapstruct-binding.version}-sources.jar" />
+ <include name="lombok-mapstruct-binding-${mapstruct-binding.version}-javadoc.jar" />
+ </tarfileset>
+ <tarfileset dir="build/mapstruct-binding/maven" includes="pom.xml" />
+ </tar>
+ <ivy:scpUpload
+ from="dist/mavenPublish-mapstructBinding.tar.bz2"
+ to="/data/lombok/staging"
+ server="projectlombok.org"
+ username="${ssh.username}"
+ keyfile="${ssh.keyfile}"
+ knownHosts="ssh.knownHosts" />
+ <ivy:sshExec
+ cmd="/data/lombok/stagingCmd/publishToMavenCentral-mapstructBinding"
+ server="projectlombok.org"
+ username="${ssh.username}"
+ keyfile="${ssh.keyfile}"
+ knownHosts="ssh.knownHosts" />
+ <echo>The artifact has been published to staging. Now go to https://oss.sonatype.org/ and log in as Reinier, then doublecheck if all is well and 'release' it.</echo>
+ <ivy:sshExec
+ cmd="/data/lombok/stagingCmd/showMavenCentralPassword"
+ server="projectlombok.org"
+ username="${ssh.username}"
+ keyfile="${ssh.keyfile}"
+ knownHosts="ssh.knownHosts" />
+ </target>
+
<target name="mapstructBinding.maven" depends="mapstructBinding.pack" description="Create a maven repo for mapstruct binding into a build dir.">
<delete quiet="true" dir="build/mapstruct-binding-maven" />
<mkdir dir="build/mapstruct-binding-maven" />
diff --git a/buildScripts/maven.ant.xml b/buildScripts/maven.ant.xml
index dcba2ccb..57bb6b99 100644
--- a/buildScripts/maven.ant.xml
+++ b/buildScripts/maven.ant.xml
@@ -59,7 +59,7 @@ This buildfile is part of projectlombok.org. It makes maven-compatible repositor
</sequential>
</macrodef>
- <target name="maven" depends="version, dist, javadoc.build" description="Creates a maven repo for the current release into a build dir. The intent is for you to put that on a server someplace. Will invoke your local mvn installation.">
+ <target name="maven" depends="version, dist, javadoc.build, -setup.build" description="Creates a maven repo for the current release into a build dir. The intent is for you to put that on a server someplace. Will invoke your local mvn installation.">
<mkdir dir="build" />
<mkdir dir="dist" />
diff --git a/buildScripts/setup.ant.xml b/buildScripts/setup.ant.xml
index 9b96240d..2a9104eb 100644
--- a/buildScripts/setup.ant.xml
+++ b/buildScripts/setup.ant.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2020 The Project Lombok Authors.
+ Copyright (C) 2020-2021 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
@@ -24,6 +24,9 @@
This buildfile is part of projectlombok.org. It sets up the build itself.
</description>
+ <!-- increment this number to force a clean of the 'build' dir -->
+ <property name="build.version" value="2021-03-18_001" />
+
<property name="pattern.jdk11plus" value="^(\d\d\d+|1[1-9]|[2-9]\d)(\..*)?$" />
<property name="ivy.retrieve.pattern" value="lib/[conf]/[organisation]-[artifact].[ext]" />
<property environment="env" />
@@ -84,6 +87,37 @@ This buildfile is part of projectlombok.org. It sets up the build itself.
<target name="setup.ssh" depends="-setup.ssh.ask, -setup.ssh.save" />
+ <target name="-autoclean.check">
+ <available type="dir" file="build" property="existingbuild.present" />
+ <loadresource property="existingbuild.ver">
+ <first count="1">
+ <resources>
+ <restrict>
+ <fileset dir="." includes="build/build-ver.txt" />
+ <exists />
+ </restrict>
+ <string>0</string>
+ </resources>
+ </first>
+ </loadresource>
+ <condition property="existingbuild.mismatch">
+ <and>
+ <isset property="existingbuild.present" />
+ <not><equals arg1="${existingbuild.ver}" arg2="${build.version}" trim="true" /></not>
+ </and>
+ </condition>
+ </target>
+
+ <target name="autoclean" depends="-autoclean.check" if="existingbuild.mismatch" description="Checks if a change in the build or deplist neccessitates a clean">
+ <echo>build ver has been incremented, neccessitating a clean...</echo>
+ <delete dir="build" />
+ </target>
+
+ <target name="-setup.build" depends="autoclean">
+ <mkdir dir="build" />
+ <echo file="build/build-ver.txt">${build.version}</echo>
+ </target>
+
<target name="clean" description="Removes all generated files.">
<delete dir="build" quiet="true" />
</target>
@@ -106,7 +140,7 @@ This buildfile is part of projectlombok.org. It sets up the build itself.
<target name="-ipp.load" depends="-ipp.download">
<taskdef classpath="lib/ivyplusplus.jar" resource="com/zwitserloot/ivyplusplus/antlib.xml" uri="antlib:com.zwitserloot.ivyplusplus" />
- <ivy:ensureippversion version="1.36" property="ivyplusplus.minimumAvailable" />
+ <ivy:ensureippversion version="1.40" property="ivyplusplus.minimumAvailable" />
</target>
<target name="-ipp.redownload" unless="ivyplusplus.minimumAvailable">
diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml
index cb840048..4cd36b9e 100644
--- a/buildScripts/tests.ant.xml
+++ b/buildScripts/tests.ant.xml
@@ -1,5 +1,5 @@
<!--
- Copyright (C) 2020 The Project Lombok Authors.
+ Copyright (C) 2020-2021 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
@@ -24,6 +24,14 @@
This buildfile is part of projectlombok.org. It takes care of compiling and running tests.
</description>
+ <target name="test.formatter.compile" depends="deps">
+ <mkdir dir="build/ant" />
+ <ivy:compile ecj="true" srcdir="src/ant" includes="**/SimpleTestFormatter.java" destdir="build/ant" source="1.6" target="1.6">
+ <classpath refid="cp.build" />
+ <classpath refid="cp.test" />
+ </ivy:compile>
+ </target>
+
<target name="test.compile" depends="deps, compile" description="compiles the tests" unless="skip.tests">
<mkdir dir="build/tests" />
<ivy:compile destdir="build/teststubs" source="1.6" target="1.6" ecj="true" nowarn="true">
@@ -33,8 +41,9 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<bootclasspath path="${jdk6-rt.loc}" />
<classpath refid="cp.test" />
<classpath refid="cp.eclipse-oxygen" />
- <classpath location="build/lombok" />
- <classpath location="build/tests" />
+ <classpath refid="cp.javac6" />
+ <classpath refid="packing.basedirs.path" />
+ <classpath path="build/tests" />
<src path="test/core/src" />
<src path="test/transform/src" />
<src path="test/bytecode/src" />
@@ -54,54 +63,42 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<echo>run ecj11 with a test file to confirm agent injection works: OK</echo>
</target>
- <property name="test.addopens.raw">
- --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
- --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
- </property>
<property name="test.limitmodules">--limit-modules java.base,jdk.unsupported</property>
- <loadresource property="test.addopens">
- <propertyresource name="test.addopens.raw" />
- <filterchain><tokenfilter>
- <filetokenizer />
- <replaceregex pattern="\s+" replace=" " flags="g" />
- </tokenfilter></filterchain>
- </loadresource>
-
- <target name="test.javac6" depends="test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler">
+ <target name="test.javac6" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler">
<echo>Running TestJavac on JVM${ant.java.version}, with lowest supported javac: 1.6.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
+ <classpath location="build/ant" />
<jvmarg value="-Xbootclasspath/a:${jdk6-rt.loc}" />
<jvmarg line="${test.limitmodules}" />
<jvmarg value="-Ddelombok.bootclasspath=${jdk6-rt.loc}" />
- <formatter type="plain" usefile="false" unless="tests.quiet" />
+ <jvmarg value="-Dsun.boot.class.path=${jdk6-rt.loc}" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
<classpath refid="cp.javac6" />
- <classpath location="build/lombok" />
+ <classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
+ <classpath location="build/teststubs" />
<test name="lombok.TestJavac" />
</junit>
</target>
- <target name="test.javac8" depends="test.compile, deps.jdk8-runtime" description="runs the tests on your default VM, using javac8 as underlying compiler">
+ <target name="test.javac8" depends="test.formatter.compile, test.compile, deps.jdk8-runtime" description="runs the tests on your default VM, using javac8 as underlying compiler">
<echo>Running TestJavac on JVM${ant.java.version}, with javac: 1.8.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
<jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
<jvmarg line="${test.limitmodules}" />
<jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
- <formatter type="plain" usefile="false" unless="tests.quiet" />
+ <jvmarg value="-Dsun.boot.class.path=${jdk8-rt.loc}" />
+ <classpath location="build/ant" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
<classpath refid="cp.javac8" />
- <classpath location="build/lombok" />
+ <classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
+ <classpath location="build/teststubs" />
<test name="lombok.TestJavac" />
</junit>
</target>
@@ -113,11 +110,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<echo>Running TestJavac with JVM ${jvm.loc.@{version}}.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once" jvm="${jvm.loc.@{version}}/bin/${exe.java}">
- <jvmarg line="${test.addopens}" />
- <formatter type="plain" usefile="false" unless="tests.quiet" />
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
+ <classpath location="build/ant" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
- <classpath location="build/lombok" />
+ <classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
<classpath location="build/teststubs" />
<test name="lombok.TestJavac" />
@@ -125,22 +122,28 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
</sequential>
</macrodef>
- <target name="test.javac11" depends="test.compile" description="runs the tests on your default VM, using javac11 as underlying compiler">
+ <target name="test.javac11" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac11 as underlying compiler">
<test.javacX version="11" />
</target>
- <target name="test.javac14" depends="test.compile" description="runs the tests on your default VM, using javac14 as underlying compiler">
+ <!-- For non-LTS versions, feel free to aggressively update these to the current non-LTS openjdk version, and delete them once they roll out of the 6month window. -->
+
+ <target name="test.javac14" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac14 as underlying compiler">
<test.javacX version="14" />
</target>
- <target name="test.javacCurrent" depends="test.compile" description="runs the tests on your default VM, using its javac as underlying compiler">
+ <target name="test.javac16" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac16 as underlying compiler">
+ <test.javacX version="16" />
+ </target>
+
+ <target name="test.javacCurrent" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using its javac as underlying compiler">
<echo>Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">
- <jvmarg line="${test.addopens}" />
- <formatter type="plain" usefile="false" unless="tests.quiet" />
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
+ <classpath location="build/ant" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
- <classpath location="build/lombok" />
+ <classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
<classpath location="build/teststubs" />
<test name="lombok.TestJavac" />
@@ -152,26 +155,26 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<sequential>
<echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version}.</echo>
<junit haltonfailure="yes" fork="true" forkmode="once">
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
<jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
<jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
<jvmarg value="-javaagent:dist/lombok.jar" />
- <jvmarg line="${test.addopens}" />
- <formatter type="plain" usefile="false" unless="tests.quiet" />
+ <classpath location="build/ant" />
<classpath refid="cp.test" />
<classpath refid="cp.stripe" />
<classpath refid="cp.eclipse-@{version}" />
- <classpath location="build/lombok" />
+ <classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
<test name="lombok.TestEclipse" />
</junit>
</sequential>
</macrodef>
- <target name="test.eclipse-oxygen" depends="test.compile" description="runs the tests on your default VM, testing the oxygen release of eclipse">
+ <target name="test.eclipse-oxygen" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the oxygen release of eclipse">
<test.eclipse-X version="oxygen" />
</target>
- <target name="test.eclipse-202006" depends="test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse">
+ <target name="test.eclipse-202006" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse">
<fetchdep.eclipse version="202006" />
<test.eclipse-X version="202006" />
</target>
diff --git a/buildScripts/vm-finder.ant.xml b/buildScripts/vm-finder.ant.xml
index 2b2c4c4c..2a33b2b8 100644
--- a/buildScripts/vm-finder.ant.xml
+++ b/buildScripts/vm-finder.ant.xml
@@ -38,7 +38,7 @@ This buildfile is part of projectlombok.org. It contains platform specific code
<condition property="jvm.loc" value="${jvm.loc.force}">
<and>
<isset property="jvm.loc.force" />
- <not><matches string="${jvm.loc.force}" pattern="^\$\{jvm[0-9\.]+\.loc\}$" /></not>
+ <not><matches string="${jvm.loc.force}" pattern="^\$\{jvm\.locations\.j[0-9\.]+\}$" /></not>
</and>
</condition>
<condition property="jvm.loc.invalid">
@@ -60,7 +60,8 @@ and rerun the build; this build is capable of finding VMs automatically on many
<fail unless="find-vm.version">Set property find-vm.version first</fail>
<local name="java_home.answer" />
<local name="java_home.result" />
- <exec executable="${exe.java_home}" errorproperty="discard" outputproperty="java_home.answer" failifexecutionfails="false" resultproperty="java_home.result">
+ <exec newenvironment="true" executable="${exe.java_home}" errorproperty="discard" outputproperty="java_home.answer" failifexecutionfails="false" resultproperty="java_home.result">
+ <env key="floobargle" value="FOO" /> <!-- we do not want JAVA_HOME to be set. This requires newenvironment="true" AND some sort of env value -->
<arg value="-v" />
<arg value="${find-vm.version}" />
</exec>
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index 730b79c2..1fc58fd4 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -57,7 +57,7 @@ such as applying the templates to produce the website, converting the changelog
<echo>Live full versionstring : ${lombok.fullversion.live}</echo>
</target>
- <target name="changelog.build" depends="version, deps, compile.support" description="Turns the current changelog (doc/changelog.txt) into HTML">
+ <target name="changelog.build" depends="version, deps, compile.support" description="Turns the current changelog (doc/changelog.markdown) into HTML">
<mkdir dir="build/website" />
<java classname="lombok.website.WebsiteMaker" failonerror="true">
<classpath>
@@ -217,7 +217,7 @@ such as applying the templates to produce the website, converting the changelog
<package name="lombok" />
<package name="lombok.experimental" />
<package name="lombok.extern.*" />
- <classpath location="build/lombok" />
+ <classpath location="build/lombok-main" />
<header><![CDATA[<a href='https://projectlombok.org/' target='_blank'>Lombok</a> - ]]>v${lombok.version}</header>
<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>
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 91fdd6a5..64bad8ba 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -1,21 +1,41 @@
Lombok Changelog
----------------
-### v1.18.13 "Edgy Guinea Pig"
-* PERFORMANCE: Several performance improvements during parsing/compilation, both using javac and Eclipse. Thanks __@Rawi01__!
-* PERFORMANCE: The generated equals method will first compare primitives, then primitive wrappers and then reference fields. Manual re-ordering is possible using `@Include(rank=n)`. [Pull Request #2485](https://github.com/rzwitserloot/lombok/pull/2485), [Issue #1543](https://github.com/rzwitserloot/lombok/issues/1543)
-* IMPROBABLE BREAKING CHANGE: The generated hashcode has changed for classes that include both primitive fields and reference fields.
-* PLATFORM: Added support for compiling projects with OpenJ9 [Pull Request #2437](https://github.com/rzwitserloot/lombok/pull/2437)
+### v1.18.19 "Edgy Guinea Pig"
+* PLATFORM: JDK16 support added. [Issue #2681](https://github.com/mplushnikov/lombok-intellij-plugin/issues/2681).
+* BUGFIX: Trying to use a lambda expression as parameter to an `@ExtensionMethod` did not work. [Issue #2741](https://github.com/rzwitserloot/lombok/issues/2741). (by __@Rawi01__).
+* BUGFIX: `@SuperBuilder` with an existing constructor caused issues in eclipse. [Issue #2704](https://github.com/rzwitserloot/lombok/issues/2704). (by [@JanRieke](https://github.com/rzwitserloot/lombok/pull/2770)).
+* BUGFIX: Using `@SuperBuilder` with a handwritten builder class caused issues. [Issue #2701](https://github.com/rzwitserloot/lombok/issues/2701). (by [@JanRieke](https://github.com/rzwitserloot/lombok/pull/2772)).
+* POTENTIAL BUGFIX: lombok + errorprone could cause `IllegalArgumentException` if using the `MissingSummary` bug pattern. [Issue #2730](https://github.com/rzwitserloot/lombok/issues/2730).
+
+### v1.18.18 (January 28th, 2021)
+* BUGFIX: Various tools using ecj under the hood (including intellij) could cause corrupt class files to be generated. [PR #2637](https://github.com/rzwitserloot/lombok/pull/2637), [lombok-intellij-plugin issue #969](https://github.com/mplushnikov/lombok-intellij-plugin/issues/969).
+* BUGFIX: Netbeans would not work with 1.18.16 anymore. [Issue #2612](https://github.com/rzwitserloot/lombok/issues/2612).
+* BUGFIX: `@ExtensionMethod` support in ecj improved when generics are involved. [Issue #2648](https://github.com/rzwitserloot/lombok/issues/2648), [PR #2658](https://github.com/rzwitserloot/lombok/pull/2658) thanks to __@Rawi01__.
+* PLATFORM: using `lombok.config` files when compiling with sbt 1.4 now works again. [Issue #2645](https://github.com/rzwitserloot/lombok/issues/2645)
+
+### v1.18.16 (October 15th, 2020)
+* BUGFIX: Version 1.18.14 could not be installed in Eclipse, it would break Eclipse.
* BREAKING CHANGE: mapstruct users should now add a dependency to lombok-mapstruct-binding. This solves compiling modules with lombok (and mapstruct).
+* IMPROBABLE BREAKING CHANGE: The generated hashcode has changed for classes that include both primitive fields and reference fields.
* FEATURE: Similar to `@Builder`, you can now configure a `@SuperBuilder`'s 'setter' prefixes via `@SuperBuilder(setterPrefix = "set")` for example. We still discourage doing this. [Pull Request #2357](https://github.com/rzwitserloot/lombok/pull/2357).
* FEATURE: If using `@Synchronized("lockVar")`, if `lockVar` is referring to a static field, the code lombok generates no longer causes a warning about accessing a static entity incorrectly. [Issue #678](https://github.com/rzwitserloot/lombok/issues/678)
-* BUGFIX: Delombok print the first `this` parameter. [Issue #2444](https://github.com/rzwitserloot/lombok/issues/2444)
+* FEATURE: `@Jacksonized` on a `@Builder` or `@SuperBuilder` will configure [Jackson](https://github.com/FasterXML/jackson) to use this builder when deserializing. [Pull Request #2387](https://github.com/rzwitserloot/lombok/pull/2387) thanks to __@JanRieke__. [@Jacksonized documentation](https://projectlombok.org/features/experimental/Jacksonized).
+* FEATURE: The checkerframework support has been updated; the relevant annotations were renamed in checkerframework's APIs, lombok now generates the annotations according to their current API names.
+* FEATURE: Add option to cache hashCode via `@EqualsAndHashCode(cacheStrategy = EqualsAndHashCode.CacheStrategy.LAZY)`. [Issue #784](https://github.com/rzwitserloot/lombok/issues/784) [Pull Request #2513](https://github.com/rzwitserloot/lombok/pull/2513) thanks to __@andrebrait__.
+* PLATFORM: Added support for compiling projects with OpenJ9 [Pull Request #2437](https://github.com/rzwitserloot/lombok/pull/2437)
+* PLATFORM: Improved support for recent JVM/javac versions (14 and 15) and new language features.
+* PERFORMANCE: Several performance improvements during parsing/compilation, both using javac and Eclipse. Thanks __@Rawi01__!
+* PERFORMANCE: The generated equals method will first compare primitives, then primitive wrappers and then reference fields. Manual re-ordering is possible using `@Include(rank=n)`. [Pull Request #2485](https://github.com/rzwitserloot/lombok/pull/2485), [Issue #1543](https://github.com/rzwitserloot/lombok/issues/1543)
+* BUGFIX: Delombok prints the first `this` parameter. [Issue #2444](https://github.com/rzwitserloot/lombok/issues/2444)
* BUGFIX: Using `val` in combination with values whose generics include wildcards that reference themselves would cause a `StackOverflowError` in javac. [Issue #2358](https://github.com/rzwitserloot/lombok/issues/2358).
* BUGFIX: Using `@SuperBuilder` on a class that has some fairly convoluted generics usage would fail with 'Wrong number of type arguments'. [Issue #2359](https://github.com/rzwitserloot/lombok/issues/2359) [Pull Request #2362](https://github.com/rzwitserloot/lombok/pull/2362)
* BUGFIX: Various lombok annotations on classes nested inside enums or interfaces would cause errors in eclipse. [Issue #2369](https://github.com/rzwitserloot/lombok/issues/2369)
* BUGFIX: Trying to add `@ExtensionMethod`s with exactly 2 arguments would fail in eclipse. [Issue #1441](https://github.com/rzwitserloot/lombok/issues/1441) [Pull Request #2376](https://github.com/rzwitserloot/lombok/pull/2376) thanks to __@Rawi01__.
* BUGFIX: Javac sets incorrect annotated type on with methods. [Issue #2463](https://github.com/rzwitserloot/lombok/issues/2463)
-* FEATURE: `@Jacksonized` on a `@Builder` or `@SuperBuilder` will configure [Jackson](https://github.com/FasterXML/jackson) to use this builder when deserializing. [Pull Request #2387](https://github.com/rzwitserloot/lombok/pull/2387) thanks to __@JanRieke__. [@Jacksonized documentation](https://projectlombok.org/features/experimental/Jacksonized).
+
+### v1.18.14 (October 8th, 2020)
+* Don't use this version. It is broken. Changes are listed under 1.18.16
### v1.18.12 (February 1st, 2020)
@@ -116,7 +136,7 @@ Lombok Changelog
### v1.16.22 "Envious Ferret" (May 29th, 2018)
* FEATURE: Private no-args constructor for `@Data` and `@Value` to enable deserialization frameworks (like Jackson) to operate out-of-the-box. Use `lombok.noArgsConstructor.extraPrivate = false` to disable this behavior.
* FEATURE: Methods can now be marked for inclusion in `toString`, `equals`, and `hashCode` generation. There is a new mechanism to mark which fields (and now, methods) are to be included or excluded for the generation of these methods: mark the relevant member with for example `@ToString.Include` or `@EqualsAndHashCode.Exclude`. [ToString documentation](https://projectlombok.org/features/ToString) [EqualsAndHashCode documentation](https://projectlombok.org/features/EqualsAndHashCode)
-* FEATURE: `@Getter` and `@Setter` also allow `onMethod` and `onParam` when put on a type. [Issue #1653](https://github.com/rzwitserloot/lombok/issues/1653)
+* FEATURE: `@Getter` and `@Setter` also allow `onMethod` and `onParam` when put on a type. [Issue #1653](https://github.com/rzwitserloot/lombok/issues/1653)
* FEATURE: `@FieldNameConstants` is a new feature that generates string constants for your field names. [Docs on @FieldNameConstants](https://projectlombok.org/features/experimental/FieldNameConstants).
* PLATFORM: Lombok can be compiled on JDK10, and should run on JDK10. [Issue #1693](https://github.com/rzwitserloot/lombok/issues/1693)
* PLATFORM: lombok now counts as an _incremental annotation processor_ for gradle. Should speed up your gradle builds considerably! [Issue #1580](https://github.com/rzwitserloot/lombok/issues/1580)
@@ -159,7 +179,7 @@ Lombok Changelog
* DEPRECATION: The configuration key `lombok.addGeneratedAnnotation` is now deprecated, use `lombok.addJavaxGeneratedAnnotation` instead.
### v1.16.12 (December 5th, 2016)
-* FEATURE: `var` is the mutable sister of `val`. For now experimental, and opt-in using `ALLOW` in the flagUsage configuration key. Thanks for the contribution, Bulgakov Alexander.
+* FEATURE: `var` is the mutable sister of `val`. For now experimental, and opt-in using `ALLOW` in the flagUsage configuration key. Thanks for the contribution, Bulgakov Alexander.
* CHANGE: `@Value` and `@FieldDefaults` no longer touch static fields [Issue #1254](https://github.com/rzwitserloot/lombok/issues/1254)
* BUGFIX: `val` in lambda expressions now work as expected [Issue #911](https://github.com/rzwitserloot/lombok/issues/911)
* BUGFIX: `Getter(lazy=true)` now emits an error message when used on a transient field [Issue #1236](https://github.com/rzwitserloot/lombok/issues/1236)
diff --git a/docker/ant/Dockerfile b/docker/ant/Dockerfile
index 57a2faf9..c38c6541 100644
--- a/docker/ant/Dockerfile
+++ b/docker/ant/Dockerfile
@@ -1,6 +1,6 @@
FROM ubuntu:18.04 as downloader
-ARG jdk=13
+ARG jdk=16
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
@@ -22,7 +22,7 @@ WORKDIR workspace
ADD shared/ ./
-ARG jdk=13
+ARG jdk=16
ADD ant/files/jdk-${jdk} ./
COPY --from=downloader /lombok.jar /workspace/classpath/lombok.jar
diff --git a/docker/ant/files/jdk-16/classpath/build.xml b/docker/ant/files/jdk-16/classpath/build.xml
new file mode 100644
index 00000000..01decd3f
--- /dev/null
+++ b/docker/ant/files/jdk-16/classpath/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" modulepath="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-16/modules/build.xml b/docker/ant/files/jdk-16/modules/build.xml
new file mode 100644
index 00000000..3f181ed9
--- /dev/null
+++ b/docker/ant/files/jdk-16/modules/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 7dce84e3..cfe90774 100644
--- a/docker/ant/readme.md
+++ b/docker/ant/readme.md
@@ -15,21 +15,22 @@ The ant version to be used. Supported values:
(To be executed from the `<lombokhome>/docker` directory)
```
-docker build -t lombok-ant-jdk13 -f ant/Dockerfile .
+docker build -t lombok-ant-jdk16 -f ant/Dockerfile .
-docker build -t lombok-ant-jdk13 --build-arg lombokjar=lombok-1.16.20.jar -f ant/Dockerfile .
+docker build -t lombok-ant-jdk16 --build-arg lombokjar=lombok-1.18.20.jar -f ant/Dockerfile .
```
## Example run commands:
```
-docker run -it lombok-ant-jdk13
+docker run -it lombok-ant-jdk16
-docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-ant-jdk13
+docker run --rm -it -v /<lombokhome>/dist/lombok.jar:/workspace/lombok.jar lombok-ant-jdk16
```
## Example container commands:
```
+cd classpath
ant dist
```
diff --git a/docker/bazel/Dockerfile b/docker/bazel/Dockerfile
index edc5e6fd..06149b1e 100644
--- a/docker/bazel/Dockerfile
+++ b/docker/bazel/Dockerfile
@@ -1,6 +1,6 @@
FROM ubuntu:18.04 as downloader
-ARG jdk=13
+ARG jdk=16
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
@@ -27,7 +27,7 @@ ADD bazel/files/ ./
COPY --from=downloader /lombok.jar /workspace/classpath/lombok.jar
COPY --from=downloader /lombok.jar /workspace/modules/lombok.jar
-ARG jdk=13
+ARG jdk=16
ENV JDK_VERSION=${jdk}
ENV JAVA_HOME=/opt/jdk
ENV BAZEL_HOME=/opt/bazel
diff --git a/docker/gradle/Dockerfile b/docker/gradle/Dockerfile
index 42c4775f..de85ca6f 100644
--- a/docker/gradle/Dockerfile
+++ b/docker/gradle/Dockerfile
@@ -1,6 +1,6 @@
FROM ubuntu:18.04 as downloader
-ARG jdk=13
+ARG jdk=16
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
@@ -26,7 +26,7 @@ ADD gradle/files/ ./
COPY --from=downloader /lombok.jar /workspace/classpath/lombok.jar
COPY --from=downloader /lombok.jar /workspace/modules/lombok.jar
-ARG jdk=13
+ARG jdk=16
ENV JDK_VERSION=${jdk}
ENV JAVA_HOME=/opt/jdk
ENV GRADLE_HOME=/opt/gradle/gradle
diff --git a/docker/maven/Dockerfile b/docker/maven/Dockerfile
index 32ebbe48..7d30dbf3 100644
--- a/docker/maven/Dockerfile
+++ b/docker/maven/Dockerfile
@@ -1,6 +1,6 @@
FROM ubuntu:18.04 as downloader
-ARG jdk=13
+ARG jdk=16
ADD provision/jdk/java-${jdk}.sh provision/jdk/java-${jdk}.sh
RUN provision/jdk/java-${jdk}.sh
@@ -22,7 +22,7 @@ WORKDIR workspace
ADD shared/ ./
-ARG jdk=13
+ARG jdk=16
ADD maven/files/jdk-${jdk} ./
COPY --from=downloader /lombok.jar /workspace/classpath/lombok.jar
diff --git a/docker/provision/jdk/java-16.sh b/docker/provision/jdk/java-16.sh
new file mode 100644
index 00000000..339bc11e
--- /dev/null
+++ b/docker/provision/jdk/java-16.sh
@@ -0,0 +1,4 @@
+apt-get update && apt-get install -y wget
+wget https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16%2B36/OpenJDK16-jdk_x64_linux_hotspot_16_36.tar.gz -O jdk.tar.gz
+tar -xzf jdk.tar.gz -C /opt/
+mv /opt/jdk-16+36 /opt/jdk \ No newline at end of file
diff --git a/src/ant/lombok/ant/SimpleTestFormatter.java b/src/ant/lombok/ant/SimpleTestFormatter.java
new file mode 100644
index 00000000..a2a38420
--- /dev/null
+++ b/src/ant/lombok/ant/SimpleTestFormatter.java
@@ -0,0 +1,63 @@
+package lombok.ant;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+
+public class SimpleTestFormatter implements JUnitResultFormatter {
+ private PrintStream out = System.out;
+
+ @Override
+ public void addError(Test test, Throwable error) {
+ logResult(test, "ERR");
+ out.println(error.getMessage());
+ }
+
+ @Override
+ public void addFailure(Test test, AssertionFailedError failure) {
+ logResult(test, "FAIL");
+ out.println(failure.getMessage());
+ }
+
+ @Override
+ public void endTest(Test test) {
+ logResult(test, "PASS");
+ }
+
+ @Override
+ public void startTest(Test test) { }
+
+ @Override
+ public void endTestSuite(JUnitTest testSuite) throws BuildException { }
+
+ @Override
+ public void setOutput(OutputStream out) {
+ this.out = new PrintStream(out);
+ }
+
+ @Override
+ public void setSystemError(String msg) {
+ if (msg.trim().isEmpty()) return;
+ out.println(msg);
+ }
+
+ @Override
+ public void setSystemOutput(String msg) {
+ if (msg.trim().isEmpty()) return;
+ out.println(msg);
+ }
+
+ @Override
+ public void startTestSuite(JUnitTest testSuite) throws BuildException { }
+
+ private void logResult(Test test, String result) {
+ out.println("[" + result + "] " + String.valueOf(test));
+ out.flush();
+ }
+}
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index 01a4b576..ba66649b 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -274,7 +274,7 @@ public class ConfigurationKeys {
*
* For any class with an {@code @ToString} annotation which extends a class other than {@code java.lang.Object}, should a call to superclass's implementation of {@code toString} be included in the generated method? (Default = skip)
*/
- public static final ConfigurationKey<CallSuperType> TO_STRING_CALL_SUPER = new ConfigurationKey<CallSuperType>("lombok.toString.callSuper", "When generating toString for classes that extend something (other than Object), either automatically take into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = warn).") {};
+ public static final ConfigurationKey<CallSuperType> TO_STRING_CALL_SUPER = new ConfigurationKey<CallSuperType>("lombok.toString.callSuper", "When generating toString for classes that extend something (other than Object), either automatically take into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = skip).") {};
/**
* lombok configuration: {@code lombok.toString.flagUsage} = {@code WARNING} | {@code ERROR}.
diff --git a/src/core/lombok/EqualsAndHashCode.java b/src/core/lombok/EqualsAndHashCode.java
index 6805d214..279e6e3d 100644
--- a/src/core/lombok/EqualsAndHashCode.java
+++ b/src/core/lombok/EqualsAndHashCode.java
@@ -71,6 +71,14 @@ public @interface EqualsAndHashCode {
* @return If {@code true}, always use direct field access instead of calling the getter method.
*/
boolean doNotUseGetters() default false;
+
+ /**
+ * Determines how the result of the {@code hashCode} method will be cached.
+ * <strong>default: {@link CacheStrategy#NEVER}</strong>
+ *
+ * @return The {@code hashCode} cache strategy to be used.
+ */
+ CacheStrategy cacheStrategy() default CacheStrategy.NEVER;
/**
* Any annotations listed here are put on the generated parameter of {@code equals} and {@code canEqual}.
@@ -132,4 +140,19 @@ public @interface EqualsAndHashCode {
*/
int rank() default 0;
}
+
+ public enum CacheStrategy {
+ /**
+ * Never cache. Perform the calculation every time the method is called.
+ */
+ NEVER,
+ /**
+ * Cache the result of the first invocation of {@code hashCode} and use it for subsequent invocations.
+ * This can improve performance if all fields used for calculating the {@code hashCode} are immutable
+ * and thus every invocation of {@code hashCode} will always return the same value.
+ * <strong>Do not use this if there's <em>any</em> chance that different invocations of {@code hashCode}
+ * might return different values.</strong>
+ */
+ LAZY
+ }
}
diff --git a/src/core/lombok/bytecode/PoolConstantsApp.java b/src/core/lombok/bytecode/PoolConstantsApp.java
index c2120cc0..65b51f17 100644
--- a/src/core/lombok/bytecode/PoolConstantsApp.java
+++ b/src/core/lombok/bytecode/PoolConstantsApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -26,8 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import lombok.core.LombokApp;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
@@ -36,9 +35,8 @@ import com.zwitserloot.cmdreader.Mandatory;
import com.zwitserloot.cmdreader.Sequential;
import com.zwitserloot.cmdreader.Shorthand;
-@ProviderFor(LombokApp.class)
+@Provides
public class PoolConstantsApp extends LombokApp {
-
@Override public String getAppName() {
return "Xprintpool";
}
diff --git a/src/core/lombok/bytecode/PostCompilerApp.java b/src/core/lombok/bytecode/PostCompilerApp.java
index 5f49bd81..7f2237c0 100644
--- a/src/core/lombok/bytecode/PostCompilerApp.java
+++ b/src/core/lombok/bytecode/PostCompilerApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -33,8 +33,7 @@ import java.util.List;
import lombok.core.DiagnosticsReceiver;
import lombok.core.LombokApp;
import lombok.core.PostCompiler;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
@@ -43,7 +42,7 @@ import com.zwitserloot.cmdreader.Mandatory;
import com.zwitserloot.cmdreader.Sequential;
import com.zwitserloot.cmdreader.Shorthand;
-@ProviderFor(LombokApp.class)
+@Provides
public class PostCompilerApp extends LombokApp {
@Override public List<String> getAppAliases() {
return Arrays.asList("post", "postcompile");
diff --git a/src/core/lombok/bytecode/PreventNullAnalysisRemover.java b/src/core/lombok/bytecode/PreventNullAnalysisRemover.java
index 20572e22..14e95c46 100644
--- a/src/core/lombok/bytecode/PreventNullAnalysisRemover.java
+++ b/src/core/lombok/bytecode/PreventNullAnalysisRemover.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2014 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -27,15 +27,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
import lombok.core.DiagnosticsReceiver;
import lombok.core.PostCompilerTransformation;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-@ProviderFor(PostCompilerTransformation.class)
+@Provides
public class PreventNullAnalysisRemover implements PostCompilerTransformation {
@Override public byte[] applyTransformations(byte[] original, String fileName, DiagnosticsReceiver diagnostics) {
diff --git a/src/core/lombok/bytecode/SneakyThrowsRemover.java b/src/core/lombok/bytecode/SneakyThrowsRemover.java
index 037cb109..7ed3f80f 100644
--- a/src/core/lombok/bytecode/SneakyThrowsRemover.java
+++ b/src/core/lombok/bytecode/SneakyThrowsRemover.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2014 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -27,8 +27,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import lombok.core.DiagnosticsReceiver;
import lombok.core.PostCompilerTransformation;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
@@ -37,7 +37,7 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
-@ProviderFor(PostCompilerTransformation.class)
+@Provides
public class SneakyThrowsRemover implements PostCompilerTransformation {
@Override public byte[] applyTransformations(byte[] original, String fileName, final DiagnosticsReceiver diagnostics) {
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java
index d4a92408..28d16298 100644
--- a/src/core/lombok/core/AnnotationProcessor.java
+++ b/src/core/lombok/core/AnnotationProcessor.java
@@ -26,8 +26,9 @@ import static lombok.core.Augments.ClassLoader_lombokAlreadyAddedTo;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -68,7 +69,7 @@ public class AnnotationProcessor extends AbstractProcessor {
private final List<String> delayedWarnings = new ArrayList<String>();
/**
- * This method is a simplified version of {@link lombok.javac.apt.LombokProcessor.getJavacProcessingEnvironment}
+ * This method is a simplified version of {@link lombok.javac.apt.LombokProcessor#getJavacProcessingEnvironment}
* It simply returns the processing environment, but in case of gradle incremental compilation,
* the delegate ProcessingEnvironment of the gradle wrapper is returned.
*/
@@ -83,15 +84,11 @@ public class AnnotationProcessor extends AbstractProcessor {
for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
try {
- Field field;
- try {
- field = Permit.getField(procEnvClass, "delegate");
- } catch (NoSuchFieldException e) {
- field = Permit.getField(procEnvClass, "processingEnv");
- }
- Object delegate = field.get(procEnv);
-
- return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
+ Object delegate = tryGetDelegateField(procEnvClass, procEnv);
+ if (delegate == null) delegate = tryGetProcessingEnvField(procEnvClass, procEnv);
+ if (delegate == null) delegate = tryGetProxyDelegateToField(procEnvClass, procEnv);
+
+ if (delegate != null) return tryRecursivelyObtainJavacProcessingEnvironment((ProcessingEnvironment) delegate);
} catch (final Exception e) {
// no valid delegate, try superclass
}
@@ -100,6 +97,40 @@ public class AnnotationProcessor extends AbstractProcessor {
return null;
}
+ /**
+ * Gradle incremental processing
+ */
+ private static Object tryGetDelegateField(Class<?> delegateClass, Object instance) {
+ try {
+ return Permit.getField(delegateClass, "delegate").get(instance);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Kotlin incremental processing
+ */
+ private static Object tryGetProcessingEnvField(Class<?> delegateClass, Object instance) {
+ try {
+ return Permit.getField(delegateClass, "processingEnv").get(instance);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * IntelliJ IDEA >= 2020.3
+ */
+ private static Object tryGetProxyDelegateToField(Class<?> delegateClass, Object instance) {
+ try {
+ InvocationHandler handler = Proxy.getInvocationHandler(instance);
+ return Permit.getField(handler.getClass(), "val$delegateTo").get(handler);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
static class JavacDescriptor extends ProcessorDescriptor {
private Processor processor;
@@ -143,7 +174,7 @@ public class AnnotationProcessor extends AbstractProcessor {
if (!ClassLoader_lombokAlreadyAddedTo.getAndSet(environmentClassLoader, true)) {
Method m = Permit.getMethod(environmentClassLoader.getClass(), "addURL", URL.class);
URL selfUrl = new File(ClassRootFinder.findClassRootOfClass(AnnotationProcessor.class)).toURI().toURL();
- m.invoke(environmentClassLoader, selfUrl);
+ Permit.invoke(m, environmentClassLoader, selfUrl);
}
}
@@ -188,8 +219,12 @@ public class AnnotationProcessor extends AbstractProcessor {
if (supported.length() > 0) supported.append(", ");
supported.append(proc.getName());
}
- procEnv.getMessager().printMessage(Kind.WARNING, String.format("You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.\n" +
+ if (procEnv.getClass().getName().equals("com.google.turbine.processing.TurbineProcessingEnvironment")) {
+ procEnv.getMessager().printMessage(Kind.ERROR, String.format("Turbine is not currently supported by lombok."));
+ } else {
+ procEnv.getMessager().printMessage(Kind.WARNING, String.format("You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.\n" +
"Your processor is: %s\nLombok supports: %s", procEnv.getClass().getName(), supported));
+ }
}
}
@@ -226,6 +261,6 @@ public class AnnotationProcessor extends AbstractProcessor {
* We just return the latest version of whatever JDK we run on. Stupid? Yeah, but it's either that or warnings on all versions but 1. Blame Joe.
*/
@Override public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.values()[SourceVersion.values().length - 1];
+ return SourceVersion.latest();
}
}
diff --git a/src/core/lombok/core/Main.java b/src/core/lombok/core/Main.java
index 47afaefd..2c9d1dcb 100644
--- a/src/core/lombok/core/Main.java
+++ b/src/core/lombok/core/Main.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -30,7 +30,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
public class Main {
private static final Collection<?> HELP_SWITCHES = Collections.unmodifiableList(Arrays.asList(
@@ -46,7 +46,7 @@ public class Main {
}
}
- @ProviderFor(LombokApp.class)
+ @Provides
public static class VersionApp extends LombokApp {
@Override public String getAppName() {
return "version";
@@ -66,7 +66,7 @@ public class Main {
}
}
- @ProviderFor(LombokApp.class)
+ @Provides
public static class LicenseApp extends LombokApp {
@Override public String getAppName() {
return "license";
diff --git a/src/core/lombok/core/PostCompiler.java b/src/core/lombok/core/PostCompiler.java
index 72f4b3a2..122bb268 100644
--- a/src/core/lombok/core/PostCompiler.java
+++ b/src/core/lombok/core/PostCompiler.java
@@ -28,6 +28,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
public final class PostCompiler {
private PostCompiler() {/* prevent instantiation*/};
@@ -67,8 +68,17 @@ public final class PostCompiler {
public static OutputStream wrapOutputStream(final OutputStream originalStream, final String fileName, final DiagnosticsReceiver diagnostics) throws IOException {
if (System.getProperty("lombok.disablePostCompiler", null) != null) return originalStream;
+
+ // close() can be called more than once and should be idempotent, therefore, ensure we never transform more than once.
+ final AtomicBoolean closed = new AtomicBoolean();
+
return new ByteArrayOutputStream() {
@Override public void close() throws IOException {
+ if (closed.getAndSet(true)) {
+ originalStream.close();
+ return;
+ }
+
// no need to call super
byte[] original = toByteArray();
byte[] copy = null;
diff --git a/src/core/lombok/core/PublicApiCreatorApp.java b/src/core/lombok/core/PublicApiCreatorApp.java
index c1430c24..f45808fe 100644
--- a/src/core/lombok/core/PublicApiCreatorApp.java
+++ b/src/core/lombok/core/PublicApiCreatorApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -36,10 +36,9 @@ import java.util.zip.ZipEntry;
import lombok.Lombok;
import lombok.patcher.ClassRootFinder;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(LombokApp.class)
+@Provides
public class PublicApiCreatorApp extends LombokApp {
@Override public String getAppName() {
return "publicApi";
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java
index 2962a8e0..af0941bb 100644
--- a/src/core/lombok/core/Version.java
+++ b/src/core/lombok/core/Version.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -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.13";
+ private static final String VERSION = "1.18.19";
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
index 5805678f..c37ba91d 100644
--- a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
+++ b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java
@@ -32,9 +32,9 @@ public final class CheckerFrameworkVersion implements ConfigurationValueType {
public static final String NAME__SIDE_EFFECT_FREE = "org.checkerframework.dataflow.qual.SideEffectFree";
public static final String NAME__PURE = "org.checkerframework.dataflow.qual.Pure";
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 String NAME__RETURNS_RECEIVER = "org.checkerframework.common.returnsreceiver.qual.This";
+ public static final String NAME__NOT_CALLED = "org.checkerframework.checker.calledmethods.qual.NotCalledMethods";
+ public static final String NAME__CALLED = "org.checkerframework.checker.calledmethods.qual.CalledMethods";
public static final CheckerFrameworkVersion NONE = new CheckerFrameworkVersion(0);
diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java
index 9c225fdb..8d794c8a 100644
--- a/src/core/lombok/core/configuration/ConfigurationApp.java
+++ b/src/core/lombok/core/configuration/ConfigurationApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2020 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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
@@ -41,8 +41,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.mangosdk.spi.ProviderFor;
-
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
import com.zwitserloot.cmdreader.Excludes;
@@ -56,8 +54,9 @@ import com.zwitserloot.cmdreader.Shorthand;
import lombok.ConfigurationKeys;
import lombok.core.LombokApp;
import lombok.core.configuration.ConfigurationParser.Collector;
+import lombok.spi.Provides;
-@ProviderFor(LombokApp.class)
+@Provides
public class ConfigurationApp extends LombokApp {
private static final URI NO_CONFIG = URI.create("");
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index 1c4437d7..19cc5a9e 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.AllArgsConstructor;
@@ -324,7 +325,9 @@ public class HandlerUtil {
"com.fasterxml.jackson.annotation.JsonTypeInfo",
"com.fasterxml.jackson.annotation.JsonView",
"com.fasterxml.jackson.databind.annotation.JsonDeserialize",
+ "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper",
"com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty",
+ "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText",
}));
COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
"com.fasterxml.jackson.annotation.JsonAnySetter",
@@ -756,4 +759,90 @@ public class HandlerUtil {
if (PRIMITIVE_WRAPPER_TYPE_NAME_PATTERN.matcher(typeName).matches()) return 800;
return 0;
}
+
+ private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITH(?:ER)?)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
+ private static final Pattern LINE_BREAK_FINDER = Pattern.compile("(\\r?\\n)?");
+
+ public enum JavadocTag {
+ PARAM("@param(?:eter)?"),
+ RETURN("@returns?");
+
+ private Pattern pattern;
+
+ JavadocTag(String regexpFragment) {
+ pattern = Pattern.compile("\\s?^[ \\t]*\\**[ \\t]*" + regexpFragment + "(\\S|\\s)*?(?=(\\s^\\s*\\**\\s*@|\\Z))", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
+ }
+ }
+
+ public static String stripLinesWithTagFromJavadoc(String javadoc, JavadocTag tag) {
+ if (javadoc == null || javadoc.isEmpty()) return javadoc;
+ return tag.pattern.matcher(javadoc).replaceAll("");
+ }
+
+ public static String stripSectionsFromJavadoc(String javadoc) {
+ if (javadoc == null || javadoc.isEmpty()) return javadoc;
+ Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
+ if (!sectionMatcher.find()) return javadoc;
+
+ return javadoc.substring(0, sectionMatcher.start());
+ }
+
+ public static String getJavadocSection(String javadoc, String sectionNameSpec) {
+ if (javadoc == null || javadoc.isEmpty()) return null;
+ String[] sectionNames = sectionNameSpec.split("\\|");
+ Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
+ Matcher lineBreakMatcher = LINE_BREAK_FINDER.matcher(javadoc);
+ int sectionStart = -1;
+ int sectionEnd = -1;
+ while (sectionMatcher.find()) {
+ boolean found = false;
+ for (String sectionName : sectionNames) if (sectionMatcher.group(1).equalsIgnoreCase(sectionName)) {
+ found = true;
+ break;
+ }
+ if (found) {
+ lineBreakMatcher.find(sectionMatcher.end());
+ sectionStart = lineBreakMatcher.end();
+ } else if (sectionStart != -1) {
+ sectionEnd = sectionMatcher.start();
+ }
+ }
+
+ if (sectionStart != -1) {
+ if (sectionEnd != -1) return javadoc.substring(sectionStart, sectionEnd);
+ return javadoc.substring(sectionStart);
+ }
+
+ return null;
+ }
+
+ private static final Pattern FIND_RETURN = Pattern.compile("^\\s*\\**\\s*@returns?\\s+.*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
+
+ public static String addReturnsThisIfNeeded(String in) {
+ if (in != null && FIND_RETURN.matcher(in).find()) return in;
+
+ return addJavadocLine(in, "@return {@code this}.");
+ }
+
+ public static String addReturnsUpdatedSelfIfNeeded(String in) {
+ if (in != null && FIND_RETURN.matcher(in).find()) return in;
+
+ return addJavadocLine(in, "@return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).");
+ }
+
+ public static String addJavadocLine(String in, String line) {
+ if (in == null) return line;
+ if (in.endsWith("\n")) return in + line + "\n";
+ return in + "\n" + line;
+ }
+
+ public static String getParamJavadoc(String methodComment, String param) {
+ if (methodComment == null || methodComment.isEmpty()) return methodComment;
+ Pattern pattern = Pattern.compile("@param " + param + " (\\S|\\s)+?(?=^ ?@)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
+ Matcher matcher = pattern.matcher(methodComment);
+ if (matcher.find()) {
+ return matcher.group();
+ }
+ return null;
+ }
}
diff --git a/src/core/lombok/core/handlers/SneakyThrowsAndCleanupDependencyInfo.java b/src/core/lombok/core/handlers/SneakyThrowsAndCleanupDependencyInfo.java
index 3b6f8974..482c166b 100644
--- a/src/core/lombok/core/handlers/SneakyThrowsAndCleanupDependencyInfo.java
+++ b/src/core/lombok/core/handlers/SneakyThrowsAndCleanupDependencyInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -25,10 +25,9 @@ import java.util.Arrays;
import java.util.List;
import lombok.core.runtimeDependencies.RuntimeDependencyInfo;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(RuntimeDependencyInfo.class)
+@Provides
public class SneakyThrowsAndCleanupDependencyInfo implements RuntimeDependencyInfo {
@Override public List<String> getRuntimeDependencies() {
return Arrays.asList(
diff --git a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
index 4d5988af..21f097d7 100644
--- a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
+++ b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,8 +38,7 @@ import java.util.zip.ZipEntry;
import lombok.core.LombokApp;
import lombok.core.SpiLoadUtil;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
@@ -48,7 +47,7 @@ import com.zwitserloot.cmdreader.Mandatory;
import com.zwitserloot.cmdreader.Requires;
import com.zwitserloot.cmdreader.Shorthand;
-@ProviderFor(LombokApp.class)
+@Provides
public class CreateLombokRuntimeApp extends LombokApp {
private List<RuntimeDependencyInfo> infoObjects;
diff --git a/src/core/lombok/eclipse/EclipseAugments.java b/src/core/lombok/eclipse/EcjAugments.java
index f4583ac4..cd7173a8 100644
--- a/src/core/lombok/eclipse/EclipseAugments.java
+++ b/src/core/lombok/eclipse/EcjAugments.java
@@ -21,14 +21,21 @@
*/
package lombok.eclipse;
+import java.util.Map;
+import java.util.List;
+import java.util.concurrent.ConcurrentMap;
+
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.core.CompilationUnit;
+import org.eclipse.jdt.internal.core.SourceMethod;
import lombok.core.FieldAugment;
-public final class EclipseAugments {
- private EclipseAugments() {
+public final class EcjAugments {
+ private EcjAugments() {
// Prevent instantiation
}
@@ -36,4 +43,13 @@ public final class EclipseAugments {
public static final FieldAugment<ASTNode, Boolean> ASTNode_handled = FieldAugment.augment(ASTNode.class, boolean.class, "lombok$handled");
public static final FieldAugment<ASTNode, ASTNode> ASTNode_generatedBy = FieldAugment.augment(ASTNode.class, ASTNode.class, "$generatedBy");
public static final FieldAugment<Annotation, Boolean> Annotation_applied = FieldAugment.augment(Annotation.class, boolean.class, "lombok$applied");
+ public static final FieldAugment<ICompilationUnit, Map<String, String>> CompilationUnit_javadoc = FieldAugment.augment(ICompilationUnit.class, Map.class, "$javadoc");
+
+ public static final class EclipseAugments {
+ private EclipseAugments() {
+ // Prevent instantiation
+ }
+
+ public static final FieldAugment<CompilationUnit, ConcurrentMap<String, List<SourceMethod>>> CompilationUnit_delegateMethods = FieldAugment.augment(CompilationUnit.class, ConcurrentMap.class, "$delegateMethods");
+ }
}
diff --git a/src/core/lombok/eclipse/EclipseAST.java b/src/core/lombok/eclipse/EclipseAST.java
index 2c860e14..0036ec23 100644
--- a/src/core/lombok/eclipse/EclipseAST.java
+++ b/src/core/lombok/eclipse/EclipseAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,11 +21,8 @@
*/
package lombok.eclipse;
-import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
-
import java.io.File;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.ArrayList;
@@ -33,9 +30,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import lombok.Lombok;
import lombok.core.AST;
import lombok.core.LombokImmutableList;
+import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import lombok.permit.Permit;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -287,23 +284,8 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
*/
public static void addProblemToCompilationResult(char[] fileNameArray, CompilationResult result,
boolean isWarning, String message, int sourceStart, int sourceEnd) {
- try {
- EcjReflectionCheck.addProblemToCompilationResult.invoke(null, fileNameArray, result, isWarning, message, sourceStart, sourceEnd);
- } catch (NoClassDefFoundError e) {
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e);
- } catch (NullPointerException e) {
- if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) {
- e.initCause(EcjReflectionCheck.problemAddProblemToCompilationResult);
- throw e;
- }
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- }
+
+ Permit.invokeSneaky(EcjReflectionCheck.problemAddProblemToCompilationResult, EcjReflectionCheck.addProblemToCompilationResult, null, fileNameArray, result, isWarning, message, sourceStart, sourceEnd);
}
public static Annotation[] getTopLevelTypeReferenceAnnotations(TypeReference tr) {
@@ -311,14 +293,14 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
if (m == null) return null;
Annotation[][] annss = null;
try {
- annss = (Annotation[][]) m.invoke(tr);
+ annss = (Annotation[][]) Permit.invoke(m, tr);
if (annss != null) return annss[0];
} catch (Throwable ignore) {}
try {
Field f = EcjReflectionCheck.typeReferenceAnnotations;
if (f == null) return null;
- annss = (Annotation[][]) f.get(tr);
+ annss = (Annotation[][]) Permit.get(f, tr);
if (annss == null) return null;
return annss[annss.length - 1];
} catch (Throwable t) {
@@ -411,7 +393,9 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
private Collection<EclipseNode> buildFields(FieldDeclaration[] children, Annotation[][] annotations) {
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
- if (children != null) for (int i = 0; i < children.length; i++) addIfNotNull(childNodes, buildField(children[i], annotations[i]));
+ if (children != null) for (int i = 0; i < children.length; i++) {
+ addIfNotNull(childNodes, buildField(children[i], annotations[i]));
+ }
return childNodes;
}
@@ -422,7 +406,7 @@ public class EclipseAST extends AST<EclipseAST, EclipseNode, ASTNode> {
}
private EclipseNode buildField(FieldDeclaration field, Annotation[] annotations) {
- if (field instanceof Initializer) return buildInitializer((Initializer)field);
+ if (field instanceof Initializer) return buildInitializer((Initializer) field);
if (setAndGetAsHandled(field)) return null;
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
addIfNotNull(childNodes, buildTypeUse(field.type));
diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java
index 361a8d42..4f86f0a5 100644
--- a/src/core/lombok/eclipse/EclipseNode.java
+++ b/src/core/lombok/eclipse/EclipseNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java
index 0e72fb38..8d69325e 100644
--- a/src/core/lombok/eclipse/HandlerLibrary.java
+++ b/src/core/lombok/eclipse/HandlerLibrary.java
@@ -23,7 +23,7 @@ package lombok.eclipse;
import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
-import static lombok.eclipse.EclipseAugments.ASTNode_handled;
+import static lombok.eclipse.EcjAugments.ASTNode_handled;
import java.io.IOException;
import java.lang.annotation.Annotation;
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index c70e4e5c..defe8d34 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -23,7 +23,7 @@ package lombok.eclipse.handlers;
import static lombok.core.handlers.HandlerUtil.*;
import static lombok.eclipse.Eclipse.*;
-import static lombok.eclipse.EclipseAugments.*;
+import static lombok.eclipse.EcjAugments.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.EclipseReflectiveMembers.*;
import java.lang.reflect.Array;
@@ -39,6 +39,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
@@ -94,6 +95,7 @@ import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
@@ -121,10 +123,10 @@ import lombok.core.configuration.TypeName;
import lombok.core.debug.ProblemReporter;
import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.HandlerUtil.FieldAccess;
+import lombok.eclipse.EcjAugments;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseNode;
-import lombok.eclipse.Java14Bits;
import lombok.experimental.Accessors;
import lombok.experimental.Tolerate;
import lombok.permit.Permit;
@@ -289,9 +291,7 @@ public class EclipseHandlerUtil {
MarkerAnnotation ann = new MarkerAnnotation(copyType(annotation.type, source), pS);
setGeneratedBy(ann, source);
ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
@@ -300,9 +300,7 @@ public class EclipseHandlerUtil {
setGeneratedBy(ann, source);
ann.declarationSourceEnd = ann.sourceEnd = ann.statementEnd = pE;
ann.memberValue = copyAnnotationMemberValue(((SingleMemberAnnotation) annotation).memberValue);
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
@@ -318,15 +316,21 @@ public class EclipseHandlerUtil {
for (int i = 0; i < inPairs.length; i++) ann.memberValuePairs[i] =
new MemberValuePair(inPairs[i].name, inPairs[i].sourceStart, inPairs[i].sourceEnd, copyAnnotationMemberValue(inPairs[i].value));
}
- try {
- reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, ann, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, annotation));
- } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ copyMemberValuePairName(ann, annotation);
return ann;
}
return annotation;
}
+ private static void copyMemberValuePairName(Annotation source, Annotation target) {
+ if (ANNOTATION__MEMBER_VALUE_PAIR_NAME == null) return;
+
+ try {
+ reflectSet(ANNOTATION__MEMBER_VALUE_PAIR_NAME, source, reflect(ANNOTATION__MEMBER_VALUE_PAIR_NAME, target));
+ } catch (Exception ignore) { /* Various eclipse versions don't have it */ }
+ }
+
static class EclipseReflectiveMembers {
public static final Field STRING_LITERAL__LINE_NUMBER;
public static final Field ANNOTATION__MEMBER_VALUE_PAIR_NAME;
@@ -372,7 +376,7 @@ public class EclipseHandlerUtil {
private static Class<?> getClass(String fqn) {
try {
return Class.forName(fqn);
- } catch (Exception e) {
+ } catch (Throwable t) {
return null;
}
}
@@ -380,7 +384,7 @@ public class EclipseHandlerUtil {
private static Field getField(Class<?> c, String fName) {
try {
return Permit.getField(c, fName);
- } catch (Exception e) {
+ } catch (Throwable t) {
return null;
}
}
@@ -775,10 +779,9 @@ public class EclipseHandlerUtil {
public static boolean hasNonNullAnnotations(EclipseNode node) {
for (EclipseNode child : node.down()) {
- if (child.getKind() == Kind.ANNOTATION) {
- Annotation annotation = (Annotation) child.get();
- for (String bn : NONNULL_ANNOTATIONS) if (typeMatches(bn, node, annotation.type)) return true;
- }
+ if (child.getKind() != Kind.ANNOTATION) continue;
+ Annotation annotation = (Annotation) child.get();
+ for (String bn : NONNULL_ANNOTATIONS) if (typeMatches(bn, node, annotation.type)) return true;
}
return false;
}
@@ -1873,15 +1876,12 @@ public class EclipseHandlerUtil {
public static MemberExistsResult constructorExists(EclipseNode node) {
node = upToTypeNode(node);
if (node != null && node.get() instanceof TypeDeclaration) {
- TypeDeclaration typeDecl = (TypeDeclaration)node.get();
+ TypeDeclaration typeDecl = (TypeDeclaration) node.get();
if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) {
- if (def instanceof ConstructorDeclaration) {
- if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
-
- if (isTolerate(node, def)) continue;
-
- return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
- }
+ if (!(def instanceof ConstructorDeclaration)) continue;
+ if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
+ if (isTolerate(node, def)) continue;
+ return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
@@ -1889,24 +1889,19 @@ public class EclipseHandlerUtil {
}
/**
- * Checks if there is a constructor generated by lombok.
+ * Checks if there is at least one constructor that is generated by lombok.
*
* @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.
*/
public static boolean lombokConstructorExists(EclipseNode node) {
node = upToTypeNode(node);
if (node != null && node.get() instanceof TypeDeclaration) {
- TypeDeclaration typeDecl = (TypeDeclaration)node.get();
+ TypeDeclaration typeDecl = (TypeDeclaration) node.get();
if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) {
- if (def instanceof ConstructorDeclaration) {
- if ((def.bits & (ASTNode.IsDefaultConstructor | Java14Bits.IsCanonicalConstructor)) != 0) continue;
-
- if (isTolerate(node, def)) continue;
-
- if (getGeneratedBy(def) != null) {
- return true;
- }
- }
+ if (!(def instanceof ConstructorDeclaration)) continue;
+ if ((def.bits & ASTNode.IsDefaultConstructor | IsCanonicalConstructor) != 0) continue;
+ if (isTolerate(node, def)) continue;
+ if (getGeneratedBy(def) != null) return true;
}
}
@@ -2331,18 +2326,10 @@ public class EclipseHandlerUtil {
public static IntLiteral makeIntLiteral(char[] token, ASTNode source) {
int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd;
IntLiteral result;
- try {
- if (intLiteralConstructor != null) {
- result = intLiteralConstructor.newInstance(token, pS, pE);
- } else {
- result = (IntLiteral) intLiteralFactoryMethod.invoke(null, token, pS, pE);
- }
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InstantiationException e) {
- throw Lombok.sneakyThrow(e);
+ if (intLiteralConstructor != null) {
+ result = Permit.newInstanceSneaky(intLiteralConstructor, token, pS, pE);
+ } else {
+ result = (IntLiteral) Permit.invokeSneaky(intLiteralFactoryMethod, null, token, pS, pE);
}
if (source != null) setGeneratedBy(result, source);
@@ -2496,18 +2483,7 @@ public class EclipseHandlerUtil {
}
public static NameReference createNameReference(String name, Annotation source) {
- int pS = source.sourceStart, pE = source.sourceEnd;
- long p = (long)pS << 32 | pE;
-
- char[][] nameTokens = fromQualifiedName(name);
- long[] pos = new long[nameTokens.length];
- Arrays.fill(pos, p);
-
- QualifiedNameReference nameReference = new QualifiedNameReference(nameTokens, pos, pS, pE);
- nameReference.statementEnd = pE;
-
- setGeneratedBy(nameReference, source);
- return nameReference;
+ return generateQualifiedNameRef(source, fromQualifiedName(name));
}
private static long[] copy(long[] array) {
@@ -2662,39 +2638,57 @@ public class EclipseHandlerUtil {
return ref;
}
- static boolean isClass(EclipseNode typeNode) {
- return isClassAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation | Java14Bits.AccRecord);
+ public static TypeReference createTypeReference(String typeName, ASTNode source) {
+ return generateQualifiedTypeRef(source, fromQualifiedName(typeName));
}
- static boolean isClassOrEnum(EclipseNode typeNode) {
- return isClassAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | Java14Bits.AccRecord);
+ /**
+ * Returns {@code true} if the provided node is an actual class and not some other type declaration (so, not an annotation definition, interface, enum, or record).
+ */
+ public static boolean isClass(EclipseNode typeNode) {
+ return isTypeAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccEnum | ClassFileConstants.AccAnnotation | AccRecord);
}
- public static boolean isClassAndDoesNotHaveFlags(EclipseNode typeNode, long flags) {
+ /**
+ * Returns {@code true} if the provided node is an actual class or enum and not some other type declaration (so, not an annotation definition, interface, or record).
+ */
+ public static boolean isClassOrEnum(EclipseNode typeNode) {
+ return isTypeAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | AccRecord);
+ }
+
+ /**
+ * Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
+ */
+ public static boolean isRecord(EclipseNode typeNode) {
TypeDeclaration typeDecl = null;
if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
- return (modifiers & flags) == 0;
+ return (modifiers & AccRecord) != 0;
}
- public static boolean isRecord(EclipseNode typeNode) {
- return typeNode.getKind() == Kind.TYPE && isRecord((TypeDeclaration) typeNode.get());
+ /**
+ * Returns {@code true} If the provided node is a field declaration, and represents a field in a {@code record} declaration.
+ */
+ public static boolean isRecordField(EclipseNode fieldNode) {
+ return fieldNode.getKind() == Kind.FIELD && (((FieldDeclaration) fieldNode.get()).modifiers & AccRecord) != 0;
}
- public static boolean isRecord(TypeDeclaration typeDeclaration) {
- return (typeDeclaration.modifiers & Java14Bits.AccRecord) != 0;
+ /**
+ * Returns {@code true) if the provided node is a type declaration <em>and</em> is <strong>not</strong> of any kind indicated by the flags (the intent is to pass flags usch as `ClassFileConstants.AccEnum`).
+ */
+ static boolean isTypeAndDoesNotHaveFlags(EclipseNode typeNode, long flags) {
+ TypeDeclaration typeDecl = null;
+ if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
+ int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
+ return (modifiers & flags) == 0;
}
- public static boolean isRecordField(EclipseNode fieldNode) {
- return fieldNode.getKind() == Kind.FIELD && (((FieldDeclaration) fieldNode.get()).modifiers & Java14Bits.AccRecord) != 0;
- }
-
public static AbstractVariableDeclaration[] getRecordComponents(TypeDeclaration typeDeclaration) {
- if (!isRecord(typeDeclaration)) return null;
+ if (typeDeclaration == null || (typeDeclaration.modifiers & AccRecord) == 0) return null;
try {
return (AbstractVariableDeclaration[]) TYPE_DECLARATION_RECORD_COMPONENTS.get(typeDeclaration);
} catch (Exception e) {
- // Ignore
+ // This presumably means this isn't a JDK16 - fall through.
}
return null;
}
@@ -2707,11 +2701,154 @@ public class EclipseHandlerUtil {
if (recordComponents != null) {
int j = 0;
for (int i = 0; i < typeDeclaration.fields.length; i++) {
- if ((typeDeclaration.fields[i].modifiers & Java14Bits.AccRecord) != 0) {
+ if ((typeDeclaration.fields[i].modifiers & AccRecord) != 0) {
annotations[i] = recordComponents[j++].annotations;
}
}
}
return annotations;
}
+
+ public static String getDocComment(CompilationUnitDeclaration cud, ASTNode node) {
+ ICompilationUnit compilationUnit = cud.compilationResult.compilationUnit;
+ if (node instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
+ char[] rawContent = CharOperation.subarray(compilationUnit.getContents(), fieldDeclaration.declarationSourceStart, fieldDeclaration.declarationSourceEnd);
+ String rawContentString = new String(rawContent);
+ int startIndex = rawContentString.indexOf("/**");
+ int endIndex = rawContentString.indexOf("*/");
+ if (startIndex != -1 && endIndex != -1) {
+ /* Remove all leading asterisks */
+ return rawContentString.substring(startIndex + 3, endIndex).replaceAll("(?m)^\\s*\\* ?", "").trim();
+ }
+ }
+ return null;
+ }
+
+ public static void setDocComment(CompilationUnitDeclaration cud, EclipseNode eclipseNode, String doc) {
+ setDocComment(cud, (TypeDeclaration) upToTypeNode(eclipseNode).get(), eclipseNode.get(), doc);
+ }
+
+ public static void setDocComment(CompilationUnitDeclaration cud, TypeDeclaration type, ASTNode node, String doc) {
+ if (doc == null) return;
+
+ Map<String, String> docs = EcjAugments.CompilationUnit_javadoc.setIfAbsent(cud.compilationResult.compilationUnit, new HashMap<String, String>());
+ if (node instanceof AbstractMethodDeclaration) {
+ AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
+ String signature = getSignature(type, methodDeclaration);
+ /* Add javadoc start marker, remove trailing line break, add leading asterisks to each line, add javadoc end marker */
+ docs.put(signature, String.format("/**%n%s%n */", doc.replaceAll("$\\r?\\n", "").replaceAll("(?m)^", " * ")));
+ }
+ }
+
+ public static String getSignature(TypeDeclaration type, AbstractMethodDeclaration methodDeclaration) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(type.name);
+ sb.append(".");
+ sb.append(methodDeclaration.selector);
+ sb.append("(");
+ Argument[] arguments = methodDeclaration.arguments;
+ if (arguments != null) {
+ for (Argument argument : arguments) {
+ sb.append(String.valueOf(argument.type));
+ }
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public static enum CopyJavadoc {
+ VERBATIM {
+ @Override public String apply(final CompilationUnitDeclaration cu, final EclipseNode node) {
+ return getDocComment(cu, node.get());
+ }
+ },
+ GETTER {
+ @Override public String apply(final CompilationUnitDeclaration cu, final EclipseNode node) {
+ final ASTNode n = node.get();
+ String javadoc = getDocComment(cu, n);
+ // step 1: Check if there is a 'GETTER' section. If yes, that becomes the new method's javadoc.
+ String out = getJavadocSection(javadoc, "GETTER");
+ final boolean sectionBased = out != null;
+ if (!sectionBased) {
+ out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.PARAM);
+ }
+ return out;
+ }
+ },
+ SETTER {
+ @Override public String apply(final CompilationUnitDeclaration cu, final EclipseNode node) {
+ return applySetter(cu, node, "SETTER");
+ }
+ },
+ WITH {
+ @Override public String apply(final CompilationUnitDeclaration cu, final EclipseNode node) {
+ return addReturnsUpdatedSelfIfNeeded(applySetter(cu, node, "WITH|WITHER"));
+ }
+ },
+ WITH_BY {
+ @Override public String apply(final CompilationUnitDeclaration cu, final EclipseNode node) {
+ return applySetter(cu, node, "WITHBY|WITH_BY");
+ }
+ };
+
+ public abstract String apply(final CompilationUnitDeclaration cu, final EclipseNode node);
+
+ private static String applySetter(final CompilationUnitDeclaration cu, EclipseNode node, String sectionName) {
+ final ASTNode n = node.get();
+ String javadoc = getDocComment(cu, n);
+ // step 1: Check if there is a 'SETTER' section. If yes, that becomes the new method's javadoc.
+ String out = getJavadocSection(javadoc, sectionName);
+ final boolean sectionBased = out != null;
+ if (!sectionBased) {
+ out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.RETURN);
+ }
+ return shouldReturnThis(node) ? addReturnsThisIfNeeded(out) : out;
+ }
+ }
+
+ /**
+ * Copies javadoc on one node to the other.
+ *
+ * This one is a shortcut for {@link EclipseHandlerUtil#copyJavadoc(EclipseNode, ASTNode, TypeDeclaration, CopyJavadoc, boolean)}
+ * if source and target node are in the same type.
+ */
+ public static void copyJavadoc(EclipseNode from, ASTNode to, CopyJavadoc copyMode) {
+ copyJavadoc(from, to, (TypeDeclaration) upToTypeNode(from).get(), copyMode, false);
+ }
+
+ /**
+ * Copies javadoc on one node to the other.
+ *
+ * This one is a shortcut for {@link EclipseHandlerUtil#copyJavadoc(EclipseNode, ASTNode, TypeDeclaration, CopyJavadoc, boolean)}
+ * if source and target node are in the same type.
+ */
+ public static void copyJavadoc(EclipseNode from, ASTNode to, CopyJavadoc copyMode, boolean forceAddReturn) {
+ copyJavadoc(from, to, (TypeDeclaration) upToTypeNode(from).get(), copyMode, forceAddReturn);
+ }
+
+ public static void copyJavadoc(EclipseNode from, ASTNode to, TypeDeclaration type, CopyJavadoc copyMode) {
+ copyJavadoc(from, to, type, copyMode, false);
+ }
+
+ /**
+ * Copies javadoc on one node to the other.
+ *
+ * in 'GETTER' copyMode, first a 'GETTER' segment is searched for. If it exists, that will become the javadoc for the 'to' node, and this section is
+ * stripped out of the 'from' node. If no 'GETTER' segment is found, then the entire javadoc is taken minus any {@code @param} lines and other sections.
+ * any {@code @return} lines are stripped from 'from'.
+ *
+ * in 'SETTER' mode, stripping works similarly to 'GETTER' mode, except {@code param} are copied and stripped from the original and {@code @return} are skipped.
+ */
+ public static void copyJavadoc(EclipseNode from, ASTNode to, TypeDeclaration type, CopyJavadoc copyMode, boolean forceAddReturn) {
+ if (copyMode == null) copyMode = CopyJavadoc.VERBATIM;
+ try {
+ CompilationUnitDeclaration cud = ((CompilationUnitDeclaration) from.top().get());
+ String newJavadoc = copyMode.apply(cud, from);
+ if (forceAddReturn) {
+ newJavadoc = addReturnsThisIfNeeded(newJavadoc);
+ }
+ setDocComment(cud, type, to, newJavadoc);
+ } catch (Exception ignore) {}
+ }
}
diff --git a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
index 85243ec1..d099cab2 100755
--- a/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
+++ b/src/core/lombok/eclipse/handlers/EclipseSingularsRecipes.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -68,6 +68,7 @@ import lombok.core.SpiLoadUtil;
import lombok.core.TypeLibrary;
import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.eclipse.EclipseNode;
+import lombok.eclipse.handlers.HandleBuilder.BuilderJob;
public class EclipseSingularsRecipes {
public interface TypeReferenceMaker {
@@ -258,20 +259,20 @@ 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(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, final EclipseNode builderType, boolean fluent, final boolean chain, AccessLevel access) {
+ public void generateMethods(final BuilderJob job, SingularData data, boolean deprecate) {
TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() {
@Override public TypeReference make() {
- return chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
+ return job.oldChain ? cloneSelfType(job.builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
}
};
StatementMaker returnStatementMaker = new StatementMaker() {
@Override public ReturnStatement make() {
- return chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
+ return job.oldChain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
}
};
- generateMethods(cfv, data, deprecate, builderType, fluent, returnTypeMaker, returnStatementMaker, access);
+ generateMethods(job.checkerFramework, data, deprecate, job.builderType, job.oldFluent, returnTypeMaker, returnStatementMaker, job.accessInners);
}
/**
@@ -450,7 +451,17 @@ public class EclipseSingularsRecipes {
statements.add(0, nullCheck);
}
+ protected abstract int getTypeArgumentsCount();
+
protected abstract char[][] getEmptyMakerReceiver(String targetFqn);
protected abstract char[] getEmptyMakerSelector(String targetFqn);
+
+ public MessageSend getEmptyExpression(String targetFqn, SingularData data, EclipseNode typeNode, ASTNode source) {
+ MessageSend send = new MessageSend();
+ send.receiver = generateQualifiedNameRef(source, getEmptyMakerReceiver(targetFqn));
+ send.selector = getEmptyMakerSelector(targetFqn);
+ send.typeArguments = createTypeArgs(getTypeArgumentsCount(), false, typeNode, data.getTypeArgs());
+ return send;
+ }
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleAccessors.java b/src/core/lombok/eclipse/handlers/HandleAccessors.java
index 864ff50b..6a92dee2 100644
--- a/src/core/lombok/eclipse/handlers/HandleAccessors.java
+++ b/src/core/lombok/eclipse/handlers/HandleAccessors.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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
@@ -28,11 +28,11 @@ import lombok.core.HandlerPriority;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Accessors;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.mangosdk.spi.ProviderFor;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(65536)
public class HandleAccessors extends EclipseAnnotationHandler<Accessors> {
@Override public void handle(AnnotationValues<Accessors> annotation, Annotation ast, EclipseNode annotationNode) {
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 5054703a..c2b73988 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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,11 +21,10 @@
*/
package lombok.eclipse.handlers;
-import static lombok.eclipse.Eclipse.*;
import static lombok.core.handlers.HandlerUtil.*;
+import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -75,7 +74,6 @@ import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.Builder;
@@ -84,27 +82,38 @@ import lombok.ConfigurationKeys;
import lombok.Singular;
import lombok.ToString;
import lombok.core.AST.Kind;
-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.core.handlers.HandlerUtil;
+import lombok.core.handlers.HandlerUtil.FieldAccess;
+import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.eclipse.handlers.EclipseHandlerUtil.CopyJavadoc;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.HandleConstructor.SkipIfConstructorExists;
import lombok.experimental.NonFinal;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes.
public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
private HandleConstructor handleConstructor = new HandleConstructor();
- private static final char[] CLEAN_FIELD_NAME = "$lombokUnclean".toCharArray();
- private static final char[] CLEAN_METHOD_NAME = "$lombokClean".toCharArray();
+ static final char[] CLEAN_FIELD_NAME = "$lombokUnclean".toCharArray();
+ static final char[] CLEAN_METHOD_NAME = "$lombokClean".toCharArray();
+ static final String TO_BUILDER_METHOD_NAME_STRING = "toBuilder";
+ static final char[] TO_BUILDER_METHOD_NAME = TO_BUILDER_METHOD_NAME_STRING.toCharArray();
+ static final char[] DEFAULT_PREFIX = {'$', 'd', 'e', 'f', 'a', 'u', 'l', 't', '$'};
+ static final char[] SET_PREFIX = {'$', 's', 'e', 't'};
+ static final char[] VALUE_PREFIX = {'$', 'v', 'a', 'l', 'u', 'e'};
+ static final char[] BUILDER_TEMP_VAR = {'b', 'u', 'i', 'l', 'd', 'e', 'r'};
+ static final AbstractMethodDeclaration[] EMPTY_METHODS = {};
+ static final String TO_BUILDER_NOT_SUPPORTED = "@Builder(toBuilder=true) is only supported if you return your own type.";
private static final boolean toBoolean(Object expr, boolean defaultValue) {
if (expr == null) return defaultValue;
@@ -113,6 +122,95 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return ((Boolean) expr).booleanValue();
}
+ static class BuilderJob {
+ CheckerFrameworkVersion checkerFramework;
+ EclipseNode parentType;
+ String builderMethodName, buildMethodName;
+ boolean isStatic;
+ TypeParameter[] typeParams;
+ TypeParameter[] builderTypeParams;
+ ASTNode source;
+ EclipseNode sourceNode;
+ List<BuilderFieldData> builderFields;
+ AccessLevel accessInners, accessOuters;
+ boolean oldFluent, oldChain, toBuilder;
+
+ EclipseNode builderType;
+ String builderClassName;
+ char[] builderClassNameArr;
+
+ void setBuilderClassName(String builderClassName) {
+ this.builderClassName = builderClassName;
+ this.builderClassNameArr = builderClassName.toCharArray();
+ }
+
+ TypeParameter[] copyTypeParams() {
+ return EclipseHandlerUtil.copyTypeParams(typeParams, source);
+ }
+
+ long getPos() {
+ return ((long) source.sourceStart) << 32 | source.sourceEnd;
+ }
+
+ public TypeReference createBuilderTypeReference() {
+ return namePlusTypeParamsToTypeReference(parentType, builderClassNameArr, !isStatic, builderTypeParams, getPos());
+ }
+
+ public TypeReference createBuilderTypeReferenceForceStatic() {
+ return namePlusTypeParamsToTypeReference(parentType, builderClassNameArr, false, builderTypeParams, getPos());
+ }
+
+ public TypeReference createBuilderParentTypeReference() {
+ return namePlusTypeParamsToTypeReference(parentType, typeParams, getPos());
+ }
+
+ public EclipseNode getTopNode() {
+ return parentType.top();
+ }
+
+ void init(AnnotationValues<Builder> annValues, Builder ann, EclipseNode node) {
+ accessOuters = ann.access();
+ if (accessOuters == null) accessOuters = AccessLevel.PUBLIC;
+ if (accessOuters == AccessLevel.NONE) {
+ sourceNode.addError("AccessLevel.NONE is not valid here");
+ accessOuters = AccessLevel.PUBLIC;
+ }
+ accessInners = accessOuters == AccessLevel.PROTECTED ? AccessLevel.PUBLIC : accessOuters;
+
+ // These exist just to support the 'old' lombok.experimental.Builder, which had these properties. lombok.Builder no longer has them.
+ oldFluent = toBoolean(annValues.getActualExpression("fluent"), true);
+ oldChain = toBoolean(annValues.getActualExpression("chain"), true);
+
+ builderMethodName = ann.builderMethodName();
+ buildMethodName = ann.buildMethodName();
+ setBuilderClassName(fixBuilderClassName(node, ann.builderClassName()));
+ toBuilder = ann.toBuilder();
+
+ if (builderMethodName == null) builderMethodName = "builder";
+ if (buildMethodName == null) buildMethodName = "build";
+ }
+
+ static String fixBuilderClassName(EclipseNode node, String override) {
+ if (override != null && !override.isEmpty()) return override;
+ override = node.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
+ if (override != null && !override.isEmpty()) return override;
+ return "*Builder";
+ }
+
+ MethodDeclaration createNewMethodDeclaration() {
+ return new MethodDeclaration(((CompilationUnitDeclaration) getTopNode().get()).compilationResult);
+ }
+
+ String replaceBuilderClassName(char[] name) {
+ if (builderClassName.indexOf('*') == -1) return builderClassName;
+ return builderClassName.replace("*", new String(name));
+ }
+
+ String replaceBuilderClassName(String name) {
+ return builderClassName.replace("*", name);
+ }
+ }
+
static class BuilderFieldData {
Annotation[] annotations;
TypeReference type;
@@ -147,10 +245,6 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return true;
}
- private static final char[] DEFAULT_PREFIX = {'$', 'd', 'e', 'f', 'a', 'u', 'l', 't', '$'};
- private static final char[] SET_PREFIX = {'$', 's', 'e', 't'};
- private static final char[] VALUE_PREFIX = {'$', 'v', 'a', 'l', 'u', 'e'};
-
private static final char[] prefixWith(char[] prefix, char[] name) {
char[] out = new char[prefix.length + name.length];
System.arraycopy(prefix, 0, out, 0, prefix.length);
@@ -159,88 +253,65 @@ 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;
+ final String BUILDER_NODE_NOT_SUPPORTED_ERR = "@Builder is only supported on classes, records, constructors, and methods.";
- Builder builderInstance = annotation.getInstance();
- AccessLevel accessForOuters = builderInstance.access();
- if (accessForOuters == null) accessForOuters = AccessLevel.PUBLIC;
- if (builderInstance.access() == AccessLevel.NONE) {
- annotationNode.addError("AccessLevel.NONE is not valid here");
- accessForOuters = AccessLevel.PUBLIC;
- }
- AccessLevel accessForInners = accessForOuters == AccessLevel.PROTECTED ? AccessLevel.PUBLIC : accessForOuters;
-
- // These exist just to support the 'old' lombok.experimental.Builder, which had these properties. lombok.Builder no longer has them.
- boolean fluent = toBoolean(annotation.getActualExpression("fluent"), true);
- boolean chain = toBoolean(annotation.getActualExpression("chain"), true);
+ handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder");
+ BuilderJob job = new BuilderJob();
+ job.sourceNode = annotationNode;
+ job.source = ast;
+ job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
+ job.isStatic = true;
- String builderMethodName = builderInstance.builderMethodName();
- String buildMethodName = builderInstance.buildMethodName();
- String builderClassName = builderInstance.builderClassName();
- String toBuilderMethodName = "toBuilder";
- boolean toBuilder = builderInstance.toBuilder();
+ Builder annInstance = annotation.getInstance();
+ job.init(annotation, annInstance, annotationNode);
List<char[]> typeArgsForToBuilder = null;
- if (builderMethodName == null) builderMethodName = "builder";
- if (buildMethodName == null) buildMethodName = "build";
- if (builderClassName == null) builderClassName = "";
-
boolean generateBuilderMethod;
- if (builderMethodName.isEmpty()) {
+ if (job.builderMethodName.isEmpty()) {
generateBuilderMethod = false;
- } else if (!checkName("builderMethodName", builderMethodName, annotationNode)) {
+ } else if (!checkName("builderMethodName", job.builderMethodName, annotationNode)) {
return;
} else {
generateBuilderMethod = true;
}
- if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
- if (!builderClassName.isEmpty()) {
- if (!checkName("builderClassName", builderClassName, annotationNode)) return;
- }
+ if (!checkName("buildMethodName", job.buildMethodName, annotationNode)) return;
EclipseNode parent = annotationNode.up();
- List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
- TypeReference returnType;
- TypeParameter[] typeParams;
- TypeReference[] thrownExceptions;
- char[] nameOfStaticBuilderMethod;
- EclipseNode tdParent;
+ job.builderFields = new ArrayList<BuilderFieldData>();
+ TypeReference buildMethodReturnType;
+ TypeReference[] buildMethodThrownExceptions;
+ char[] nameOfBuilderMethod;
EclipseNode fillParametersFrom = parent.get() instanceof AbstractMethodDeclaration ? parent : null;
boolean addCleaning = false;
- boolean isStatic = true;
List<EclipseNode> nonFinalNonDefaultedFields = null;
- if (builderClassName.isEmpty()) builderClassName = annotationNode.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
- if (builderClassName == null || builderClassName.isEmpty()) builderClassName = "*Builder";
- boolean replaceNameInBuilderClassName = builderClassName.contains("*");
-
if (parent.get() instanceof TypeDeclaration) {
- tdParent = parent;
- TypeDeclaration td = (TypeDeclaration) tdParent.get();
+ if (!isClass(parent) && !isRecord(parent)) {
+ annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
+ return;
+ }
+
+ job.parentType = parent;
+ TypeDeclaration td = (TypeDeclaration) parent.get();
List<EclipseNode> allFields = new ArrayList<EclipseNode>();
boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent));
- for (EclipseNode fieldNode : HandleConstructor.findAllFields(tdParent, true)) {
+ for (EclipseNode fieldNode : HandleConstructor.findAllFields(parent, true)) {
FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode);
boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
- Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
-
BuilderFieldData bfd = new BuilderFieldData();
bfd.rawName = fieldNode.getName().toCharArray();
bfd.name = removePrefixFromField(fieldNode);
bfd.builderFieldName = bfd.name;
- bfd.annotations = copyAnnotations(fd, copyableAnnotations);
+ bfd.annotations = copyAnnotations(fd, findCopyableAnnotations(fieldNode));
bfd.type = fd.type;
- bfd.singularData = getSingularData(fieldNode, ast, builderInstance.setterPrefix());
+ bfd.singularData = getSingularData(fieldNode, ast, annInstance.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -265,24 +336,26 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
bfd.builderFieldName = prefixWith(bfd.name, VALUE_PREFIX);
MethodDeclaration md = generateDefaultProvider(bfd.nameOfDefaultProvider, td.typeParameters, fieldNode, ast);
- if (md != null) injectMethod(tdParent, md);
+ if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
- builderFields.add(bfd);
+ job.builderFields.add(bfd);
allFields.add(fieldNode);
}
- if (!isRecord(tdParent)) {
- handleConstructor.generateConstructor(tdParent, AccessLevel.PACKAGE, allFields, false, null, SkipIfConstructorExists.I_AM_BUILDER,
+ if (!isRecord(parent)) {
+ // Records ship with a canonical constructor that acts as @AllArgsConstructor - just use that one.
+
+ handleConstructor.generateConstructor(parent, AccessLevel.PACKAGE, allFields, false, null, SkipIfConstructorExists.I_AM_BUILDER,
Collections.<Annotation>emptyList(), annotationNode);
}
- returnType = namePlusTypeParamsToTypeReference(tdParent, td.typeParameters, p);
- typeParams = td.typeParameters;
- thrownExceptions = null;
- nameOfStaticBuilderMethod = null;
- if (replaceNameInBuilderClassName) builderClassName = builderClassName.replace("*", new String(td.name));
- replaceNameInBuilderClassName = false;
+ job.typeParams = job.builderTypeParams = td.typeParameters;
+ buildMethodReturnType = job.createBuilderParentTypeReference();
+ buildMethodThrownExceptions = null;
+ nameOfBuilderMethod = null;
+ job.setBuilderClassName(job.replaceBuilderClassName(td.name));
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
} else if (parent.get() instanceof ConstructorDeclaration) {
ConstructorDeclaration cd = (ConstructorDeclaration) parent.get();
if (cd.typeParameters != null && cd.typeParameters.length > 0) {
@@ -290,21 +363,20 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return;
}
- tdParent = parent.up();
- TypeDeclaration td = (TypeDeclaration) tdParent.get();
- returnType = namePlusTypeParamsToTypeReference(tdParent, td.typeParameters, p);
- typeParams = td.typeParameters;
- thrownExceptions = cd.thrownExceptions;
- nameOfStaticBuilderMethod = null;
- if (replaceNameInBuilderClassName) builderClassName = builderClassName.replace("*", new String(cd.selector));
- replaceNameInBuilderClassName = false;
+ job.parentType = parent.up();
+ TypeDeclaration td = (TypeDeclaration) job.parentType.get();
+ job.typeParams = job.builderTypeParams = td.typeParameters;
+ buildMethodReturnType = job.createBuilderParentTypeReference();
+ buildMethodThrownExceptions = cd.thrownExceptions;
+ nameOfBuilderMethod = null;
+ job.setBuilderClassName(job.replaceBuilderClassName(cd.selector));
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
} else if (parent.get() instanceof MethodDeclaration) {
MethodDeclaration md = (MethodDeclaration) parent.get();
- tdParent = parent.up();
- isStatic = md.isStatic();
+ job.parentType = parent.up();
+ job.isStatic = md.isStatic();
- if (toBuilder) {
- final String TO_BUILDER_NOT_SUPPORTED = "@Builder(toBuilder=true) is only supported if you return your own type.";
+ if (job.toBuilder) {
char[] token;
char[][] pkg = null;
if (md.returnType.dimensions() > 0) {
@@ -330,12 +402,12 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return;
}
- if (tdParent == null || !equals(tdParent.getName(), token)) {
+ if (job.parentType == null || !equals(job.parentType.getName(), token)) {
annotationNode.addError(TO_BUILDER_NOT_SUPPORTED);
return;
}
- TypeParameter[] tpOnType = ((TypeDeclaration) tdParent.get()).typeParameters;
+ TypeParameter[] tpOnType = ((TypeDeclaration) job.parentType.get()).typeParameters;
TypeParameter[] tpOnMethod = md.typeParameters;
TypeReference[][] tpOnRet_ = null;
if (md.returnType instanceof ParameterizedSingleTypeReference) {
@@ -374,18 +446,18 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
}
- returnType = copyType(md.returnType, ast);
- typeParams = md.typeParameters;
- thrownExceptions = md.thrownExceptions;
- nameOfStaticBuilderMethod = md.selector;
- if (replaceNameInBuilderClassName) {
- char[] token = returnTypeToBuilderClassName(annotationNode, md, typeParams);
- if (token == null)
- return;
- builderClassName = builderClassName.replace("*", new String(token));
+ job.typeParams = job.builderTypeParams = md.typeParameters;
+ buildMethodReturnType = copyType(md.returnType, ast);
+ buildMethodThrownExceptions = md.thrownExceptions;
+ nameOfBuilderMethod = md.selector;
+ if (job.builderClassName.indexOf('*') > -1) {
+ char[] token = returnTypeToBuilderClassName(annotationNode, md, job.typeParams);
+ if (token == null) return; // should not happen.
+ job.setBuilderClassName(job.replaceBuilderClassName(token));
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
}
} else {
- annotationNode.addError("@Builder is only supported on types, constructors, and methods.");
+ annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -402,40 +474,39 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = copyAnnotations(arg, copyableAnnotations);
bfd.type = arg.type;
- bfd.singularData = getSingularData(param, ast, builderInstance.setterPrefix());
+ bfd.singularData = getSingularData(param, ast, annInstance.setterPrefix());
bfd.originalFieldNode = param;
addObtainVia(bfd, param);
- builderFields.add(bfd);
+ job.builderFields.add(bfd);
}
}
- EclipseNode builderType = findInnerClass(tdParent, builderClassName);
- if (builderType == null) {
- builderType = makeBuilderClass(isStatic, tdParent, builderClassName, typeParams, ast, accessForOuters);
- } else {
- TypeDeclaration builderTypeDeclaration = (TypeDeclaration) builderType.get();
- if (isStatic && (builderTypeDeclaration.modifiers & ClassFileConstants.AccStatic) == 0) {
+ job.builderType = findInnerClass(job.parentType, job.builderClassName);
+ if (job.builderType == null) makeBuilderClass(job);
+ else {
+ TypeDeclaration builderTypeDeclaration = (TypeDeclaration) job.builderType.get();
+ if (job.isStatic && (builderTypeDeclaration.modifiers & ClassFileConstants.AccStatic) == 0) {
annotationNode.addError("Existing Builder must be a static inner class.");
return;
- } else if (!isStatic && (builderTypeDeclaration.modifiers & ClassFileConstants.AccStatic) != 0) {
+ } else if (!job.isStatic && (builderTypeDeclaration.modifiers & ClassFileConstants.AccStatic) != 0) {
annotationNode.addError("Existing Builder must be a non-static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderType, annotationNode);
/* generate errors for @Singular BFDs that have one already defined node. */ {
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
SingularData sd = bfd.singularData;
if (sd == null) continue;
EclipseSingularizer singularizer = sd.getSingularizer();
if (singularizer == null) continue;
- if (singularizer.checkForAlreadyExistingNodesAndGenerateError(builderType, sd)) {
+ if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderType, sd)) {
bfd.singularData = null;
}
}
}
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
if (bfd.singularData.getSingularizer().requiresCleaning()) {
addCleaning = true;
@@ -454,64 +525,64 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
}
- generateBuilderFields(builderType, builderFields, ast);
+ generateBuilderFields(job);
if (addCleaning) {
FieldDeclaration cleanDecl = new FieldDeclaration(CLEAN_FIELD_NAME, 0, -1);
cleanDecl.declarationSourceEnd = -1;
cleanDecl.modifiers = ClassFileConstants.AccPrivate;
cleanDecl.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
cleanDecl.traverse(new SetGeneratedByVisitor(ast), (MethodScope) null);
- injectFieldAndMarkGenerated(builderType, cleanDecl);
+ injectFieldAndMarkGenerated(job.builderType, cleanDecl);
}
- if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) {
+ if (constructorExists(job.builderType) == MemberExistsResult.NOT_EXISTS) {
ConstructorDeclaration cd = HandleConstructor.createConstructor(
- AccessLevel.PACKAGE, builderType, Collections.<EclipseNode>emptyList(), false,
+ AccessLevel.PACKAGE, job.builderType, Collections.<EclipseNode>emptyList(), false,
annotationNode, Collections.<Annotation>emptyList());
- if (cd != null) injectMethod(builderType, cd);
+ if (cd != null) injectMethod(job.builderType, cd);
}
- for (BuilderFieldData bfd : builderFields) {
- makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, bfd.originalFieldNode, builderInstance.setterPrefix());
+ for (BuilderFieldData bfd : job.builderFields) {
+ makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix());
}
{
- MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1);
- if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0);
+ MemberExistsResult methodExists = methodExists(job.buildMethodName, job.builderType, -1);
+ if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(job.buildMethodName, job.builderType, 0);
if (methodExists == MemberExistsResult.NOT_EXISTS) {
- MethodDeclaration md = generateBuildMethod(cfv, tdParent, isStatic, buildMethodName, nameOfStaticBuilderMethod, returnType, builderFields, builderType, thrownExceptions, addCleaning, ast, accessForInners);
- if (md != null) injectMethod(builderType, md);
+ MethodDeclaration md = generateBuildMethod(job, nameOfBuilderMethod, buildMethodReturnType, buildMethodThrownExceptions, addCleaning);
+ if (md != null) injectMethod(job.builderType, md);
}
}
- if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) {
+ if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) {
List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
for (EclipseNode f : bfd.createdFields) {
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true, false));
}
}
- MethodDeclaration md = HandleToString.createToString(builderType, fieldNodes, true, false, ast, FieldAccess.ALWAYS_FIELD);
- if (md != null) injectMethod(builderType, md);
+ MethodDeclaration md = HandleToString.createToString(job.builderType, fieldNodes, true, false, ast, FieldAccess.ALWAYS_FIELD);
+ if (md != null) injectMethod(job.builderType, md);
}
if (addCleaning) {
- MethodDeclaration cleanMethod = generateCleanMethod(builderFields, builderType, ast);
- if (cleanMethod != null) injectMethod(builderType, cleanMethod);
+ MethodDeclaration cleanMethod = generateCleanMethod(job);
+ if (cleanMethod != null) injectMethod(job.builderType, cleanMethod);
}
- if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
+ if (generateBuilderMethod && methodExists(job.builderMethodName, job.parentType, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- MethodDeclaration md = generateBuilderMethod(cfv, isStatic, builderMethodName, builderClassName, tdParent, typeParams, ast, accessForOuters);
- if (md != null) injectMethod(tdParent, md);
+ MethodDeclaration md = generateBuilderMethod(job);
+ if (md != null) injectMethod(job.parentType, md);
}
- if (toBuilder) switch (methodExists(toBuilderMethodName, tdParent, 0)) {
+ if (job.toBuilder) switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, job.parentType, 0)) {
case EXISTS_BY_USER:
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
break;
case NOT_EXISTS:
- TypeParameter[] tps = typeParams;
+ TypeParameter[] tps = job.typeParams;
if (typeArgsForToBuilder != null) {
tps = new TypeParameter[typeArgsForToBuilder.size()];
for (int i = 0; i < tps.length; i++) {
@@ -519,9 +590,9 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
tps[i].name = typeArgsForToBuilder.get(i);
}
}
- MethodDeclaration md = generateToBuilderMethod(cfv, isStatic, toBuilderMethodName, builderClassName, tdParent, tps, builderFields, fluent, ast, accessForOuters, builderInstance.setterPrefix());
+ MethodDeclaration md = generateToBuilderMethod(job, tps, annInstance.setterPrefix());
- if (md != null) injectMethod(tdParent, md);
+ if (md != null) injectMethod(job.parentType, md);
}
if (nonFinalNonDefaultedFields != null && generateBuilderMethod) {
@@ -530,7 +601,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
}
}
-
+
static char[] returnTypeToBuilderClassName(EclipseNode annotationNode, MethodDeclaration md, TypeParameter[] typeParams) {
char[] token;
if (md.returnType instanceof QualifiedTypeReference) {
@@ -560,26 +631,31 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return token;
}
- private static final char[] BUILDER_TEMP_VAR = {'b', 'u', 'i', 'l', 'd', 'e', 'r'};
- private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, boolean isStatic, String methodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, List<BuilderFieldData> builderFields, boolean fluent, ASTNode source, AccessLevel access, String prefix) {
- int pS = source.sourceStart, pE = source.sourceEnd;
- long p = (long) pS << 32 | pE;
+ private MethodDeclaration generateToBuilderMethod(BuilderJob job, TypeParameter[] typeParameters, String prefix) {
+ int pS = job.source.sourceStart, pE = job.source.sourceEnd;
+ long p = job.getPos();
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
- out.selector = methodName.toCharArray();
- out.modifiers = toEclipseModifier(access);
+ MethodDeclaration out = job.createNewMethodDeclaration();
+ out.selector = TO_BUILDER_METHOD_NAME;
+ out.modifiers = toEclipseModifier(job.accessOuters);
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
- out.returnType = namePlusTypeParamsToTypeReference(type, builderClassName.toCharArray(), !isStatic, typeParams, p);
+
+ out.returnType = job.createBuilderTypeReference();
+ if (job.checkerFramework.generateUnique()) {
+ int len = out.returnType.getTypeName().length;
+ out.returnType.annotations = new Annotation[len][];
+ out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
AllocationExpression invoke = new AllocationExpression();
- invoke.type = namePlusTypeParamsToTypeReference(type, builderClassName.toCharArray(), !isStatic, typeParams, p);
+ invoke.type = job.createBuilderTypeReference();
Expression receiver = invoke;
List<Statement> preStatements = null;
List<Statement> postStatements = null;
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
String setterName = new String(bfd.name);
- String setterPrefix = !prefix.isEmpty() ? prefix : fluent ? "" : "set";
+ String setterPrefix = !prefix.isEmpty() ? prefix : job.oldFluent ? "" : "set";
if (!setterPrefix.isEmpty()) setterName = HandlerUtil.buildAccessorName(setterPrefix, setterName);
MessageSend ms = new MessageSend();
@@ -597,13 +673,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
boolean obtainIsStatic = bfd.obtainVia.isStatic();
MessageSend obtainExpr = new MessageSend();
if (obtainIsStatic) {
- if (typeParams != null && typeParams.length > 0) {
- obtainExpr.typeArguments = new TypeReference[typeParams.length];
- for (int j = 0; j<typeParams.length; j++) {
- obtainExpr.typeArguments[j] = new SingleTypeReference(typeParams[j].name, 0);
+ if (typeParameters != null && typeParameters.length > 0) {
+ obtainExpr.typeArguments = new TypeReference[typeParameters.length];
+ for (int j = 0; j < typeParameters.length; j++) {
+ obtainExpr.typeArguments[j] = new SingleTypeReference(typeParameters[j].name, 0);
}
}
- obtainExpr.receiver = generateNameReference(type, 0);
+ obtainExpr.receiver = generateNameReference(job.parentType, 0);
} else {
obtainExpr.receiver = new ThisReference(0, 0);
}
@@ -616,7 +692,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
// for ecj so we match what javac's handler does.
LocalDeclaration ld = new LocalDeclaration(bfd.name, 0, 0);
ld.modifiers = ClassFileConstants.AccFinal;
- ld.type = EclipseHandlerUtil.copyType(bfd.type, source);
+ ld.type = EclipseHandlerUtil.copyType(bfd.type, job.source);
ld.initialization = obtainExpr;
if (preStatements == null) preStatements = new ArrayList<Statement>();
preStatements.add(ld);
@@ -645,7 +721,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
LocalDeclaration b = new LocalDeclaration(BUILDER_TEMP_VAR, pS, pE);
out.statements[preSs] = b;
b.modifiers |= ClassFileConstants.AccFinal;
- b.type = namePlusTypeParamsToTypeReference(type, builderClassName.toCharArray(), !isStatic, typeParams, p);
+ b.type = job.createBuilderTypeReference();
b.type.sourceStart = pS; b.type.sourceEnd = pE;
b.initialization = receiver;
out.statements[preSs + postSs + 1] = new ReturnStatement(new SingleNameReference(BUILDER_TEMP_VAR, p), pS, pE);
@@ -655,69 +731,81 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
out.statements[preSs] = new ReturnStatement(receiver, pS, pE);
}
- if (cfv.generateUnique()) {
- out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
- }
-
- createRelevantNonNullAnnotation(type, out);
- out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
+ createRelevantNonNullAnnotation(job.parentType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.parentType.get()).scope);
return out;
}
- private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
+ private MethodDeclaration generateCleanMethod(BuilderJob job) {
List<Statement> statements = new ArrayList<Statement>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
+ bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, statements);
}
}
FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
thisUnclean.receiver = new ThisReference(0, 0);
statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
- MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
+ MethodDeclaration decl = job.createNewMethodDeclaration();
decl.selector = CLEAN_METHOD_NAME;
decl.modifiers = ClassFileConstants.AccPrivate;
decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
decl.statements = statements.toArray(new Statement[0]);
- decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ decl.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return decl;
}
- static Receiver generateBuildReceiver(CheckerFrameworkVersion cfv, EclipseNode type, List<BuilderFieldData> builderFields, ASTNode source) {
- if (!cfv.generateCalledMethods()) return null;
+ static Receiver generateNotCalledReceiver(BuilderJob job, String setterName) {
+ char[][] nameNotCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__NOT_CALLED);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameNotCalled, poss(job.source, nameNotCalled.length)), job.source.sourceStart);
+ ann.memberValue = new StringLiteral(setterName.toCharArray(), 0, 0, 0);
+
+ TypeReference typeReference = job.createBuilderTypeReference();
+ int trLen = typeReference.getTypeName().length;
+ typeReference.annotations = new Annotation[trLen][];
+ typeReference.annotations[trLen - 1] = new Annotation[] {ann};
+ return new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, 0);
+ }
+
+ static Receiver generateBuildReceiver(BuilderJob job) {
+ if (!job.checkerFramework.generateCalledMethods()) return null;
List<char[]> mandatories = new ArrayList<char[]>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData == null && bfd.nameOfSetFlag == null) mandatories.add(bfd.name);
}
if (mandatories.size() == 0) return null;
+
+ int pS = job.source.sourceStart, pE = job.source.sourceEnd;
+
char[][] nameCalled = fromQualifiedName(CheckerFrameworkVersion.NAME__CALLED);
- SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameCalled, poss(source, nameCalled.length)), source.sourceStart);
+ SingleMemberAnnotation ann = new SingleMemberAnnotation(new QualifiedTypeReference(nameCalled, poss(job.source, nameCalled.length)), pS);
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.sourceStart = pS;
+ arr.sourceEnd = pE;
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);
+ arr.expressions[i] = new StringLiteral(mandatories.get(i), pS, pE, 0);
}
ann.memberValue = arr;
}
-
- QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(type, source.sourceStart);
- typeReference.annotations = new Annotation[typeReference.tokens.length][];
- typeReference.annotations[0] = new Annotation[] {ann};
- return new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
+
+ TypeReference typeReference = job.createBuilderTypeReference();
+ int len = typeReference.getTypeName().length;
+ typeReference.annotations = new Annotation[len][];
+ typeReference.annotations[len - 1] = new Annotation[] {ann};
+ return new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, 0);
}
- 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);
+ public MethodDeclaration generateBuildMethod(BuilderJob job, char[] staticName, TypeReference returnType, TypeReference[] thrownExceptions, boolean addCleaning) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
List<Statement> statements = new ArrayList<Statement>();
@@ -730,14 +818,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
statements.add(new IfStatement(notClean, invokeClean, 0, 0));
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, type, statements, bfd.builderFieldName, "this");
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, job.builderType, statements, bfd.builderFieldName, "this");
}
}
List<Expression> args = new ArrayList<Expression>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.nameOfSetFlag != null) {
LocalDeclaration ld = new LocalDeclaration(bfd.builderFieldName, 0, 0);
ld.type = copyType(bfd.type);
@@ -747,11 +835,11 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
statements.add(ld);
MessageSend inv = new MessageSend();
- inv.sourceStart = source.sourceStart;
- inv.sourceEnd = source.sourceEnd;
- inv.receiver = new SingleNameReference(((TypeDeclaration) tdParent.get()).name, 0L);
+ inv.sourceStart = job.source.sourceStart;
+ inv.sourceEnd = job.source.sourceEnd;
+ inv.receiver = new SingleNameReference(((TypeDeclaration) job.parentType.get()).name, 0L);
inv.selector = bfd.nameOfDefaultProvider;
- inv.typeArguments = typeParameterNames(((TypeDeclaration) type.get()).typeParameters);
+ inv.typeArguments = typeParameterNames(((TypeDeclaration) job.builderType.get()).typeParameters);
Assignment defaultAssign = new Assignment(new SingleNameReference(bfd.builderFieldName, 0L), inv, 0);
FieldReference thisSet = new FieldReference(bfd.nameOfSetFlag, 0L);
@@ -775,8 +863,8 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
statements.add(new Assignment(thisUnclean, new TrueLiteral(0, 0), 0));
}
- out.modifiers = toEclipseModifier(access);
- out.selector = name.toCharArray();
+ out.modifiers = toEclipseModifier(job.accessInners);
+ out.selector = job.buildMethodName.toCharArray();
out.thrownExceptions = copyTypes(thrownExceptions);
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.returnType = returnType;
@@ -789,13 +877,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
} else {
MessageSend invoke = new MessageSend();
invoke.selector = staticName;
- if (isStatic) {
- invoke.receiver = new SingleNameReference(type.up().getName().toCharArray(), 0);
+ if (job.isStatic) {
+ invoke.receiver = new SingleNameReference(job.builderType.up().getName().toCharArray(), 0);
} else {
- invoke.receiver = new QualifiedThisReference(generateTypeReference(type.up(), 0) , 0, 0);
+ invoke.receiver = new QualifiedThisReference(generateTypeReference(job.builderType.up(), 0) , 0, 0);
}
- invoke.typeArguments = typeParameterNames(((TypeDeclaration) type.get()).typeParameters);
+ invoke.typeArguments = typeParameterNames(((TypeDeclaration) job.builderType.get()).typeParameters);
invoke.arguments = args.isEmpty() ? null : args.toArray(new Expression[0]);
if (returnType instanceof SingleTypeReference && Arrays.equals(TypeConstants.VOID, ((SingleTypeReference) returnType).token)) {
statements.add(invoke);
@@ -804,12 +892,12 @@ 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)};
+ if (job.checkerFramework.generateSideEffectFree()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
}
- out.receiver = generateBuildReceiver(cfv, type, builderFields, source);
- if (staticName == null) createRelevantNonNullAnnotation(type, out);
- out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ out.receiver = generateBuildReceiver(job);
+ if (staticName == null) createRelevantNonNullAnnotation(job.builderType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return out;
}
@@ -840,57 +928,55 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
return out;
}
- 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;
- char[] builderClassName_ = builderClassName.toCharArray();
+ public MethodDeclaration generateBuilderMethod(BuilderJob job) {
+ int pS = job.source.sourceStart, pE = job.source.sourceEnd;
+ long p = job.getPos();
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
- out.selector = builderMethodName.toCharArray();
- out.modifiers = toEclipseModifier(access);
- if (isStatic) out.modifiers |= ClassFileConstants.AccStatic;
+ MethodDeclaration out = job.createNewMethodDeclaration();
+ out.selector = job.builderMethodName.toCharArray();
+ out.modifiers = toEclipseModifier(job.accessOuters);
+ if (job.isStatic) out.modifiers |= ClassFileConstants.AccStatic;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
- out.returnType = namePlusTypeParamsToTypeReference(type, builderClassName_, !isStatic, typeParams, p);
- out.typeParameters = copyTypeParams(typeParams, source);
+ out.returnType = job.createBuilderTypeReference();
+ if (job.checkerFramework.generateUnique()) {
+ int len = out.returnType.getTypeName().length;
+ out.returnType.annotations = new Annotation[len][];
+ out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
+ out.typeParameters = job.copyTypeParams();
AllocationExpression invoke = new AllocationExpression();
- if (isStatic) {
- invoke.type = namePlusTypeParamsToTypeReference(type, builderClassName_, false, typeParams, p);
+ if (job.isStatic) {
+ invoke.type = job.createBuilderTypeReferenceForceStatic();
out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
} else {
// return this.new Builder();
QualifiedAllocationExpression qualifiedInvoke = new QualifiedAllocationExpression();
qualifiedInvoke.enclosingInstance = new ThisReference(pS, pE);
- if (typeParams == null || typeParams.length == 0) {
- qualifiedInvoke.type = new SingleTypeReference(builderClassName_, p);
+ if (job.typeParams == null || job.typeParams.length == 0) {
+ qualifiedInvoke.type = new SingleTypeReference(job.builderClassNameArr, p);
} else {
- qualifiedInvoke.type = namePlusTypeParamsToTypeReference(null, builderClassName_, false, typeParams, p);
+ qualifiedInvoke.type = namePlusTypeParamsToTypeReference(null, job.builderClassNameArr, false, job.typeParams, p);
}
out.statements = new Statement[] {new ReturnStatement(qualifiedInvoke, 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};
+ if (job.checkerFramework.generateSideEffectFree()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
}
- createRelevantNonNullAnnotation(type, out);
- out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
+ createRelevantNonNullAnnotation(job.builderType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.builderType.get()).scope);
return out;
}
- public void generateBuilderFields(EclipseNode builderType, List<BuilderFieldData> builderFields, ASTNode source) {
+ public void generateBuilderFields(BuilderJob job) {
List<EclipseNode> existing = new ArrayList<EclipseNode>();
- for (EclipseNode child : builderType.down()) {
+ for (EclipseNode child : job.builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType));
+ bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType));
} else {
EclipseNode field = null, setFlag = null;
for (EclipseNode exists : existing) {
@@ -904,45 +990,43 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
- fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
- field = injectFieldAndMarkGenerated(builderType, fd);
+ fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null);
+ field = injectFieldAndMarkGenerated(job.builderType, fd);
}
if (setFlag == null && bfd.nameOfSetFlag != null) {
FieldDeclaration fd = new FieldDeclaration(bfd.nameOfSetFlag, 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
- fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
- injectFieldAndMarkGenerated(builderType, fd);
+ fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null);
+ injectFieldAndMarkGenerated(job.builderType, fd);
}
bfd.createdFields.add(field);
}
}
}
- private static final AbstractMethodDeclaration[] EMPTY = {};
-
- public void makePrefixedSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain, AccessLevel access, EclipseNode originalFieldNode, String prefix) {
+ public void makePrefixedSetterMethodsForBuilder(BuilderJob job, BuilderFieldData bfd, String prefix) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- makePrefixedSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations, access, originalFieldNode, prefix);
+ makePrefixedSetterMethodForBuilder(job, bfd, deprecate, prefix);
} else {
- bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, fluent, chain, access);
+ bfd.singularData.getSingularizer().generateMethods(job, bfd.singularData, deprecate);
}
}
- 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();
+ private void makePrefixedSetterMethodForBuilder(BuilderJob job, BuilderFieldData bfd, boolean deprecate, String prefix) {
+ TypeDeclaration td = (TypeDeclaration) job.builderType.get();
+ EclipseNode fieldNode = bfd.createdFields.get(0);
AbstractMethodDeclaration[] existing = td.methods;
- if (existing == null) existing = EMPTY;
+ if (existing == null) existing = EMPTY_METHODS;
int len = existing.length;
-
String setterPrefix = prefix.isEmpty() ? "set" : prefix;
String setterName;
- if(fluent) {
- setterName = prefix.isEmpty() ? new String(paramName) : HandlerUtil.buildAccessorName(setterPrefix, new String(paramName));
+ if (job.oldFluent) {
+ setterName = prefix.isEmpty() ? new String(bfd.name) : HandlerUtil.buildAccessorName(setterPrefix, new String(bfd.name));
} else {
- setterName = HandlerUtil.buildAccessorName(setterPrefix, new String(paramName));
+ setterName = HandlerUtil.buildAccessorName(setterPrefix, new String(bfd.name));
}
for (int i = 0; i < len; i++) {
@@ -952,34 +1036,39 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
List<Annotation> methodAnnsList = Collections.<Annotation>emptyList();
- Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode);
+ Annotation[] methodAnns = EclipseHandlerUtil.findCopyableToSetterAnnotations(bfd.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(source, annotations)) : Collections.<Annotation>emptyList());
- if (cfv.generateCalledMethods()) {
- 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);
-
- QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(builderType, 0);
- typeReference.annotations = new Annotation[typeReference.tokens.length][];
- typeReference.annotations[0] = new Annotation[] {ann};
- setter.receiver = new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
+ ASTNode source = job.sourceNode.get();
+ MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, toEclipseModifier(job.accessInners),
+ job.sourceNode, methodAnnsList, bfd.annotations != null ? Arrays.asList(copyAnnotations(source, bfd.annotations)) : Collections.<Annotation>emptyList());
+ if (job.checkerFramework.generateCalledMethods()) setter.receiver = generateNotCalledReceiver(job, setterName);
+ if (job.sourceNode.up().getKind() == Kind.METHOD) {
+ copyJavadocFromParam(bfd.originalFieldNode.up(), setter, td, bfd.name.toString());
+ } else {
+ copyJavadoc(bfd.originalFieldNode, setter, td, CopyJavadoc.SETTER, true);
}
- injectMethod(builderType, setter);
+ injectMethod(job.builderType, setter);
+ }
+
+ private void copyJavadocFromParam(EclipseNode from, MethodDeclaration to, TypeDeclaration type, String param) {
+ try {
+ CompilationUnitDeclaration cud = (CompilationUnitDeclaration) from.top().get();
+ String methodComment = getDocComment(cud, from.get());
+ String newJavadoc = addReturnsThisIfNeeded(getParamJavadoc(methodComment, param));
+ setDocComment(cud, type, to, newJavadoc);
+ } catch (Exception ignore) {}
}
- public EclipseNode makeBuilderClass(boolean isStatic, EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, ASTNode source, AccessLevel access) {
- TypeDeclaration parent = (TypeDeclaration) tdParent.get();
+ public void makeBuilderClass(BuilderJob job) {
+ TypeDeclaration parent = (TypeDeclaration) job.parentType.get();
TypeDeclaration builder = new TypeDeclaration(parent.compilationResult);
builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
- builder.modifiers |= toEclipseModifier(access);
- if (isStatic) builder.modifiers |= ClassFileConstants.AccStatic;
- builder.typeParameters = copyTypeParams(typeParams, source);
- builder.name = builderClassName.toCharArray();
- builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
- return injectType(tdParent, builder);
+ builder.modifiers |= toEclipseModifier(job.accessOuters);
+ if (job.isStatic) builder.modifiers |= ClassFileConstants.AccStatic;
+ builder.typeParameters = job.copyTypeParams();
+ builder.name = job.builderClassNameArr;
+ builder.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
+ job.builderType = injectType(job.parentType, builder);
}
private void addObtainVia(BuilderFieldData bfd, EclipseNode node) {
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilderDefault.java b/src/core/lombok/eclipse/handlers/HandleBuilderDefault.java
index d0c597fd..464a0efd 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilderDefault.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilderDefault.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2018 The Project Lombok Authors.
+ * Copyright (C) 2017-2021 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
@@ -23,7 +23,6 @@ package lombok.eclipse.handlers;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.mangosdk.spi.ProviderFor;
import lombok.Builder;
import lombok.core.AST.Kind;
@@ -32,8 +31,9 @@ import lombok.core.HandlerPriority;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.SuperBuilder;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(-1025) //HandleBuilder's level, minus one.
public class HandleBuilderDefault extends EclipseAnnotationHandler<Builder.Default> {
@Override public void handle(AnnotationValues<Builder.Default> annotation, Annotation ast, EclipseNode annotationNode) {
diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java
index dde7cd08..3ce41763 100644
--- a/src/core/lombok/eclipse/handlers/HandleCleanup.java
+++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,6 +32,7 @@ import lombok.core.AnnotationValues;
import lombok.core.AST.Kind;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -52,12 +53,11 @@ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Cleanup} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleCleanup extends EclipseAnnotationHandler<Cleanup> {
public void handle(AnnotationValues<Cleanup> annotation, Annotation ast, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.CLEANUP_FLAG_USAGE, "@Cleanup");
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index ff81b763..e69c3267 100755
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2020 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -44,6 +44,7 @@ import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -79,10 +80,9 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
public class HandleConstructor {
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleNoArgsConstructor extends EclipseAnnotationHandler<NoArgsConstructor> {
private static final String NAME = NoArgsConstructor.class.getSimpleName();
private HandleConstructor handleConstructor = new HandleConstructor();
@@ -105,7 +105,7 @@ public class HandleConstructor {
}
}
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleRequiredArgsConstructor extends EclipseAnnotationHandler<RequiredArgsConstructor> {
private static final String NAME = RequiredArgsConstructor.class.getSimpleName();
private HandleConstructor handleConstructor = new HandleConstructor();
@@ -166,7 +166,7 @@ public class HandleConstructor {
return fields;
}
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleAllArgsConstructor extends EclipseAnnotationHandler<AllArgsConstructor> {
private static final String NAME = AllArgsConstructor.class.getSimpleName();
@@ -456,14 +456,12 @@ 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, checkerFramework = null;
+ Annotation[] constructorProperties = 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,
- checkerFramework);
+ constructorProperties);
}
constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
@@ -531,6 +529,11 @@ public class HandleConstructor {
TypeDeclaration typeDecl = (TypeDeclaration) type.get();
constructor.returnType = EclipseHandlerUtil.namePlusTypeParamsToTypeReference(type, typeDecl.typeParameters, p);
constructor.annotations = null;
+ if (getCheckerFrameworkVersion(type).generateUnique()) {
+ int len = constructor.returnType.getTypeName().length;
+ constructor.returnType.annotations = new Annotation[len][];
+ constructor.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
constructor.selector = name.toCharArray();
constructor.thrownExceptions = null;
constructor.typeParameters = copyTypeParams(((TypeDeclaration) type.get()).typeParameters, source);
@@ -551,9 +554,7 @@ public class HandleConstructor {
assigns.add(nameRef);
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
- Annotation[] checkerFramework = null;
- if (getCheckerFrameworkVersion(fieldNode).generateUnique()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE) };
- parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode), checkerFramework);
+ parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode));
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleData.java b/src/core/lombok/eclipse/handlers/HandleData.java
index 6663d7d0..00e1fd38 100644
--- a/src/core/lombok/eclipse/handlers/HandleData.java
+++ b/src/core/lombok/eclipse/handlers/HandleData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -22,7 +22,7 @@
package lombok.eclipse.handlers;
import static lombok.core.handlers.HandlerUtil.*;
-import static lombok.eclipse.handlers.EclipseHandlerUtil.isClass;
+import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import java.util.Collections;
@@ -33,14 +33,14 @@ import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.HandleConstructor.SkipIfConstructorExists;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Data} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleData extends EclipseAnnotationHandler<Data> {
private HandleGetter handleGetter = new HandleGetter();
private HandleSetter handleSetter = new HandleSetter();
diff --git a/src/core/lombok/eclipse/handlers/HandleDelegate.java b/src/core/lombok/eclipse/handlers/HandleDelegate.java
index 9d352558..0e3eab66 100644
--- a/src/core/lombok/eclipse/handlers/HandleDelegate.java
+++ b/src/core/lombok/eclipse/handlers/HandleDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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
@@ -27,14 +27,14 @@ import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Delegate;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.mangosdk.spi.ProviderFor;
/**
* This class just handles basic error cases. The real meat of eclipse '@Delegate' support is in {@code PatchDelegate}.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleDelegate extends EclipseAnnotationHandler<Delegate> {
public void handle(AnnotationValues<Delegate> annotation, Annotation ast, EclipseNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.DELEGATE_FLAG_USAGE, "@Delegate");
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 83e6de61..753c489c 100755
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -36,6 +36,7 @@ import java.util.Set;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.EqualsAndHashCode;
+import lombok.EqualsAndHashCode.CacheStrategy;
import lombok.core.AST.Kind;
import lombok.core.handlers.HandlerUtil;
import lombok.core.handlers.InclusionExclusionUtils;
@@ -47,6 +48,7 @@ import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -59,6 +61,8 @@ import org.eclipse.jdt.internal.compiler.ast.ConditionalExpression;
import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.IfStatement;
import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression;
import org.eclipse.jdt.internal.compiler.ast.IntLiteral;
@@ -86,14 +90,16 @@ import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code EqualsAndHashCode} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndHashCode> {
+ private static final String HASH_CODE_CACHE_NAME = "$hashCodeCache";
+
+ private final char[] HASH_CODE_CACHE_NAME_ARR = HASH_CODE_CACHE_NAME.toCharArray();
private final char[] PRIME = "PRIME".toCharArray();
private final char[] RESULT = "result".toCharArray();
@@ -116,7 +122,9 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
boolean doNotUseGetters = annotation.isExplicit("doNotUseGetters") || doNotUseGettersConfiguration == null ? ann.doNotUseGetters() : doNotUseGettersConfiguration;
FieldAccess fieldAccess = doNotUseGetters ? FieldAccess.PREFER_FIELD : FieldAccess.GETTER;
- generateMethods(annotationNode.up(), annotationNode, members, callSuper, true, fieldAccess, onParam);
+ boolean cacheHashCode = ann.cacheStrategy() == CacheStrategy.LAZY;
+
+ generateMethods(annotationNode.up(), annotationNode, members, callSuper, true, cacheHashCode, fieldAccess, onParam);
}
public void generateEqualsAndHashCodeForType(EclipseNode typeNode, EclipseNode errorNode) {
@@ -130,20 +138,18 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
Boolean doNotUseGettersConfiguration = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_DO_NOT_USE_GETTERS);
FieldAccess access = doNotUseGettersConfiguration == null || !doNotUseGettersConfiguration ? FieldAccess.GETTER : FieldAccess.PREFER_FIELD;
- generateMethods(typeNode, errorNode, members, null, false, access, new ArrayList<Annotation>());
+ generateMethods(typeNode, errorNode, members, null, false, false, access, new ArrayList<Annotation>());
}
public void generateMethods(EclipseNode typeNode, EclipseNode errorNode, List<Included<EclipseNode, EqualsAndHashCode.Include>> members,
- Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess, List<Annotation> onParam) {
-
- TypeDeclaration typeDecl = null;
- if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
+ Boolean callSuper, boolean whineIfExists, boolean cacheHashCode, FieldAccess fieldAccess, List<Annotation> onParam) {
if (!isClass(typeNode)) {
errorNode.addError("@EqualsAndHashCode is only supported on a class.");
return;
}
+ TypeDeclaration typeDecl = (TypeDeclaration) typeNode.get();
boolean implicitCallSuper = callSuper == null;
if (callSuper == null) {
@@ -156,30 +162,6 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
boolean isDirectDescendantOfObject = isDirectDescendantOfObject(typeNode);
- if (isDirectDescendantOfObject && callSuper) {
- errorNode.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
- return;
- }
-
- if (implicitCallSuper && !isDirectDescendantOfObject) {
- CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
- if (cst == null) cst = CallSuperType.WARN;
-
- switch (cst) {
- default:
- case WARN:
- errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
- callSuper = false;
- break;
- case SKIP:
- callSuper = false;
- break;
- case CALL:
- callSuper = true;
- break;
- }
- }
-
boolean isFinal = (typeDecl.modifiers & ClassFileConstants.AccFinal) != 0;
boolean needsCanEqual = !isFinal || !isDirectDescendantOfObject;
MemberExistsResult equalsExists = methodExists("equals", typeNode, 1);
@@ -208,6 +190,30 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
//fallthrough
}
+ if (isDirectDescendantOfObject && callSuper) {
+ errorNode.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
+ return;
+ }
+
+ if (implicitCallSuper && !isDirectDescendantOfObject) {
+ CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ if (cst == null) cst = CallSuperType.WARN;
+
+ switch (cst) {
+ default:
+ case WARN:
+ errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
+ callSuper = false;
+ break;
+ case SKIP:
+ callSuper = false;
+ break;
+ case CALL:
+ callSuper = true;
+ break;
+ }
+ }
+
MethodDeclaration equalsMethod = createEquals(typeNode, members, callSuper, errorNode.get(), fieldAccess, needsCanEqual, onParam);
equalsMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, equalsMethod);
@@ -218,12 +224,33 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
injectMethod(typeNode, canEqualMethod);
}
- MethodDeclaration hashCodeMethod = createHashCode(typeNode, members, callSuper, errorNode.get(), fieldAccess);
+ if (cacheHashCode){
+ if (fieldExists(HASH_CODE_CACHE_NAME, typeNode) != MemberExistsResult.NOT_EXISTS) {
+ String msg = String.format("Not caching the result of hashCode: A field named %s already exists.", HASH_CODE_CACHE_NAME);
+ errorNode.addWarning(msg);
+ cacheHashCode = false;
+ } else {
+ createHashCodeCacheField(typeNode, errorNode.get());
+ }
+ }
+
+ MethodDeclaration hashCodeMethod = createHashCode(typeNode, members, callSuper, cacheHashCode, errorNode.get(), fieldAccess);
hashCodeMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, hashCodeMethod);
}
+
+ private void createHashCodeCacheField(EclipseNode typeNode, ASTNode source) {
+ FieldDeclaration hashCodeCacheDecl = new FieldDeclaration(HASH_CODE_CACHE_NAME_ARR, 0, 0);
+ hashCodeCacheDecl.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccTransient;
+ hashCodeCacheDecl.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
+ hashCodeCacheDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0);
+ hashCodeCacheDecl.declarationSourceEnd = -1;
+ injectFieldAndMarkGenerated(typeNode, hashCodeCacheDecl);
+ setGeneratedBy(hashCodeCacheDecl, source);
+ setGeneratedBy(hashCodeCacheDecl.type, source);
+ }
- public MethodDeclaration createHashCode(EclipseNode type, Collection<Included<EclipseNode, EqualsAndHashCode.Include>> members, boolean callSuper, ASTNode source, FieldAccess fieldAccess) {
+ public MethodDeclaration createHashCode(EclipseNode type, Collection<Included<EclipseNode, EqualsAndHashCode.Include>> members, boolean callSuper, boolean cacheHashCode, ASTNode source, FieldAccess fieldAccess) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long) pS << 32 | pE;
@@ -234,7 +261,10 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
method.returnType = TypeReference.baseTypeReference(TypeIds.T_int, 0);
setGeneratedBy(method.returnType, source);
Annotation overrideAnnotation = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
- if (getCheckerFrameworkVersion(type).generateSideEffectFree()) {
+ CheckerFrameworkVersion checkerFramework = getCheckerFrameworkVersion(type);
+ if (cacheHashCode && checkerFramework.generatePure()) {
+ method.annotations = new Annotation[] { overrideAnnotation, generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__PURE) };
+ } else if (checkerFramework.generateSideEffectFree()) {
method.annotations = new Annotation[] { overrideAnnotation, generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
} else {
method.annotations = new Annotation[] { overrideAnnotation };
@@ -258,6 +288,22 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
}
}
+ /* if (this.$hashCodeCache != 0) return this.$hashCodeCache; */ {
+ if (cacheHashCode) {
+ FieldReference hashCodeCacheRef = new FieldReference(HASH_CODE_CACHE_NAME_ARR, p);
+ hashCodeCacheRef.receiver = new ThisReference(pS, pE);
+ setGeneratedBy(hashCodeCacheRef, source);
+ setGeneratedBy(hashCodeCacheRef.receiver, source);
+ EqualExpression cacheNotZero = new EqualExpression(hashCodeCacheRef, makeIntLiteral("0".toCharArray(), source), OperatorIds.NOT_EQUAL);
+ setGeneratedBy(cacheNotZero, source);
+ ReturnStatement returnCache = new ReturnStatement(hashCodeCacheRef, pS, pE);
+ setGeneratedBy(returnCache, source);
+ IfStatement ifStatement = new IfStatement(cacheNotZero, returnCache, pS, pE);
+ setGeneratedBy(ifStatement, source);
+ statements.add(ifStatement);
+ }
+ }
+
/* final int PRIME = X; */ {
/* Without members, PRIME isn't used, as that would trigger a 'local variable not used' warning. */
if (!isEmpty) {
@@ -292,7 +338,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
resultDecl.initialization = init;
resultDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0);
resultDecl.type.sourceStart = pS; resultDecl.type.sourceEnd = pE;
- if (isEmpty) resultDecl.modifiers |= Modifier.FINAL;
+ if (isEmpty && !cacheHashCode) resultDecl.modifiers |= Modifier.FINAL;
setGeneratedBy(resultDecl.type, source);
statements.add(resultDecl);
}
@@ -387,6 +433,49 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
}
}
+ /*
+ * if (result == 0) result = Integer.MIN_VALUE;
+ * this.$hashCodeCache = result;
+ *
+ */ {
+ if (cacheHashCode) {
+ SingleNameReference resultRef = new SingleNameReference(RESULT, p);
+ setGeneratedBy(resultRef, source);
+
+ EqualExpression resultIsZero = new EqualExpression(resultRef, makeIntLiteral("0".toCharArray(), source), OperatorIds.EQUAL_EQUAL);
+ setGeneratedBy(resultIsZero, source);
+
+ resultRef = new SingleNameReference(RESULT, p);
+ setGeneratedBy(resultRef, source);
+
+ FieldReference integerMinValue = new FieldReference("MIN_VALUE".toCharArray(), p);
+ integerMinValue.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA_LANG_INTEGER);
+ setGeneratedBy(integerMinValue, source);
+
+ Assignment newResult = new Assignment(resultRef, integerMinValue, pE);
+ newResult.sourceStart = pS; newResult.statementEnd = newResult.sourceEnd = pE;
+ setGeneratedBy(newResult, source);
+
+ IfStatement ifStatement = new IfStatement(resultIsZero, newResult, pS, pE);
+ setGeneratedBy(ifStatement, source);
+ statements.add(ifStatement);
+
+
+ FieldReference hashCodeCacheRef = new FieldReference(HASH_CODE_CACHE_NAME_ARR, p);
+ hashCodeCacheRef.receiver = new ThisReference(pS, pE);
+ setGeneratedBy(hashCodeCacheRef, source);
+ setGeneratedBy(hashCodeCacheRef.receiver, source);
+
+ resultRef = new SingleNameReference(RESULT, p);
+ setGeneratedBy(resultRef, source);
+
+ Assignment cacheResult = new Assignment(hashCodeCacheRef, resultRef, pE);
+ cacheResult.sourceStart = pS; cacheResult.statementEnd = cacheResult.sourceEnd = pE;
+ setGeneratedBy(cacheResult, source);
+ statements.add(cacheResult);
+ }
+ }
+
/* return result; */ {
SingleNameReference resultRef = new SingleNameReference(RESULT, p);
setGeneratedBy(resultRef, source);
diff --git a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
index 8e53d873..5857780c 100644
--- a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -28,7 +28,6 @@ import java.util.List;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.ConfigurationKeys;
import lombok.core.AnnotationValues;
@@ -36,9 +35,10 @@ import lombok.core.HandlerPriority;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.ExtensionMethod;
+import lombok.spi.Provides;
// This handler just does some additional error checking; the real work is done in the agent.
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(66560) // 2^16 + 2^10; we must run AFTER HandleVal which is at 2^16
public class HandleExtensionMethod extends EclipseAnnotationHandler<ExtensionMethod> {
@Override public void handle(AnnotationValues<ExtensionMethod> annotation, Annotation ast, EclipseNode annotationNode) {
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
index 4927a8fb..5900e7ed 100644
--- a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
+++ b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2016 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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.eclipse.EclipseNode;
import lombok.experimental.FieldDefaults;
import lombok.experimental.NonFinal;
import lombok.experimental.PackagePrivate;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -47,12 +48,11 @@ import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.FieldDefaults} annotation for eclipse.
*/
-@ProviderFor(EclipseASTVisitor.class)
+@Provides(EclipseASTVisitor.class)
@HandlerPriority(-2048) //-2^11; to ensure @Value picks up on messing with the fields' 'final' state, run earlier.
public class HandleFieldDefaults extends EclipseASTAdapter {
public boolean generateFieldDefaultsForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean makeFinal, boolean checkForTypeLevelFieldDefaults) {
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
index cee3912c..cc1a5c3f 100644
--- a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2019 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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
@@ -41,7 +41,6 @@ import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
@@ -54,8 +53,9 @@ import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
import lombok.experimental.FieldNameConstants;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldNameConstants> {
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index 755311b1..7f8fdef2 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -35,6 +35,7 @@ import java.util.Map;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.experimental.Delegate;
+import lombok.spi.Provides;
import lombok.Getter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
@@ -73,14 +74,14 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Getter} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleGetter extends EclipseAnnotationHandler<Getter> {
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0];
+ private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field.";
public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter, List<Annotation> onMethod) {
if (checkForTypeLevelGetter) {
@@ -91,7 +92,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
}
if (!isClassOrEnum(typeNode)) {
- pos.addError("@Getter is only supported on a class, an enum, or a field.");
+ pos.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return false;
}
@@ -165,8 +166,9 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
public void createGetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List<Annotation> onMethod) {
+
if (fieldNode.getKind() != Kind.FIELD) {
- errorNode.addError("@Getter is only supported on a class or a field.");
+ errorNode.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -290,6 +292,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
}
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
+ copyJavadoc(fieldNode, method, CopyJavadoc.GETTER);
return method;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleHelper.java b/src/core/lombok/eclipse/handlers/HandleHelper.java
index 36f53813..7977c507 100755
--- a/src/core/lombok/eclipse/handlers/HandleHelper.java
+++ b/src/core/lombok/eclipse/handlers/HandleHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2016 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,6 @@ import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.mangosdk.spi.ProviderFor;
import lombok.ConfigurationKeys;
import lombok.core.AST.Kind;
@@ -53,11 +52,12 @@ import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Helper;
+import lombok.spi.Provides;
/**
* Handles the {@code lombok.Cleanup} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleHelper extends EclipseAnnotationHandler<Helper> {
private Statement[] getStatementsFromAstNode(ASTNode node) {
if (node instanceof Block) return ((Block) node).statements;
diff --git a/src/core/lombok/eclipse/handlers/HandleJacksonized.java b/src/core/lombok/eclipse/handlers/HandleJacksonized.java
index 90ee7582..466cc338 100644
--- a/src/core/lombok/eclipse/handlers/HandleJacksonized.java
+++ b/src/core/lombok/eclipse/handlers/HandleJacksonized.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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,7 +37,6 @@ import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.Builder;
import lombok.ConfigurationKeys;
@@ -50,13 +49,15 @@ import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
+import lombok.spi.Provides;
/**
* This (ecj) handler deals with {@code @Jacksonized} modifying the (already
* generated) {@code @Builder} or {@code @SuperBuilder} to conform to Jackson's
* needs for builders.
*/
-@ProviderFor(EclipseAnnotationHandler.class) @HandlerPriority(-512) // Above Handle(Super)Builder's level (builders must be already generated).
+@Provides
+@HandlerPriority(-512) // Above Handle(Super)Builder's level (builders must be already generated).
public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
private static final char[][] JSON_POJO_BUILDER_ANNOTATION = Eclipse.fromQualifiedName("com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder");
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index 9eae601b..df3989a4 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -22,11 +22,9 @@
package lombok.eclipse.handlers;
import static lombok.core.handlers.HandlerUtil.handleFlagUsage;
-import static lombok.eclipse.Eclipse.fromQualifiedName;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import java.lang.reflect.Modifier;
-import java.util.Arrays;
import java.util.List;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -35,13 +33,11 @@ import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.ConfigurationKeys;
import lombok.core.AnnotationValues;
@@ -52,10 +48,11 @@ import lombok.core.handlers.LoggingFramework;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
public class HandleLog {
private static final IdentifierName LOG = IdentifierName.valueOf("log");
-
+
private HandleLog() {
throw new UnsupportedOperationException();
}
@@ -85,14 +82,15 @@ public class HandleLog {
annotationNode.addWarning("Field '" + logFieldName + "' already exists.");
return;
}
+
if (isRecord(owner) && !useStatic) {
annotationNode.addError("Logger fields must be static in records.");
return;
}
-
+
Object valueGuess = annotation.getValueGuess("topic");
Expression loggerTopic = (Expression) annotation.getActualExpression("topic");
-
+
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
@@ -160,19 +158,6 @@ public class HandleLog {
return fieldDecl;
}
- public static TypeReference createTypeReference(String typeName, Annotation source) {
- int pS = source.sourceStart, pE = source.sourceEnd;
- long p = (long) pS << 32 | pE;
-
- char[][] typeNameTokens = fromQualifiedName(typeName);
- long[] pos = new long[typeNameTokens.length];
- Arrays.fill(pos, p);
-
- TypeReference typeReference = new QualifiedTypeReference(typeNameTokens, pos);
- setGeneratedBy(typeReference, source);
- return typeReference;
- }
-
private static final Expression[] createFactoryParameters(ClassLiteralAccess loggingType, Annotation source, List<LogFactoryParameter> parameters, Expression loggerTopic) {
Expression[] expressions = new Expression[parameters.size()];
int pS = source.sourceStart, pE = source.sourceEnd;
@@ -223,7 +208,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -234,7 +219,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.java.Log} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -245,7 +230,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.log4j.Log4j} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -256,7 +241,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.log4j.Log4j2} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -267,7 +252,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.slf4j.Slf4j} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -278,7 +263,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.slf4j.XSlf4j} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleXSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -289,7 +274,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.jbosslog.JBossLog} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleJBossLog extends EclipseAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -300,7 +285,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.flogger.Flogger} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleFloggerLog extends EclipseAnnotationHandler<lombok.extern.flogger.Flogger> {
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -311,7 +296,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.CustomLog} annotation for Eclipse.
*/
- @ProviderFor(EclipseAnnotationHandler.class)
+ @Provides
public static class HandleCustomLog extends EclipseAnnotationHandler<lombok.CustomLog> {
@Override public void handle(AnnotationValues<lombok.CustomLog> annotation, Annotation source, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_CUSTOM_FLAG_USAGE, "@CustomLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java
index 8dc4f4f7..27e78d32 100644
--- a/src/core/lombok/eclipse/handlers/HandleNonNull.java
+++ b/src/core/lombok/eclipse/handlers/HandleNonNull.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -47,7 +47,6 @@ import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement;
import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
@@ -55,13 +54,14 @@ import lombok.NonNull;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
+import lombok.eclipse.EcjAugments;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseAnnotationHandler;
-import lombok.eclipse.EclipseAugments;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.HandleConstructor.SkipIfConstructorExists;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first.
public class HandleNonNull extends EclipseAnnotationHandler<NonNull> {
private static final char[] REQUIRE_NON_NULL = "requireNonNull".toCharArray();
@@ -91,7 +91,7 @@ public class HandleNonNull extends EclipseAnnotationHandler<NonNull> {
if (isRecordField(annotationNode.up()) && !lombokConstructorExists(typeNode)) {
handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, null, SkipIfConstructorExists.NO, Collections.<Annotation>emptyList(), annotationNode);
}
- EclipseAugments.ASTNode_handled.clear(ast);
+ EcjAugments.ASTNode_handled.clear(ast);
return;
}
diff --git a/src/core/lombok/eclipse/handlers/HandlePrintAST.java b/src/core/lombok/eclipse/handlers/HandlePrintAST.java
index 234e29b8..9cc3e1ae 100644
--- a/src/core/lombok/eclipse/handlers/HandlePrintAST.java
+++ b/src/core/lombok/eclipse/handlers/HandlePrintAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -26,7 +26,6 @@ import java.io.FileNotFoundException;
import java.io.PrintStream;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.mangosdk.spi.ProviderFor;
import lombok.Lombok;
import lombok.core.AnnotationValues;
@@ -36,11 +35,12 @@ import lombok.eclipse.DeferUntilPostDiet;
import lombok.eclipse.EclipseASTVisitor;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
/**
* Handles the {@code lombok.core.PrintAST} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@DeferUntilPostDiet
@HandlerPriority(536870912) // 2^29; this handler is customarily run at the very end.
public class HandlePrintAST extends EclipseAnnotationHandler<PrintAST> {
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index 9ebbde6d..ddae21fb 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
@@ -56,13 +57,14 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Setter} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleSetter extends EclipseAnnotationHandler<Setter> {
+ private static final String SETTER_NODE_NOT_SUPPORTED_ERR = "@Setter is only supported on a class or a field.";
+
public boolean generateSetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelSetter, List<Annotation> onMethod, List<Annotation> onParam) {
if (checkForTypeLevelSetter) {
if (hasAnnotation(Setter.class, typeNode)) {
@@ -72,7 +74,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
}
if (!isClass(typeNode)) {
- pos.addError("@Setter is only supported on a class or a field.");
+ pos.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return false;
}
@@ -142,7 +144,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
ASTNode source = sourceNode.get();
if (fieldNode.getKind() != Kind.FIELD) {
- sourceNode.addError("@Setter is only supported on a class or a field.");
+ sourceNode.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -257,6 +259,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
if (returnType != null && returnStatement != null) createRelevantNonNullAnnotation(sourceNode, method);
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
+ copyJavadoc(fieldNode, method, CopyJavadoc.SETTER, returnStatement != null);
return method;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
index 481dbcde..5f0ca3fb 100644
--- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
+++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -36,6 +36,7 @@ import lombok.core.HandlerPriority;
import lombok.eclipse.DeferUntilPostDiet;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -56,12 +57,11 @@ import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.HandleSneakyThrows} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@DeferUntilPostDiet
@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it.
public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> {
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 89c27fe3..4f4baecd 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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.eclipse.handlers;
+import static lombok.eclipse.handlers.HandleBuilder.*;
import static lombok.core.handlers.HandlerUtil.*;
import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
@@ -49,6 +50,7 @@ import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.IfStatement;
+import org.eclipse.jdt.internal.compiler.ast.Initializer;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
@@ -57,13 +59,10 @@ import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference
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.Receiver;
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;
@@ -76,7 +75,6 @@ import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.Builder;
@@ -99,75 +97,102 @@ import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker;
import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker;
import lombok.eclipse.handlers.HandleBuilder.BuilderFieldData;
+import lombok.eclipse.handlers.HandleBuilder.BuilderJob;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes.
public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
- private static final char[] CLEAN_FIELD_NAME = "$lombokUnclean".toCharArray();
- private static final char[] CLEAN_METHOD_NAME = "$lombokClean".toCharArray();
- private static final char[] DEFAULT_PREFIX = "$default$".toCharArray();
- private static final char[] SET_PREFIX = "$set".toCharArray();
- private static final char[] VALUE_PREFIX = "$value".toCharArray();
private static final char[] SELF_METHOD_NAME = "self".toCharArray();
- private static final String TO_BUILDER_METHOD_NAME_STRING = "toBuilder";
- private static final char[] TO_BUILDER_METHOD_NAME = TO_BUILDER_METHOD_NAME_STRING.toCharArray();
private static final char[] FILL_VALUES_METHOD_NAME = "$fillValuesFrom".toCharArray();
private static final char[] FILL_VALUES_STATIC_METHOD_NAME = "$fillValuesFromInstanceIntoBuilder".toCharArray();
private static final char[] INSTANCE_VARIABLE_NAME = "instance".toCharArray();
private static final String BUILDER_VARIABLE_NAME_STRING = "b";
private static final char[] BUILDER_VARIABLE_NAME = BUILDER_VARIABLE_NAME_STRING.toCharArray();
- private static final AbstractMethodDeclaration[] EMPTY_METHODS = {};
-
- @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;
+ class SuperBuilderJob extends BuilderJob {
+ void init(AnnotationValues<SuperBuilder> annValues, SuperBuilder ann, EclipseNode node) {
+ accessOuters = accessInners = AccessLevel.PUBLIC;
+ oldFluent = true;
+ oldChain = true;
+
+ builderMethodName = ann.builderMethodName();
+ buildMethodName = ann.buildMethodName();
+ toBuilder = ann.toBuilder();
+
+ if (builderMethodName == null) builderMethodName = "builder";
+ if (buildMethodName == null) buildMethodName = "build";
+ builderClassName = fixBuilderClassName(node, "");
+ }
- SuperBuilder superbuilderAnnotation = annotation.getInstance();
+ EclipseNode builderAbstractType;
+ String builderAbstractClassName;
+ char[] builderAbstractClassNameArr;
+ EclipseNode builderImplType;
+ String builderImplClassName;
+ char[] builderImplClassNameArr;
+ private TypeParameter[] builderTypeParams_;
+ void setBuilderToImpl() {
+ builderType = builderImplType;
+ builderClassName = builderImplClassName;
+ builderClassNameArr = builderImplClassNameArr;
+ builderTypeParams = typeParams;
+ }
- String builderMethodName = superbuilderAnnotation.builderMethodName();
- String buildMethodName = superbuilderAnnotation.buildMethodName();
+ void setBuilderToAbstract() {
+ builderType = builderAbstractType;
+ builderClassName = builderAbstractClassName;
+ builderClassNameArr = builderAbstractClassNameArr;
+ builderTypeParams = builderTypeParams_;
+ }
+ }
+
+ @Override public void handle(AnnotationValues<SuperBuilder> annotation, Annotation ast, EclipseNode annotationNode) {
+ handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.SUPERBUILDER_FLAG_USAGE, "@SuperBuilder");
+ SuperBuilderJob job = new SuperBuilderJob();
+ job.sourceNode = annotationNode;
+ job.source = ast;
+ job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
+ job.isStatic = true;
- if (builderMethodName == null) builderMethodName = "builder";
- if (buildMethodName == null) buildMethodName = "build";
+ SuperBuilder annInstance = annotation.getInstance();
+ job.init(annotation, annInstance, annotationNode);
boolean generateBuilderMethod;
- if (builderMethodName.isEmpty()) {
+ if (job.builderMethodName.isEmpty()) {
generateBuilderMethod = false;
- } else if (!checkName("builderMethodName", builderMethodName, annotationNode)) {
+ } else if (!checkName("builderMethodName", job.builderMethodName, annotationNode)) {
return;
} else {
generateBuilderMethod = true;
}
- if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
- boolean toBuilder = superbuilderAnnotation.toBuilder();
+ if (!checkName("buildMethodName", job.buildMethodName, annotationNode)) return;
- EclipseNode tdParent = annotationNode.up();
+ EclipseNode parent = annotationNode.up();
- java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
- TypeReference returnType;
- TypeParameter[] typeParams;
+ job.builderFields = new ArrayList<BuilderFieldData>();
+ TypeReference buildMethodReturnType;
boolean addCleaning = false;
- if (!isClass(tdParent)) {
- annotationNode.addError("@SuperBuilder is only supported on types.");
+ List<EclipseNode> nonFinalNonDefaultedFields = null;
+
+ if (!isClass(parent)) {
+ annotationNode.addError("@SuperBuilder is only supported on classes.");
return;
}
- TypeDeclaration td = (TypeDeclaration) tdParent.get();
+
+ job.parentType = parent;
+ TypeDeclaration td = (TypeDeclaration) parent.get();
// Gather all fields of the class that should be set by the builder.
List<EclipseNode> allFields = new ArrayList<EclipseNode>();
- List<EclipseNode> nonFinalNonDefaultedFields = null;
- boolean valuePresent = (hasAnnotation(lombok.Value.class, tdParent) || hasAnnotation("lombok.experimental.Value", tdParent));
- for (EclipseNode fieldNode : HandleConstructor.findAllFields(tdParent, true)) {
+ boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent));
+ for (EclipseNode fieldNode : HandleConstructor.findAllFields(parent, true)) {
FieldDeclaration fd = (FieldDeclaration) fieldNode.get();
EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode);
boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
@@ -180,7 +205,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = copyAnnotations(fd, copyableAnnotations);
bfd.type = fd.type;
- bfd.singularData = getSingularData(fieldNode, ast, superbuilderAnnotation.setterPrefix());
+ bfd.singularData = getSingularData(fieldNode, ast, annInstance.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -205,21 +230,15 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
bfd.builderFieldName = prefixWith(bfd.name, VALUE_PREFIX);
MethodDeclaration md = HandleBuilder.generateDefaultProvider(bfd.nameOfDefaultProvider, td.typeParameters, fieldNode, ast);
- if (md != null) injectMethod(tdParent, md);
+ if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
- builderFields.add(bfd);
+ job.builderFields.add(bfd);
allFields.add(fieldNode);
}
- // Set the names of the builder classes.
- String builderClassNameTemplate = annotationNode.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
- if (builderClassNameTemplate == null || builderClassNameTemplate.isEmpty()) builderClassNameTemplate = "*Builder";
- String builderClassName = builderClassNameTemplate.replace("*", String.valueOf(td.name));
- String builderImplClassName = builderClassName + "Impl";
-
- typeParams = td.typeParameters != null ? td.typeParameters : new TypeParameter[0];
- returnType = namePlusTypeParamsToTypeReference(tdParent, typeParams, p);
+ job.typeParams = td.typeParameters != null ? td.typeParameters : new TypeParameter[0];
+ buildMethodReturnType = job.createBuilderParentTypeReference();
// <C, B> are the generics for our builder.
String classGenericName = "C";
@@ -227,25 +246,41 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// We have to make sure that the generics' names do not collide with any generics on the annotated class,
// the classname itself, or any member type name of the annotated class.
// For instance, if there are generics <B, B2, C> on the annotated class, use "C2" and "B3" for our builder.
- java.util.Set<String> usedNames = gatherUsedTypeNames(typeParams, td);
+ java.util.Set<String> usedNames = gatherUsedTypeNames(job.typeParams, td);
classGenericName = generateNonclashingNameFor(classGenericName, usedNames);
builderGenericName = generateNonclashingNameFor(builderGenericName, usedNames);
+ TypeParameter[] paddedTypeParameters; {
+ paddedTypeParameters = new TypeParameter[job.typeParams.length + 2];
+ System.arraycopy(job.typeParams, 0, paddedTypeParameters, 0, job.typeParams.length);
+
+ TypeParameter c = new TypeParameter();
+ c.name = classGenericName.toCharArray();
+ c.type = cloneSelfType(job.parentType, job.source);
+ paddedTypeParameters[paddedTypeParameters.length - 2] = c;
+
+ TypeParameter b = new TypeParameter();
+ b.name = builderGenericName.toCharArray();
+ b.type = cloneSelfType(job.parentType, job.source);
+ paddedTypeParameters[paddedTypeParameters.length - 1] = b;
+ }
+ job.builderTypeParams = job.builderTypeParams_ = paddedTypeParameters;
+
TypeReference extendsClause = td.superclass;
TypeReference superclassBuilderClass = null;
TypeReference[] typeArguments = new TypeReference[] {
new SingleTypeReference(classGenericName.toCharArray(), 0),
- new SingleTypeReference(builderGenericName.toCharArray(), 0)
+ new SingleTypeReference(builderGenericName.toCharArray(), 0),
};
if (extendsClause instanceof QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference)extendsClause;
String superclassClassName = String.valueOf(qualifiedTypeReference.getLastToken());
- String superclassBuilderClassName = builderClassNameTemplate.replace("*", superclassClassName);
+ String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName);
char[][] tokens = Arrays.copyOf(qualifiedTypeReference.tokens, qualifiedTypeReference.tokens.length + 1);
tokens[tokens.length-1] = superclassBuilderClassName.toCharArray();
long[] poss = new long[tokens.length];
- Arrays.fill(poss, p);
+ Arrays.fill(poss, job.getPos());
TypeReference[] superclassTypeArgs = getTypeParametersFrom(extendsClause);
@@ -261,7 +296,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
char[][] tokens = new char[][] {superClass.toCharArray(), superclassBuilderClassName.toCharArray()};
long[] poss = new long[tokens.length];
- Arrays.fill(poss, p);
+ Arrays.fill(poss, job.getPos());
TypeReference[] superclassTypeArgs = getTypeParametersFrom(extendsClause);
@@ -272,40 +307,43 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
superclassBuilderClass = new ParameterizedQualifiedTypeReference(tokens, typeArgsForTokens, 0, poss);
}
+ job.builderAbstractClassName = job.builderClassName = job.replaceBuilderClassName(td.name);
+ job.builderAbstractClassNameArr = job.builderClassNameArr = job.builderAbstractClassName.toCharArray();
+ job.builderImplClassName = job.builderAbstractClassName + "Impl";
+ job.builderImplClassNameArr = job.builderImplClassName.toCharArray();
+
// If there is no superclass, superclassBuilderClassExpression is still == null at this point.
// You can use it to check whether to inherit or not.
- if (!constructorExists(tdParent, builderClassName)) {
- generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
- superclassBuilderClass != null);
+ if (!constructorExists(parent, job.builderClassName)) {
+ generateBuilderBasedConstructor(job, superclassBuilderClass != null);
}
// Create the abstract builder class, or reuse an existing one.
- EclipseNode builderType = findInnerClass(tdParent, builderClassName);
- if (builderType == null) {
- builderType = generateBuilderAbstractClass(tdParent, builderClassName, superclassBuilderClass,
- typeParams, ast, classGenericName, builderGenericName);
+ job.builderAbstractType = findInnerClass(parent, job.builderClassName);
+ if (job.builderAbstractType == null) {
+ job.builderAbstractType = generateBuilderAbstractClass(job, superclassBuilderClass, classGenericName, builderGenericName);
} else {
- TypeDeclaration builderTypeDeclaration = (TypeDeclaration) builderType.get();
+ TypeDeclaration builderTypeDeclaration = (TypeDeclaration) job.builderAbstractType.get();
if ((builderTypeDeclaration.modifiers & (ClassFileConstants.AccStatic | ClassFileConstants.AccAbstract)) == 0) {
annotationNode.addError("Existing Builder must be an abstract static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderAbstractType, annotationNode);
// Generate errors for @Singular BFDs that have one already defined node.
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
SingularData sd = bfd.singularData;
if (sd == null) continue;
EclipseSingularizer singularizer = sd.getSingularizer();
if (singularizer == null) continue;
- if (singularizer.checkForAlreadyExistingNodesAndGenerateError(builderType, sd)) {
+ if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderAbstractType, sd)) {
bfd.singularData = null;
}
}
}
// Check validity of @ObtainVia fields, and add check if adding cleaning for @Singular is necessary.
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
if (bfd.singularData.getSingularizer().requiresCleaning()) {
addCleaning = true;
@@ -325,47 +363,52 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
// Generate the fields in the abstract builder class that hold the values for the instance.
- generateBuilderFields(builderType, builderFields, ast);
+ job.setBuilderToAbstract();
+ generateBuilderFields(job);
if (addCleaning) {
FieldDeclaration cleanDecl = new FieldDeclaration(CLEAN_FIELD_NAME, 0, -1);
cleanDecl.declarationSourceEnd = -1;
cleanDecl.modifiers = ClassFileConstants.AccPrivate;
cleanDecl.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
- injectFieldAndMarkGenerated(builderType, cleanDecl);
+ injectFieldAndMarkGenerated(job.builderType, cleanDecl);
}
- if (toBuilder) {
+ if (job.toBuilder) {
// Generate $fillValuesFrom() method in the abstract builder.
- injectMethod(builderType, generateFillValuesMethod(tdParent, superclassBuilderClass != null, builderGenericName, classGenericName, builderClassName, typeParams));
+ injectMethod(job.builderType, generateFillValuesMethod(job, superclassBuilderClass != null, builderGenericName, classGenericName));
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
- injectMethod(builderType, generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, ast, superbuilderAnnotation.setterPrefix()));
+ injectMethod(job.builderType, generateStaticFillValuesMethod(job, annInstance.setterPrefix()));
}
// Generate abstract self() and build() methods in the abstract builder.
- injectMethod(builderType, generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClass != null, builderGenericName));
- injectMethod(builderType, generateAbstractBuildMethod(cfv, builderType, buildMethodName, builderFields, superclassBuilderClass != null, classGenericName, ast));
+ injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName));
+ job.setBuilderToAbstract();
+ injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName));
// Create the setter methods in the abstract builder.
- for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName, superbuilderAnnotation.setterPrefix());
+ for (BuilderFieldData bfd : job.builderFields) {
+ generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix());
}
// Create the toString() method for the abstract builder.
- if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) {
+ if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) {
List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
for (EclipseNode f : bfd.createdFields) {
fieldNodes.add(new Included<EclipseNode, ToString.Include>(f, null, true, false));
}
}
// Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder.
- MethodDeclaration md = HandleToString.createToString(builderType, fieldNodes, true, superclassBuilderClass != null, ast, FieldAccess.ALWAYS_FIELD);
+ MethodDeclaration md = HandleToString.createToString(job.builderType, fieldNodes, true, superclassBuilderClass != null, ast, FieldAccess.ALWAYS_FIELD);
if (md != null) {
- injectMethod(builderType, md);
+ injectMethod(job.builderType, md);
}
}
- if (addCleaning) injectMethod(builderType, generateCleanMethod(builderFields, builderType, ast));
+ if (addCleaning) {
+ job.setBuilderToAbstract();
+ injectMethod(job.builderType, generateCleanMethod(job));
+ }
boolean isAbstract = (td.modifiers & ClassFileConstants.AccAbstract) != 0;
if (isAbstract) {
@@ -374,26 +417,27 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
// Create the builder implementation class, or reuse an existing one.
- EclipseNode builderImplType = findInnerClass(tdParent, builderImplClassName);
- if (builderImplType == null) {
- builderImplType = generateBuilderImplClass(tdParent, builderImplClassName, builderClassName, typeParams, ast);
+ job.builderImplType = findInnerClass(parent, job.builderImplClassName);
+ if (job.builderImplType == null) {
+ job.builderImplType = generateBuilderImplClass(job, job.builderImplClassName);
} else {
- TypeDeclaration builderImplTypeDeclaration = (TypeDeclaration) builderImplType.get();
+ TypeDeclaration builderImplTypeDeclaration = (TypeDeclaration) job.builderImplType.get();
if ((builderImplTypeDeclaration.modifiers & ClassFileConstants.AccAbstract) != 0 ||
(builderImplTypeDeclaration.modifiers & ClassFileConstants.AccStatic) == 0) {
annotationNode.addError("Existing BuilderImpl must be a non-abstract static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderImplType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderImplType, annotationNode);
}
- if (toBuilder) {
+ job.setBuilderToImpl();
+ if (job.toBuilder) {
// Add the toBuilder() method to the annotated class.
- switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, tdParent, 0)) {
+ switch (methodExists(TO_BUILDER_METHOD_NAME_STRING, job.parentType, 0)) {
case EXISTS_BY_USER:
break;
case NOT_EXISTS:
- injectMethod(tdParent, generateToBuilderMethod(cfv, builderClassName, builderImplClassName, tdParent, typeParams, ast));
+ injectMethod(parent, generateToBuilderMethod(job));
break;
default:
// Should not happen.
@@ -401,17 +445,19 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
// Create the self() and build() methods in the BuilderImpl.
- injectMethod(builderImplType, generateSelfMethod(cfv, builderImplType, typeParams, p));
+ job.setBuilderToImpl();
+ injectMethod(job.builderImplType, generateSelfMethod(job));
- if (methodExists(buildMethodName, builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
- injectMethod(builderImplType, generateBuildMethod(cfv, builderImplType, buildMethodName, returnType, builderFields, ast));
+ if (methodExists(job.buildMethodName, job.builderImplType, -1) == MemberExistsResult.NOT_EXISTS) {
+ job.setBuilderToImpl();
+ injectMethod(job.builderImplType, generateBuildMethod(job, buildMethodReturnType));
}
// Add the builder() method to the annotated class.
- if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
+ if (generateBuilderMethod && methodExists(job.builderMethodName, parent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- MethodDeclaration md = generateBuilderMethod(cfv, builderMethodName, builderClassName, builderImplClassName, tdParent, typeParams, ast);
- if (md != null) injectMethod(tdParent, md);
+ MethodDeclaration md = generateBuilderMethod(job);
+ if (md != null) injectMethod(parent, md);
}
if (nonFinalNonDefaultedFields != null && generateBuilderMethod) {
@@ -421,97 +467,82 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
}
- private EclipseNode generateBuilderAbstractClass(EclipseNode tdParent, String builderClass,
- TypeReference superclassBuilderClass, TypeParameter[] typeParams,
- ASTNode source, String classGenericName, String builderGenericName) {
-
- TypeDeclaration parent = (TypeDeclaration) tdParent.get();
+ private EclipseNode generateBuilderAbstractClass(BuilderJob job, TypeReference superclassBuilderClass, String classGenericName, String builderGenericName) {
+ TypeDeclaration parent = (TypeDeclaration) job.parentType.get();
TypeDeclaration builder = new TypeDeclaration(parent.compilationResult);
builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
builder.modifiers |= ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccAbstract;
- builder.name = builderClass.toCharArray();
+ builder.name = job.builderClassNameArr;
// Keep any type params of the annotated class.
- builder.typeParameters = Arrays.copyOf(copyTypeParams(typeParams, source), typeParams.length + 2);
+ builder.typeParameters = Arrays.copyOf(copyTypeParams(job.typeParams, job.source), job.typeParams.length + 2);
// Add builder-specific type params required for inheritable builders.
// 1. The return type for the build() method, named "C", which extends the annotated class.
TypeParameter o = new TypeParameter();
o.name = classGenericName.toCharArray();
- o.type = cloneSelfType(tdParent, source);
+ o.type = cloneSelfType(job.parentType, job.source);
builder.typeParameters[builder.typeParameters.length - 2] = o;
// 2. The return type for all setter methods, named "B", which extends this builder class.
o = new TypeParameter();
o.name = builderGenericName.toCharArray();
- TypeReference[] typerefs = appendBuilderTypeReferences(typeParams, classGenericName, builderGenericName);
- o.type = generateParameterizedTypeReference(tdParent, builderClass.toCharArray(), false, typerefs, 0);
+ TypeReference[] typerefs = appendBuilderTypeReferences(job.typeParams, classGenericName, builderGenericName);
+ o.type = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, typerefs, 0);
builder.typeParameters[builder.typeParameters.length - 1] = o;
- builder.superclass = copyType(superclassBuilderClass, source);
+ if (superclassBuilderClass != null) builder.superclass = copyType(superclassBuilderClass, job.source);
builder.createDefaultConstructor(false, true);
- builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
- return injectType(tdParent, builder);
+ builder.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
+ return injectType(job.parentType, builder);
}
- private EclipseNode generateBuilderImplClass(EclipseNode tdParent, String builderImplClass, String builderAbstractClass, TypeParameter[] typeParams, ASTNode source) {
- TypeDeclaration parent = (TypeDeclaration) tdParent.get();
+ private EclipseNode generateBuilderImplClass(BuilderJob job, String builderImplClass) {
+ TypeDeclaration parent = (TypeDeclaration) job.parentType.get();
TypeDeclaration builder = new TypeDeclaration(parent.compilationResult);
builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
builder.modifiers |= ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal;
builder.name = builderImplClass.toCharArray();
// Add type params if there are any.
- if (typeParams != null && typeParams.length > 0) builder.typeParameters = copyTypeParams(typeParams, source);
+ if (job.typeParams != null && job.typeParams.length > 0) builder.typeParameters = copyTypeParams(job.typeParams, job.source);
- if (builderAbstractClass != null) {
+ if (job.builderClassName != null) {
// Extend the abstract builder.
// 1. Add any type params of the annotated class.
- TypeReference[] typeArgs = new TypeReference[typeParams.length + 2];
- for (int i = 0; i < typeParams.length; i++) {
- typeArgs[i] = new SingleTypeReference(typeParams[i].name, 0);
+ TypeReference[] typeArgs = new TypeReference[job.typeParams.length + 2];
+ for (int i = 0; i < job.typeParams.length; i++) {
+ typeArgs[i] = new SingleTypeReference(job.typeParams[i].name, 0);
}
// 2. The return type for the build() method (named "C" in the abstract builder), which is the annotated class.
// 3. The return type for all setter methods (named "B" in the abstract builder), which is this builder class.
- typeArgs[typeArgs.length - 2] = cloneSelfType(tdParent, source);
- typeArgs[typeArgs.length - 1] = createTypeReferenceWithTypeParameters(tdParent, builderImplClass, typeParams);
- builder.superclass = generateParameterizedTypeReference(tdParent, builderAbstractClass.toCharArray(), false, typeArgs, 0);
+ typeArgs[typeArgs.length - 2] = cloneSelfType(job.parentType, job.source);
+ typeArgs[typeArgs.length - 1] = createTypeReferenceWithTypeParameters(job.parentType, builderImplClass, job.typeParams);
+ builder.superclass = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, typeArgs, 0);
}
builder.createDefaultConstructor(false, true);
- builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
- return injectType(tdParent, builder);
+ builder.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
+ return injectType(job.parentType, builder);
}
/**
* Generates a constructor that has a builder as the only parameter.
* The values from the builder are used to initialize the fields of new instances.
*
- * @param typeNode
- * 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
* If {@code true}, the constructor will explicitly call a super
* constructor with the builder as argument. Requires
* {@code builderClassAsParameter != null}.
*/
- private void generateBuilderBasedConstructor(CheckerFrameworkVersion cfv, EclipseNode typeNode, TypeParameter[] typeParams, List<BuilderFieldData> builderFields,
- EclipseNode sourceNode, String builderClassName, boolean callBuilderBasedSuperConstructor) {
+ private void generateBuilderBasedConstructor(BuilderJob job, boolean callBuilderBasedSuperConstructor) {
+ TypeDeclaration typeDeclaration = ((TypeDeclaration) job.parentType.get());
+ long p = job.getPos();
- ASTNode source = sourceNode.get();
-
- TypeDeclaration typeDeclaration = ((TypeDeclaration) typeNode.get());
- long p = (long) source.sourceStart << 32 | source.sourceEnd;
-
- ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) typeNode.top().get()).compilationResult);
+ ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) job.parentType.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);
@@ -519,21 +550,21 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
} else {
constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
}
- constructor.constructorCall.sourceStart = source.sourceStart;
- constructor.constructorCall.sourceEnd = source.sourceEnd;
+ constructor.constructorCall.sourceStart = job.source.sourceStart;
+ constructor.constructorCall.sourceEnd = job.source.sourceEnd;
constructor.thrownExceptions = null;
constructor.typeParameters = null;
constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
- constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = source.sourceStart;
- constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = source.sourceEnd;
+ constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = job.source.sourceStart;
+ constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = job.source.sourceEnd;
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND)};
- TypeReference builderType = generateParameterizedTypeReference(typeNode, builderClassName.toCharArray(), false, mergeToTypeReferences(typeParams, wildcards), p);
+ TypeReference builderType = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p);
constructor.arguments = new Argument[] {new Argument(BUILDER_VARIABLE_NAME, p, builderType, Modifier.FINAL)};
List<Statement> statements = new ArrayList<Statement>();
- for (BuilderFieldData fieldNode : builderFields) {
+ for (BuilderFieldData fieldNode : job.builderFields) {
FieldReference fieldInThis = new FieldReference(fieldNode.rawName, p);
int s = (int) (p >> 32);
int e = (int) p;
@@ -541,7 +572,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
Expression assignmentExpr;
if (fieldNode.singularData != null && fieldNode.singularData.getSingularizer() != null) {
- fieldNode.singularData.getSingularizer().appendBuildCode(fieldNode.singularData, typeNode, statements, fieldNode.builderFieldName, BUILDER_VARIABLE_NAME_STRING);
+ fieldNode.singularData.getSingularizer().appendBuildCode(fieldNode.singularData, job.parentType, statements, fieldNode.builderFieldName, BUILDER_VARIABLE_NAME_STRING);
assignmentExpr = new SingleNameReference(fieldNode.builderFieldName, p);
} else {
char[][] variableInBuilder = new char[][] {BUILDER_VARIABLE_NAME, fieldNode.builderFieldName};
@@ -557,11 +588,11 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
QualifiedNameReference setVariableInBuilderRef = new QualifiedNameReference(setVariableInBuilder, positions, s, e);
MessageSend defaultMethodCall = new MessageSend();
- defaultMethodCall.sourceStart = source.sourceStart;
- defaultMethodCall.sourceEnd = source.sourceEnd;
- defaultMethodCall.receiver = generateNameReference(typeNode, 0L);
+ defaultMethodCall.sourceStart = job.source.sourceStart;
+ defaultMethodCall.sourceEnd = job.source.sourceEnd;
+ defaultMethodCall.receiver = generateNameReference(job.parentType, 0L);
defaultMethodCall.selector = fieldNode.nameOfDefaultProvider;
- defaultMethodCall.typeArguments = typeParameterNames(((TypeDeclaration) typeNode.get()).typeParameters);
+ defaultMethodCall.typeArguments = typeParameterNames(((TypeDeclaration) job.parentType.get()).typeParameters);
Statement defaultAssignment = new Assignment(fieldInThis, defaultMethodCall, (int) p);
IfStatement ifBlockForDefault = new IfStatement(setVariableInBuilderRef, assignment, defaultAssignment, s, e);
@@ -571,41 +602,50 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
if (hasNonNullAnnotations(fieldNode.originalFieldNode)) {
- Statement nullCheck = generateNullCheck((FieldDeclaration) fieldNode.originalFieldNode.get(), sourceNode, null);
+ Statement nullCheck = generateNullCheck((FieldDeclaration) fieldNode.originalFieldNode.get(), job.sourceNode, null);
if (nullCheck != null) statements.add(nullCheck);
}
}
constructor.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
+ if (job.checkerFramework.generateSideEffectFree()) {
+ constructor.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
+ }
- constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
+ constructor.traverse(new SetGeneratedByVisitor(job.source), typeDeclaration.scope);
- injectMethod(typeNode, constructor);
+ injectMethod(job.parentType, constructor);
}
- private MethodDeclaration generateBuilderMethod(CheckerFrameworkVersion cfv, String builderMethodName, String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
- int pS = source.sourceStart, pE = source.sourceEnd;
+ private MethodDeclaration generateBuilderMethod(SuperBuilderJob job) {
+ int pS = job.source.sourceStart, pE = job.source.sourceEnd;
long p = (long) pS << 32 | pE;
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
- out.selector = builderMethodName.toCharArray();
+ MethodDeclaration out = job.createNewMethodDeclaration();
+ out.selector = job.builderMethodName.toCharArray();
out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
// Add type params if there are any.
- if (typeParams != null && typeParams.length > 0) out.typeParameters = copyTypeParams(typeParams, source);
+ if (job.typeParams != null && job.typeParams.length > 0) out.typeParameters = copyTypeParams(job.typeParams, job.source);
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND) };
- out.returnType = generateParameterizedTypeReference(type, builderClassName.toCharArray(), false, mergeToTypeReferences(typeParams, wildcards), p);
+ out.returnType = generateParameterizedTypeReference(job.parentType, job.builderAbstractClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p);
+ if (job.checkerFramework.generateUnique()) {
+ int len = out.returnType.getTypeName().length;
+ out.returnType.annotations = new Annotation[len][];
+ out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
AllocationExpression invoke = new AllocationExpression();
- invoke.type = namePlusTypeParamsToTypeReference(type, builderImplClassName.toCharArray(), false, typeParams, p);
+ invoke.type = namePlusTypeParamsToTypeReference(job.parentType, job.builderImplClassNameArr, false, job.typeParams, p);
out.statements = new Statement[] {new ReturnStatement(invoke, pS, pE)};
+ if (job.checkerFramework.generateSideEffectFree()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
+ }
- if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
-
- createRelevantNonNullAnnotation(type, out);
- out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
+ createRelevantNonNullAnnotation(job.parentType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.parentType.get()).scope);
return out;
}
@@ -617,30 +657,36 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* }
* </pre>
*/
- private MethodDeclaration generateToBuilderMethod(CheckerFrameworkVersion cfv, String builderClassName, String builderImplClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) {
- int pS = source.sourceStart, pE = source.sourceEnd;
+ private MethodDeclaration generateToBuilderMethod(SuperBuilderJob job) {
+ int pS = job.source.sourceStart, pE = job.source.sourceEnd;
long p = (long) pS << 32 | pE;
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) type.top().get()).compilationResult);
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.selector = TO_BUILDER_METHOD_NAME;
out.modifiers = ClassFileConstants.AccPublic;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND) };
- out.returnType = generateParameterizedTypeReference(type, builderClassName.toCharArray(), false, mergeToTypeReferences(typeParams, wildcards), p);
+ out.returnType = generateParameterizedTypeReference(job.parentType, job.builderAbstractClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), p);
+ if (job.checkerFramework.generateUnique()) {
+ int len = out.returnType.getTypeName().length;
+ out.returnType.annotations = new Annotation[len][];
+ out.returnType.annotations[len - 1] = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ }
AllocationExpression newClass = new AllocationExpression();
- newClass.type = namePlusTypeParamsToTypeReference(type, builderImplClassName.toCharArray(), false, typeParams, p);
+ newClass.type = namePlusTypeParamsToTypeReference(job.parentType, job.builderImplClassNameArr, false, job.typeParams, p);
MessageSend invokeFillMethod = new MessageSend();
invokeFillMethod.receiver = newClass;
invokeFillMethod.selector = FILL_VALUES_METHOD_NAME;
invokeFillMethod.arguments = new Expression[] {new ThisReference(0, 0)};
out.statements = new Statement[] {new ReturnStatement(invokeFillMethod, pS, pE)};
+ if (job.checkerFramework.generateSideEffectFree()) {
+ out.annotations = new Annotation[] {generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
+ }
- if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
-
- createRelevantNonNullAnnotation(type, out);
- out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
+ createRelevantNonNullAnnotation(job.parentType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), ((TypeDeclaration) job.parentType.get()).scope);
return out;
}
@@ -650,17 +696,17 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* <pre>
* protected B $fillValuesFrom(final C instance) {
* super.$fillValuesFrom(instance);
- * Foobar.FoobarBuilderImpl.$fillValuesFromInstanceIntoBuilder(instance, this);
+ * Foobar.FoobarBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
* return self();
* }
* </pre>
*/
- private MethodDeclaration generateFillValuesMethod(EclipseNode tdParent, boolean inherited, String builderGenericName, String classGenericName, String builderClassName, TypeParameter[] typeParams) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
+ private MethodDeclaration generateFillValuesMethod(SuperBuilderJob job, boolean inherited, String builderGenericName, String classGenericName) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.selector = FILL_VALUES_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccProtected;
- if (inherited) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, tdParent.get())};
+ if (inherited) out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.parentType.get())};
out.returnType = new SingleTypeReference(builderGenericName.toCharArray(), 0);
TypeReference builderType = new SingleTypeReference(classGenericName.toCharArray(), 0);
@@ -679,7 +725,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// Call the builder implemention's helper method that actually fills the values from the instance.
MessageSend callStaticFillValuesMethod = new MessageSend();
- callStaticFillValuesMethod.receiver = generateNameReference(tdParent, builderClassName.toCharArray(), 0);
+ callStaticFillValuesMethod.receiver = generateNameReference(job.parentType, job.builderAbstractClassNameArr, 0);
callStaticFillValuesMethod.selector = FILL_VALUES_STATIC_METHOD_NAME;
callStaticFillValuesMethod.arguments = new Expression[] {new SingleNameReference(INSTANCE_VARIABLE_NAME, 0), new ThisReference(0, 0)};
body.add(callStaticFillValuesMethod);
@@ -707,40 +753,40 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
* </pre>
* @param setterPrefix the prefix for setter methods
*/
- private MethodDeclaration generateStaticFillValuesMethod(EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, java.util.List<BuilderFieldData> builderFields, ASTNode source, String setterPrefix) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
+ private MethodDeclaration generateStaticFillValuesMethod(BuilderJob job, String setterPrefix) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.selector = FILL_VALUES_STATIC_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic;
out.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
TypeReference[] wildcards = new TypeReference[] {new Wildcard(Wildcard.UNBOUND), new Wildcard(Wildcard.UNBOUND)};
- TypeReference builderType = generateParameterizedTypeReference(tdParent, builderClassName.toCharArray(), false, mergeToTypeReferences(typeParams, wildcards), 0);
+ TypeReference builderType = generateParameterizedTypeReference(job.parentType, job.builderClassNameArr, false, mergeToTypeReferences(job.typeParams, wildcards), 0);
Argument builderArgument = new Argument(BUILDER_VARIABLE_NAME, 0, builderType, Modifier.FINAL);
TypeReference[] typerefs = null;
- if (typeParams.length > 0) {
- typerefs = new TypeReference[typeParams.length];
- for (int i = 0; i < typeParams.length; i++) typerefs[i] = new SingleTypeReference(typeParams[i].name, 0);
+ if (job.typeParams.length > 0) {
+ typerefs = new TypeReference[job.typeParams.length];
+ for (int i = 0; i < job.typeParams.length; i++) typerefs[i] = new SingleTypeReference(job.typeParams[i].name, 0);
}
- long p = source.sourceStart;
- p = (p << 32) | source.sourceEnd;
+ long p = job.getPos();
- TypeReference parentArgument = typerefs == null ? generateTypeReference(tdParent, p) : generateParameterizedTypeReference(tdParent, typerefs, p);
+ TypeReference parentArgument = typerefs == null ? generateTypeReference(job.parentType, p) : generateParameterizedTypeReference(job.parentType, typerefs, p);
out.arguments = new Argument[] {new Argument(INSTANCE_VARIABLE_NAME, 0, parentArgument, Modifier.FINAL), builderArgument};
// Add type params if there are any.
- if (typeParams.length > 0) out.typeParameters = copyTypeParams(typeParams, source);
+ if (job.typeParams.length > 0) out.typeParameters = copyTypeParams(job.typeParams, job.source);
List<Statement> body = new ArrayList<Statement>();
// Call the builder's setter methods to fill the values from the instance.
- for (BuilderFieldData bfd : builderFields) {
- MessageSend exec = createSetterCallWithInstanceValue(bfd, tdParent, source, setterPrefix);
+ for (BuilderFieldData bfd : job.builderFields) {
+ MessageSend exec = createSetterCallWithInstanceValue(bfd, job.parentType, job.source, setterPrefix);
body.add(exec);
}
out.statements = body.isEmpty() ? null : body.toArray(new Statement[0]);
+ out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return out;
}
@@ -772,9 +818,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
ms.arguments = tgt;
} else {
Expression ifNull = new EqualExpression(tgt[0], new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL);
- MessageSend emptyCollection = new MessageSend();
- emptyCollection.receiver = generateQualifiedNameRef(source, bfd.singularData.getSingularizer().getEmptyMakerReceiver(bfd.singularData.getTargetFqn()));
- emptyCollection.selector = bfd.singularData.getSingularizer().getEmptyMakerSelector(bfd.singularData.getTargetFqn());
+ MessageSend emptyCollection = bfd.singularData.getSingularizer().getEmptyExpression(bfd.singularData.getTargetFqn(), bfd.singularData, type, source);
ms.arguments = new Expression[] {new ConditionalExpression(ifNull, emptyCollection, tgt[1])};
}
ms.receiver = new SingleNameReference(BUILDER_VARIABLE_NAME, 0);
@@ -782,14 +826,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
return ms;
}
- private MethodDeclaration generateAbstractSelfMethod(CheckerFrameworkVersion cfv, EclipseNode tdParent, boolean override, String builderGenericName) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) tdParent.top().get()).compilationResult);
+ private MethodDeclaration generateAbstractSelfMethod(BuilderJob job, boolean override, String builderGenericName) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.selector = SELF_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccAbstract | ClassFileConstants.AccProtected | ExtraCompilerModifiers.AccSemicolonBody;
- 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.generatePure() ? generateNamedAnnotation(tdParent.get(), CheckerFrameworkVersion.NAME__PURE): null;
+ Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.parentType.get()) : null;
+ Annotation rrAnn = job.checkerFramework.generateReturnsReceiver() ? generateNamedAnnotation(job.parentType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER): null;
+ Annotation sefAnn = job.checkerFramework.generatePure() ? generateNamedAnnotation(job.parentType.get(), CheckerFrameworkVersion.NAME__PURE): 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};
@@ -801,54 +845,52 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
return out;
}
- private MethodDeclaration generateSelfMethod(CheckerFrameworkVersion cfv, EclipseNode builderImplType, TypeParameter[] typeParams, long p) {
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderImplType.top().get()).compilationResult);
+ private MethodDeclaration generateSelfMethod(BuilderJob job) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.selector = SELF_METHOD_NAME;
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccProtected;
- Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get());
- Annotation rrAnn = cfv.generateReturnsReceiver() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) : null;
- Annotation sefAnn = cfv.generatePure() ? generateNamedAnnotation(builderImplType.get(), CheckerFrameworkVersion.NAME__PURE) : null;
+ Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.builderType.get());
+ Annotation rrAnn = job.checkerFramework.generateReturnsReceiver() ? generateNamedAnnotation(job.builderType.get(), CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) : null;
+ Annotation sefAnn = job.checkerFramework.generatePure() ? generateNamedAnnotation(job.builderType.get(), CheckerFrameworkVersion.NAME__PURE) : 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, typeParams, p);
+ out.returnType = namePlusTypeParamsToTypeReference(job.builderType, job.typeParams, job.getPos());
out.statements = new Statement[] {new ReturnStatement(new ThisReference(0, 0), 0, 0)};
return out;
}
- private MethodDeclaration generateAbstractBuildMethod(CheckerFrameworkVersion cfv, EclipseNode builderType, String methodName, List<BuilderFieldData> builderFields, boolean override,
- String classGenericName, ASTNode source) {
-
- MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
+ private MethodDeclaration generateAbstractBuildMethod(BuilderJob job, boolean override, String classGenericName) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract | ExtraCompilerModifiers.AccSemicolonBody;
- out.selector = methodName.toCharArray();
+ out.selector = job.buildMethodName.toCharArray();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.returnType = new SingleTypeReference(classGenericName.toCharArray(), 0);
- Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source) : null;
- Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ Annotation overrideAnn = override ? makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.source) : null;
+ Annotation sefAnn = job.checkerFramework.generateSideEffectFree() ? generateNamedAnnotation(job.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.receiver = HandleBuilder.generateBuildReceiver(cfv, builderType, builderFields, source);
- out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ out.receiver = HandleBuilder.generateBuildReceiver(job);
+ out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return out;
}
- 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);
+ private MethodDeclaration generateBuildMethod(BuilderJob job, TypeReference returnType) {
+ MethodDeclaration out = job.createNewMethodDeclaration();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
List<Statement> statements = new ArrayList<Statement>();
out.modifiers = ClassFileConstants.AccPublic;
- out.selector = name.toCharArray();
+ out.selector = job.buildMethodName.toCharArray();
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
out.returnType = returnType;
- Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, source);
- Annotation sefAnn = cfv.generateSideEffectFree() ? generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
+ Annotation overrideAnn = makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, job.source);
+ Annotation sefAnn = job.checkerFramework.generateSideEffectFree() ? generateNamedAnnotation(job.source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE): null;
if (sefAnn != null) out.annotations = new Annotation[] {overrideAnn, sefAnn};
else out.annotations = new Annotation[] {overrideAnn};
@@ -858,43 +900,44 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
allocationStatement.arguments = new Expression[] {new ThisReference(0, 0)};
statements.add(new ReturnStatement(allocationStatement, 0, 0));
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
- out.receiver = HandleBuilder.generateBuildReceiver(cfv, builderType, builderFields, source);
- createRelevantNonNullAnnotation(builderType, out);
- out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ out.receiver = HandleBuilder.generateBuildReceiver(job);
+ createRelevantNonNullAnnotation(job.builderType, out);
+ out.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return out;
}
- private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
+ private MethodDeclaration generateCleanMethod(BuilderJob job) {
List<Statement> statements = new ArrayList<Statement>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
+ bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, statements);
}
}
FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
thisUnclean.receiver = new ThisReference(0, 0);
statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
- MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
+ MethodDeclaration decl = job.createNewMethodDeclaration();
+ //new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
decl.selector = CLEAN_METHOD_NAME;
decl.modifiers = ClassFileConstants.AccPrivate;
decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
decl.statements = statements.toArray(new Statement[0]);
- decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
+ decl.traverse(new SetGeneratedByVisitor(job.source), (ClassScope) null);
return decl;
}
- private void generateBuilderFields(EclipseNode builderType, List<BuilderFieldData> builderFields, ASTNode source) {
+ private void generateBuilderFields(BuilderJob job) {
List<EclipseNode> existing = new ArrayList<EclipseNode>();
- for (EclipseNode child : builderType.down()) {
+ for (EclipseNode child : job.builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType));
+ bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType));
} else {
EclipseNode field = null, setFlag = null;
for (EclipseNode exists : existing) {
@@ -908,23 +951,23 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = copyType(bfd.type);
- fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
- field = injectFieldAndMarkGenerated(builderType, fd);
+ fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null);
+ field = injectFieldAndMarkGenerated(job.builderType, fd);
}
if (setFlag == null && bfd.nameOfSetFlag != null) {
FieldDeclaration fd = new FieldDeclaration(bfd.nameOfSetFlag, 0, 0);
fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
fd.modifiers = ClassFileConstants.AccPrivate;
fd.type = TypeReference.baseTypeReference(TypeIds.T_boolean, 0);
- fd.traverse(new SetGeneratedByVisitor(source), (MethodScope) null);
- injectFieldAndMarkGenerated(builderType, fd);
+ fd.traverse(new SetGeneratedByVisitor(job.source), (MethodScope) null);
+ injectFieldAndMarkGenerated(job.builderType, fd);
}
bfd.createdFields.add(field);
}
}
}
- private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, final String builderGenericName, String setterPrefix) {
+ private void generateSetterMethodsForBuilder(BuilderJob job, BuilderFieldData bfd, final String builderGenericName, String setterPrefix) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
TypeReferenceMaker returnTypeMaker = new TypeReferenceMaker() {
@@ -943,15 +986,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
};
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations, bfd.originalFieldNode, setterPrefix);
+ generateSimpleSetterMethodForBuilder(job, deprecate, bfd.createdFields.get(0), bfd.name, bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), bfd.annotations, bfd.originalFieldNode, setterPrefix);
} else {
- bfd.singularData.getSingularizer().generateMethods(cfv, bfd.singularData, deprecate, builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
+ bfd.singularData.getSingularizer().generateMethods(job.checkerFramework, bfd.singularData, deprecate, job.builderType, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
-
- private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam, EclipseNode originalFieldNode, String setterPrefix) {
- TypeDeclaration td = (TypeDeclaration) builderType.get();
- ASTNode source = sourceNode.get();
+
+ private void generateSimpleSetterMethodForBuilder(BuilderJob job, boolean deprecate, EclipseNode fieldNode, char[] paramName, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, Annotation[] annosOnParam, EclipseNode originalFieldNode, String setterPrefix) {
+ TypeDeclaration td = (TypeDeclaration) job.builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY_METHODS;
int len = existing.length;
@@ -965,23 +1007,14 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
List<Annotation> methodAnnsList = Arrays.asList(EclipseHandlerUtil.findCopyableToSetterAnnotations(originalFieldNode));
- if (cfv.generateReturnsReceiver()) {
+ if (job.checkerFramework.generateReturnsReceiver()) {
methodAnnsList = new ArrayList<Annotation>(methodAnnsList);
- methodAnnsList.add(generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER));
+ methodAnnsList.add(generateNamedAnnotation(job.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(source, annosOnParam)) : Collections.<Annotation>emptyList());
- if (cfv.generateCalledMethods()) {
- 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);
-
- QualifiedTypeReference typeReference = (QualifiedTypeReference) generateTypeReference(builderType, 0);
- typeReference.annotations = new Annotation[typeReference.tokens.length][];
- typeReference.annotations[0] = new Annotation[] {ann};
- setter.receiver = new Receiver(new char[] { 't', 'h', 'i', 's' }, 0, typeReference, null, Modifier.FINAL);
- }
- injectMethod(builderType, setter);
+ job.sourceNode, methodAnnsList, annosOnParam != null ? Arrays.asList(copyAnnotations(job.source, annosOnParam)) : Collections.<Annotation>emptyList());
+ if (job.checkerFramework.generateCalledMethods()) setter.receiver = generateNotCalledReceiver(job, setterName);
+ injectMethod(job.builderType, setter);
}
private void addObtainVia(BuilderFieldData bfd, EclipseNode node) {
@@ -1069,6 +1102,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// 3. Add used type names.
if (td.fields != null) {
for (FieldDeclaration field : td.fields) {
+ if (field instanceof Initializer) continue;
char[][] typeName = field.type.getTypeName();
if (typeName.length >= 1) // Add the first token, because only that can collide.
usedNames.add(String.valueOf(typeName[0]));
@@ -1171,7 +1205,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
if (!def.isConstructor()) continue;
if (isTolerate(type, def)) continue;
- if (def.arguments.length != 1) continue;
+ if (def.arguments == null || def.arguments.length != 1) continue;
// Cannot use typeMatches() here, because the parameter could be fully-qualified, partially-qualified, or not qualified.
// A string-compare of the last part should work. If it's a false-positive, users could still @Tolerate it.
diff --git a/src/core/lombok/eclipse/handlers/HandleSynchronized.java b/src/core/lombok/eclipse/handlers/HandleSynchronized.java
index 37d6755c..18d1e7b7 100644
--- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java
+++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -36,6 +36,7 @@ import lombok.eclipse.DeferUntilPostDiet;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
@@ -51,12 +52,11 @@ import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Synchronized} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@DeferUntilPostDiet
@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it.
public class HandleSynchronized extends EclipseAnnotationHandler<Synchronized> {
@@ -153,7 +153,6 @@ public class HandleSynchronized extends EclipseAnnotationHandler<Synchronized> {
annotationNode.addError("@Synchronized is legal only on methods in classes and enums.");
return;
}
-
boolean[] isStatic = { method.isStatic() };
char[] lockName = createLockField(annotation, annotationNode, isStatic, true);
if (lockName == null) return;
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java
index 9b58474c..72491277 100644
--- a/src/core/lombok/eclipse/handlers/HandleToString.java
+++ b/src/core/lombok/eclipse/handlers/HandleToString.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -51,7 +51,6 @@ import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
@@ -66,11 +65,12 @@ import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
/**
* Handles the {@code ToString} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleToString extends EclipseAnnotationHandler<ToString> {
public void handle(AnnotationValues<ToString> annotation, Annotation ast, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.TO_STRING_FLAG_USAGE, "@ToString");
diff --git a/src/core/lombok/eclipse/handlers/HandleUtilityClass.java b/src/core/lombok/eclipse/handlers/HandleUtilityClass.java
index 338aab0d..9a18b20b 100644
--- a/src/core/lombok/eclipse/handlers/HandleUtilityClass.java
+++ b/src/core/lombok/eclipse/handlers/HandleUtilityClass.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -25,8 +25,6 @@ import static lombok.core.handlers.HandlerUtil.*;
import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
-import java.util.Arrays;
-
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
@@ -45,7 +43,6 @@ import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.ConfigurationKeys;
import lombok.core.AnnotationValues;
@@ -54,12 +51,13 @@ import lombok.core.AST.Kind;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.UtilityClass;
+import lombok.spi.Provides;
/**
* Handles the {@code lombok.experimental.UtilityClass} annotation for eclipse.
*/
+@Provides
@HandlerPriority(-4096) //-2^12; to ensure @FieldDefaults picks up on the 'static' we set here.
-@ProviderFor(EclipseAnnotationHandler.class)
public class HandleUtilityClass extends EclipseAnnotationHandler<UtilityClass> {
@Override public void handle(AnnotationValues<UtilityClass> annotation, Annotation ast, EclipseNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.UTILITY_CLASS_FLAG_USAGE, "@UtilityClass");
@@ -71,7 +69,7 @@ public class HandleUtilityClass extends EclipseAnnotationHandler<UtilityClass> {
private static boolean checkLegality(EclipseNode typeNode, EclipseNode errorNode) {
if (!isClass(typeNode)) {
- errorNode.addError("@UtilityClass is only supported on a class (can't be an interface, enum, annotation, or record).");
+ errorNode.addError("@UtilityClass is only supported on a class.");
return false;
}
@@ -153,37 +151,28 @@ public class HandleUtilityClass extends EclipseAnnotationHandler<UtilityClass> {
ASTNode source = sourceNode.get();
TypeDeclaration typeDeclaration = ((TypeDeclaration) typeNode.get());
- long p = (long) source.sourceStart << 32 | source.sourceEnd;
ConstructorDeclaration constructor = new ConstructorDeclaration(((CompilationUnitDeclaration) typeNode.top().get()).compilationResult);
constructor.modifiers = ClassFileConstants.AccPrivate;
constructor.selector = typeDeclaration.name;
constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
- constructor.constructorCall.sourceStart = source.sourceStart;
- constructor.constructorCall.sourceEnd = source.sourceEnd;
constructor.thrownExceptions = null;
constructor.typeParameters = null;
constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
- constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = source.sourceStart;
- constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = source.sourceEnd;
constructor.arguments = null;
- AllocationExpression exception = new AllocationExpression();
- setGeneratedBy(exception, source);
long[] ps = new long[JAVA_LANG_UNSUPPORTED_OPERATION_EXCEPTION.length];
- Arrays.fill(ps, p);
+ AllocationExpression exception = new AllocationExpression();
exception.type = new QualifiedTypeReference(JAVA_LANG_UNSUPPORTED_OPERATION_EXCEPTION, ps);
- setGeneratedBy(exception.type, source);
exception.arguments = new Expression[] {
- new StringLiteral(UNSUPPORTED_MESSAGE, source.sourceStart, source.sourceEnd, 0)
+ new StringLiteral(UNSUPPORTED_MESSAGE, 0, 0, 0)
};
- setGeneratedBy(exception.arguments[0], source);
- ThrowStatement throwStatement = new ThrowStatement(exception, source.sourceStart, source.sourceEnd);
- setGeneratedBy(throwStatement, source);
+ ThrowStatement throwStatement = new ThrowStatement(exception, 0, 0);
constructor.statements = new Statement[] {throwStatement};
+ constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
injectMethod(typeNode, constructor);
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java
index 3742ac00..ac53e27e 100644
--- a/src/core/lombok/eclipse/handlers/HandleVal.java
+++ b/src/core/lombok/eclipse/handlers/HandleVal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2018 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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.eclipse.DeferUntilPostDiet;
import lombok.eclipse.EclipseASTAdapter;
import lombok.eclipse.EclipseASTVisitor;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
@@ -39,12 +40,11 @@ import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.mangosdk.spi.ProviderFor;
/*
* This class just handles 3 basic error cases. The real meat of eclipse 'val' support is in {@code PatchVal} and {@code PatchValEclipse}.
*/
-@ProviderFor(EclipseASTVisitor.class)
+@Provides(EclipseASTVisitor.class)
@DeferUntilPostDiet
@HandlerPriority(65536) // 2^16; resolution needs to work, so if the RHS expression is i.e. a call to a generated getter, we have to run after that getter has been generated.
public class HandleVal extends EclipseASTAdapter {
diff --git a/src/core/lombok/eclipse/handlers/HandleValue.java b/src/core/lombok/eclipse/handlers/HandleValue.java
index abea5603..7a73e5ed 100644
--- a/src/core/lombok/eclipse/handlers/HandleValue.java
+++ b/src/core/lombok/eclipse/handlers/HandleValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -34,17 +34,17 @@ import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.HandleConstructor.SkipIfConstructorExists;
import lombok.experimental.NonFinal;
+import lombok.spi.Provides;
import lombok.Value;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
/**
* Handles the {@code lombok.Value} annotation for eclipse.
*/
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
@HandlerPriority(-512) //-2^9; to ensure @EqualsAndHashCode and such pick up on this handler making the class final and messing with the fields' access levels, run earlier.
public class HandleValue extends EclipseAnnotationHandler<Value> {
private HandleFieldDefaults handleFieldDefaults = new HandleFieldDefaults();
@@ -59,13 +59,11 @@ public class HandleValue extends EclipseAnnotationHandler<Value> {
Value ann = annotation.getInstance();
EclipseNode typeNode = annotationNode.up();
- TypeDeclaration typeDecl = null;
- if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
-
if (!isClass(typeNode)) {
annotationNode.addError("@Value is only supported on a class.");
return;
}
+ TypeDeclaration typeDecl = (TypeDeclaration) typeNode.get();
// Make class final.
if (!hasAnnotation(NonFinal.class, typeNode)) {
diff --git a/src/core/lombok/eclipse/handlers/HandleWith.java b/src/core/lombok/eclipse/handlers/HandleWith.java
index 83357710..bfad682b 100644
--- a/src/core/lombok/eclipse/handlers/HandleWith.java
+++ b/src/core/lombok/eclipse/handlers/HandleWith.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2020 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
@@ -57,9 +58,8 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
-import org.mangosdk.spi.ProviderFor;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleWith extends EclipseAnnotationHandler<With> {
public boolean generateWithForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWith) {
if (checkForTypeLevelWith) {
@@ -290,6 +290,7 @@ public class HandleWith extends EclipseAnnotationHandler<With> {
EclipseHandlerUtil.createRelevantNonNullAnnotation(fieldNode, method);
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
+ copyJavadoc(fieldNode, method, CopyJavadoc.WITH);
return method;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleWithBy.java b/src/core/lombok/eclipse/handlers/HandleWithBy.java
index 5f229aaf..a8d13a84 100644
--- a/src/core/lombok/eclipse/handlers/HandleWithBy.java
+++ b/src/core/lombok/eclipse/handlers/HandleWithBy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -51,7 +51,6 @@ import org.eclipse.jdt.internal.compiler.ast.Wildcard;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
@@ -63,8 +62,9 @@ import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.WithBy;
+import lombok.spi.Provides;
-@ProviderFor(EclipseAnnotationHandler.class)
+@Provides
public class HandleWithBy extends EclipseAnnotationHandler<WithBy> {
public boolean generateWithByForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWithBy) {
if (checkForTypeLevelWithBy) {
@@ -373,6 +373,7 @@ public class HandleWithBy extends EclipseAnnotationHandler<WithBy> {
createRelevantNonNullAnnotation(fieldNode, method);
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
+ copyJavadoc(fieldNode, method, CopyJavadoc.WITH_BY);
return method;
}
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaMapSingularizer.java
index 5956c01b..088a4506 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaMapSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,12 +21,11 @@
*/
package lombok.eclipse.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
+import lombok.spi.Provides;
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseGuavaMapSingularizer extends EclipseGuavaSingularizer {
// TODO cgcc.ImmutableMultimap, cgcc.ImmutableListMultimap, cgcc.ImmutableSetMultimap
// TODO cgcc.ImmutableClassToInstanceMap
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSetListSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSetListSingularizer.java
index 326a9179..1f3603da 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSetListSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSetListSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,12 +21,11 @@
*/
package lombok.eclipse.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
+import lombok.spi.Provides;
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseGuavaSetListSingularizer extends EclipseGuavaSingularizer {
// TODO com.google.common.collect.ImmutableRangeSet
// TODO com.google.common.collect.ImmutableMultiset and com.google.common.collect.ImmutableSortedMultiset
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index 395d2e59..7dcf18c9 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -279,7 +279,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
protected abstract String getAddMethodName();
protected abstract String getAddAllTypeName();
- protected int getTypeArgumentsCount() {
+ @Override protected int getTypeArgumentsCount() {
return getArgumentSuffixes().size();
}
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaTableSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaTableSingularizer.java
index 4d25811b..ee92ad5a 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaTableSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaTableSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,12 +21,11 @@
*/
package lombok.eclipse.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
+import lombok.spi.Provides;
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseGuavaTableSingularizer extends EclipseGuavaSingularizer {
private static final LombokImmutableList<String> SUFFIXES =
LombokImmutableList.of("rowKey", "columnKey", "value");
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
index deab4530..882b7adc 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -156,7 +156,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
-
+
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
@@ -194,9 +194,13 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
-
+
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
+
+ @Override protected int getTypeArgumentsCount() {
+ return 1;
+ }
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
index bf50aef6..0d0f3130 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2019 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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.eclipse.Eclipse;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
@@ -45,10 +46,8 @@ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseJavaUtilListSingularizer extends EclipseJavaUtilListSetSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.List", "java.util.Collection", "java.lang.Iterable");
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index 1a40369d..a766612f 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,7 +50,6 @@ import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.mangosdk.spi.ProviderFor;
import lombok.AccessLevel;
import lombok.core.LombokImmutableList;
@@ -62,8 +61,9 @@ import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker;
import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker;
import lombok.eclipse.handlers.HandleNonNull;
+import lombok.spi.Provides;
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.Map", "java.util.SortedMap", "java.util.NavigableMap");
@@ -349,4 +349,8 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
statements.addAll(createJavaUtilSimpleCreationAndFillStatements(data, builderType, true, true, false, true, "TreeMap", builderVariable));
}
}
+
+ @Override protected int getTypeArgumentsCount() {
+ return 2;
+ }
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
index 2076ec7d..a432f3fe 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilSetSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2019 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -27,11 +27,11 @@ import lombok.core.LombokImmutableList;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
+import lombok.spi.Provides;
import org.eclipse.jdt.internal.compiler.ast.Statement;
-import org.mangosdk.spi.ProviderFor;
-@ProviderFor(EclipseSingularizer.class)
+@Provides(EclipseSingularizer.class)
public class EclipseJavaUtilSetSingularizer extends EclipseJavaUtilListSetSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.Set", "java.util.SortedSet", "java.util.NavigableSet");
diff --git a/src/core/lombok/javac/CompilerMessageSuppressor.java b/src/core/lombok/javac/CompilerMessageSuppressor.java
index 02dc6c26..7d7b81e6 100644
--- a/src/core/lombok/javac/CompilerMessageSuppressor.java
+++ b/src/core/lombok/javac/CompilerMessageSuppressor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2013 The Project Lombok Authors.
+ * Copyright (C) 2011-2021 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
@@ -226,7 +226,7 @@ public final class CompilerMessageSuppressor {
ListBuffer<Object> newDeferredDiagnostics = new ListBuffer<Object>();
for (Object diag_ : deferredDiagnostics) {
if (!(diag_ instanceof JCDiagnostic)) {
- newDeferredDiagnostics.add(diag_);
+ newDeferredDiagnostics.append(diag_);
continue;
}
JCDiagnostic diag = (JCDiagnostic) diag_;
@@ -234,7 +234,7 @@ public final class CompilerMessageSuppressor {
if (here >= startPos && here < endPos && diag.getSource() == sourcefile) {
// We eliminate it
} else {
- newDeferredDiagnostics.add(diag);
+ newDeferredDiagnostics.append(diag);
}
}
field.set(receiver, newDeferredDiagnostics);
diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java
index 9e7b8fe5..c2bf8512 100644
--- a/src/core/lombok/javac/HandlerLibrary.java
+++ b/src/core/lombok/javac/HandlerLibrary.java
@@ -65,7 +65,7 @@ public class HandlerLibrary {
/**
* Creates a new HandlerLibrary that will report any problems or errors to the provided messager.
- * You probably want to use {@link #load(Messager)} instead.
+ * You probably want to use {@link #load(Messager, Trees)} instead.
*/
public HandlerLibrary(Messager messager) {
ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys();
diff --git a/src/core/lombok/javac/Javac6BasedLombokOptions.java b/src/core/lombok/javac/Javac6BasedLombokOptions.java
index fc73181c..93f448a7 100644
--- a/src/core/lombok/javac/Javac6BasedLombokOptions.java
+++ b/src/core/lombok/javac/Javac6BasedLombokOptions.java
@@ -58,7 +58,7 @@ public class Javac6BasedLombokOptions extends LombokOptions {
@Override public void putJavacOption(String optionName, String value) {
try {
- options_put.invoke(this, optionName_valueOf.invoke(null, optionName), value);
+ Permit.invoke(options_put, this, Permit.invoke(optionName_valueOf, null, optionName), value);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Can't initialize Javac6-based lombok options due to reflection issue.", e);
} catch (InvocationTargetException e) {
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index 86ff7646..f58de60f 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2020 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.javac;
+import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URI;
@@ -110,14 +111,97 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
return memoizedAbsoluteFileLocation;
}
+ private static Class<?> wrappedFileObjectClass, sbtJavaFileObjectClass, sbtMappedVirtualFileClass, sbtOptionClass;
+ private static Field wrappedFileObjectField, sbtJavaFileObjectField, sbtMappedVirtualFilePathField, sbtMappedVirtualFileRootsField, sbtOptionField;
+ private static Method sbtMapGetMethod;
+
public static URI getAbsoluteFileLocation(JCCompilationUnit cu) {
try {
- return cu.sourcefile.toUri();
+ URI uri = cu.sourcefile.toUri();
+ String fn = uri.toString();
+ if (fn.startsWith("file:")) return uri;
+ URI sbtUri = tryGetSbtFile(cu.sourcefile);
+ if (sbtUri != null) return sbtUri;
+ return uri;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static URI tryGetSbtFile(JavaFileObject sourcefile) {
+ try {
+ return tryGetSbtFile_(sourcefile);
} catch (Exception e) {
return null;
}
}
+ private static URI tryGetSbtFile_(JavaFileObject sourcefile) throws Exception {
+ Class<?> c = sourcefile.getClass();
+ String cn;
+
+ if (wrappedFileObjectClass == null) {
+ if (!c.getName().equals("com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileObject")) return null;
+ wrappedFileObjectClass = c;
+ }
+ if (c != wrappedFileObjectClass) return null;
+
+ if (wrappedFileObjectField == null) wrappedFileObjectField = Permit.permissiveGetField(wrappedFileObjectClass.getSuperclass(), "clientFileObject");
+ if (wrappedFileObjectField == null) return null;
+ Object fileObject = wrappedFileObjectField.get(sourcefile);
+ c = fileObject.getClass();
+
+ if (sbtJavaFileObjectClass == null) {
+ cn = c.getName();
+ if (!cn.startsWith("sbt.") || !cn.endsWith("JavaFileObject")) return null;
+ sbtJavaFileObjectClass = c;
+ }
+ if (sbtJavaFileObjectClass != c) return null;
+ if (sbtJavaFileObjectField == null) sbtJavaFileObjectField = Permit.permissiveGetField(sbtJavaFileObjectClass, "underlying");
+ if (sbtJavaFileObjectField == null) return null;
+
+ Object mappedVirtualFile = sbtJavaFileObjectField.get(fileObject);
+ c = mappedVirtualFile.getClass();
+
+ if (sbtMappedVirtualFileClass == null) {
+ cn = c.getName();
+ if (!cn.startsWith("sbt.") || !cn.endsWith("MappedVirtualFile")) return null;
+ sbtMappedVirtualFileClass = c;
+ }
+ if (sbtMappedVirtualFilePathField == null) sbtMappedVirtualFilePathField = Permit.permissiveGetField(sbtMappedVirtualFileClass, "encodedPath");
+ if (sbtMappedVirtualFilePathField == null) return null;
+ if (sbtMappedVirtualFileRootsField == null) sbtMappedVirtualFileRootsField = Permit.permissiveGetField(sbtMappedVirtualFileClass, "rootPathsMap");
+ if (sbtMappedVirtualFileRootsField == null) return null;
+
+ String encodedPath = (String) sbtMappedVirtualFilePathField.get(mappedVirtualFile);
+ if (!encodedPath.startsWith("${")) {
+ File maybeAbsoluteFile = new File(encodedPath);
+ if (maybeAbsoluteFile.exists()) {
+ return maybeAbsoluteFile.toURI();
+ } else {
+ return null;
+ }
+ }
+ int idx = encodedPath.indexOf('}');
+ if (idx == -1) return null;
+ String base = encodedPath.substring(2, idx);
+ Object roots = sbtMappedVirtualFileRootsField.get(mappedVirtualFile);
+ if (sbtMapGetMethod == null) sbtMapGetMethod = Permit.getMethod(roots.getClass(), "get", Object.class);
+ if (sbtMapGetMethod == null) return null;
+
+ Object option = sbtMapGetMethod.invoke(roots, base);
+ c = option.getClass();
+ if (sbtOptionClass == null) {
+ if (c.getName().equals("scala.Some")) sbtOptionClass = c;
+ }
+ if (c != sbtOptionClass) return null;
+ if (sbtOptionField == null) sbtOptionField = Permit.permissiveGetField(sbtOptionClass, "value");
+ if (sbtOptionField == null) return null;
+
+ Object path = sbtOptionField.get(option);
+ return new File(path.toString() + encodedPath.substring(idx + 1)).toURI();
+ }
+
private static String sourceName(JCCompilationUnit cu) {
return cu.sourcefile == null ? null : cu.sourcefile.toString();
}
@@ -397,11 +481,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
}
private JCTree getBody(JCTree jcTree) {
- try {
- return (JCTree) getBodyMethod(jcTree.getClass()).invoke(jcTree);
- } catch (Exception e) {
- throw Javac.sneakyThrow(e);
- }
+ return (JCTree) Permit.invokeSneaky(getBodyMethod(jcTree.getClass()), jcTree);
}
private final static ConcurrentMap<Class<?>, Method> getBodyMethods = new ConcurrentHashMap<Class<?>, Method>();
@@ -662,42 +742,26 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
}
@Override void error1(DiagnosticPosition pos, String message) {
- try {
- Object error = this.errorKey.invoke(diags, PROC_MESSAGER, new Object[] { message });
- errorMethod.invoke(log, multiple, pos, error);
- } catch (Throwable t) {
- //t.printStackTrace();
- }
+ Object error = Permit.invokeSneaky(this.errorKey, diags, PROC_MESSAGER, new Object[] { message });
+ if (error != null) Permit.invokeSneaky(errorMethod, log, multiple, pos, error);
}
@Override
void warning1(DiagnosticPosition pos, String message) {
- try {
- Object warning = this.warningKey.invoke(diags, PROC_MESSAGER, new Object[] { message });
- warningMethod.invoke(log, pos, warning);
- } catch (Throwable t) {
- //t.printStackTrace();
- }
+ Object warning = Permit.invokeSneaky(this.warningKey, diags, PROC_MESSAGER, new Object[] { message });
+ if (warning != null) Permit.invokeSneaky(warningMethod, log, pos, warning);
}
@Override
void mandatoryWarning1(DiagnosticPosition pos, String message) {
- try {
- Object warning = this.warningKey.invoke(diags, PROC_MESSAGER, new Object[] { message });
- mandatoryWarningMethod.invoke(log, pos, warning);
- } catch (Throwable t) {
- //t.printStackTrace();
- }
+ Object warning = Permit.invokeSneaky(this.warningKey, diags, PROC_MESSAGER, new Object[] { message });
+ if (warning != null) Permit.invokeSneaky(mandatoryWarningMethod, log, pos, warning);
}
@Override
void note(DiagnosticPosition pos, String message) {
- try {
- Object note = this.noteKey.invoke(diags, PROC_MESSAGER, new Object[] { message });
- noteMethod.invoke(log, pos, note);
- } catch (Throwable t) {
- //t.printStackTrace();
- }
+ Object note = Permit.invokeSneaky(this.noteKey, diags, PROC_MESSAGER, new Object[] { message });
+ if (note != null) Permit.invokeSneaky(noteMethod, log, pos, note);
}
}
}
diff --git a/src/core/lombok/javac/JavacASTVisitor.java b/src/core/lombok/javac/JavacASTVisitor.java
index 9b67dda3..e8fd295c 100644
--- a/src/core/lombok/javac/JavacASTVisitor.java
+++ b/src/core/lombok/javac/JavacASTVisitor.java
@@ -22,6 +22,7 @@
package lombok.javac;
import java.io.PrintStream;
+import java.lang.reflect.Field;
import com.sun.source.util.Trees;
import com.sun.tools.javac.code.Flags;
@@ -32,6 +33,7 @@ import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.util.List;
/**
* Implement so you can ask any JavacAST.LombokNode to traverse depth-first through all children,
@@ -223,6 +225,26 @@ public interface JavacASTVisitor {
} else type = "METHOD";
print("<%s %s> %s returns: %s", type, method.name, printFlags(method.mods.flags), method.restype);
indent++;
+ JCVariableDecl recv;
+ try {
+ Field f = JCMethodDecl.class.getField("recvparam");
+ recv = (JCVariableDecl) f.get(method);
+ } catch (Exception ignore) {
+ recv = null;
+ }
+
+ if (recv != null) {
+ List<JCAnnotation> annotations = recv.mods.annotations;
+ if (recv.mods != null) annotations = recv.mods.annotations;
+ boolean innerContent = annotations != null && annotations.isEmpty();
+ print("<RECEIVER-PARAM (%s) %s %s%s> %s", recv.vartype == null ? "null" : recv.vartype.getClass().toString(), recv.vartype, recv.name, innerContent ? "" : " /", printFlags(recv.mods.flags));
+ if (innerContent) {
+ indent++;
+ for (JCAnnotation ann : annotations) print("<ANNOTATION: %s />", ann);
+ indent--;
+ print("</RECEIVER-PARAM>");
+ }
+ }
if (printContent) {
if (method.body == null) print("(ABSTRACT)");
else print("%s", method.body);
@@ -237,11 +259,11 @@ public interface JavacASTVisitor {
@Override public void endVisitMethod(JavacNode node, JCMethodDecl method) {
if (printContent) disablePrinting--;
indent--;
- print("</%s %s>", "XMETHOD", method.name);
+ print("</%s %s>", "METHOD", method.name);
}
@Override public void visitMethodArgument(JavacNode node, JCVariableDecl arg, JCMethodDecl method) {
- print("<METHODARG %s %s> %s", arg.vartype, arg.name, printFlags(arg.mods.flags));
+ print("<METHODARG (%s) %s %s> %s", arg.vartype.getClass().toString(), arg.vartype, arg.name, printFlags(arg.mods.flags));
indent++;
}
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index e648cd51..035f7c53 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 6b2f4637..e96079e0 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -25,7 +25,6 @@ import static lombok.javac.Javac.*;
import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Collection;
@@ -65,7 +64,6 @@ import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Name;
-import lombok.Lombok;
import lombok.core.debug.AssertionLogger;
import lombok.permit.Permit;
@@ -73,6 +71,16 @@ public class JavacResolution {
private final Attr attr;
private final CompilerMessageSuppressor messageSuppressor;
+ private static final Method isLocal;
+
+ static {
+ Method local = Permit.permissiveGetMethod(TypeSymbol.class, "isLocal");
+ if (local == null) {
+ local = Permit.permissiveGetMethod(TypeSymbol.class, "isDirectlyOrIndirectlyLocal");
+ }
+ isLocal = local;
+ }
+
public JavacResolution(Context context) {
attr = Attr.instance(context);
messageSuppressor = new CompilerMessageSuppressor(context);
@@ -251,27 +259,27 @@ public class JavacResolution {
private static class ReflectiveAccess {
private static Method UPPER_BOUND;
+ private static Throwable initError;
static {
Method upperBound = null;
try {
upperBound = Permit.getMethod(Types.class, "upperBound", Type.class);
- } catch (Throwable ignore) {}
+ } catch (Throwable e) {
+ initError = e;
+ }
+
if (upperBound == null) try {
upperBound = Permit.getMethod(Types.class, "wildUpperBound", Type.class);
- } catch (Throwable ignore) {}
+ } catch (Throwable e) {
+ initError = e;
+ }
UPPER_BOUND = upperBound;
}
public static Type Types_upperBound(Types types, Type type) {
- try {
- return (Type) UPPER_BOUND.invoke(types, type);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
- } catch (Exception e) {
- throw Lombok.sneakyThrow(e);
- }
+ return (Type) Permit.invokeSneaky(initError, UPPER_BOUND, types, type);
}
}
@@ -354,6 +362,15 @@ public class JavacResolution {
return a.compareTo(b);
}
+ private static boolean isLocalType(TypeSymbol symbol) {
+ try {
+ return (Boolean) Permit.invoke(isLocal, symbol);
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid, boolean allowCapture) throws TypeNotConvertibleException {
// NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too.
// -- so we write our own take on that here.
@@ -452,7 +469,7 @@ public class JavacResolution {
}
String qName;
- if (symbol.isLocal()) {
+ if (isLocalType(symbol)) {
qName = symbol.getSimpleName().toString();
} else if (symbol.type != null && symbol.type.getEnclosingType() != null && typeTag(symbol.type.getEnclosingType()).equals(typeTag("CLASS"))) {
replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false, false);
diff --git a/src/core/lombok/javac/apt/InterceptingJavaFileObject.java b/src/core/lombok/javac/apt/InterceptingJavaFileObject.java
index 368928d4..75cf0713 100644
--- a/src/core/lombok/javac/apt/InterceptingJavaFileObject.java
+++ b/src/core/lombok/javac/apt/InterceptingJavaFileObject.java
@@ -26,7 +26,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.nio.charset.CharsetDecoder;
@@ -35,9 +34,9 @@ import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
-import lombok.Lombok;
import lombok.core.DiagnosticsReceiver;
import lombok.core.PostCompiler;
+import lombok.permit.Permit;
final class InterceptingJavaFileObject implements LombokFileObject {
private final JavaFileObject delegate;
@@ -63,16 +62,8 @@ final class InterceptingJavaFileObject implements LombokFileObject {
}
@Override public CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
- if (decoderMethod == null) {
- throw new UnsupportedOperationException();
- }
- try {
- return (CharsetDecoder) decoderMethod.invoke(delegate, ignoreEncodingErrors);
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e);
- }
+ if (decoderMethod == null) throw new UnsupportedOperationException();
+ return (CharsetDecoder) Permit.invokeSneaky(decoderMethod, delegate, ignoreEncodingErrors);
}
@Override public boolean equals(Object obj) {
diff --git a/src/core/lombok/javac/apt/LombokProcessor.java b/src/core/lombok/javac/apt/LombokProcessor.java
index 852e5de6..6552f15b 100644
--- a/src/core/lombok/javac/apt/LombokProcessor.java
+++ b/src/core/lombok/javac/apt/LombokProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2020 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
@@ -24,8 +24,10 @@ package lombok.javac.apt;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -61,6 +63,8 @@ import lombok.core.CleanupRegistry;
import lombok.core.DiagnosticsReceiver;
import lombok.javac.JavacTransformer;
import lombok.permit.Permit;
+import lombok.permit.dummy.Parent;
+import sun.misc.Unsafe;
/**
* This Annotation Processor is the standard injection mechanism for lombok-enabling the javac compiler.
@@ -154,10 +158,10 @@ public class LombokProcessor extends AbstractProcessor {
disablePartialReparseInNetBeansEditor(context);
try {
Method keyMethod = Permit.getMethod(Context.class, "key", Class.class);
- Object key = keyMethod.invoke(context, JavaFileManager.class);
+ Object key = Permit.invoke(keyMethod, context, JavaFileManager.class);
Field htField = Permit.getField(Context.class, "ht");
@SuppressWarnings("unchecked")
- Map<Object,Object> ht = (Map<Object,Object>) htField.get(context);
+ Map<Object,Object> ht = (Map<Object,Object>) Permit.get(htField, context);
final JavaFileManager originalFiler = (JavaFileManager) ht.get(key);
if (!(originalFiler instanceof InterceptingJavaFileManager)) {
final Messager messager = processingEnv.getMessager();
@@ -180,10 +184,10 @@ public class LombokProcessor extends AbstractProcessor {
private void replaceFileManagerJdk9(Context context, JavaFileManager newFiler) {
try {
- JavaCompiler compiler = (JavaCompiler) Permit.getMethod(JavaCompiler.class, "instance", Context.class).invoke(null, context);
+ JavaCompiler compiler = (JavaCompiler) Permit.invoke(Permit.getMethod(JavaCompiler.class, "instance", Context.class), null, context);
try {
Field fileManagerField = Permit.getField(JavaCompiler.class, "fileManager");
- fileManagerField.set(compiler, newFiler);
+ Permit.set(fileManagerField, compiler, newFiler);
}
catch (Exception e) {}
@@ -191,7 +195,7 @@ public class LombokProcessor extends AbstractProcessor {
Field writerField = Permit.getField(JavaCompiler.class, "writer");
ClassWriter writer = (ClassWriter) writerField.get(compiler);
Field fileManagerField = Permit.getField(ClassWriter.class, "fileManager");
- fileManagerField.set(writer, newFiler);
+ Permit.set(fileManagerField, writer, newFiler);
}
catch (Exception e) {}
}
@@ -213,8 +217,8 @@ public class LombokProcessor extends AbstractProcessor {
private void disablePartialReparseInNetBeansEditor(Context context) {
try {
Class<?> cancelServiceClass = Class.forName("com.sun.tools.javac.util.CancelService");
- Method cancelServiceInstace = Permit.getMethod(cancelServiceClass, "instance", Context.class);
- Object cancelService = cancelServiceInstace.invoke(null, context);
+ Method cancelServiceInstance = Permit.getMethod(cancelServiceClass, "instance", Context.class);
+ Object cancelService = Permit.invoke(cancelServiceInstance, null, context);
if (cancelService == null) return;
Field parserField = Permit.getField(cancelService.getClass(), "parser");
Object parser = parserField.get(cancelService);
@@ -386,8 +390,8 @@ public class LombokProcessor extends AbstractProcessor {
try {
if (qualifiedNamableClass == null) qualifiedNamableClass = Class.forName("javax.lang.model.element.QualifiedNamable");
if (!qualifiedNamableClass.isInstance(element)) return null;
- if (qualifiedNamableQualifiedNameMethod == null) qualifiedNamableQualifiedNameMethod = qualifiedNamableClass.getMethod("getQualifiedName");
- String name = qualifiedNamableQualifiedNameMethod.invoke(element).toString().trim();
+ if (qualifiedNamableQualifiedNameMethod == null) qualifiedNamableQualifiedNameMethod = Permit.getMethod(qualifiedNamableClass, "getQualifiedName");
+ String name = Permit.invoke(qualifiedNamableQualifiedNameMethod, element).toString().trim();
return name.isEmpty() ? null : name;
} catch (ClassNotFoundException e) {
return null;
@@ -428,22 +432,108 @@ public class LombokProcessor extends AbstractProcessor {
* gradle incremental compilation, the delegate ProcessingEnvironment of the gradle wrapper is returned.
*/
public JavacProcessingEnvironment getJavacProcessingEnvironment(Object procEnv) {
+ addOpensForLombok();
if (procEnv instanceof JavacProcessingEnvironment) return (JavacProcessingEnvironment) procEnv;
// try to find a "delegate" field in the object, and use this to try to obtain a JavacProcessingEnvironment
for (Class<?> procEnvClass = procEnv.getClass(); procEnvClass != null; procEnvClass = procEnvClass.getSuperclass()) {
- try {
- return getJavacProcessingEnvironment(tryGetDelegateField(procEnvClass, procEnv));
- } catch (final Exception e) {
- // delegate field was not found, try on superclass
- }
+ Object delegate = tryGetDelegateField(procEnvClass, procEnv);
+ if (delegate == null) delegate = tryGetProxyDelegateToField(procEnvClass, procEnv);
+ if (delegate == null) delegate = tryGetProcessingEnvField(procEnvClass, procEnv);
+
+ if (delegate != null) return getJavacProcessingEnvironment(delegate);
+ // delegate field was not found, try on superclass
}
processingEnv.getMessager().printMessage(Kind.WARNING,
"Can't get the delegate of the gradle IncrementalProcessingEnvironment. Lombok won't work.");
return null;
}
-
+
+ private static Object getOwnModule() {
+ try {
+ Method m = Permit.getMethod(Class.class, "getModule");
+ return m.invoke(LombokProcessor.class);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private static Object getJdkCompilerModule() {
+ /* call public api: ModuleLayer.boot().findModule("jdk.compiler").get();
+ but use reflection because we don't want this code to crash on jdk1.7 and below.
+ In that case, none of this stuff was needed in the first place, so we just exit via
+ the catch block and do nothing.
+ */
+
+ try {
+ Class<?> cModuleLayer = Class.forName("java.lang.ModuleLayer");
+ Method mBoot = cModuleLayer.getDeclaredMethod("boot");
+ Object bootLayer = mBoot.invoke(null);
+ Class<?> cOptional = Class.forName("java.util.Optional");
+ Method mFindModule = cModuleLayer.getDeclaredMethod("findModule", String.class);
+ Object oCompilerO = mFindModule.invoke(bootLayer, "jdk.compiler");
+ return cOptional.getDeclaredMethod("get").invoke(oCompilerO);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /** Useful from jdk9 and up; required from jdk16 and up. This code is supposed to gracefully do nothing on jdk8 and below, as this operation isn't needed there. */
+ public static void addOpensForLombok() {
+ Class<?> cModule;
+ try {
+ cModule = Class.forName("java.lang.Module");
+ } catch (ClassNotFoundException e) {
+ return; //jdk8-; this is not needed.
+ }
+
+ Unsafe unsafe = getUnsafe();
+ Object jdkCompilerModule = getJdkCompilerModule();
+ Object ownModule = getOwnModule();
+ String[] allPkgs = {
+ "com.sun.tools.javac.code",
+ "com.sun.tools.javac.comp",
+ "com.sun.tools.javac.file",
+ "com.sun.tools.javac.main",
+ "com.sun.tools.javac.model",
+ "com.sun.tools.javac.parser",
+ "com.sun.tools.javac.processing",
+ "com.sun.tools.javac.tree",
+ "com.sun.tools.javac.util",
+ "com.sun.tools.javac.jvm",
+ };
+
+ try {
+ Method m = cModule.getDeclaredMethod("implAddOpens", String.class, cModule);
+ long firstFieldOffset = getFirstFieldOffset(unsafe);
+ unsafe.putBooleanVolatile(m, firstFieldOffset, true);
+ for (String p : allPkgs) m.invoke(jdkCompilerModule, p, ownModule);
+ } catch (Exception ignore) {}
+ }
+
+ private static long getFirstFieldOffset(Unsafe unsafe) {
+ try {
+ return unsafe.objectFieldOffset(Parent.class.getDeclaredField("first"));
+ } catch (NoSuchFieldException e) {
+ // can't happen.
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ // can't happen
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Unsafe getUnsafe() {
+ try {
+ Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
+ theUnsafe.setAccessible(true);
+ return (Unsafe) theUnsafe.get(null);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
/**
* This class returns the given filer as a JavacFiler. In case the filer is no
* JavacFiler (e.g. the Gradle IncrementalFiler), its "delegate" field is used to get the JavacFiler
@@ -454,11 +544,12 @@ public class LombokProcessor extends AbstractProcessor {
// try to find a "delegate" field in the object, and use this to check for a JavacFiler
for (Class<?> filerClass = filer.getClass(); filerClass != null; filerClass = filerClass.getSuperclass()) {
- try {
- return getJavacFiler(tryGetDelegateField(filerClass, filer));
- } catch (final Exception e) {
- // delegate field was not found, try on superclass
- }
+ Object delegate = tryGetDelegateField(filerClass, filer);
+ if (delegate == null) delegate = tryGetProxyDelegateToField(filerClass, filer);
+ if (delegate == null) delegate = tryGetFilerField(filerClass, filer);
+
+ if (delegate != null) return getJavacFiler(delegate);
+ // delegate field was not found, try on superclass
}
processingEnv.getMessager().printMessage(Kind.WARNING,
@@ -466,7 +557,48 @@ public class LombokProcessor extends AbstractProcessor {
return null;
}
- private Object tryGetDelegateField(Class<?> delegateClass, Object instance) throws Exception {
- return Permit.getField(delegateClass, "delegate").get(instance);
+ /**
+ * Gradle incremental processing
+ */
+ private Object tryGetDelegateField(Class<?> delegateClass, Object instance) {
+ try {
+ return Permit.getField(delegateClass, "delegate").get(instance);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Kotlin incremental processing
+ */
+ private Object tryGetProcessingEnvField(Class<?> delegateClass, Object instance) {
+ try {
+ return Permit.getField(delegateClass, "processingEnv").get(instance);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Kotlin incremental processing
+ */
+ private Object tryGetFilerField(Class<?> delegateClass, Object instance) {
+ try {
+ return Permit.getField(delegateClass, "filer").get(instance);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * IntelliJ IDEA >= 2020.3
+ */
+ private Object tryGetProxyDelegateToField(Class<?> delegateClass, Object instance) {
+ try {
+ InvocationHandler handler = Proxy.getInvocationHandler(instance);
+ return Permit.getField(handler.getClass(), "val$delegateTo").get(handler);
+ } catch (Exception e) {
+ return null;
+ }
}
}
diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java
index f15bf74c..e0de363d 100644
--- a/src/core/lombok/javac/apt/Processor.java
+++ b/src/core/lombok/javac/apt/Processor.java
@@ -222,7 +222,7 @@ public class Processor extends AbstractProcessor {
* We just return the latest version of whatever JDK we run on. Stupid? Yeah, but it's either that or warnings on all versions but 1.
*/
@Override public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.values()[SourceVersion.values().length - 1];
+ return SourceVersion.latest();
}
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
diff --git a/src/core/lombok/javac/handlers/HandleAccessors.java b/src/core/lombok/javac/handlers/HandleAccessors.java
index 46fe1cd2..60466d78 100644
--- a/src/core/lombok/javac/handlers/HandleAccessors.java
+++ b/src/core/lombok/javac/handlers/HandleAccessors.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -24,8 +24,6 @@ package lombok.javac.handlers;
import static lombok.core.handlers.HandlerUtil.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.ConfigurationKeys;
@@ -34,8 +32,9 @@ import lombok.core.HandlerPriority;
import lombok.experimental.Accessors;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(65536)
public class HandleAccessors extends JavacAnnotationHandler<Accessors> {
@Override public void handle(AnnotationValues<Accessors> annotation, JCAnnotation ast, JavacNode annotationNode) {
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index f9675813..a25baeb0 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -27,13 +27,9 @@ import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
import static lombok.javac.handlers.JavacHandlerUtil.*;
import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.lang.model.element.Modifier;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -55,6 +51,7 @@ import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeApply;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -82,18 +79,102 @@ import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes.
public class HandleBuilder extends JavacAnnotationHandler<Builder> {
private HandleConstructor handleConstructor = new HandleConstructor();
+ static final String CLEAN_FIELD_NAME = "$lombokUnclean";
+ static final String CLEAN_METHOD_NAME = "$lombokClean";
+ static final String TO_BUILDER_METHOD_NAME = "toBuilder";
+ static final String DEFAULT_PREFIX = "$default$";
+ static final String SET_PREFIX = "$set";
+ static final String VALUE_PREFIX = "$value";
+ static final String BUILDER_TEMP_VAR = "builder";
+ static final String TO_BUILDER_NOT_SUPPORTED = "@Builder(toBuilder=true) is only supported if you return your own type.";
+
private static final boolean toBoolean(Object expr, boolean defaultValue) {
if (expr == null) return defaultValue;
if (expr instanceof JCLiteral) return ((Integer) ((JCLiteral) expr).value) != 0;
return ((Boolean) expr).booleanValue();
}
+ static class BuilderJob {
+ CheckerFrameworkVersion checkerFramework;
+ JavacNode parentType;
+ String builderMethodName, buildMethodName;
+ boolean isStatic;
+ List<JCTypeParameter> typeParams;
+ List<JCTypeParameter> builderTypeParams;
+ JavacNode sourceNode;
+ java.util.List<BuilderFieldData> builderFields;
+ AccessLevel accessInners, accessOuters;
+ boolean oldFluent, oldChain, toBuilder;
+
+ JavacNode builderType;
+ String builderClassName;
+
+ void init(AnnotationValues<Builder> annValues, Builder ann, JavacNode node) {
+ accessOuters = ann.access();
+ if (accessOuters == null) accessOuters = AccessLevel.PUBLIC;
+ if (accessOuters == AccessLevel.NONE) {
+ sourceNode.addError("AccessLevel.NONE is not valid here");
+ accessOuters = AccessLevel.PUBLIC;
+ }
+ accessInners = accessOuters == AccessLevel.PROTECTED ? AccessLevel.PUBLIC : accessOuters;
+
+ oldFluent = toBoolean(annValues.getActualExpression("fluent"), true);
+ oldChain = toBoolean(annValues.getActualExpression("chain"), true);
+
+ builderMethodName = ann.builderMethodName();
+ buildMethodName = ann.buildMethodName();
+ builderClassName = fixBuilderClassName(node, ann.builderClassName());
+ toBuilder = ann.toBuilder();
+
+ if (builderMethodName == null) builderMethodName = "builder";
+ if (buildMethodName == null) buildMethodName = "build";
+ if (builderClassName == null) builderClassName = "";
+ }
+
+ static String fixBuilderClassName(JavacNode node, String override) {
+ if (override != null && !override.isEmpty()) return override;
+ override = node.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
+ if (override != null && !override.isEmpty()) return override;
+ return "*Builder";
+ }
+
+ String replaceBuilderClassName(Name name) {
+ if (builderClassName.indexOf('*') == -1) return builderClassName;
+ return builderClassName.replace("*", name.toString());
+ }
+
+ JCExpression createBuilderParentTypeReference() {
+ return namePlusTypeParamsToTypeReference(parentType.getTreeMaker(), parentType, typeParams);
+ }
+
+ Name getBuilderClassName() {
+ return parentType.toName(builderClassName);
+ }
+
+ List<JCTypeParameter> copyTypeParams() {
+ return JavacHandlerUtil.copyTypeParams(sourceNode, typeParams);
+ }
+
+ Name toName(String name) {
+ return parentType.toName(name);
+ }
+
+ Context getContext() {
+ return parentType.getContext();
+ }
+
+ JavacTreeMaker getTreeMaker() {
+ return parentType.getTreeMaker();
+ }
+ }
+
static class BuilderFieldData {
List<JCAnnotation> annotations;
JCExpression type;
@@ -111,74 +192,56 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
@Override public void handle(AnnotationValues<Builder> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ final String BUILDER_NODE_NOT_SUPPORTED_ERR = "@Builder is only supported on classes, records, constructors, and methods.";
+
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;
- if (accessForOuters == AccessLevel.NONE) {
- annotationNode.addError("AccessLevel.NONE is not valid here");
- accessForOuters = AccessLevel.PUBLIC;
- }
- AccessLevel accessForInners = accessForOuters == AccessLevel.PROTECTED ? AccessLevel.PUBLIC : accessForOuters;
-
- // These exist just to support the 'old' lombok.experimental.Builder, which had these properties. lombok.Builder no longer has them.
- boolean fluent = toBoolean(annotation.getActualExpression("fluent"), true);
- boolean chain = toBoolean(annotation.getActualExpression("chain"), true);
-
- String builderMethodName = builderInstance.builderMethodName();
- String buildMethodName = builderInstance.buildMethodName();
- String builderClassName = builderInstance.builderClassName();
- String toBuilderMethodName = "toBuilder";
- boolean toBuilder = builderInstance.toBuilder();
- java.util.List<Name> typeArgsForToBuilder = null;
+ BuilderJob job = new BuilderJob();
+ job.sourceNode = annotationNode;
+ job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
+ job.isStatic = true;
- if (builderMethodName == null) builderMethodName = "builder";
- if (buildMethodName == null) buildMethodName = "build";
- if (builderClassName == null) builderClassName = "";
+ Builder annInstance = annotation.getInstance();
+ job.init(annotation, annInstance, annotationNode);
+ java.util.List<Name> typeArgsForToBuilder = null;
boolean generateBuilderMethod;
- if (builderMethodName.isEmpty()) {
+ if (job.builderMethodName.isEmpty()) {
generateBuilderMethod = false;
- } else if (!checkName("builderMethodName", builderMethodName, annotationNode)) {
+ } else if (!checkName("builderMethodName", job.builderMethodName, annotationNode)) {
return;
} else {
generateBuilderMethod = true;
}
- if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
- if (!builderClassName.isEmpty()) {
- if (!checkName("builderClassName", builderClassName, annotationNode)) return;
- }
+ if (!checkName("buildMethodName", job.buildMethodName, annotationNode)) return;
- // Do not delete the Builder annotation here, we need it for @Jacksonized.
+ // Do not delete the Builder annotation yet, we need it for @Jacksonized.
JavacNode parent = annotationNode.up();
- java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
- JCExpression returnType;
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrownExceptions = List.nil();
+ job.builderFields = new ArrayList<BuilderFieldData>();
+ JCExpression buildMethodReturnType;
+ job.typeParams = List.nil();
+ List<JCExpression> buildMethodThrownExceptions;
Name nameOfBuilderMethod;
- JavacNode tdParent;
JavacNode fillParametersFrom = parent.get() instanceof JCMethodDecl ? parent : null;
boolean addCleaning = false;
- boolean isStatic = true;
ArrayList<JavacNode> nonFinalNonDefaultedFields = null;
- if (builderClassName.isEmpty()) builderClassName = annotationNode.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
- if (builderClassName == null || builderClassName.isEmpty()) builderClassName = "*Builder";
- boolean replaceNameInBuilderClassName = builderClassName.contains("*");
-
if (parent.get() instanceof JCClassDecl) {
- tdParent = parent;
- JCClassDecl td = (JCClassDecl) tdParent.get();
+ if (!isClass(parent) && !isRecord(parent)) {
+ annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
+ return;
+ }
+
+ job.parentType = parent;
+ JCClassDecl td = (JCClassDecl) parent.get();
+
ListBuffer<JavacNode> allFields = new ListBuffer<JavacNode>();
boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent));
- for (JavacNode fieldNode : HandleConstructor.findAllFields(tdParent, true)) {
+ for (JavacNode fieldNode : HandleConstructor.findAllFields(parent, true)) {
JCVariableDecl fd = (JCVariableDecl) fieldNode.get();
JavacNode isDefault = findAnnotation(Builder.Default.class, fieldNode, false);
boolean isFinal = (fd.mods.flags & Flags.FINAL) != 0 || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
@@ -189,7 +252,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = findCopyableAnnotations(fieldNode);
bfd.type = fd.vartype;
- bfd.singularData = getSingularData(fieldNode, builderInstance.setterPrefix());
+ bfd.singularData = getSingularData(fieldNode, annInstance.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -211,28 +274,30 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
if (isDefault != null) {
- bfd.nameOfDefaultProvider = parent.toName("$default$" + bfd.name);
- bfd.nameOfSetFlag = parent.toName(bfd.name + "$set");
- bfd.builderFieldName = parent.toName(bfd.name + "$value");
+ bfd.nameOfDefaultProvider = parent.toName(DEFAULT_PREFIX + bfd.name);
+ bfd.nameOfSetFlag = parent.toName(bfd.name + SET_PREFIX);
+ bfd.builderFieldName = parent.toName(bfd.name + VALUE_PREFIX);
JCMethodDecl md = generateDefaultProvider(bfd.nameOfDefaultProvider, fieldNode, td.typarams);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- if (md != null) injectMethod(tdParent, md);
+ recursiveSetGeneratedBy(md, annotationNode);
+ if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
- builderFields.add(bfd);
+ job.builderFields.add(bfd);
allFields.append(fieldNode);
}
- if (!isRecord(tdParent)) {
- handleConstructor.generateConstructor(tdParent, AccessLevel.PACKAGE, List.<JCAnnotation>nil(), allFields.toList(), false, null, SkipIfConstructorExists.I_AM_BUILDER, annotationNode);
+ if (!isRecord(parent)) {
+ // Records ship with a canonical constructor that acts as @AllArgsConstructor - just use that one.
+
+ handleConstructor.generateConstructor(parent, AccessLevel.PACKAGE, List.<JCAnnotation>nil(), allFields.toList(), false, null, SkipIfConstructorExists.I_AM_BUILDER, annotationNode);
}
- returnType = namePlusTypeParamsToTypeReference(tdParent.getTreeMaker(), tdParent, td.typarams);
- typeParams = td.typarams;
- thrownExceptions = List.nil();
+ buildMethodReturnType = namePlusTypeParamsToTypeReference(parent.getTreeMaker(), parent, td.typarams);
+ job.typeParams = job.builderTypeParams = td.typarams;
+ buildMethodThrownExceptions = List.nil();
nameOfBuilderMethod = null;
- if (replaceNameInBuilderClassName) builderClassName = builderClassName.replace("*", td.name.toString());
- replaceNameInBuilderClassName = false;
+ job.builderClassName = job.replaceBuilderClassName(td.name);
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
} else if (fillParametersFrom != null && fillParametersFrom.getName().toString().equals("<init>")) {
JCMethodDecl jmd = (JCMethodDecl) fillParametersFrom.get();
if (!jmd.typarams.isEmpty()) {
@@ -240,38 +305,35 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
return;
}
- tdParent = parent.up();
- JCClassDecl td = (JCClassDecl) tdParent.get();
- returnType = namePlusTypeParamsToTypeReference(tdParent.getTreeMaker(), tdParent, td.typarams);
- typeParams = td.typarams;
- thrownExceptions = jmd.thrown;
+ job.parentType = parent.up();
+ JCClassDecl td = (JCClassDecl) job.parentType.get();
+ job.typeParams = job.builderTypeParams = td.typarams;
+ buildMethodReturnType = job.createBuilderParentTypeReference();
+ buildMethodThrownExceptions = jmd.thrown;
nameOfBuilderMethod = null;
- if (replaceNameInBuilderClassName) builderClassName = builderClassName.replace("*", td.name.toString());
- replaceNameInBuilderClassName = false;
+ job.builderClassName = job.replaceBuilderClassName(td.name);
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
} else if (fillParametersFrom != null) {
- tdParent = parent.up();
- JCClassDecl td = (JCClassDecl) tdParent.get();
+ job.parentType = parent.up();
+ JCClassDecl td = (JCClassDecl) job.parentType.get();
JCMethodDecl jmd = (JCMethodDecl) fillParametersFrom.get();
- isStatic = (jmd.mods.flags & Flags.STATIC) != 0;
+ job.isStatic = (jmd.mods.flags & Flags.STATIC) != 0;
+
JCExpression fullReturnType = jmd.restype;
- returnType = fullReturnType;
- typeParams = jmd.typarams;
- thrownExceptions = jmd.thrown;
+ buildMethodReturnType = fullReturnType;
+ job.typeParams = job.builderTypeParams = jmd.typarams;
+ buildMethodThrownExceptions = jmd.thrown;
nameOfBuilderMethod = jmd.name;
- if (returnType instanceof JCTypeApply) {
- returnType = cloneType(tdParent.getTreeMaker(), returnType, ast, annotationNode.getContext());
+ if (buildMethodReturnType instanceof JCTypeApply) {
+ buildMethodReturnType = cloneType(job.getTreeMaker(), buildMethodReturnType, annotationNode);
}
- if (replaceNameInBuilderClassName) {
- String replStr = returnTypeToBuilderClassName(annotationNode, td, returnType, typeParams);
- if (replStr == null)
- return;
- builderClassName = builderClassName.replace("*", replStr);
- replaceNameInBuilderClassName = false;
+ if (job.builderClassName.indexOf('*') > -1) {
+ String replStr = returnTypeToBuilderClassName(annotationNode, td, buildMethodReturnType, job.typeParams);
+ if (replStr == null) return; // shuold not happen
+ job.builderClassName = job.builderClassName.replace("*", replStr);
}
- if (replaceNameInBuilderClassName) builderClassName = builderClassName.replace("*", td.name.toString());
- if (toBuilder) {
- final String TO_BUILDER_NOT_SUPPORTED = "@Builder(toBuilder=true) is only supported if you return your own type.";
- if (returnType instanceof JCArrayTypeTree) {
+ if (job.toBuilder) {
+ if (fullReturnType instanceof JCArrayTypeTree) {
annotationNode.addError(TO_BUILDER_NOT_SUPPORTED);
return;
}
@@ -284,8 +346,8 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
tpOnRet = ((JCTypeApply) fullReturnType).arguments;
}
- JCExpression namingType = returnType;
- if (returnType instanceof JCTypeApply) namingType = ((JCTypeApply) returnType).clazz;
+ JCExpression namingType = fullReturnType;
+ if (buildMethodReturnType instanceof JCTypeApply) namingType = ((JCTypeApply) buildMethodReturnType).clazz;
if (namingType instanceof JCIdent) {
simpleName = ((JCIdent) namingType).name;
@@ -309,13 +371,13 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
return;
}
- if (!tdParent.getName().contentEquals(simpleName)) {
+ if (!job.parentType.getName().contentEquals(simpleName)) {
annotationNode.addError(TO_BUILDER_NOT_SUPPORTED);
return;
}
List<JCTypeParameter> tpOnMethod = jmd.typarams;
- List<JCTypeParameter> tpOnType = ((JCClassDecl) tdParent.get()).typarams;
+ List<JCTypeParameter> tpOnType = ((JCClassDecl) job.parentType.get()).typarams;
typeArgsForToBuilder = new ArrayList<Name>();
for (JCTypeParameter tp : tpOnMethod) {
@@ -336,7 +398,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
}
} else {
- annotationNode.addError("@Builder is only supported on types, constructors, and methods.");
+ annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -351,41 +413,41 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
bfd.rawName = raw.name;
bfd.annotations = findCopyableAnnotations(param);
bfd.type = raw.vartype;
- bfd.singularData = getSingularData(param, builderInstance.setterPrefix());
+ bfd.singularData = getSingularData(param, annInstance.setterPrefix());
bfd.originalFieldNode = param;
addObtainVia(bfd, param);
- builderFields.add(bfd);
+ job.builderFields.add(bfd);
}
}
- JavacNode builderType = findInnerClass(tdParent, builderClassName);
- if (builderType == null) {
- builderType = makeBuilderClass(isStatic, annotationNode, tdParent, builderClassName, typeParams, ast, accessForOuters);
- recursiveSetGeneratedBy(builderType.get(), ast, annotationNode.getContext());
+ job.builderType = findInnerClass(job.parentType, job.builderClassName);
+ if (job.builderType == null) {
+ job.builderType = makeBuilderClass(job);
+ recursiveSetGeneratedBy(job.builderType.get(), annotationNode);
} else {
- JCClassDecl builderTypeDeclaration = (JCClassDecl) builderType.get();
- if (isStatic && !builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)) {
+ JCClassDecl builderTypeDeclaration = (JCClassDecl) job.builderType.get();
+ if (job.isStatic && !builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)) {
annotationNode.addError("Existing Builder must be a static inner class.");
return;
- } else if (!isStatic && builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)) {
+ } else if (!job.isStatic && builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)) {
annotationNode.addError("Existing Builder must be a non-static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderType, annotationNode);
/* generate errors for @Singular BFDs that have one already defined node. */ {
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
SingularData sd = bfd.singularData;
if (sd == null) continue;
JavacSingularizer singularizer = sd.getSingularizer();
if (singularizer == null) continue;
- if (singularizer.checkForAlreadyExistingNodesAndGenerateError(builderType, sd)) {
+ if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderType, sd)) {
bfd.singularData = null;
}
}
}
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
if (bfd.singularData.getSingularizer().requiresCleaning()) {
addCleaning = true;
@@ -404,75 +466,75 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
}
- generateBuilderFields(builderType, builderFields, ast);
+ generateBuilderFields(job);
if (addCleaning) {
- JavacTreeMaker maker = builderType.getTreeMaker();
- JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), builderType.toName("$lombokUnclean"), maker.TypeIdent(CTC_BOOLEAN), null);
- injectFieldAndMarkGenerated(builderType, uncleanField);
- recursiveSetGeneratedBy(uncleanField, ast, annotationNode.getContext());
+ JavacTreeMaker maker = job.getTreeMaker();
+ JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), job.builderType.toName(CLEAN_FIELD_NAME), maker.TypeIdent(CTC_BOOLEAN), null);
+ injectFieldAndMarkGenerated(job.builderType, uncleanField);
+ recursiveSetGeneratedBy(uncleanField, annotationNode);
}
- if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, List.<JCAnnotation>nil(), builderType, List.<JavacNode>nil(), false, annotationNode);
- if (cd != null) injectMethod(builderType, cd);
+ if (constructorExists(job.builderType) == MemberExistsResult.NOT_EXISTS) {
+ JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, List.<JCAnnotation>nil(), job.builderType, List.<JavacNode>nil(), false, annotationNode);
+ if (cd != null) injectMethod(job.builderType, cd);
}
- for (BuilderFieldData bfd : builderFields) {
- makePrefixedSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, fluent, chain, accessForInners, builderInstance.setterPrefix());
+ for (BuilderFieldData bfd : job.builderFields) {
+ makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix());
}
{
- MemberExistsResult methodExists = methodExists(buildMethodName, builderType, -1);
- if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(buildMethodName, builderType, 0);
+ MemberExistsResult methodExists = methodExists(job.buildMethodName, job.builderType, -1);
+ if (methodExists == MemberExistsResult.EXISTS_BY_LOMBOK) methodExists = methodExists(job.buildMethodName, job.builderType, 0);
if (methodExists == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl md = generateBuildMethod(cfv, tdParent, isStatic, buildMethodName, nameOfBuilderMethod, returnType, builderFields, builderType, thrownExceptions, ast, addCleaning, accessForInners);
+ JCMethodDecl md = generateBuildMethod(job, nameOfBuilderMethod, buildMethodReturnType, buildMethodThrownExceptions, addCleaning);
if (md != null) {
- injectMethod(builderType, md);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
+ injectMethod(job.builderType, md);
}
}
}
- if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) {
+ if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) {
java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
for (JavacNode f : bfd.createdFields) {
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true, false));
}
}
- JCMethodDecl md = HandleToString.createToString(builderType, fieldNodes, true, false, FieldAccess.ALWAYS_FIELD, ast);
- if (md != null) injectMethod(builderType, md);
+ JCMethodDecl md = HandleToString.createToString(job.builderType, fieldNodes, true, false, FieldAccess.ALWAYS_FIELD, job.sourceNode);
+ if (md != null) injectMethod(job.builderType, md);
}
- if (addCleaning) injectMethod(builderType, generateCleanMethod(builderFields, builderType, ast));
+ if (addCleaning) injectMethod(job.builderType, generateCleanMethod(job));
- if (generateBuilderMethod && methodExists(builderMethodName, tdParent, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
+ if (generateBuilderMethod && methodExists(job.builderMethodName, job.parentType, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
- JCMethodDecl md = generateBuilderMethod(cfv, isStatic, builderMethodName, builderClassName, annotationNode, tdParent, typeParams, accessForOuters);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- if (md != null) injectMethod(tdParent, md);
+ JCMethodDecl md = generateBuilderMethod(job);
+ recursiveSetGeneratedBy(md, annotationNode);
+ if (md != null) injectMethod(job.parentType, md);
}
- if (toBuilder) {
- switch (methodExists(toBuilderMethodName, tdParent, 0)) {
+ if (job.toBuilder) {
+ switch (methodExists(TO_BUILDER_METHOD_NAME, job.parentType, 0)) {
case EXISTS_BY_USER:
annotationNode.addWarning("Not generating toBuilder() as it already exists.");
return;
case NOT_EXISTS:
- List<JCTypeParameter> tps = typeParams;
+ List<JCTypeParameter> tps = job.typeParams;
if (typeArgsForToBuilder != null) {
ListBuffer<JCTypeParameter> lb = new ListBuffer<JCTypeParameter>();
- JavacTreeMaker maker = tdParent.getTreeMaker();
+ JavacTreeMaker maker = job.getTreeMaker();
for (Name n : typeArgsForToBuilder) {
lb.append(maker.TypeParameter(n, List.<JCExpression>nil()));
}
tps = lb.toList();
}
- JCMethodDecl md = generateToBuilderMethod(cfv, toBuilderMethodName, builderClassName, tdParent, isStatic, tps, builderFields, fluent, ast, accessForOuters, builderInstance.setterPrefix());
+ JCMethodDecl md = generateToBuilderMethod(job, tps, annInstance.setterPrefix());
if (md != null) {
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- injectMethod(tdParent, md);
+ recursiveSetGeneratedBy(md, annotationNode);
+ injectMethod(job.parentType, md);
}
}
}
@@ -553,47 +615,41 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
sb.append("__ERR__");
}
- private static final String BUILDER_TEMP_VAR = "builder";
- private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String toBuilderMethodName, String builderClassName, JavacNode type, boolean isStatic, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, boolean fluent, JCAnnotation ast, AccessLevel access, String prefix) {
+ private JCMethodDecl generateToBuilderMethod(BuilderJob job, List<JCTypeParameter> typeParameters, String prefix) {
// return new ThingieBuilder<A, B>().setA(this.a).setB(this.b);
- JavacTreeMaker maker = type.getTreeMaker();
+ JavacTreeMaker maker = job.getTreeMaker();
- ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
- for (JCTypeParameter typeParam : typeParams) {
- typeArgs.append(maker.Ident(typeParam.name));
- }
-
- JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), List.<JCExpression>nil(), null);
+ JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderClassName), !job.isStatic, job.builderTypeParams), List.<JCExpression>nil(), null);
JCExpression invoke = call;
ListBuffer<JCStatement> preStatements = null;
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- for (BuilderFieldData bfd : builderFields) {
- String setterPrefix = !prefix.isEmpty() ? prefix : fluent ? "" : "set";
+ for (BuilderFieldData bfd : job.builderFields) {
+ String setterPrefix = !prefix.isEmpty() ? prefix : job.oldFluent ? "" : "set";
String prefixedSetterName = bfd.name.toString();
if (!setterPrefix.isEmpty()) prefixedSetterName = HandlerUtil.buildAccessorName(setterPrefix, prefixedSetterName);
- Name setterName = type.toName(prefixedSetterName);
+ Name setterName = job.toName(prefixedSetterName);
JCExpression[] tgt = new JCExpression[bfd.singularData == null ? 1 : 2];
if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) {
for (int i = 0; i < tgt.length; i++) {
- tgt[i] = maker.Select(maker.Ident(type.toName("this")), bfd.obtainVia == null ? bfd.rawName : type.toName(bfd.obtainVia.field()));
+ tgt[i] = maker.Select(maker.Ident(job.toName("this")), bfd.obtainVia == null ? bfd.rawName : job.toName(bfd.obtainVia.field()));
}
} else {
String name = bfd.obtainVia.method();
JCMethodInvocation inv;
if (bfd.obtainVia.isStatic()) {
- JCExpression c = maker.Select(maker.Ident(type.toName(type.getName())), type.toName(name));
- inv = maker.Apply(typeParameterNames(maker, typeParams), c, List.<JCExpression>of(maker.Ident(type.toName("this"))));
+ JCExpression c = maker.Select(maker.Ident(job.toName(job.parentType.getName())), job.toName(name));
+ inv = maker.Apply(typeParameterNames(maker, typeParameters), c, List.<JCExpression>of(maker.Ident(job.toName("this"))));
} else {
- JCExpression c = maker.Select(maker.Ident(type.toName("this")), type.toName(name));
+ JCExpression c = maker.Select(maker.Ident(job.toName("this")), job.toName(name));
inv = maker.Apply(List.<JCExpression>nil(), c, List.<JCExpression>nil());
}
for (int i = 0; i < tgt.length; i++) tgt[i] = maker.Ident(bfd.name);
// javac appears to cache the type of JCMethodInvocation expressions based on position, meaning, if you have 2 ObtainVia-based method invokes on different types, you get bizarre type mismatch errors.
// going via a local variable declaration solves the problem.
- JCExpression varType = JavacHandlerUtil.cloneType(maker, bfd.type, ast, type.getContext());
+ JCExpression varType = JavacHandlerUtil.cloneType(maker, bfd.type, job.sourceNode);
if (preStatements == null) preStatements = new ListBuffer<JCStatement>();
preStatements.append(maker.VarDef(maker.Modifiers(Flags.FINAL), bfd.name, varType, inv));
}
@@ -604,15 +660,15 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
invoke = maker.Apply(List.<JCExpression>nil(), maker.Select(invoke, setterName), List.of(arg));
} else {
JCExpression isNotNull = maker.Binary(CTC_NOT_EQUAL, tgt[0], maker.Literal(CTC_BOT, null));
- JCExpression invokeBuilder = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(type.toName(BUILDER_TEMP_VAR)), setterName), List.<JCExpression>of(tgt[1]));
+ JCExpression invokeBuilder = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(job.toName(BUILDER_TEMP_VAR)), setterName), List.<JCExpression>of(tgt[1]));
statements.append(maker.If(isNotNull, maker.Exec(invokeBuilder), null));
}
}
if (!statements.isEmpty()) {
- JCExpression tempVarType = namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams);
- statements.prepend(maker.VarDef(maker.Modifiers(Flags.FINAL), type.toName(BUILDER_TEMP_VAR), tempVarType, invoke));
- statements.append(maker.Return(maker.Ident(type.toName(BUILDER_TEMP_VAR))));
+ JCExpression tempVarType = namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), !job.isStatic, typeParameters);
+ statements.prepend(maker.VarDef(maker.Modifiers(Flags.FINAL), job.toName(BUILDER_TEMP_VAR), tempVarType, invoke));
+ statements.append(maker.Return(maker.Ident(job.toName(BUILDER_TEMP_VAR))));
} else {
statements.append(maker.Return(invoke));
}
@@ -622,77 +678,78 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
statements = preStatements;
}
JCBlock body = maker.Block(0, statements.toList());
- List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
- JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(toBuilderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- createRelevantNonNullAnnotation(type, methodDef);
+ List<JCAnnotation> annsOnParamType = List.nil();
+ if (job.checkerFramework.generateUnique()) annsOnParamType = List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
+ JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(job.accessOuters)), job.toName(TO_BUILDER_METHOD_NAME), namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), !job.isStatic, typeParameters, annsOnParamType), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ createRelevantNonNullAnnotation(job.parentType, methodDef);
return methodDef;
}
- private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateCleanMethod(BuilderJob job) {
+ JavacTreeMaker maker = job.getTreeMaker();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, type, source, statements);
+ bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, job.sourceNode, statements);
}
}
- statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, 0))));
+ statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(job.toName("this")), job.toName(CLEAN_FIELD_NAME)), maker.Literal(CTC_BOOLEAN, 0))));
JCBlock body = maker.Block(0, statements.toList());
- JCMethodDecl method = maker.MethodDef(maker.Modifiers(toJavacModifier(AccessLevel.PRIVATE)), type.toName("$lombokClean"), maker.Type(Javac.createVoidType(type.getSymbolTable(), CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- recursiveSetGeneratedBy(method, source, type.getContext());
+ JCMethodDecl method = maker.MethodDef(maker.Modifiers(toJavacModifier(AccessLevel.PRIVATE)), job.toName(CLEAN_METHOD_NAME), maker.Type(Javac.createVoidType(job.builderType.getSymbolTable(), CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ recursiveSetGeneratedBy(method, job.sourceNode);
return method;
}
- static List<JCVariableDecl> generateBuildArgs(CheckerFrameworkVersion cfv, JavacNode type, java.util.List<BuilderFieldData> builderFields) {
- if (!cfv.generateCalledMethods()) return List.<JCVariableDecl>nil();
-
+ static JCVariableDecl generateReceiver(BuilderJob job) {
+ if (!job.checkerFramework.generateCalledMethods()) return null;
+
ArrayList<String> mandatories = new ArrayList<String>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.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();
+ JavacTreeMaker maker = job.getTreeMaker();
+ if (mandatories.size() == 0) return null;
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"), namePlusTypeParamsToTypeReference(maker, type, builderTypeNode.typarams), null);
- return List.of(recv);
+ JCAnnotation recvAnno = maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__CALLED), List.of(arg));
+ JCClassDecl builderTypeNode = (JCClassDecl) job.builderType.get();
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(Flags.PARAMETER, List.<JCAnnotation>nil()), job.toName("this"), namePlusTypeParamsToTypeReference(maker, job.builderType, builderTypeNode.typarams, List.<JCAnnotation>of(recvAnno)), null);
+ return 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();
+ private JCMethodDecl generateBuildMethod(BuilderJob job, Name staticName, JCExpression returnType, List<JCExpression> thrownExceptions, boolean addCleaning) {
+ JavacTreeMaker maker = job.getTreeMaker();
JCExpression call;
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
if (addCleaning) {
- JCExpression notClean = maker.Unary(CTC_NOT, maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")));
- JCStatement invokeClean = maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(type.toName("$lombokClean")), List.<JCExpression>nil()));
+ JCExpression notClean = maker.Unary(CTC_NOT, maker.Select(maker.Ident(job.toName("this")), job.toName(CLEAN_FIELD_NAME)));
+ JCStatement invokeClean = maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(job.toName(CLEAN_METHOD_NAME)), List.<JCExpression>nil()));
JCIf ifUnclean = maker.If(notClean, invokeClean, null);
statements.append(ifUnclean);
}
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, type, source, statements, bfd.builderFieldName, "this");
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, job.builderType, job.sourceNode, statements, bfd.builderFieldName, "this");
}
}
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
- Name thisName = type.toName("this");
- for (BuilderFieldData bfd : builderFields) {
+ Name thisName = job.toName("this");
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.nameOfSetFlag != null) {
- statements.append(maker.VarDef(maker.Modifiers(0L), bfd.builderFieldName, cloneType(maker, bfd.type, source, tdParent.getContext()), maker.Select(maker.Ident(thisName), bfd.builderFieldName)));
- statements.append(maker.If(maker.Unary(CTC_NOT, maker.Select(maker.Ident(thisName), bfd.nameOfSetFlag)), maker.Exec(maker.Assign(maker.Ident(bfd.builderFieldName), maker.Apply(typeParameterNames(maker, ((JCClassDecl) tdParent.get()).typarams), maker.Select(maker.Ident(((JCClassDecl) tdParent.get()).name), bfd.nameOfDefaultProvider), List.<JCExpression>nil()))), null));
+ statements.append(maker.VarDef(maker.Modifiers(0L), bfd.builderFieldName, cloneType(maker, bfd.type, job.sourceNode), maker.Select(maker.Ident(thisName), bfd.builderFieldName)));
+ statements.append(maker.If(maker.Unary(CTC_NOT, maker.Select(maker.Ident(thisName), bfd.nameOfSetFlag)), maker.Exec(maker.Assign(maker.Ident(bfd.builderFieldName), maker.Apply(typeParameterNames(maker, ((JCClassDecl) job.parentType.get()).typarams), maker.Select(maker.Ident(((JCClassDecl) job.parentType.get()).name), bfd.nameOfDefaultProvider), List.<JCExpression>nil()))), null));
}
if (bfd.nameOfSetFlag != null || (bfd.singularData != null && bfd.singularData.getSingularizer().shadowedDuringBuild())) {
args.append(maker.Ident(bfd.builderFieldName));
@@ -702,20 +759,20 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
if (addCleaning) {
- statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, 1))));
+ statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(job.toName("this")), job.toName(CLEAN_FIELD_NAME)), maker.Literal(CTC_BOOLEAN, 1))));
}
- if (builderName == null) {
+ if (staticName == null) {
call = maker.NewClass(null, List.<JCExpression>nil(), returnType, args.toList(), null);
statements.append(maker.Return(call));
} else {
ListBuffer<JCExpression> typeParams = new ListBuffer<JCExpression>();
- for (JCTypeParameter tp : ((JCClassDecl) type.get()).typarams) {
+ for (JCTypeParameter tp : ((JCClassDecl) job.builderType.get()).typarams) {
typeParams.append(maker.Ident(tp.name));
}
- JCExpression callee = maker.Ident(((JCClassDecl) type.up().get()).name);
- if (!isStatic) callee = maker.Select(callee, type.up().toName("this"));
- JCExpression fn = maker.Select(callee, builderName);
+ JCExpression callee = maker.Ident(((JCClassDecl) job.parentType.get()).name);
+ if (!job.isStatic) callee = maker.Select(callee, job.toName("this"));
+ JCExpression fn = maker.Select(callee, staticName);
call = maker.Apply(typeParams.toList(), fn, args.toList());
if (returnType instanceof JCPrimitiveTypeTree && CTC_VOID.equals(typeTag(returnType))) {
statements.append(maker.Exec(call));
@@ -726,10 +783,15 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCBlock body = maker.Block(0, statements.toList());
- 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);
- JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(access), annsOnMethod), type.toName(buildName), returnType, List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
- if (builderName == null) createRelevantNonNullAnnotation(type, methodDef);
+ List<JCAnnotation> annsOnMethod = job.checkerFramework.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ JCVariableDecl recv = generateReceiver(job);
+ JCMethodDecl methodDef;
+ if (recv != null && maker.hasMethodDefWithRecvParam()) {
+ methodDef = maker.MethodDefWithRecvParam(maker.Modifiers(toJavacModifier(job.accessInners), annsOnMethod), job.toName(job.buildMethodName), returnType, List.<JCTypeParameter>nil(), recv, List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ } else {
+ methodDef = maker.MethodDef(maker.Modifiers(toJavacModifier(job.accessInners), annsOnMethod), job.toName(job.buildMethodName), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ }
+ if (staticName == null) createRelevantNonNullAnnotation(job.builderType, methodDef);
return methodDef;
}
@@ -742,55 +804,56 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
int modifiers = Flags.PRIVATE | Flags.STATIC;
- 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);
+ return maker.MethodDef(maker.Modifiers(modifiers), methodName, cloneType(maker, field.vartype, fieldNode), copyTypeParams(fieldNode, params), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- public JCMethodDecl generateBuilderMethod(CheckerFrameworkVersion cfv, boolean isStatic, String builderMethodName, String builderClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams, AccessLevel access) {
- JavacTreeMaker maker = type.getTreeMaker();
+ public JCMethodDecl generateBuilderMethod(BuilderJob job) {
+ //String builderClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams, AccessLevel access) {
+ //builderClassName, annotationNode, tdParent, typeParams, accessForOuters);
- ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
- for (JCTypeParameter typeParam : typeParams) {
- typeArgs.append(maker.Ident(typeParam.name));
- }
+ JavacTreeMaker maker = job.getTreeMaker();
JCExpression call;
- if (isStatic) {
- call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), false, typeParams), List.<JCExpression>nil(), null);
+ if (job.isStatic) {
+ call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderClassName), false, job.typeParams), List.<JCExpression>nil(), null);
} else {
- call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, null, type.toName(builderClassName), false, typeParams), List.<JCExpression>nil(), null);
- ((JCNewClass) call).encl = maker.Ident(type.toName("this"));
+ call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, null, job.toName(job.builderClassName), false, job.typeParams), List.<JCExpression>nil(), null);
+ ((JCNewClass) call).encl = maker.Ident(job.toName("this"));
}
JCStatement statement = maker.Return(call);
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
- int modifiers = toJavacModifier(access);
- if (isStatic) modifiers |= Flags.STATIC;
- 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();
- JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), !isStatic, typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- createRelevantNonNullAnnotation(type, methodDef);
+ int modifiers = toJavacModifier(job.accessOuters);
+ if (job.isStatic) modifiers |= Flags.STATIC;
+ List<JCAnnotation> annsOnMethod = List.nil();
+ if (job.checkerFramework.generateSideEffectFree()) annsOnMethod = List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ List<JCAnnotation> annsOnParamType = List.nil();
+ if (job.checkerFramework.generateUnique()) annsOnParamType = List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
+
+ JCExpression returnType = namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), !job.isStatic, job.builderTypeParams, annsOnParamType);
+ JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), job.toName(job.builderMethodName), returnType, job.copyTypeParams(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ createRelevantNonNullAnnotation(job.parentType, methodDef);
return methodDef;
}
- public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
- int len = builderFields.size();
+ public void generateBuilderFields(BuilderJob job) {
+ int len = job.builderFields.size();
java.util.List<JavacNode> existing = new ArrayList<JavacNode>();
- for (JavacNode child : builderType.down()) {
+ for (JavacNode child : job.builderType.down()) {
if (child.getKind() == Kind.FIELD) existing.add(child);
}
java.util.List<JCVariableDecl> generated = new ArrayList<JCVariableDecl>();
for (int i = len - 1; i >= 0; i--) {
- BuilderFieldData bfd = builderFields.get(i);
+ BuilderFieldData bfd = job.builderFields.get(i);
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source));
+ java.util.List<JavacNode> generateSingularFields = bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType, job.sourceNode);
+ for (JavacNode field : generateSingularFields) {
+ generated.add((JCVariableDecl) field.get());
+ }
+ bfd.createdFields.addAll(generateSingularFields);
} else {
JavacNode field = null, setFlag = null;
for (JavacNode exists : existing) {
@@ -798,40 +861,41 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (n.equals(bfd.builderFieldName)) field = exists;
if (n.equals(bfd.nameOfSetFlag)) setFlag = exists;
}
- JavacTreeMaker maker = builderType.getTreeMaker();
+ JavacTreeMaker maker = job.getTreeMaker();
if (field == null) {
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
- JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, source, builderType.getContext()), null);
- field = injectFieldAndMarkGenerated(builderType, newField);
+ JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, job.sourceNode), null);
+ field = injectFieldAndMarkGenerated(job.builderType, newField);
generated.add(newField);
}
if (setFlag == null && bfd.nameOfSetFlag != null) {
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
JCVariableDecl newField = maker.VarDef(mods, bfd.nameOfSetFlag, maker.TypeIdent(CTC_BOOLEAN), null);
- injectFieldAndMarkGenerated(builderType, newField);
+ injectFieldAndMarkGenerated(job.builderType, newField);
generated.add(newField);
}
bfd.createdFields.add(field);
}
}
- for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
+ for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, job.sourceNode);
}
- 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(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, fluent, chain, fieldNode.annotations, fieldNode.originalFieldNode, access, prefix);
+ public void makePrefixedSetterMethodsForBuilder(BuilderJob job, BuilderFieldData bfd, String prefix) {
+ boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
+ if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
+ makePrefixedSetterMethodForBuilder(job, bfd, deprecate, prefix);
} else {
- fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), fluent, chain, access);
+ bfd.singularData.getSingularizer().generateMethods(job, bfd.singularData, deprecate);
}
}
- 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) {
- String setterPrefix = !prefix.isEmpty() ? prefix : fluent ? "" : "set";
- String setterName = HandlerUtil.buildAccessorName(setterPrefix, paramName.toString());
- Name setterName_ = builderType.toName(setterName);
+ private void makePrefixedSetterMethodForBuilder(BuilderJob job, BuilderFieldData bfd, boolean deprecate, String prefix) {
+ JavacNode fieldNode = bfd.createdFields.get(0);
+ String setterPrefix = !prefix.isEmpty() ? prefix : job.oldFluent ? "" : "set";
+ String setterName = HandlerUtil.buildAccessorName(setterPrefix, bfd.name.toString());
+ Name setterName_ = job.builderType.toName(setterName);
- for (JavacNode child : builderType.down()) {
+ for (JavacNode child : job.builderType.down()) {
if (child.getKind() != Kind.METHOD) continue;
JCMethodDecl methodDecl = (JCMethodDecl) child.get();
Name existingName = methodDecl.name;
@@ -840,47 +904,45 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JavacTreeMaker maker = fieldNode.getTreeMaker();
- 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();
- JCExpression selfType = namePlusTypeParamsToTypeReference(maker, builderType, builderTypeNode.typarams);
- JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>of(ncAnno)), builderType.toName("this"), selfType, null);
- newMethod.params = List.of(recv, newMethod.params.get(0));
- }
- recursiveSetGeneratedBy(newMethod, source.get(), builderType.getContext());
- if (source.up().getKind() == Kind.METHOD) {
- copyJavadocFromParam(originalFieldNode.up(), newMethod, paramName.toString());
+ List<JCAnnotation> methodAnns = JavacHandlerUtil.findCopyableToSetterAnnotations(bfd.originalFieldNode);
+ JCMethodDecl newMethod = null;
+ if (job.checkerFramework.generateCalledMethods() && maker.hasMethodDefWithRecvParam()) {
+ JCAnnotation ncAnno = maker.Annotation(genTypeRef(job.sourceNode, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(setterName.toString())));
+ JCClassDecl builderTypeNode = (JCClassDecl) job.builderType.get();
+ JCExpression selfType = namePlusTypeParamsToTypeReference(maker, job.builderType, builderTypeNode.typarams, List.<JCAnnotation>of(ncAnno));
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(Flags.PARAMETER, List.<JCAnnotation>nil()), job.builderType.toName("this"), selfType, null);
+ newMethod = HandleSetter.createSetterWithRecv(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations, recv);
+ }
+ if (newMethod == null) newMethod = HandleSetter.createSetter(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations);
+ recursiveSetGeneratedBy(newMethod, job.sourceNode);
+ if (job.sourceNode.up().getKind() == Kind.METHOD) {
+ copyJavadocFromParam(bfd.originalFieldNode.up(), newMethod, bfd.name.toString());
} else {
- copyJavadoc(originalFieldNode, newMethod, CopyJavadoc.SETTER, true);
+ copyJavadoc(bfd.originalFieldNode, newMethod, CopyJavadoc.SETTER, true);
}
- injectMethod(builderType, newMethod);
+ injectMethod(job.builderType, newMethod);
}
private void copyJavadocFromParam(JavacNode from, JCMethodDecl to, String param) {
try {
JCCompilationUnit cu = ((JCCompilationUnit) from.top().get());
String methodComment = Javac.getDocComment(cu, from.get());
- if (methodComment == null) return;
-
- Pattern pattern = Pattern.compile("@param " + param + " (\\S|\\s)+?(?=^ ?@)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
- Matcher matcher = pattern.matcher(methodComment);
- if (matcher.find()) {
- String newJavadoc = addReturnsThisIfNeeded(matcher.group());
- Javac.setDocComment(cu, to, newJavadoc);
- }
+ String newJavadoc = addReturnsThisIfNeeded(getParamJavadoc(methodComment, param));
+ Javac.setDocComment(cu, to, newJavadoc);
} catch (Exception ignore) {}
- }
-
- public JavacNode makeBuilderClass(boolean isStatic, JavacNode source, JavacNode tdParent, String builderClassName, List<JCTypeParameter> typeParams, JCAnnotation ast, AccessLevel access) {
- JavacTreeMaker maker = tdParent.getTreeMaker();
- int modifiers = toJavacModifier(access);
- if (isStatic) modifiers |= Flags.STATIC;
+ }
+
+ public JavacNode makeBuilderClass(BuilderJob job) {
+ //boolean isStatic, JavacNode source, JavacNode tdParent, String builderClassName, List<JCTypeParameter> typeParams, JCAnnotation ast, AccessLevel access) {
+ //isStatic, annotationNode, tdParent, builderClassName, typeParams, ast, accessForOuters
+ JavacTreeMaker maker = job.getTreeMaker();
+ int modifiers = toJavacModifier(job.accessOuters);
+ if (job.isStatic) modifiers |= Flags.STATIC;
JCModifiers mods = maker.Modifiers(modifiers);
- JCClassDecl builder = maker.ClassDef(mods, tdParent.toName(builderClassName), copyTypeParams(source, typeParams), null, List.<JCExpression>nil(), List.<JCTree>nil());
- return injectType(tdParent, builder);
+ JCClassDecl builder = maker.ClassDef(mods, job.getBuilderClassName(), job.copyTypeParams(), null, List.<JCExpression>nil(), List.<JCTree>nil());
+ recursiveSetGeneratedBy(builder, job.sourceNode);
+ return injectType(job.parentType, builder);
}
private void addObtainVia(BuilderFieldData bfd, JavacNode node) {
diff --git a/src/core/lombok/javac/handlers/HandleBuilderDefault.java b/src/core/lombok/javac/handlers/HandleBuilderDefault.java
index df5eebc9..8438057a 100644
--- a/src/core/lombok/javac/handlers/HandleBuilderDefault.java
+++ b/src/core/lombok/javac/handlers/HandleBuilderDefault.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2018 The Project Lombok Authors.
+ * Copyright (C) 2017-2021 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
@@ -23,8 +23,6 @@ package lombok.javac.handlers;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCIdent;
@@ -36,8 +34,9 @@ import lombok.core.HandlerPriority;
import lombok.experimental.SuperBuilder;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(-1025) //HandleBuilder's level, minus one.
public class HandleBuilderDefault extends JavacAnnotationHandler<Builder.Default> {
@Override public void handle(AnnotationValues<Builder.Default> annotation, JCAnnotation ast, JavacNode annotationNode) {
@@ -55,6 +54,7 @@ public class HandleBuilderDefault extends JavacAnnotationHandler<Builder.Default
JCFieldAccess jfa = (JCFieldAccess) ast.annotationType;
if (jfa.selected instanceof JCIdent && ((JCIdent) jfa.selected).name.contentEquals("Builder") && jfa.name.contentEquals("Default")) {
JCFieldAccess newJfaSel = annotationNode.getTreeMaker().Select(annotationNode.getTreeMaker().Ident(annotationNode.toName("lombok")), ((JCIdent) jfa.selected).name);
+ recursiveSetGeneratedBy(newJfaSel, annotationNode);
jfa.selected = newJfaSel;
}
}
diff --git a/src/core/lombok/javac/handlers/HandleBuilderDefaultRemove.java b/src/core/lombok/javac/handlers/HandleBuilderDefaultRemove.java
index fc0738c3..d7bc28cb 100644
--- a/src/core/lombok/javac/handlers/HandleBuilderDefaultRemove.java
+++ b/src/core/lombok/javac/handlers/HandleBuilderDefaultRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Project Lombok Authors.
+ * Copyright (C) 2018-2021 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
@@ -23,8 +23,6 @@ package lombok.javac.handlers;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.Builder;
@@ -34,9 +32,10 @@ import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
-@HandlerPriority(65536)
+@Provides
+@HandlerPriority(32768)
@AlreadyHandledAnnotations
public class HandleBuilderDefaultRemove extends JavacAnnotationHandler<Builder.Default> {
@Override public void handle(AnnotationValues<Default> annotation, JCAnnotation ast, JavacNode annotationNode) {
diff --git a/src/core/lombok/javac/handlers/HandleBuilderRemove.java b/src/core/lombok/javac/handlers/HandleBuilderRemove.java
index 6e59b40f..a47ed6b0 100644
--- a/src/core/lombok/javac/handlers/HandleBuilderRemove.java
+++ b/src/core/lombok/javac/handlers/HandleBuilderRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 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
@@ -23,8 +23,6 @@ package lombok.javac.handlers;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.Builder;
@@ -33,9 +31,10 @@ import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
-@HandlerPriority(65536)
+@Provides
+@HandlerPriority(32768)
@AlreadyHandledAnnotations
public class HandleBuilderRemove extends JavacAnnotationHandler<Builder> {
@Override public void handle(AnnotationValues<Builder> annotation, JCAnnotation ast, JavacNode annotationNode) {
diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java
index 4aa61764..785ebf8a 100644
--- a/src/core/lombok/javac/handlers/HandleCleanup.java
+++ b/src/core/lombok/javac/handlers/HandleCleanup.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,8 +32,7 @@ import lombok.delombok.LombokOptionsFactory;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -52,7 +51,6 @@ import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -60,7 +58,7 @@ import com.sun.tools.javac.util.Name;
/**
* Handles the {@code lombok.Cleanup} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleCleanup extends JavacAnnotationHandler<Cleanup> {
@Override public void handle(AnnotationValues<Cleanup> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.CLEANUP_FLAG_USAGE, "@Cleanup");
@@ -129,10 +127,9 @@ public class HandleCleanup extends JavacAnnotationHandler<Cleanup> {
JCIf ifNotNullCleanup = maker.If(isNull, maker.Block(0, cleanupCall), null);
- Context context = annotationNode.getContext();
- JCBlock finalizer = recursiveSetGeneratedBy(maker.Block(0, List.<JCStatement>of(ifNotNullCleanup)), ast, context);
+ JCBlock finalizer = recursiveSetGeneratedBy(maker.Block(0, List.<JCStatement>of(ifNotNullCleanup)), annotationNode);
- newStatements.append(setGeneratedBy(maker.Try(setGeneratedBy(maker.Block(0, tryBlock.toList()), ast, context), List.<JCCatch>nil(), finalizer), ast, context));
+ newStatements.append(setGeneratedBy(maker.Try(setGeneratedBy(maker.Block(0, tryBlock.toList()), annotationNode), List.<JCCatch>nil(), finalizer), annotationNode));
if (blockNode instanceof JCBlock) {
((JCBlock)blockNode).stats = newStatements.toList();
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java
index 54a9f821..9c74ca0e 100644
--- a/src/core/lombok/javac/handlers/HandleConstructor.java
+++ b/src/core/lombok/javac/handlers/HandleConstructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -25,8 +25,6 @@ import static lombok.core.handlers.HandlerUtil.*;
import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Type;
@@ -55,18 +53,17 @@ import lombok.NoArgsConstructor;
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;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
public class HandleConstructor {
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleNoArgsConstructor extends JavacAnnotationHandler<NoArgsConstructor> {
private static final String NAME = NoArgsConstructor.class.getSimpleName();
private HandleConstructor handleConstructor = new HandleConstructor();
@@ -88,7 +85,7 @@ public class HandleConstructor {
}
}
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleRequiredArgsConstructor extends JavacAnnotationHandler<RequiredArgsConstructor> {
private static final String NAME = RequiredArgsConstructor.class.getSimpleName();
private HandleConstructor handleConstructor = new HandleConstructor();
@@ -138,7 +135,7 @@ public class HandleConstructor {
return fields.toList();
}
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleAllArgsConstructor extends JavacAnnotationHandler<AllArgsConstructor> {
private static final String NAME = AllArgsConstructor.class.getSimpleName();
private HandleConstructor handleConstructor = new HandleConstructor();
@@ -264,11 +261,11 @@ public class HandleConstructor {
generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, allToDefault, fields, source, argTypes_);
}
- private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, LombokNode<JavacAST, JavacNode, JCTree> source, List<Type> argTypes_) {
+ private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, JavacNode source, List<Type> argTypes_) {
if (staticConstrRequired) {
ClassSymbol sym = ((JCClassDecl) typeNode.get()).sym;
Type returnType = sym == null ? null : sym.type;
- JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, allToDefault ? List.<JavacNode>nil() : fields, source.get());
+ JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, allToDefault ? List.<JavacNode>nil() : fields, source);
injectMethod(typeNode, staticConstr, argTypes_, returnType);
}
}
@@ -337,7 +334,7 @@ public class HandleConstructor {
Name rawName = field.name;
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
- JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
params.append(param);
if (hasNonNullAnnotations(fieldNode)) {
@@ -372,10 +369,9 @@ 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());
+ maker.Block(0L, nullChecks.appendList(assigns).toList()), null), source);
}
/**
@@ -446,12 +442,11 @@ public class HandleConstructor {
return true;
}
- public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JCTree source) {
+ public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
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;
@@ -464,13 +459,15 @@ public class HandleConstructor {
typeParams.append(maker.TypeParameter(param.name, param.bounds));
}
}
- returnType = namePlusTypeParamsToTypeReference(maker, typeNode, type.typarams);
+ List<JCAnnotation> annsOnReturnType = List.nil();
+ if (getCheckerFrameworkVersion(typeNode).generateUnique()) annsOnReturnType = List.of(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
+ returnType = namePlusTypeParamsToTypeReference(maker, typeNode, type.typarams, annsOnReturnType);
constructorType = namePlusTypeParamsToTypeReference(maker, typeNode, type.typarams);
for (JavacNode fieldNode : fields) {
JCVariableDecl field = (JCVariableDecl) fieldNode.get();
Name fieldName = removePrefixFromField(fieldNode);
- JCExpression pType = cloneType(maker, field.vartype, source, typeNode.getContext());
+ JCExpression pType = cloneType(maker, field.vartype, source);
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
@@ -482,6 +479,6 @@ public class HandleConstructor {
JCMethodDecl methodDef = maker.MethodDef(mods, typeNode.toName(name), returnType, typeParams.toList(), params.toList(), List.<JCExpression>nil(), body, null);
createRelevantNonNullAnnotation(typeNode, methodDef);
- return recursiveSetGeneratedBy(methodDef, source, typeNode.getContext());
+ return recursiveSetGeneratedBy(methodDef, source);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleData.java b/src/core/lombok/javac/handlers/HandleData.java
index 15c9c9e7..06524aa8 100644
--- a/src/core/lombok/javac/handlers/HandleData.java
+++ b/src/core/lombok/javac/handlers/HandleData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -30,8 +30,7 @@ import lombok.core.AnnotationValues;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.handlers.HandleConstructor.SkipIfConstructorExists;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.util.List;
@@ -39,7 +38,7 @@ import com.sun.tools.javac.util.List;
/**
* Handles the {@code lombok.Data} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleData extends JavacAnnotationHandler<Data> {
private HandleConstructor handleConstructor = new HandleConstructor();
private HandleGetter handleGetter = new HandleGetter();
@@ -52,9 +51,8 @@ public class HandleData extends JavacAnnotationHandler<Data> {
deleteAnnotationIfNeccessary(annotationNode, Data.class);
JavacNode typeNode = annotationNode.up();
- boolean notAClass = !isClass(typeNode);
- if (notAClass) {
+ if (!isClass(typeNode)) {
annotationNode.addError("@Data is only supported on a class.");
return;
}
diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java
index d6e76ab1..4d72eea3 100644
--- a/src/core/lombok/javac/handlers/HandleDelegate.java
+++ b/src/core/lombok/javac/handlers/HandleDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2014 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -43,8 +43,6 @@ import javax.lang.model.type.ExecutableType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.Attribute.Compound;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symbol;
@@ -81,8 +79,10 @@ import lombok.javac.JavacResolution;
import lombok.javac.JavacResolution.TypeNotConvertibleException;
import lombok.javac.JavacTreeMaker;
import lombok.javac.ResolutionResetNeeded;
+import lombok.permit.Permit;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(HandleDelegate.HANDLE_DELEGATE_PRIORITY) //2^16; to make sure that we also delegate generated methods.
@ResolutionResetNeeded
public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
@@ -348,7 +348,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
JCStatement body = useReturn ? maker.Return(delegateCall) : maker.Exec(delegateCall);
JCBlock bodyBlock = maker.Block(0, com.sun.tools.javac.util.List.of(body));
- return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation.get(), annotation.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation);
}
public static <T> com.sun.tools.javac.util.List<T> toList(ListBuffer<T> collection) {
@@ -466,7 +466,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
static {
Method m = null;
try {
- m = Type.class.getDeclaredMethod("unannotatedType");
+ m = Permit.getMethod(Type.class, "unannotatedType");
} catch (Exception e) {/* ignore */}
unannotated = m;
}
@@ -474,7 +474,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
static Type unannotatedType(Type t) {
if (unannotated == null) return t;
try {
- return (Type) unannotated.invoke(t);
+ return (Type) Permit.invoke(unannotated, t);
} catch (Exception e) {
return t;
}
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index e35deb5b..ffe882d8 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -30,11 +30,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBinary;
@@ -42,6 +39,8 @@ import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
+import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCModifiers;
@@ -56,6 +55,7 @@ import com.sun.tools.javac.util.Name;
import lombok.ConfigurationKeys;
import lombok.EqualsAndHashCode;
+import lombok.EqualsAndHashCode.CacheStrategy;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.configuration.CallSuperType;
@@ -68,19 +68,22 @@ import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
+import lombok.spi.Provides;
/**
* Handles the {@code lombok.EqualsAndHashCode} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHashCode> {
private static final String RESULT_NAME = "result";
private static final String PRIME_NAME = "PRIME";
+ private static final String HASH_CODE_CACHE_NAME = "$hashCodeCache";
@Override public void handle(AnnotationValues<EqualsAndHashCode> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.EQUALS_AND_HASH_CODE_FLAG_USAGE, "@EqualsAndHashCode");
deleteAnnotationIfNeccessary(annotationNode, EqualsAndHashCode.class);
+ deleteImportFromCompilationUnit(annotationNode, CacheStrategy.class.getName());
EqualsAndHashCode ann = annotation.getInstance();
java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members = InclusionExclusionUtils.handleEqualsAndHashCodeMarking(annotationNode.up(), annotation, annotationNode);
JavacNode typeNode = annotationNode.up();
@@ -93,7 +96,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
boolean doNotUseGetters = annotation.isExplicit("doNotUseGetters") || doNotUseGettersConfiguration == null ? ann.doNotUseGetters() : doNotUseGettersConfiguration;
FieldAccess fieldAccess = doNotUseGetters ? FieldAccess.PREFER_FIELD : FieldAccess.GETTER;
- generateMethods(typeNode, annotationNode, members, callSuper, true, fieldAccess, onParam);
+ boolean cacheHashCode = ann.cacheStrategy() == CacheStrategy.LAZY;
+
+ generateMethods(typeNode, annotationNode, members, callSuper, true, cacheHashCode, fieldAccess, onParam);
}
public void generateEqualsAndHashCodeForType(JavacNode typeNode, JavacNode source) {
@@ -107,11 +112,11 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members = InclusionExclusionUtils.handleEqualsAndHashCodeMarking(typeNode, null, null);
- generateMethods(typeNode, source, members, null, false, access, List.<JCAnnotation>nil());
+ generateMethods(typeNode, source, members, null, false, false, access, List.<JCAnnotation>nil());
}
public void generateMethods(JavacNode typeNode, JavacNode source, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members,
- Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess, List<JCAnnotation> onParam) {
+ Boolean callSuper, boolean whineIfExists, boolean cacheHashCode, FieldAccess fieldAccess, List<JCAnnotation> onParam) {
if (!isClass(typeNode)) {
source.addError("@EqualsAndHashCode is only supported on a class.");
@@ -129,30 +134,6 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
boolean isDirectDescendantOfObject = isDirectDescendantOfObject(typeNode);
- if (isDirectDescendantOfObject && callSuper) {
- source.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
- return;
- }
-
- if (implicitCallSuper && !isDirectDescendantOfObject) {
- CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
- if (cst == null) cst = CallSuperType.WARN;
-
- switch (cst) {
- default:
- case WARN:
- source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
- callSuper = false;
- break;
- case SKIP:
- callSuper = false;
- break;
- case CALL:
- callSuper = true;
- break;
- }
- }
-
boolean isFinal = (((JCClassDecl) typeNode.get()).mods.flags & Flags.FINAL) != 0;
boolean needsCanEqual = !isFinal || !isDirectDescendantOfObject;
MemberExistsResult equalsExists = methodExists("equals", typeNode, 1);
@@ -181,26 +162,72 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
//fallthrough
}
- JCMethodDecl equalsMethod = createEquals(typeNode, members, callSuper, fieldAccess, needsCanEqual, source.get(), onParam);
+ if (isDirectDescendantOfObject && callSuper) {
+ source.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
+ return;
+ }
+
+ if (implicitCallSuper && !isDirectDescendantOfObject) {
+ CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ if (cst == null) cst = CallSuperType.WARN;
+
+ switch (cst) {
+ default:
+ case WARN:
+ source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
+ callSuper = false;
+ break;
+ case SKIP:
+ callSuper = false;
+ break;
+ case CALL:
+ callSuper = true;
+ break;
+ }
+ }
+
+ JCMethodDecl equalsMethod = createEquals(typeNode, members, callSuper, fieldAccess, needsCanEqual, source, onParam);
injectMethod(typeNode, equalsMethod);
if (needsCanEqual && canEqualExists == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl canEqualMethod = createCanEqual(typeNode, source.get(), onParam);
+ JCMethodDecl canEqualMethod = createCanEqual(typeNode, source, onParam);
injectMethod(typeNode, canEqualMethod);
}
- JCMethodDecl hashCodeMethod = createHashCode(typeNode, members, callSuper, fieldAccess, source.get());
+ if (cacheHashCode){
+ if (fieldExists(HASH_CODE_CACHE_NAME, typeNode) != MemberExistsResult.NOT_EXISTS) {
+ String msg = String.format("Not caching the result of hashCode: A field named %s already exists.", HASH_CODE_CACHE_NAME);
+ source.addWarning(msg);
+ cacheHashCode = false;
+ } else {
+ createHashCodeCacheField(typeNode, source);
+ }
+ }
+
+ JCMethodDecl hashCodeMethod = createHashCode(typeNode, members, callSuper, cacheHashCode, fieldAccess, source);
injectMethod(typeNode, hashCodeMethod);
}
+
+ private void createHashCodeCacheField(JavacNode typeNode, JavacNode source) {
+ JavacTreeMaker maker = typeNode.getTreeMaker();
+ JCModifiers mods = maker.Modifiers(Flags.PRIVATE | Flags.TRANSIENT);
+ JCVariableDecl hashCodeCacheField = maker.VarDef(mods, typeNode.toName(HASH_CODE_CACHE_NAME), maker.TypeIdent(CTC_INT), null);
+ injectFieldAndMarkGenerated(typeNode, hashCodeCacheField);
+ recursiveSetGeneratedBy(hashCodeCacheField, source);
+ }
- public JCMethodDecl createHashCode(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, FieldAccess fieldAccess, JCTree source) {
+ public JCMethodDecl createHashCode(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, boolean cacheHashCode, FieldAccess fieldAccess, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil());
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()));
+ if (cacheHashCode && checkerFramework.generatePure()) {
+ annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__PURE), List.<JCExpression>nil()));
+ } else 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>();
@@ -211,6 +238,15 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
boolean isEmpty = members.isEmpty();
+ /* if (this.$hashCodeCache != 0) return this.$hashCodeCache; */ {
+ if (cacheHashCode) {
+ JCIdent receiver = maker.Ident(typeNode.toName("this"));
+ JCFieldAccess cacheHashCodeFieldAccess = maker.Select(receiver, typeNode.toName(HASH_CODE_CACHE_NAME));
+ JCExpression cacheNotZero = maker.Binary(CTC_NOT_EQUAL, cacheHashCodeFieldAccess, maker.Literal(CTC_INT, 0));
+ statements.append(maker.If(cacheNotZero, maker.Return(cacheHashCodeFieldAccess), null));
+ }
+ }
+
/* final int PRIME = X; */ {
if (!isEmpty) {
statements.append(maker.VarDef(maker.Modifiers(finalFlag), primeName, maker.TypeIdent(CTC_INT), maker.Literal(HandlerUtil.primeForHashcode())));
@@ -228,7 +264,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
/* ... 1; */
init = maker.Literal(1);
}
- statements.append(maker.VarDef(maker.Modifiers(isEmpty ? finalFlag : 0), resultName, maker.TypeIdent(CTC_INT), init));
+ statements.append(maker.VarDef(maker.Modifiers(isEmpty && !cacheHashCode ? finalFlag : 0L), resultName, maker.TypeIdent(CTC_INT), init));
}
for (Included<JavacNode, EqualsAndHashCode.Include> member : members) {
@@ -300,13 +336,27 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
}
}
+ /*
+ * if (result == 0) result = Integer.MIN_VALUE;
+ * this.$hashCodeCache = result;
+ *
+ */ {
+ if (cacheHashCode) {
+ statements.append(maker.If(maker.Binary(CTC_EQUAL, maker.Ident(resultName), maker.Literal(CTC_INT, 0)),
+ maker.Exec(maker.Assign(maker.Ident(resultName), genJavaLangTypeRef(typeNode, "Integer", "MIN_VALUE"))), null));
+
+ JCFieldAccess cacheHashCodeFieldAccess = maker.Select(maker.Ident(typeNode.toName("this")), typeNode.toName(HASH_CODE_CACHE_NAME));
+ statements.append(maker.Exec(maker.Assign(cacheHashCodeFieldAccess, maker.Ident(resultName))));
+ }
+ }
+
/* return result; */ {
statements.append(maker.Return(maker.Ident(resultName)));
}
JCBlock body = maker.Block(0, statements.toList());
return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("hashCode"), returnType,
- List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source);
}
public JCExpressionStatement createResultCalculation(JavacNode typeNode, JCExpression expr) {
@@ -368,7 +418,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
return maker.TypeApply(expr, wildcards.toList());
}
- public JCMethodDecl createEquals(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source, List<JCAnnotation> onParam) {
+ public JCMethodDecl createEquals(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JavacNode source, List<JCAnnotation> onParam) {
JavacTreeMaker maker = typeNode.getTreeMaker();
Name oName = typeNode.toName("o");
@@ -502,10 +552,10 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
}
JCBlock body = maker.Block(0, statements.toList());
- return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("equals"), returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("equals"), returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source);
}
- public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source, List<JCAnnotation> onParam) {
+ public JCMethodDecl createCanEqual(JavacNode typeNode, JavacNode source, List<JCAnnotation> onParam) {
/* protected boolean canEqual(final java.lang.Object other) {
* return other instanceof Outer.Inner.MyType;
* }
@@ -530,7 +580,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
JCBlock body = maker.Block(0, List.<JCStatement>of(
maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode, false)))));
- return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source);
}
public JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField,
diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
index 345c5f8e..dd565f72 100644
--- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -28,6 +28,7 @@ import static lombok.javac.handlers.JavacResolver.*;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.lang.model.element.ElementKind;
@@ -37,12 +38,13 @@ import lombok.core.HandlerPriority;
import lombok.experimental.ExtensionMethod;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.javac.JavacResolution;
+import lombok.spi.Provides;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.util.TreeScanner;
import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Type;
@@ -51,6 +53,7 @@ import com.sun.tools.javac.code.Type.ErrorType;
import com.sun.tools.javac.code.Type.ForAll;
import com.sun.tools.javac.code.Type.MethodType;
import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
@@ -61,7 +64,7 @@ import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
/**
* Handles the {@link ExtensionMethod} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(66560) // 2^16 + 2^10; we must run AFTER HandleVal which is at 2^16
public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMethod> {
@Override
@@ -148,8 +151,9 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
@Override
public Void visitMethodInvocation(final MethodInvocationTree tree, final Void p) {
+ super.visitMethodInvocation(tree, p);
handleMethodCall((JCMethodInvocation) tree);
- return super.visitMethodInvocation(tree, p);
+ return null;
}
private void handleMethodCall(final JCMethodInvocation methodCall) {
@@ -166,13 +170,25 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
JCExpression receiver = receiverOf(methodCall);
String methodName = methodNameOf(methodCall);
- if ("this".equals(methodName) || "super".equals(methodName)) return;
- Type resolvedMethodCall = CLASS_AND_METHOD.resolveMember(methodCallNode, methodCall);
- if (resolvedMethodCall == null) return;
- if (!suppressBaseMethods && !(resolvedMethodCall instanceof ErrorType)) return;
- Type receiverType = CLASS_AND_METHOD.resolveMember(methodCallNode, receiver);
- if (receiverType == null) return;
- if (receiverType.tsym.toString().endsWith(receiver.toString())) return;
+ if ("this".equals(receiver.toString()) || "this".equals(methodName) || "super".equals(methodName)) return;
+ Map<JCTree, JCTree> resolution = new JavacResolution(methodCallNode.getContext()).resolveMethodMember(methodCallNode);
+
+ JCTree resolvedMethodCall = resolution.get(methodCall);
+ if (resolvedMethodCall == null || resolvedMethodCall.type == null) return;
+ if (!suppressBaseMethods && !(resolvedMethodCall.type instanceof ErrorType)) return;
+
+ JCTree resolvedReceiver = resolution.get(receiver);
+ if (resolvedReceiver == null || resolvedReceiver.type == null) return;
+ Type receiverType = resolvedReceiver.type;
+
+ // Skip static method access
+ Symbol sym = null;
+ if (resolvedReceiver instanceof JCIdent) {
+ sym = ((JCIdent) resolvedReceiver).sym;
+ } else if (resolvedReceiver instanceof JCFieldAccess) {
+ sym = ((JCFieldAccess) resolvedReceiver).sym;
+ }
+ if (sym instanceof ClassSymbol) return;
Types types = Types.instance(annotationNode.getContext());
for (Extension extension : extensions) {
@@ -186,6 +202,7 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
if (!types.isAssignable(receiverType, firstArgType)) continue;
methodCall.args = methodCall.args.prepend(receiver);
methodCall.meth = chainDotsString(annotationNode, extensionProvider.toString() + "." + methodName);
+ recursiveSetGeneratedBy(methodCall.meth, methodCallNode);
return;
}
}
diff --git a/src/core/lombok/javac/handlers/HandleFieldDefaults.java b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
index c974bdb9..ebab67e3 100644
--- a/src/core/lombok/javac/handlers/HandleFieldDefaults.java
+++ b/src/core/lombok/javac/handlers/HandleFieldDefaults.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2016 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -34,8 +34,7 @@ import lombok.experimental.PackagePrivate;
import lombok.javac.JavacASTAdapter;
import lombok.javac.JavacASTVisitor;
import lombok.javac.JavacNode;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
@@ -46,7 +45,7 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
/**
* Handles the {@code lombok.FieldDefaults} annotation for javac.
*/
-@ProviderFor(JavacASTVisitor.class)
+@Provides(JavacASTVisitor.class)
@HandlerPriority(-2048) //-2^11; to ensure @Value picks up on messing with the fields' 'final' state, run earlier.
public class HandleFieldDefaults extends JavacASTAdapter {
public boolean generateFieldDefaultsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean makeFinal, boolean checkForTypeLevelFieldDefaults) {
diff --git a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
index ec4015c7..f3c879d5 100644
--- a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2019 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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
@@ -36,8 +36,7 @@ import lombok.experimental.FieldNameConstants;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
@@ -53,7 +52,7 @@ import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Name;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameConstants> {
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
@@ -78,7 +77,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
if (qualified.isEmpty()) {
errorNode.addWarning("No fields qualify for @FieldNameConstants, therefore this annotation does nothing");
} else {
- createInnerTypeFieldNameConstants(typeNode, errorNode, errorNode.get(), level, qualified, asEnum, innerTypeName, uppercase);
+ createInnerTypeFieldNameConstants(typeNode, errorNode, level, qualified, asEnum, innerTypeName, uppercase);
}
}
@@ -133,7 +132,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
generateFieldNameConstantsForType(node, annotationNode, level, asEnum, innerTypeName, annotationInstance.onlyExplicitlyIncluded(), uppercase);
}
- private void createInnerTypeFieldNameConstants(JavacNode typeNode, JavacNode errorNode, JCTree pos, AccessLevel level, java.util.List<JavacNode> fields, boolean asEnum, IdentifierName innerTypeName, boolean uppercase) {
+ private void createInnerTypeFieldNameConstants(JavacNode typeNode, JavacNode errorNode, AccessLevel level, java.util.List<JavacNode> fields, boolean asEnum, IdentifierName innerTypeName, boolean uppercase) {
if (fields.isEmpty()) return;
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -146,7 +145,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
if (fieldsType == null) {
JCClassDecl innerType = maker.ClassDef(mods, fieldsName, List.<JCTypeParameter>nil(), null, List.<JCExpression>nil(), List.<JCTree>nil());
fieldsType = injectType(typeNode, innerType);
- recursiveSetGeneratedBy(innerType, pos, typeNode.getContext());
+ recursiveSetGeneratedBy(innerType, errorNode);
genConstr = true;
} else {
JCClassDecl builderTypeDeclaration = (JCClassDecl) fieldsType.get();
@@ -166,7 +165,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
JCModifiers genConstrMods = maker.Modifiers(Flags.GENERATEDCONSTR | (asEnum ? 0L : Flags.PRIVATE));
JCBlock genConstrBody = maker.Block(0L, List.<JCStatement>of(maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(typeNode.toName("super")), List.<JCExpression>nil()))));
JCMethodDecl c = maker.MethodDef(genConstrMods, typeNode.toName("<init>"), null, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), genConstrBody, null);
- recursiveSetGeneratedBy(c, pos, typeNode.getContext());
+ recursiveSetGeneratedBy(c, errorNode);
injectMethod(fieldsType, c);
}
@@ -187,9 +186,9 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
}
JCVariableDecl constantField = maker.VarDef(constantValueMods, fName, returnType, init);
injectField(fieldsType, constantField, false, true);
- setGeneratedBy(constantField, pos, typeNode.getContext());
+ setGeneratedBy(constantField, errorNode);
generated.add(constantField);
}
- for (JCVariableDecl cf : generated) recursiveSetGeneratedBy(cf, pos, typeNode.getContext());
+ for (JCVariableDecl cf : generated) recursiveSetGeneratedBy(cf, errorNode);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java
index 1b4d404b..8f6de9bb 100644
--- a/src/core/lombok/javac/handlers/HandleGetter.java
+++ b/src/core/lombok/javac/handlers/HandleGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -43,8 +43,7 @@ import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.JavacTreeMaker.TypeTag;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Type;
@@ -70,8 +69,10 @@ import com.sun.tools.javac.util.Name;
/**
* Handles the {@code lombok.Getter} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleGetter extends JavacAnnotationHandler<Getter> {
+ private static final String GETTER_NODE_NOT_SUPPORTED_ERR = "@Getter is only supported on a class, an enum, or a field.";
+
public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter, List<JCAnnotation> onMethod) {
if (checkForTypeLevelGetter) {
if (hasAnnotation(Getter.class, typeNode)) {
@@ -81,7 +82,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
}
if (!isClassOrEnum(typeNode)) {
- errorNode.addError("@Getter is only supported on a class, an enum, or a field.");
+ errorNode.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -165,7 +166,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
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.");
+ source.addError(GETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -213,14 +214,14 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC);
- injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source.get(), lazy, onMethod), List.<Type>nil(), getMirrorForFieldType(fieldNode));
+ injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source, lazy, onMethod), List.<Type>nil(), getMirrorForFieldType(fieldNode));
}
- public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, boolean lazy, List<JCAnnotation> onMethod) {
+ public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JavacNode source, boolean lazy, List<JCAnnotation> onMethod) {
JCVariableDecl fieldNode = (JCVariableDecl) field.get();
// Remember the type; lazy will change it
- JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source, field.getContext());
+ JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source);
// Generate the methodName; lazy will change the field type
Name methodName = field.toName(toGetterName(field));
@@ -261,9 +262,9 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
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());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
- if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null, null);
+ if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null);
if (methodArgPos != null) {
for (int i = 0; i < methodArgPos.length; i++) {
((JCMethodInvocation) toClearOfMarkers).args.get(i).pos = methodArgPos[i];
@@ -274,10 +275,10 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
if (addSuppressWarningsUnchecked) {
ListBuffer<JCExpression> suppressions = new ListBuffer<JCExpression>();
if (!Boolean.FALSE.equals(field.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS))) {
- suppressions.add(treeMaker.Literal("all"));
+ suppressions.append(treeMaker.Literal("all"));
}
- suppressions.add(treeMaker.Literal("unchecked"));
- addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
+ suppressions.append(treeMaker.Literal("unchecked"));
+ addAnnotation(decl.mods, field, source, "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
}
copyJavadoc(field, decl, CopyJavadoc.GETTER);
@@ -328,7 +329,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
TYPE_MAP = Collections.unmodifiableMap(m);
}
- public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) {
+ public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JavacNode source) {
/*
java.lang.Object value = this.fieldName.get();
if (value == null) {
@@ -374,7 +375,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
/* java.lang.Object value = this.fieldName.get();*/ {
JCExpression valueVarType = genJavaLangTypeRef(fieldNode, "Object");
- statements.append(maker.VarDef(maker.Modifiers(0), valueName, valueVarType, callGet(fieldNode, createFieldAccessor(maker, fieldNode, FieldAccess.ALWAYS_FIELD))));
+ statements.append(maker.VarDef(maker.Modifiers(0L), valueName, valueVarType, callGet(fieldNode, createFieldAccessor(maker, fieldNode, FieldAccess.ALWAYS_FIELD))));
}
/* if (value == null) { */ {
@@ -441,8 +442,8 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
/* private final java.util.concurrent.atomic.AtomicReference<Object> fieldName = new java.util.concurrent.atomic.AtomicReference<Object>(); */ {
field.vartype = recursiveSetGeneratedBy(
- maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source, fieldNode.getContext());
- field.init = recursiveSetGeneratedBy(maker.NewClass(null, NIL_EXPRESSION, copyType(maker, field), NIL_EXPRESSION, null), source, fieldNode.getContext());
+ maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source);
+ field.init = recursiveSetGeneratedBy(maker.NewClass(null, NIL_EXPRESSION, copyType(maker, field), NIL_EXPRESSION, null), source);
}
return statements.toList();
diff --git a/src/core/lombok/javac/handlers/HandleHelper.java b/src/core/lombok/javac/handlers/HandleHelper.java
index 6f4361c1..35b0c4f2 100755
--- a/src/core/lombok/javac/handlers/HandleHelper.java
+++ b/src/core/lombok/javac/handlers/HandleHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2016 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,8 +29,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.TreeVisitor;
import com.sun.source.util.TreeScanner;
@@ -56,8 +54,9 @@ import lombok.experimental.Helper;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleHelper extends JavacAnnotationHandler<Helper> {
private List<JCStatement> getStatementsFromJcNode(JCTree tree) {
if (tree instanceof JCBlock) return ((JCBlock) tree).stats;
@@ -71,7 +70,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
else throw new IllegalArgumentException("Can't set statements on node type: " + tree.getClass());
}
- @Override public void handle(AnnotationValues<Helper> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ @Override public void handle(AnnotationValues<Helper> annotation, JCAnnotation ast, final JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.HELPER_FLAG_USAGE, "@Helper");
deleteAnnotationIfNeccessary(annotationNode, Helper.class);
@@ -120,6 +119,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
JCIdent jci = (JCIdent) jcmi.meth;
if (Arrays.binarySearch(knownMethodNames_, jci.name.toString()) < 0) return;
jcmi.meth = maker.Select(maker.Ident(helperName), jci.name);
+ recursiveSetGeneratedBy(jcmi.meth, annotationNode);
helperUsed[0] = true;
}
};
@@ -144,6 +144,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
JCExpression init = maker.NewClass(null, List.<JCExpression>nil(), maker.Ident(annotatedType_.name), List.<JCExpression>nil(), null);
JCExpression varType = maker.Ident(annotatedType_.name);
JCVariableDecl decl = maker.VarDef(maker.Modifiers(Flags.FINAL), helperName, varType, init);
+ recursiveSetGeneratedBy(decl, annotationNode);
newStatements.append(decl);
}
setStatementsOfJcNode(containingBlock.get(), newStatements.toList());
diff --git a/src/core/lombok/javac/handlers/HandleJacksonized.java b/src/core/lombok/javac/handlers/HandleJacksonized.java
index 0aa02d1b..3ee0eec4 100644
--- a/src/core/lombok/javac/handlers/HandleJacksonized.java
+++ b/src/core/lombok/javac/handlers/HandleJacksonized.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 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
@@ -24,8 +24,6 @@ package lombok.javac.handlers;
import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -49,13 +47,14 @@ import lombok.extern.jackson.Jacksonized;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
+import lombok.spi.Provides;
/**
* This (javac) handler deals with {@code @Jacksonized} modifying the (already
* generated) {@code @Builder} or {@code @SuperBuilder} to conform to Jackson's
* needs for builders.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(-512) // Above Handle(Super)Builder's level (builders must be already generated).
public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
@@ -107,7 +106,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JavacTreeMaker maker = annotatedNode.getTreeMaker();
// Now lets find the generated builder class.
- String builderClassName = getBuilderClassName(ast, annotationNode, annotatedNode, td, builderAnnotation, maker);
+ String builderClassName = getBuilderClassName(annotationNode, annotatedNode, td, builderAnnotation, maker);
JCClassDecl builderClass = null;
for (JCTree member : td.getMembers()) {
@@ -132,11 +131,15 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCFieldAccess builderClassReference = maker.Select(builderClassExpression, annotatedNode.toName("class"));
JCExpression assign = maker.Assign(maker.Ident(annotationNode.toName("builder")), builderClassReference);
JCAnnotation annotationJsonDeserialize = maker.Annotation(jsonDeserializeType, List.of(assign));
+ recursiveSetGeneratedBy(annotationJsonDeserialize, annotationNode);
td.mods.annotations = td.mods.annotations.append(annotationJsonDeserialize);
// Copy annotations from the class to the builder class.
List<JCAnnotation> copyableAnnotations = findJacksonAnnotationsOnClass(tdNode);
List<JCAnnotation> copiedAnnotations = copyAnnotations(copyableAnnotations);
+ for (JCAnnotation anno : copiedAnnotations) {
+ recursiveSetGeneratedBy(anno, annotationNode);
+ }
builderClass.mods.annotations = builderClass.mods.annotations.appendList(copiedAnnotations);
// Insert @JsonPOJOBuilder on the builder class.
@@ -144,6 +147,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCExpression withPrefixExpr = maker.Assign(maker.Ident(annotationNode.toName("withPrefix")), maker.Literal(setPrefix));
JCExpression buildMethodNameExpr = maker.Assign(maker.Ident(annotationNode.toName("buildMethodName")), maker.Literal(buildMethodName));
JCAnnotation annotationJsonPOJOBuilder = maker.Annotation(jsonPOJOBuilderType, List.of(withPrefixExpr, buildMethodNameExpr));
+ recursiveSetGeneratedBy(annotationJsonPOJOBuilder, annotatedNode);
builderClass.mods.annotations = builderClass.mods.annotations.append(annotationJsonPOJOBuilder);
// @SuperBuilder? Make it package-private!
@@ -151,7 +155,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
builderClass.mods.flags = builderClass.mods.flags & ~Flags.PRIVATE;
}
- private String getBuilderClassName(JCAnnotation ast, JavacNode annotationNode, JavacNode annotatedNode, JCClassDecl td, AnnotationValues<Builder> builderAnnotation, JavacTreeMaker maker) {
+ private String getBuilderClassName(JavacNode annotationNode, JavacNode annotatedNode, JCClassDecl td, AnnotationValues<Builder> builderAnnotation, JavacTreeMaker maker) {
String builderClassName = builderAnnotation != null ?
builderAnnotation.getInstance().builderClassName() : null;
if (builderClassName == null || builderClassName.isEmpty()) {
@@ -166,7 +170,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCExpression returnType = fillParametersFrom.restype;
List<JCTypeParameter> typeParams = fillParametersFrom.typarams;
if (returnType instanceof JCTypeApply) {
- returnType = cloneType(maker, returnType, ast, annotationNode.getContext());
+ returnType = cloneType(maker, returnType, annotatedNode);
}
replacement = HandleBuilder.returnTypeToBuilderClassName(annotationNode, td, returnType, typeParams);
} else {
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index 1ff10ad1..47c4098f 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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,15 +31,14 @@ import lombok.core.configuration.IdentifierName;
import lombok.core.configuration.LogDeclaration;
import lombok.core.configuration.LogDeclaration.LogFactoryParameter;
import lombok.core.handlers.LoggingFramework;
+import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
@@ -75,6 +74,7 @@ public class HandleLog {
annotationNode.addWarning("Field '" + logFieldName + "' already exists.");
return;
}
+
if (isRecord(typeNode) && !useStatic) {
annotationNode.addError("Logger fields must be static in records.");
return;
@@ -82,7 +82,7 @@ public class HandleLog {
Object valueGuess = annotation.getValueGuess("topic");
JCExpression loggerTopic = (JCExpression) annotation.getActualExpression("topic");
-
+
if (valueGuess instanceof String && ((String) valueGuess).trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
@@ -94,7 +94,7 @@ public class HandleLog {
}
JCFieldAccess loggingType = selfType(typeNode);
- createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName.getName(), useStatic, loggerTopic);
+ createField(framework, typeNode, loggingType, annotationNode, logFieldName.getName(), useStatic, loggerTopic);
break;
default:
annotationNode.addError("@Log is legal only on types.");
@@ -108,7 +108,7 @@ public class HandleLog {
return maker.Select(maker.Ident(name), typeNode.toName("class"));
}
- private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
+ private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JavacNode source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
JavacTreeMaker maker = typeNode.getTreeMaker();
LogDeclaration logDeclaration = framework.getDeclaration();
@@ -122,17 +122,19 @@ public class HandleLog {
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)),
- typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext());
+ typeNode.toName(logFieldName), loggerType, factoryMethodCall), source);
- // This is a workaround for https://bugs.openjdk.java.net/browse/JDK-8243057
- if (isRecord(typeNode)) {
+ if (isRecord(typeNode) && Javac.getJavaCompilerVersion() < 16) {
+ // This is a workaround for https://bugs.openjdk.java.net/browse/JDK-8243057
+
injectField(typeNode, fieldDecl);
} else {
injectFieldAndMarkGenerated(typeNode, fieldDecl);
}
+
return true;
}
-
+
private static JCExpression[] createFactoryParameters(JavacNode typeNode, JCFieldAccess loggingType, java.util.List<LogFactoryParameter> parameters, JCExpression loggerTopic) {
JCExpression[] expressions = new JCExpression[parameters.size()];
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -164,7 +166,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleCommonsLog extends JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -175,7 +177,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.java.Log} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleJulLog extends JavacAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -186,7 +188,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.log4j.Log4j} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleLog4jLog extends JavacAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -197,7 +199,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.log4j.Log4j2} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -208,7 +210,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.slf4j.Slf4j} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -219,7 +221,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.slf4j.XSlf4j} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleXSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -230,7 +232,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.jbosslog.JBossLog} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleJBossLog extends JavacAnnotationHandler<lombok.extern.jbosslog.JBossLog> {
@Override public void handle(AnnotationValues<lombok.extern.jbosslog.JBossLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JBOSSLOG_FLAG_USAGE, "@JBossLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -241,7 +243,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.extern.flogger.Flogger} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleFloggerLog extends JavacAnnotationHandler<lombok.extern.flogger.Flogger> {
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
@@ -252,7 +254,7 @@ public class HandleLog {
/**
* Handles the {@link lombok.CustomLog} annotation for javac.
*/
- @ProviderFor(JavacAnnotationHandler.class)
+ @Provides
public static class HandleCustomLog extends JavacAnnotationHandler<lombok.CustomLog> {
@Override public void handle(AnnotationValues<lombok.CustomLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_CUSTOM_FLAG_USAGE, "@CustomLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java
index 6b6b7efa..2f359c0f 100644
--- a/src/core/lombok/javac/handlers/HandleNonNull.java
+++ b/src/core/lombok/javac/handlers/HandleNonNull.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -27,8 +27,6 @@ import static lombok.javac.JavacTreeMaker.TreeTag.treeTag;
import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCAssert;
import com.sun.tools.javac.tree.JCTree.JCAssign;
@@ -57,17 +55,16 @@ import lombok.NonNull;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
-
-import lombok.javac.Java14Flags;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.handlers.HandleConstructor.SkipIfConstructorExists;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first.
public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
private HandleConstructor handleConstructor = new HandleConstructor();
-
+
@Override public void handle(AnnotationValues<NonNull> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.NON_NULL_FLAG_USAGE, "@NonNull");
@@ -117,7 +114,7 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
// and if they exist, create a new method in the class: 'private static <T> T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and
// wrap all references to it in the super/this to a call to this method.
- JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), paramNode, annotationNode), ast, annotationNode.getContext());
+ JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), paramNode, annotationNode), annotationNode);
if (nullCheck == null) {
// @NonNull applied to a primitive. Kinda pointless. Let's generate a warning.
@@ -125,19 +122,18 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
return;
}
+ List<JCStatement> statements = declaration.body.stats;
+
+ String expectedName = paramNode.getName();
+
JavacNode typeNode = upToTypeNode(annotationNode);
- if ((declaration.mods.flags & Java14Flags.RECORD) != 0) {
- if (!lombokConstructorExists(typeNode)) {
+ if ((declaration.mods.flags & RECORD) != 0) {
+ if (!lombokConstructorExists(typeNode)) {
handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, null, SkipIfConstructorExists.NO, annotationNode);
}
- return;
}
- List<JCStatement> statements = declaration.body.stats;
-
- String expectedName = paramNode.getName();
-
/* Abort if the null check is already there, delving into try and synchronized statements */ {
List<JCStatement> stats = statements;
int idx = 0;
diff --git a/src/core/lombok/javac/handlers/HandlePrintAST.java b/src/core/lombok/javac/handlers/HandlePrintAST.java
index 0826d1d1..647139bc 100644
--- a/src/core/lombok/javac/handlers/HandlePrintAST.java
+++ b/src/core/lombok/javac/handlers/HandlePrintAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -25,8 +25,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.Lombok;
@@ -36,11 +34,12 @@ import lombok.core.PrintAST;
import lombok.javac.JavacASTVisitor;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
/**
* Handles the {@code lombok.core.PrintAST} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(536870912) // 2^29; this handler is customarily run at the very end.
public class HandlePrintAST extends JavacAnnotationHandler<PrintAST> {
@Override public void handle(AnnotationValues<PrintAST> annotation, JCAnnotation ast, JavacNode annotationNode) {
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index b51574b7..5c34f9f5 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,8 +37,7 @@ import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
@@ -60,8 +59,10 @@ import com.sun.tools.javac.util.Name;
/**
* Handles the {@code lombok.Setter} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleSetter extends JavacAnnotationHandler<Setter> {
+ private static final String SETTER_NODE_NOT_SUPPORTED_ERR = "@Setter is only supported on a class or a field.";
+
public void generateSetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelSetter, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
if (checkForTypeLevelSetter) {
if (hasAnnotation(Setter.class, typeNode)) {
@@ -71,7 +72,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
}
if (!isClass(typeNode)) {
- errorNode.addError("@Setter is only supported on a class or a field.");
+ errorNode.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -145,7 +146,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
public void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode sourceNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
if (fieldNode.getKind() != Kind.FIELD) {
- fieldNode.addError("@Setter is only supported on a class or a field.");
+ fieldNode.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -215,13 +216,36 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
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());
+ recursiveSetGeneratedBy(anno, source);
+ d.mods.annotations = annotations.prepend(anno);
+ }
+ return d;
+ }
+
+ public static JCMethodDecl createSetterWithRecv(long access, boolean deprecate, JavacNode field, JavacTreeMaker treeMaker, String setterName, Name paramName, Name booleanFieldToSet, boolean shouldReturnThis, JavacNode source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam, JCVariableDecl recv) {
+ JCExpression returnType = null;
+ JCReturn returnStatement = null;
+ if (shouldReturnThis) {
+ returnType = cloneSelfType(field);
+ returnStatement = treeMaker.Return(treeMaker.Ident(field.toName("this")));
+ }
+
+ JCMethodDecl d = createSetterWithRecv(access, deprecate, field, treeMaker, setterName, paramName, booleanFieldToSet, returnType, returnStatement, source, onMethod, onParam, recv);
+ 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);
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) {
+ return createSetterWithRecv(access, deprecate, field, treeMaker, setterName, paramName, booleanFieldToSet, methodType, returnStatement, source, onMethod, onParam, null);
+ }
+
+ public static JCMethodDecl createSetterWithRecv(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, JCVariableDecl recv) {
if (setterName == null) return null;
JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
@@ -237,7 +261,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
- JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source);
JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, pType, null);
if (!hasNonNullAnnotations(field) && !hasNonNullAnnotations(field, onParam)) {
@@ -272,10 +296,16 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
}
- JCMethodDecl methodDef = treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
- methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue);
+ JCMethodDecl methodDef;
+ if (recv != null && treeMaker.hasMethodDefWithRecvParam()) {
+ methodDef = treeMaker.MethodDefWithRecvParam(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
+ methodGenericParams, recv, parameters, throwsClauses, methodBody, annotationMethodDefaultValue);
+ } else {
+ methodDef = treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue);
+ }
if (returnStatement != null) createRelevantNonNullAnnotation(source, methodDef);
- JCMethodDecl decl = recursiveSetGeneratedBy(methodDef, source.get(), field.getContext());
+ JCMethodDecl decl = recursiveSetGeneratedBy(methodDef, source);
copyJavadoc(field, decl, CopyJavadoc.SETTER, returnStatement != null);
return decl;
}
diff --git a/src/core/lombok/javac/handlers/HandleSneakyThrows.java b/src/core/lombok/javac/handlers/HandleSneakyThrows.java
index ffe37a4c..3dde75d8 100644
--- a/src/core/lombok/javac/handlers/HandleSneakyThrows.java
+++ b/src/core/lombok/javac/handlers/HandleSneakyThrows.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -35,11 +35,9 @@ import lombok.core.HandlerPriority;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
@@ -48,14 +46,13 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTry;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import lombok.javac.Javac;
/**
* Handles the {@code lombok.SneakyThrows} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it.
public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
@Override public void handle(AnnotationValues<SneakyThrows> annotation, JCAnnotation ast, JavacNode annotationNode) {
@@ -107,7 +104,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
}
for (String exception : exceptions) {
- contents = List.of(buildTryCatchBlock(methodNode, contents, exception, annotation.get()));
+ contents = List.of(buildTryCatchBlock(methodNode, contents, exception, annotation));
}
method.body.stats = isConstructorCall ? List.of(constructorCall).appendList(contents) : contents;
@@ -122,11 +119,10 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
}
}
- public JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JCTree source) {
+ public JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
- Context context = node.getContext();
- JCBlock tryBlock = setGeneratedBy(maker.Block(0, contents), source, context);
+ JCBlock tryBlock = setGeneratedBy(maker.Block(0, contents), source);
JCExpression varType = chainDots(node, exception.split("\\."));
JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(Flags.FINAL | Flags.PARAMETER), node.toName("$ex"), varType, null);
@@ -134,7 +130,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
JCBlock catchBody = maker.Block(0, List.<JCStatement>of(maker.Throw(maker.Apply(
List.<JCExpression>nil(), lombokLombokSneakyThrowNameRef,
List.<JCExpression>of(maker.Ident(node.toName("$ex")))))));
- JCTry tryStatement = maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source, context)), null);
+ JCTry tryStatement = maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source)), null);
if (JavacHandlerUtil.inNetbeansEditor(node)) {
//set span (start and end position) of the try statement and the main block
//this allows NetBeans to dive into the statement correctly:
@@ -146,6 +142,6 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
Javac.storeEnd(tryBlock, endPos, top);
Javac.storeEnd(tryStatement, endPos, top);
}
- return setGeneratedBy(tryStatement, source, context);
+ return setGeneratedBy(tryStatement, source);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index be6ddae2..9185cedf 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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.javac.handlers;
+import static lombok.javac.handlers.HandleBuilder.*;
import static lombok.core.handlers.HandlerUtil.*;
import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
@@ -31,8 +32,6 @@ import java.util.HashSet;
import javax.lang.model.element.Modifier;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
@@ -53,7 +52,6 @@ import com.sun.tools.javac.tree.JCTree.JCTypeApply;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.JCTree.JCWildcard;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -78,68 +76,102 @@ import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.HandleBuilder.BuilderFieldData;
+import lombok.javac.handlers.HandleBuilder.BuilderJob;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
import lombok.javac.handlers.JavacSingularsRecipes.ExpressionMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(-1024) //-2^10; to ensure we've picked up @FieldDefault's changes (-2048) but @Value hasn't removed itself yet (-512), so that we can error on presence of it on the builder classes.
public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
private static final String SELF_METHOD = "self";
- private static final String TO_BUILDER_METHOD_NAME = "toBuilder";
private static final String FILL_VALUES_METHOD_NAME = "$fillValuesFrom";
private static final String STATIC_FILL_VALUES_METHOD_NAME = "$fillValuesFromInstanceIntoBuilder";
private static final String INSTANCE_VARIABLE_NAME = "instance";
private static final String BUILDER_VARIABLE_NAME = "b";
-
+
+ class SuperBuilderJob extends BuilderJob {
+ JavacNode builderAbstractType;
+ String builderAbstractClassName;
+ JavacNode builderImplType;
+ String builderImplClassName;
+ List<JCTypeParameter> builderTypeParams_;
+
+ void init(AnnotationValues<SuperBuilder> annValues, SuperBuilder ann, JavacNode node) {
+ accessOuters = accessInners = AccessLevel.PUBLIC;
+ oldFluent = true;
+ oldChain = true;
+
+ builderMethodName = ann.builderMethodName();
+ buildMethodName = ann.buildMethodName();
+ toBuilder = ann.toBuilder();
+
+ if (builderMethodName == null) builderMethodName = "builder";
+ if (buildMethodName == null) buildMethodName = "build";
+ builderClassName = fixBuilderClassName(node, "");
+ }
+
+ void setBuilderToImpl() {
+ builderType = builderImplType;
+ builderClassName = builderImplClassName;
+ builderTypeParams = typeParams;
+ }
+
+ void setBuilderToAbstract() {
+ builderType = builderAbstractType;
+ builderClassName = builderAbstractClassName;
+ builderTypeParams = builderTypeParams_;
+ }
+ }
+
@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();
- // Do not delete the SuperBuilder annotation here, we need it for @Jacksonized.
+ SuperBuilderJob job = new SuperBuilderJob();
+ job.sourceNode = annotationNode;
+ job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
+ job.isStatic = true;
- String builderMethodName = superbuilderAnnotation.builderMethodName();
- String buildMethodName = superbuilderAnnotation.buildMethodName();
+ SuperBuilder annInstance = annotation.getInstance();
- if (builderMethodName == null) builderMethodName = "builder";
- if (buildMethodName == null) buildMethodName = "build";
+ job.init(annotation, annInstance, annotationNode);
boolean generateBuilderMethod;
- if (builderMethodName.isEmpty()) {
+ if (job.builderMethodName.isEmpty()) {
generateBuilderMethod = false;
- } else if (!checkName("builderMethodName", builderMethodName, annotationNode)) {
+ } else if (!checkName("builderMethodName", job.builderMethodName, annotationNode)) {
return;
} else {
generateBuilderMethod = true;
}
- if (!checkName("buildMethodName", buildMethodName, annotationNode)) return;
+ if (!checkName("buildMethodName", job.buildMethodName, annotationNode)) return;
- boolean toBuilder = superbuilderAnnotation.toBuilder();
+ // Do not delete the SuperBuilder annotation here, we need it for @Jacksonized.
- JavacNode tdParent = annotationNode.up();
+ JavacNode parent = annotationNode.up();
- java.util.List<BuilderFieldData> builderFields = new ArrayList<BuilderFieldData>();
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrownExceptions = List.nil();
+ job.builderFields = new ArrayList<BuilderFieldData>();
+ job.typeParams = List.nil();
+ List<JCExpression> buildMethodThrownExceptions = List.nil();
List<JCExpression> superclassTypeParams = List.nil();
-
boolean addCleaning = false;
- if (!isClass(tdParent)) {
- annotationNode.addError("@SuperBuilder is only supported on types.");
+ if (!isClass(parent)) {
+ annotationNode.addError("@SuperBuilder is only supported on classes.");
return;
}
+ job.parentType = parent;
+ JCClassDecl td = (JCClassDecl) parent.get();
+
// Gather all fields of the class that should be set by the builder.
- JCClassDecl td = (JCClassDecl) tdParent.get();
- ListBuffer<JavacNode> allFields = new ListBuffer<JavacNode>();
ArrayList<JavacNode> nonFinalNonDefaultedFields = null;
- boolean valuePresent = (hasAnnotation(lombok.Value.class, tdParent) || hasAnnotation("lombok.experimental.Value", tdParent));
- for (JavacNode fieldNode : HandleConstructor.findAllFields(tdParent, true)) {
+ boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent));
+ for (JavacNode fieldNode : HandleConstructor.findAllFields(parent, true)) {
JCVariableDecl fd = (JCVariableDecl) fieldNode.get();
JavacNode isDefault = findAnnotation(Builder.Default.class, fieldNode, true);
boolean isFinal = (fd.mods.flags & Flags.FINAL) != 0 || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
@@ -149,7 +181,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
bfd.builderFieldName = bfd.name;
bfd.annotations = findCopyableAnnotations(fieldNode);
bfd.type = fd.vartype;
- bfd.singularData = getSingularData(fieldNode, superbuilderAnnotation.setterPrefix());
+ bfd.singularData = getSingularData(fieldNode, annInstance.setterPrefix());
bfd.originalFieldNode = fieldNode;
if (bfd.singularData != null && isDefault != null) {
@@ -169,44 +201,20 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
if (isDefault != null) {
- bfd.nameOfDefaultProvider = tdParent.toName("$default$" + bfd.name);
- bfd.nameOfSetFlag = tdParent.toName(bfd.name + "$set");
- bfd.builderFieldName = tdParent.toName(bfd.name + "$value");
+ bfd.nameOfDefaultProvider = parent.toName(DEFAULT_PREFIX + bfd.name);
+ bfd.nameOfSetFlag = parent.toName(bfd.name + SET_PREFIX);
+ bfd.builderFieldName = parent.toName(bfd.name + VALUE_PREFIX);
JCMethodDecl md = HandleBuilder.generateDefaultProvider(bfd.nameOfDefaultProvider, fieldNode, td.typarams);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- if (md != null) injectMethod(tdParent, md);
+ recursiveSetGeneratedBy(md, annotationNode);
+ if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
- builderFields.add(bfd);
- allFields.append(fieldNode);
+ job.builderFields.add(bfd);
}
- // Set the names of the builder classes.
- String builderClassNameTemplate = annotationNode.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
- if (builderClassNameTemplate == null || builderClassNameTemplate.isEmpty()) builderClassNameTemplate = "*Builder";
- String builderClassName = builderClassNameTemplate.replace("*", td.name.toString());
- String builderImplClassName = builderClassName + "Impl";
- JCTree extendsClause = Javac.getExtendsClause(td);
- JCExpression superclassBuilderClassExpression = null;
- if (extendsClause instanceof JCTypeApply) {
- // Remember the type arguments, because we need them for the extends clause of our abstract builder class.
- superclassTypeParams = ((JCTypeApply) extendsClause).getTypeArguments();
- // A class name with a generics type, e.g., "Superclass<A>".
- extendsClause = ((JCTypeApply) extendsClause).getType();
- }
- if (extendsClause instanceof JCFieldAccess) {
- Name superclassClassName = ((JCFieldAccess)extendsClause).getIdentifier();
- String superclassBuilderClassName = builderClassNameTemplate.replace("*", superclassClassName);
- superclassBuilderClassExpression = tdParent.getTreeMaker().Select((JCFieldAccess) extendsClause,
- tdParent.toName(superclassBuilderClassName));
- } else if (extendsClause != null) {
- String superclassBuilderClassName = builderClassNameTemplate.replace("*", extendsClause.toString());
- superclassBuilderClassExpression = chainDots(tdParent, extendsClause.toString(), superclassBuilderClassName);
- }
- // If there is no superclass, superclassBuilderClassExpression is still == null at this point.
- // You can use it to check whether to inherit or not.
-
- typeParams = td.typarams;
+ job.typeParams = job.builderTypeParams = td.typarams;
+ job.builderClassName = job.replaceBuilderClassName(td.name);
+ if (!checkName("builderClassName", job.builderClassName, annotationNode)) return;
// <C, B> are the generics for our builder.
String classGenericName = "C";
@@ -214,14 +222,46 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// We have to make sure that the generics' names do not collide with any generics on the annotated class,
// the classname itself, or any member type name of the annotated class.
// For instance, if there are generics <B, B2, C> on the annotated class, use "C2" and "B3" for our builder.
- java.util.HashSet<String> usedNames = gatherUsedTypeNames(typeParams, td);
+ java.util.HashSet<String> usedNames = gatherUsedTypeNames(job.typeParams, td);
classGenericName = generateNonclashingNameFor(classGenericName, usedNames);
builderGenericName = generateNonclashingNameFor(builderGenericName, usedNames);
- thrownExceptions = List.nil();
+ JavacTreeMaker maker = annotationNode.getTreeMaker();
+
+ {
+ JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, parent, job.typeParams);
+ JCTypeParameter c = maker.TypeParameter(parent.toName(classGenericName), List.<JCExpression>of(annotatedClass));
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
+ typeParamsForBuilder.append(maker.Ident(parent.toName(classGenericName)));
+ typeParamsForBuilder.append(maker.Ident(parent.toName(builderGenericName)));
+ JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, parent, job.getBuilderClassName(), false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
+ JCTypeParameter d = maker.TypeParameter(parent.toName(builderGenericName), List.<JCExpression>of(typeApply));
+ if (job.typeParams == null || job.typeParams.isEmpty()) {
+ job.builderTypeParams_ = List.of(c, d);
+ } else {
+ job.builderTypeParams_ = job.typeParams.append(c).append(d);
+ }
+ }
+
+ JCTree extendsClause = Javac.getExtendsClause(td);
+ JCExpression superclassBuilderClass = null;
+ if (extendsClause instanceof JCTypeApply) {
+ // Remember the type arguments, because we need them for the extends clause of our abstract builder class.
+ superclassTypeParams = ((JCTypeApply) extendsClause).getTypeArguments();
+ // A class name with a generics type, e.g., "Superclass<A>".
+ extendsClause = ((JCTypeApply) extendsClause).getType();
+ }
+ if (extendsClause instanceof JCFieldAccess) {
+ Name superclassName = ((JCFieldAccess) extendsClause).getIdentifier();
+ String superclassBuilderClassName = superclassName.toString() + "Builder";
+ superclassBuilderClass = parent.getTreeMaker().Select((JCFieldAccess) extendsClause, parent.toName(superclassBuilderClassName));
+ } else if (extendsClause != null) {
+ String superclassBuilderClassName = extendsClause.toString() + "Builder";
+ superclassBuilderClass = chainDots(parent, extendsClause.toString(), superclassBuilderClassName);
+ }
// Check validity of @ObtainVia fields, and add check if adding cleaning for @Singular is necessary.
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
if (bfd.singularData.getSingularizer().requiresCleaning()) {
addCleaning = true;
@@ -240,83 +280,85 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
}
+ job.builderAbstractClassName = job.builderClassName = job.replaceBuilderClassName(td.name);
+ job.builderImplClassName = job.builderAbstractClassName + "Impl";
+
// Create the abstract builder class.
- JavacNode builderType = findInnerClass(tdParent, builderClassName);
- if (builderType == null) {
- builderType = generateBuilderAbstractClass(annotationNode, tdParent, builderClassName, superclassBuilderClassExpression,
- typeParams, superclassTypeParams, classGenericName, builderGenericName);
- recursiveSetGeneratedBy(builderType.get(), ast, annotationNode.getContext());
+ job.builderAbstractType = findInnerClass(parent, job.builderClassName);
+ if (job.builderAbstractType == null) {
+ job.builderAbstractType = generateBuilderAbstractClass(job, superclassBuilderClass, superclassTypeParams, classGenericName, builderGenericName);
+ recursiveSetGeneratedBy(job.builderAbstractType.get(), annotationNode);
} else {
- JCClassDecl builderTypeDeclaration = (JCClassDecl) builderType.get();
+ JCClassDecl builderTypeDeclaration = (JCClassDecl) job.builderAbstractType.get();
if (!builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)
|| !builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.ABSTRACT)) {
annotationNode.addError("Existing Builder must be an abstract static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderAbstractType, annotationNode);
// Generate errors for @Singular BFDs that have one already defined node.
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
SingularData sd = bfd.singularData;
if (sd == null) continue;
JavacSingularizer singularizer = sd.getSingularizer();
if (singularizer == null) continue;
- if (singularizer.checkForAlreadyExistingNodesAndGenerateError(builderType, sd)) {
+ if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderAbstractType, sd)) {
bfd.singularData = null;
}
}
}
// Generate the fields in the abstract builder class that hold the values for the instance.
- generateBuilderFields(builderType, builderFields, ast);
+ job.setBuilderToAbstract();
+ generateBuilderFields(job.builderType, job.builderFields, annotationNode);
if (addCleaning) {
- JavacTreeMaker maker = builderType.getTreeMaker();
- JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), builderType.toName("$lombokUnclean"), maker.TypeIdent(CTC_BOOLEAN), null);
- recursiveSetGeneratedBy(uncleanField, ast, annotationNode.getContext());
- injectFieldAndMarkGenerated(builderType, uncleanField);
+ JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), job.toName("$lombokUnclean"), maker.TypeIdent(CTC_BOOLEAN), null);
+ recursiveSetGeneratedBy(uncleanField, annotationNode);
+ injectFieldAndMarkGenerated(job.builderType, uncleanField);
}
- if (toBuilder) {
+ if (job.toBuilder) {
// Generate $fillValuesFrom() method in the abstract builder.
- JCMethodDecl fvm = generateFillValuesMethod(tdParent, superclassBuilderClassExpression != null, builderGenericName, classGenericName, builderClassName);
- recursiveSetGeneratedBy(fvm, ast, annotationNode.getContext());
- injectMethod(builderType, fvm);
+ JCMethodDecl fvm = generateFillValuesMethod(job, superclassBuilderClass != null, builderGenericName, classGenericName);
+ recursiveSetGeneratedBy(fvm, annotationNode);
+ injectMethod(job.builderType, fvm);
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
- JCMethodDecl sfvm = generateStaticFillValuesMethod(tdParent, builderClassName, typeParams, builderFields, superbuilderAnnotation.setterPrefix());
- recursiveSetGeneratedBy(sfvm, ast, annotationNode.getContext());
- injectMethod(builderType, sfvm);
+ JCMethodDecl sfvm = generateStaticFillValuesMethod(job, annInstance.setterPrefix());
+ recursiveSetGeneratedBy(sfvm, annotationNode);
+ injectMethod(job.builderType, sfvm);
}
// Generate abstract self() and build() methods in the abstract builder.
- JCMethodDecl asm = generateAbstractSelfMethod(cfv, tdParent, superclassBuilderClassExpression != null, builderGenericName);
- recursiveSetGeneratedBy(asm, ast, annotationNode.getContext());
- injectMethod(builderType, asm);
- JCMethodDecl abm = generateAbstractBuildMethod(cfv, tdParent, buildMethodName, builderFields, superclassBuilderClassExpression != null, classGenericName);
- recursiveSetGeneratedBy(abm, ast, annotationNode.getContext());
- injectMethod(builderType, abm);
+ JCMethodDecl asm = generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName);
+ recursiveSetGeneratedBy(asm, annotationNode);
+ injectMethod(job.builderType, asm);
+ JCMethodDecl abm = generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName);
+ recursiveSetGeneratedBy(abm, annotationNode);
+ injectMethod(job.builderType, abm);
// Create the setter methods in the abstract builder.
- for (BuilderFieldData bfd : builderFields) {
- generateSetterMethodsForBuilder(cfv, builderType, bfd, annotationNode, builderGenericName, superbuilderAnnotation.setterPrefix());
+ for (BuilderFieldData bfd : job.builderFields) {
+ generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix());
}
// Create the toString() method for the abstract builder.
java.util.List<Included<JavacNode, ToString.Include>> fieldNodes = new ArrayList<Included<JavacNode, ToString.Include>>();
- for (BuilderFieldData bfd : builderFields) {
+ for (BuilderFieldData bfd : job.builderFields) {
for (JavacNode f : bfd.createdFields) {
fieldNodes.add(new Included<JavacNode, ToString.Include>(f, null, true, false));
}
}
// Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder.
- JCMethodDecl toStringMethod = HandleToString.createToString(builderType, fieldNodes, true, superclassBuilderClassExpression != null, FieldAccess.ALWAYS_FIELD, ast);
- if (toStringMethod != null) injectMethod(builderType, toStringMethod);
+ JCMethodDecl toStringMethod = HandleToString.createToString(job.builderType, fieldNodes, true, superclassBuilderClass != null, FieldAccess.ALWAYS_FIELD, annotationNode);
+ if (toStringMethod != null) injectMethod(job.builderType, toStringMethod);
// If clean methods are requested, add them now.
if (addCleaning) {
- JCMethodDecl md = generateCleanMethod(builderFields, builderType, ast);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- injectMethod(builderType, md);
+ JCMethodDecl md = generateCleanMethod(job.builderFields, job.builderType, annotationNode);
+ recursiveSetGeneratedBy(md, annotationNode);
+ injectMethod(job.builderType, md);
}
boolean isAbstract = (td.mods.flags & Flags.ABSTRACT) != 0;
@@ -324,69 +366,71 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Only non-abstract classes get the Builder implementation.
// Create the builder implementation class.
- JavacNode builderImplType = findInnerClass(tdParent, builderImplClassName);
- if (builderImplType == null) {
- builderImplType = generateBuilderImplClass(annotationNode, tdParent, builderImplClassName, builderClassName, typeParams);
- recursiveSetGeneratedBy(builderImplType.get(), ast, annotationNode.getContext());
+ job.builderImplType = findInnerClass(parent, job.builderImplClassName);
+ if (job.builderImplType == null) {
+ job.builderImplType = generateBuilderImplClass(job);
+ recursiveSetGeneratedBy(job.builderImplType.get(), annotationNode);
} else {
- JCClassDecl builderImplTypeDeclaration = (JCClassDecl) builderImplType.get();
+ JCClassDecl builderImplTypeDeclaration = (JCClassDecl) job.builderImplType.get();
if (!builderImplTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)
|| builderImplTypeDeclaration.getModifiers().getFlags().contains(Modifier.ABSTRACT)) {
annotationNode.addError("Existing BuilderImpl must be a non-abstract static inner class.");
return;
}
- sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(builderImplType, annotationNode);
+ sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(job.builderImplType, annotationNode);
}
// Create a simple constructor for the BuilderImpl class.
- JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PRIVATE, List.<JCAnnotation>nil(), builderImplType, List.<JavacNode>nil(), false, annotationNode);
- if (cd != null) injectMethod(builderImplType, cd);
+ JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PRIVATE, List.<JCAnnotation>nil(), job.builderImplType, List.<JavacNode>nil(), false, annotationNode);
+ if (cd != null) injectMethod(job.builderImplType, cd);
+ job.setBuilderToImpl();
// Create the self() and build() methods in the BuilderImpl.
- 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(cfv, buildMethodName, tdParent, builderImplType, builderFields, thrownExceptions);
- recursiveSetGeneratedBy(buildMethod, ast, annotationNode.getContext());
- injectMethod(builderImplType, buildMethod);
+ JCMethodDecl selfMethod = generateSelfMethod(job);
+ recursiveSetGeneratedBy(selfMethod, annotationNode);
+ injectMethod(job.builderType, selfMethod);
+ if (methodExists(job.buildMethodName, job.builderType, -1) == MemberExistsResult.NOT_EXISTS) {
+ JCMethodDecl buildMethod = generateBuildMethod(job, buildMethodThrownExceptions);
+ recursiveSetGeneratedBy(buildMethod, annotationNode);
+ injectMethod(job.builderType, buildMethod);
}
}
// Generate a constructor in the annotated class that takes a builder as argument.
- if (!constructorExists(tdParent, builderClassName)) {
- generateBuilderBasedConstructor(cfv, tdParent, typeParams, builderFields, annotationNode, builderClassName,
- superclassBuilderClassExpression != null);
+ if (!constructorExists(job.parentType, job.builderAbstractClassName)) {
+ job.setBuilderToAbstract();
+ generateBuilderBasedConstructor(job, superclassBuilderClass != null);
}
- if (isAbstract) {
+ if (!isAbstract) {
// Only non-abstract classes get the builder() and toBuilder() methods.
- return;
- }
- // Add the builder() method to the annotated class.
- // 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(cfv, builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
- recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext());
- if (builderMethod != null) injectMethod(tdParent, builderMethod);
- }
-
- // Add the toBuilder() method to the annotated class.
- if (toBuilder) {
- switch (methodExists(TO_BUILDER_METHOD_NAME, tdParent, 0)) {
- case EXISTS_BY_USER:
- break;
- case NOT_EXISTS:
- JCMethodDecl md = generateToBuilderMethod(cfv, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
- if (md != null) {
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
- injectMethod(tdParent, md);
+ // Add the builder() method to the annotated class.
+ // Allow users to specify their own builder() methods, e.g., to provide default values.
+ if (generateBuilderMethod && methodExists(job.builderMethodName, job.parentType, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
+ if (generateBuilderMethod) {
+ JCMethodDecl builderMethod = generateBuilderMethod(job);
+ if (builderMethod != null) {
+ recursiveSetGeneratedBy(builderMethod, annotationNode);
+ injectMethod(job.parentType, builderMethod);
+ }
+ }
+
+ // Add the toBuilder() method to the annotated class.
+ if (job.toBuilder) {
+ switch (methodExists(TO_BUILDER_METHOD_NAME, job.parentType, 0)) {
+ case EXISTS_BY_USER:
+ break;
+ case NOT_EXISTS:
+ JCMethodDecl md = generateToBuilderMethod(job);
+ if (md != null) {
+ recursiveSetGeneratedBy(md, annotationNode);
+ injectMethod(job.parentType, md);
+ }
+ break;
+ default:
+ // Should not happen.
}
- break;
- default:
- // Should not happen.
}
}
@@ -400,163 +444,150 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
/**
* Creates and returns the abstract builder class and injects it into the annotated class.
*/
- private JavacNode generateBuilderAbstractClass(JavacNode source, JavacNode tdParent, String builderClass,
- JCExpression superclassBuilderClassExpression, List<JCTypeParameter> typeParams,
- List<JCExpression> superclassTypeParams, String classGenericName, String builderGenericName) {
-
- JavacTreeMaker maker = tdParent.getTreeMaker();
+ private JavacNode generateBuilderAbstractClass(SuperBuilderJob job, JCExpression superclassBuilderClass, List<JCExpression> superclassTypeParams, String classGenericName, String builderGenericName) {
+ JavacTreeMaker maker = job.parentType.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.STATIC | Flags.ABSTRACT | Flags.PUBLIC);
// Keep any type params of the annotated class.
ListBuffer<JCTypeParameter> allTypeParams = new ListBuffer<JCTypeParameter>();
- allTypeParams.addAll(copyTypeParams(source, typeParams));
+ allTypeParams.appendList(copyTypeParams(job.sourceNode, job.typeParams));
// Add builder-specific type params required for inheritable builders.
// 1. The return type for the build() method, named "C", which extends the annotated class.
- JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, tdParent, typeParams);
+ JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, job.parentType, job.typeParams);
- allTypeParams.add(maker.TypeParameter(tdParent.toName(classGenericName), List.<JCExpression>of(annotatedClass)));
+ allTypeParams.append(maker.TypeParameter(job.toName(classGenericName), List.<JCExpression>of(annotatedClass)));
// 2. The return type for all setter methods, named "B", which extends this builder class.
- Name builderClassName = tdParent.toName(builderClass);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker, source.getContext());
- typeParamsForBuilder.add(maker.Ident(tdParent.toName(classGenericName)));
- typeParamsForBuilder.add(maker.Ident(tdParent.toName(builderGenericName)));
- JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, tdParent, builderClassName, false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
- allTypeParams.add(maker.TypeParameter(tdParent.toName(builderGenericName), List.<JCExpression>of(typeApply)));
+ Name builderClassName = job.toName(job.builderClassName);
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
+ typeParamsForBuilder.append(maker.Ident(job.toName(classGenericName)));
+ typeParamsForBuilder.append(maker.Ident(job.toName(builderGenericName)));
+ JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, builderClassName, false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
+ allTypeParams.append(maker.TypeParameter(job.toName(builderGenericName), List.<JCExpression>of(typeApply)));
JCExpression extending = null;
- if (superclassBuilderClassExpression != null) {
+ if (superclassBuilderClass != null) {
// If the annotated class extends another class, we want this builder to extend the builder of the superclass.
// 1. Add the type parameters of the superclass.
- typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker, source.getContext());
+ typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker, job.sourceNode);
// 2. Add the builder type params <C, B>.
- typeParamsForBuilder.add(maker.Ident(tdParent.toName(classGenericName)));
- typeParamsForBuilder.add(maker.Ident(tdParent.toName(builderGenericName)));
- extending = maker.TypeApply(superclassBuilderClassExpression, typeParamsForBuilder.toList());
+ typeParamsForBuilder.append(maker.Ident(job.toName(classGenericName)));
+ typeParamsForBuilder.append(maker.Ident(job.toName(builderGenericName)));
+ extending = maker.TypeApply(superclassBuilderClass, typeParamsForBuilder.toList());
}
JCClassDecl builder = maker.ClassDef(mods, builderClassName, allTypeParams.toList(), extending, List.<JCExpression>nil(), List.<JCTree>nil());
- return injectType(tdParent, builder);
+ recursiveSetGeneratedBy(builder, job.sourceNode);
+ return injectType(job.parentType, builder);
}
/**
* Creates and returns the concrete builder implementation class and injects it into the annotated class.
*/
- private JavacNode generateBuilderImplClass(JavacNode source, JavacNode tdParent, String builderImplClass, String builderAbstractClass, List<JCTypeParameter> typeParams) {
- JavacTreeMaker maker = tdParent.getTreeMaker();
+ private JavacNode generateBuilderImplClass(SuperBuilderJob job) {
+ JavacTreeMaker maker = job.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.STATIC | Flags.PRIVATE | Flags.FINAL);
// Extend the abstract builder.
- JCExpression extending = namePlusTypeParamsToTypeReference(maker, tdParent, tdParent.toName(builderAbstractClass), false, List.<JCTypeParameter>nil());
- // Add any type params of the annotated class.
- ListBuffer<JCTypeParameter> allTypeParams = new ListBuffer<JCTypeParameter>();
- allTypeParams.addAll(copyTypeParams(source, typeParams));
+ JCExpression extending = namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderAbstractClassName), false, List.<JCTypeParameter>nil());
+
// Add builder-specific type params required for inheritable builders.
// 1. The return type for the build() method (named "C" in the abstract builder), which is the annotated class.
- JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, tdParent, typeParams);
+ JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, job.parentType, job.typeParams);
// 2. The return type for all setter methods (named "B" in the abstract builder), which is this builder class.
- JCExpression builderImplClassExpression = namePlusTypeParamsToTypeReference(maker, tdParent, tdParent.toName(builderImplClass), false, typeParams);
+ JCExpression builderImplClassExpression = namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderImplClassName), false, job.typeParams);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker, source.getContext());
- typeParamsForBuilder.add(annotatedClass);
- typeParamsForBuilder.add(builderImplClassExpression);
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
+ typeParamsForBuilder.append(annotatedClass);
+ typeParamsForBuilder.append(builderImplClassExpression);
extending = maker.TypeApply(extending, typeParamsForBuilder.toList());
- JCClassDecl builder = maker.ClassDef(mods, tdParent.toName(builderImplClass), copyTypeParams(source, typeParams), extending, List.<JCExpression>nil(), List.<JCTree>nil());
- return injectType(tdParent, builder);
+ JCClassDecl builder = maker.ClassDef(mods, job.toName(job.builderImplClassName), copyTypeParams(job.parentType, job.typeParams), extending, List.<JCExpression>nil(), List.<JCTree>nil());
+ recursiveSetGeneratedBy(builder, job.sourceNode);
+ return injectType(job.parentType, builder);
}
/**
* Generates a constructor that has a builder as the only parameter.
* The values from the builder are used to initialize the fields of new instances.
*
- * @param typeNode
- * the type (with the {@code @Builder} annotation) for which a
- * constructor should be generated.
- * @param typeParams
- * @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
* If {@code true}, the constructor will explicitly call a super
* constructor with the builder as argument. Requires
* {@code builderClassAsParameter != null}.
*/
- 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();
+ private void generateBuilderBasedConstructor(SuperBuilderJob job, boolean callBuilderBasedSuperConstructor) {
+ JavacTreeMaker maker = job.getTreeMaker();
AccessLevel level = AccessLevel.PROTECTED;
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- Name builderVariableName = typeNode.toName(BUILDER_VARIABLE_NAME);
- for (BuilderFieldData bfd : builderFields) {
+ Name builderVariableName = job.toName(BUILDER_VARIABLE_NAME);
+ for (BuilderFieldData bfd : job.builderFields) {
JCExpression rhs;
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, bfd.originalFieldNode, bfd.type, statements, bfd.builderFieldName, "b");
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, bfd.originalFieldNode, job.sourceNode, statements, bfd.builderFieldName, "b");
rhs = maker.Ident(bfd.singularData.getPluralName());
} else {
rhs = maker.Select(maker.Ident(builderVariableName), bfd.builderFieldName);
}
- JCFieldAccess fieldInThis = maker.Select(maker.Ident(typeNode.toName("this")), bfd.rawName);
+ JCFieldAccess fieldInThis = maker.Select(maker.Ident(job.toName("this")), bfd.rawName);
JCStatement assign = maker.Exec(maker.Assign(fieldInThis, rhs));
// In case of @Builder.Default, set the value to the default if it was not set in the builder.
if (bfd.nameOfSetFlag != null) {
JCFieldAccess setField = maker.Select(maker.Ident(builderVariableName), bfd.nameOfSetFlag);
- fieldInThis = maker.Select(maker.Ident(typeNode.toName("this")), bfd.rawName);
- JCExpression parentTypeRef = namePlusTypeParamsToTypeReference(maker, typeNode, List.<JCTypeParameter>nil());
- JCAssign assignDefault = maker.Assign(fieldInThis, maker.Apply(typeParameterNames(maker, ((JCClassDecl) typeNode.get()).typarams), maker.Select(parentTypeRef, bfd.nameOfDefaultProvider), List.<JCExpression>nil()));
+ fieldInThis = maker.Select(maker.Ident(job.toName("this")), bfd.rawName);
+ JCExpression parentTypeRef = namePlusTypeParamsToTypeReference(maker, job.parentType, List.<JCTypeParameter>nil());
+ JCAssign assignDefault = maker.Assign(fieldInThis, maker.Apply(typeParameterNames(maker, ((JCClassDecl) job.parentType.get()).typarams), maker.Select(parentTypeRef, bfd.nameOfDefaultProvider), List.<JCExpression>nil()));
statements.append(maker.If(setField, assign, maker.Exec(assignDefault)));
} else {
statements.append(assign);
}
if (hasNonNullAnnotations(bfd.originalFieldNode)) {
- JCStatement nullCheck = generateNullCheck(maker, bfd.originalFieldNode, source);
+ JCStatement nullCheck = generateNullCheck(maker, bfd.originalFieldNode, job.sourceNode);
if (nullCheck != null) statements.append(nullCheck);
}
}
- List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(typeNode, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ List<JCAnnotation> annsOnMethod = job.checkerFramework.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(job.parentType, 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>();
- long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
- Name builderClassname = typeNode.toName(builderClassName);
+ long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, job.getContext());
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker, typeNode.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParamsForBuilderParameter.add(wildcard);
+ typeParamsForBuilderParameter.append(wildcard);
wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParamsForBuilderParameter.add(wildcard);
- JCTypeApply paramType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, typeNode, builderClassname, false, List.<JCTypeParameter>nil()), typeParamsForBuilderParameter.toList());
+ typeParamsForBuilderParameter.append(wildcard);
+ JCTypeApply paramType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), false, List.<JCTypeParameter>nil()), typeParamsForBuilderParameter.toList());
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags), builderVariableName, paramType, null);
params.append(param);
if (callBuilderBasedSuperConstructor) {
// The first statement must be the call to the super constructor.
JCMethodInvocation callToSuperConstructor = maker.Apply(List.<JCExpression>nil(),
- maker.Ident(typeNode.toName("super")),
+ maker.Ident(job.toName("super")),
List.<JCExpression>of(maker.Ident(builderVariableName)));
statements.prepend(maker.Exec(callToSuperConstructor));
}
- JCMethodDecl constr = recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("<init>"),
+ JCMethodDecl constr = recursiveSetGeneratedBy(maker.MethodDef(mods, job.toName("<init>"),
null, List.<JCTypeParameter>nil(), params.toList(), List.<JCExpression>nil(),
- maker.Block(0L, statements.toList()), null), source.get(), typeNode.getContext());
+ maker.Block(0L, statements.toList()), null), job.sourceNode);
- injectMethod(typeNode, constr, null, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
+ injectMethod(job.parentType, constr, null, Javac.createVoidType(job.builderType.getSymbolTable(), CTC_VOID));
}
- 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>();
- for (JCTypeParameter typeParam : typeParams) typeArgs.append(maker.Ident(typeParam.name));
+ private JCMethodDecl generateBuilderMethod(SuperBuilderJob job) {
+ JavacTreeMaker maker = job.getTreeMaker();
- JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderImplClassName), false, typeParams), List.<JCExpression>nil(), null);
+ JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderImplClassName), false, job.typeParams), List.<JCExpression>nil(), null);
JCStatement statement = maker.Return(call);
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
@@ -565,16 +596,19 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Add any type params of the annotated class to the return type.
ListBuffer<JCExpression> typeParameterNames = new ListBuffer<JCExpression>();
- typeParameterNames.addAll(typeParameterNames(maker, typeParams));
+ typeParameterNames.appendList(typeParameterNames(maker, job.typeParams));
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParameterNames.add(wildcard);
- typeParameterNames.add(wildcard);
- JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), false, List.<JCTypeParameter>nil()), typeParameterNames.toList());
-
- List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
- JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- createRelevantNonNullAnnotation(type, methodDef);
+ typeParameterNames.append(wildcard);
+ typeParameterNames.append(wildcard);
+ // And return type annotations.
+ List<JCAnnotation> annsOnParamType = List.nil();
+ if (job.checkerFramework.generateUnique()) annsOnParamType = List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__UNIQUE), List.<JCExpression>nil()));
+ JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderAbstractClassName), false, List.<JCTypeParameter>nil(), annsOnParamType), typeParameterNames.toList());
+
+ List<JCAnnotation> annsOnMethod = job.checkerFramework.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), job.toName(job.builderMethodName), returnType, copyTypeParams(job.sourceNode, job.typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ createRelevantNonNullAnnotation(job.parentType, methodDef);
return methodDef;
}
@@ -586,15 +620,12 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* }
* </pre>
*/
- private JCMethodDecl generateToBuilderMethod(CheckerFrameworkVersion cfv, String builderClassName, String builderImplClassName, JavacNode source, JavacNode type, List<JCTypeParameter> typeParams) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateToBuilderMethod(SuperBuilderJob job) {
+ JavacTreeMaker maker = job.getTreeMaker();
- ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
- for (JCTypeParameter typeParam : typeParams) typeArgs.append(maker.Ident(typeParam.name));
-
- JCExpression newClass = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type, type.toName(builderImplClassName), false, typeParams), List.<JCExpression>nil(), null);
- List<JCExpression> methodArgs = List.<JCExpression>of(maker.Ident(type.toName("this")));
- JCMethodInvocation invokeFillMethod = maker.Apply(List.<JCExpression>nil(), maker.Select(newClass, type.toName(FILL_VALUES_METHOD_NAME)), methodArgs);
+ JCExpression newClass = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderImplClassName), false, job.typeParams), List.<JCExpression>nil(), null);
+ List<JCExpression> methodArgs = List.<JCExpression>of(maker.Ident(job.toName("this")));
+ JCMethodInvocation invokeFillMethod = maker.Apply(List.<JCExpression>nil(), maker.Select(newClass, job.toName(FILL_VALUES_METHOD_NAME)), methodArgs);
JCStatement statement = maker.Return(invokeFillMethod);
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
@@ -602,16 +633,16 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Add any type params of the annotated class to the return type.
ListBuffer<JCExpression> typeParameterNames = new ListBuffer<JCExpression>();
- typeParameterNames.addAll(typeParameterNames(maker, typeParams));
+ typeParameterNames.appendList(typeParameterNames(maker, job.typeParams));
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParameterNames.add(wildcard);
- typeParameterNames.add(wildcard);
- JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassName), false, List.<JCTypeParameter>nil()), typeParameterNames.toList());
+ typeParameterNames.append(wildcard);
+ typeParameterNames.append(wildcard);
+ JCTypeApply returnType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderAbstractClassName), false, List.<JCTypeParameter>nil()), typeParameterNames.toList());
- List<JCAnnotation> annsOnMethod = cfv.generateUnique() ? List.of(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
- JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), type.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- createRelevantNonNullAnnotation(type, methodDef);
+ List<JCAnnotation> annsOnMethod = job.checkerFramework.generateSideEffectFree() ? List.of(maker.Annotation(genTypeRef(job.parentType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil())) : List.<JCAnnotation>nil();
+ JCMethodDecl methodDef = maker.MethodDef(maker.Modifiers(modifiers, annsOnMethod), job.toName(TO_BUILDER_METHOD_NAME), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ createRelevantNonNullAnnotation(job.parentType, methodDef);
return methodDef;
}
@@ -621,43 +652,43 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* <pre>
* protected B $fillValuesFrom(final C instance) {
* super.$fillValuesFrom(instance);
- * FoobarBuilderImpl.$fillValuesFromInstanceIntoBuilder(instance, this);
+ * FoobarBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
* return self();
* }
* </pre>
*/
- private JCMethodDecl generateFillValuesMethod(JavacNode type, boolean inherited, String builderGenericName, String classGenericName, String builderImplClassName) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateFillValuesMethod(SuperBuilderJob job, boolean inherited, String builderGenericName, String classGenericName) {
+ JavacTreeMaker maker = job.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
if (inherited) {
- JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
+ JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(job.builderType, "Override"), List.<JCExpression>nil());
annotations = List.of(overrideAnnotation);
}
JCModifiers modifiers = maker.Modifiers(Flags.PROTECTED, annotations);
- Name name = type.toName(FILL_VALUES_METHOD_NAME);
- JCExpression returnType = maker.Ident(type.toName(builderGenericName));
+ Name name = job.toName(FILL_VALUES_METHOD_NAME);
+ JCExpression returnType = maker.Ident(job.toName(builderGenericName));
- JCExpression classGenericNameExpr = maker.Ident(type.toName(classGenericName));
- JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.LocalVarFlags), type.toName(INSTANCE_VARIABLE_NAME), classGenericNameExpr, null);
+ JCExpression classGenericNameExpr = maker.Ident(job.toName(classGenericName));
+ JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.PARAMETER | Flags.FINAL), job.toName(INSTANCE_VARIABLE_NAME), classGenericNameExpr, null);
ListBuffer<JCStatement> body = new ListBuffer<JCStatement>();
if (inherited) {
// Call super.
JCMethodInvocation callToSuper = maker.Apply(List.<JCExpression>nil(),
- maker.Select(maker.Ident(type.toName("super")), name),
- List.<JCExpression>of(maker.Ident(type.toName(INSTANCE_VARIABLE_NAME))));
+ maker.Select(maker.Ident(job.toName("super")), name),
+ List.<JCExpression>of(maker.Ident(job.toName(INSTANCE_VARIABLE_NAME))));
body.append(maker.Exec(callToSuper));
}
// Call the builder implemention's helper method that actually fills the values from the instance.
- JCExpression ref = namePlusTypeParamsToTypeReference(maker, type, type.toName(builderImplClassName), false, List.<JCTypeParameter>nil());
+ JCExpression ref = namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), false, List.<JCTypeParameter>nil());
JCMethodInvocation callStaticFillValuesMethod = maker.Apply(List.<JCExpression>nil(),
- maker.Select(ref, type.toName(STATIC_FILL_VALUES_METHOD_NAME)),
- List.<JCExpression>of(maker.Ident(type.toName(INSTANCE_VARIABLE_NAME)), maker.Ident(type.toName("this"))));
+ maker.Select(ref, job.toName(STATIC_FILL_VALUES_METHOD_NAME)),
+ List.<JCExpression>of(maker.Ident(job.toName(INSTANCE_VARIABLE_NAME)), maker.Ident(job.toName("this"))));
body.append(maker.Exec(callStaticFillValuesMethod));
- JCReturn returnStatement = maker.Return(maker.Apply(List.<JCExpression>nil(), maker.Ident(type.toName(SELF_METHOD)), List.<JCExpression>nil()));
+ JCReturn returnStatement = maker.Return(maker.Apply(List.<JCExpression>nil(), maker.Ident(job.toName(SELF_METHOD)), List.<JCExpression>nil()));
body.append(returnStatement);
JCBlock bodyBlock = maker.Block(0, body.toList());
@@ -674,58 +705,58 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
* b.field(instance.field);
* }
* </pre>
- * @param setterPrefix the prefix for setter methods
*/
- private JCMethodDecl generateStaticFillValuesMethod(JavacNode type, String builderClassname, List<JCTypeParameter> typeParams, java.util.List<BuilderFieldData> builderFields, String setterPrefix) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateStaticFillValuesMethod(SuperBuilderJob job, String setterPrefix) {
+ JavacTreeMaker maker = job.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
JCModifiers modifiers = maker.Modifiers(Flags.PRIVATE | Flags.STATIC, annotations);
- Name name = type.toName(STATIC_FILL_VALUES_METHOD_NAME);
+ Name name = job.toName(STATIC_FILL_VALUES_METHOD_NAME);
JCExpression returnType = maker.TypeIdent(CTC_VOID);
// 1st parameter: "Foobar instance"
- JCVariableDecl paramInstance = maker.VarDef(maker.Modifiers(Flags.LocalVarFlags), type.toName(INSTANCE_VARIABLE_NAME), cloneSelfType(type), null);
+ JCVariableDecl paramInstance = maker.VarDef(maker.Modifiers(Flags.PARAMETER | Flags.FINAL), job.toName(INSTANCE_VARIABLE_NAME), cloneSelfType(job.parentType), null);
// 2nd parameter: "FoobarBuilder<?, ?> b" (plus generics on the annotated type)
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker, type.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParamsForBuilderParameter.add(wildcard);
+ typeParamsForBuilderParameter.append(wildcard);
wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
- typeParamsForBuilderParameter.add(wildcard);
- JCTypeApply builderType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, type, type.toName(builderClassname), false, List.<JCTypeParameter>nil()), typeParamsForBuilderParameter.toList());
- JCVariableDecl paramBuilder = maker.VarDef(maker.Modifiers(Flags.LocalVarFlags), type.toName(BUILDER_VARIABLE_NAME), builderType, null);
-
+ typeParamsForBuilderParameter.append(wildcard);
+ JCTypeApply builderType = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, job.getBuilderClassName(), false, List.<JCTypeParameter>nil()), typeParamsForBuilderParameter.toList());
+ JCVariableDecl paramBuilder = maker.VarDef(maker.Modifiers(Flags.PARAMETER | Flags.FINAL), job.toName(BUILDER_VARIABLE_NAME), builderType, null);
+
ListBuffer<JCStatement> body = new ListBuffer<JCStatement>();
// Call the builder's setter methods to fill the values from the instance.
- for (BuilderFieldData bfd : builderFields) {
- JCExpressionStatement exec = createSetterCallWithInstanceValue(bfd, type, maker, setterPrefix);
+ for (BuilderFieldData bfd : job.builderFields) {
+ JCExpressionStatement exec = createSetterCallWithInstanceValue(bfd, job, setterPrefix);
body.append(exec);
}
JCBlock bodyBlock = maker.Block(0, body.toList());
-
- return maker.MethodDef(modifiers, name, returnType, copyTypeParams(type, typeParams), List.of(paramInstance, paramBuilder), List.<JCExpression>nil(), bodyBlock, null);
+
+ return maker.MethodDef(modifiers, name, returnType, copyTypeParams(job.builderType, job.typeParams), List.of(paramInstance, paramBuilder), List.<JCExpression>nil(), bodyBlock, null);
}
- private JCExpressionStatement createSetterCallWithInstanceValue(BuilderFieldData bfd, JavacNode type, JavacTreeMaker maker, String setterPrefix) {
+ private JCExpressionStatement createSetterCallWithInstanceValue(BuilderFieldData bfd, SuperBuilderJob job, String setterPrefix) {
+ JavacTreeMaker maker = job.getTreeMaker();
JCExpression[] tgt = new JCExpression[bfd.singularData == null ? 1 : 2];
if (bfd.obtainVia == null || !bfd.obtainVia.field().isEmpty()) {
for (int i = 0; i < tgt.length; i++) {
- tgt[i] = maker.Select(maker.Ident(type.toName(INSTANCE_VARIABLE_NAME)), bfd.obtainVia == null ? bfd.rawName : type.toName(bfd.obtainVia.field()));
+ tgt[i] = maker.Select(maker.Ident(job.toName(INSTANCE_VARIABLE_NAME)), bfd.obtainVia == null ? bfd.rawName : job.toName(bfd.obtainVia.field()));
}
} else {
if (bfd.obtainVia.isStatic()) {
for (int i = 0; i < tgt.length; i++) {
- JCExpression typeRef = namePlusTypeParamsToTypeReference(maker, type, List.<JCTypeParameter>nil());
- JCExpression c = maker.Select(typeRef, type.toName(bfd.obtainVia.method()));
- tgt[i] = maker.Apply(List.<JCExpression>nil(), c, List.<JCExpression>of(maker.Ident(type.toName(INSTANCE_VARIABLE_NAME))));
+ JCExpression typeRef = namePlusTypeParamsToTypeReference(maker, job.parentType, List.<JCTypeParameter>nil());
+ JCExpression c = maker.Select(typeRef, job.toName(bfd.obtainVia.method()));
+ tgt[i] = maker.Apply(List.<JCExpression>nil(), c, List.<JCExpression>of(maker.Ident(job.toName(INSTANCE_VARIABLE_NAME))));
}
} else {
for (int i = 0; i < tgt.length; i++) {
- JCExpression c = maker.Select(maker.Ident(type.toName(INSTANCE_VARIABLE_NAME)), type.toName(bfd.obtainVia.method()));
+ JCExpression c = maker.Select(maker.Ident(job.toName(INSTANCE_VARIABLE_NAME)), job.toName(bfd.obtainVia.method()));
tgt[i] = maker.Apply(List.<JCExpression>nil(), c, List.<JCExpression>nil());
}
}
@@ -736,95 +767,105 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
arg = tgt[0];
} else {
JCExpression eqNull = maker.Binary(CTC_EQUAL, tgt[0], maker.Literal(CTC_BOT, null));
- String emptyMaker = bfd.singularData.getSingularizer().getEmptyMaker(bfd.singularData.getTargetFqn());
- JCExpression emptyCollection = maker.Apply(List.<JCExpression>nil(), chainDots(type, emptyMaker.split("\\.")), List.<JCExpression>nil());
+ JCExpression emptyCollection = bfd.singularData.getSingularizer().getEmptyExpression(bfd.singularData.getTargetFqn(), maker, bfd.singularData, job.parentType, job.sourceNode);
arg = maker.Conditional(eqNull, emptyCollection, tgt[1]);
}
String setterName = HandlerUtil.buildAccessorName(setterPrefix, bfd.name.toString());
- JCMethodInvocation apply = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(type.toName(BUILDER_VARIABLE_NAME)), type.toName(setterName)), List.of(arg));
+ JCMethodInvocation apply = maker.Apply(List.<JCExpression>nil(), maker.Select(maker.Ident(job.toName(BUILDER_VARIABLE_NAME)), job.toName(setterName)), List.of(arg));
JCExpressionStatement exec = maker.Exec(apply);
return exec;
}
- private JCMethodDecl generateAbstractSelfMethod(CheckerFrameworkVersion cfv, JavacNode type, boolean override, String builderGenericName) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateAbstractSelfMethod(SuperBuilderJob job, boolean override, String builderGenericName) {
+ JavacTreeMaker maker = job.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
- 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.generatePure() ? maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__PURE), List.<JCExpression>nil()) : null;
+ JCAnnotation overrideAnnotation = override ? maker.Annotation(genJavaLangTypeRef(job.builderType, "Override"), List.<JCExpression>nil()) : null;
+ JCAnnotation rrAnnotation = job.checkerFramework.generateReturnsReceiver() ? maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
+ JCAnnotation sefAnnotation = job.checkerFramework.generatePure() ? maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__PURE), 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));
+ Name name = job.toName(SELF_METHOD);
+ JCExpression returnType = maker.Ident(job.toName(builderGenericName));
return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
}
- private JCMethodDecl generateSelfMethod(CheckerFrameworkVersion cfv, JavacNode builderImplType, List<JCTypeParameter> typeParams) {
- JavacTreeMaker maker = builderImplType.getTreeMaker();
+ private JCMethodDecl generateSelfMethod(SuperBuilderJob job) {
+ JavacTreeMaker maker = job.getTreeMaker();
- JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(builderImplType, "Override"), List.<JCExpression>nil());
- JCAnnotation rrAnnotation = cfv.generateReturnsReceiver() ? maker.Annotation(genTypeRef(builderImplType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
- JCAnnotation sefAnnotation = cfv.generatePure() ? maker.Annotation(genTypeRef(builderImplType, CheckerFrameworkVersion.NAME__PURE), List.<JCExpression>nil()) : null;
+ JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(job.builderType, "Override"), List.<JCExpression>nil());
+ JCAnnotation rrAnnotation = job.checkerFramework.generateReturnsReceiver() ? maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil()) : null;
+ JCAnnotation sefAnnotation = job.checkerFramework.generatePure() ? maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__PURE), 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);
+ Name name = job.toName(SELF_METHOD);
- JCExpression returnType = namePlusTypeParamsToTypeReference(maker, builderImplType.up(), builderImplType.toName(builderImplType.getName()), false, typeParams);
- JCStatement statement = maker.Return(maker.Ident(builderImplType.toName("this")));
+ JCExpression returnType = namePlusTypeParamsToTypeReference(maker, job.builderType.up(), job.getBuilderClassName(), false, job.typeParams);
+ JCStatement statement = maker.Return(maker.Ident(job.toName("this")));
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- private JCMethodDecl generateAbstractBuildMethod(CheckerFrameworkVersion cfv, JavacNode type, String methodName, java.util.List<BuilderFieldData> builderFields, boolean override, String classGenericName) {
- JavacTreeMaker maker = type.getTreeMaker();
+ private JCMethodDecl generateAbstractBuildMethod(SuperBuilderJob job, boolean override, String classGenericName) {
+ JavacTreeMaker maker = job.getTreeMaker();
List<JCAnnotation> annotations = List.nil();
if (override) {
- JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
+ JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(job.builderType, "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()));
+ if (job.checkerFramework.generateSideEffectFree()) annotations = annotations.prepend(maker.Annotation(genTypeRef(job.builderType, 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));
+ Name name = job.toName(job.buildMethodName);
+ JCExpression returnType = maker.Ident(job.toName(classGenericName));
- List<JCVariableDecl> params = HandleBuilder.generateBuildArgs(cfv, type, builderFields);
- return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), null, null);
+ JCVariableDecl recv = HandleBuilder.generateReceiver(job);
+ JCMethodDecl methodDef;
+ if (recv != null && maker.hasMethodDefWithRecvParam()) {
+ methodDef = maker.MethodDefWithRecvParam(modifiers, name, returnType, List.<JCTypeParameter>nil(), recv, List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
+ } else {
+ methodDef = maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
+ }
+ return methodDef;
}
-
- private JCMethodDecl generateBuildMethod(CheckerFrameworkVersion cfv, String buildName, JavacNode returnType, JavacNode type, java.util.List<BuilderFieldData> builderFields, List<JCExpression> thrownExceptions) {
- JavacTreeMaker maker = type.getTreeMaker();
+
+ private JCMethodDecl generateBuildMethod(SuperBuilderJob job, List<JCExpression> thrownExceptions) {
+ JavacTreeMaker maker = job.getTreeMaker();
JCExpression call;
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
// Use a constructor that only has this builder as parameter.
- List<JCExpression> builderArg = List.<JCExpression>of(maker.Ident(type.toName("this")));
- call = maker.NewClass(null, List.<JCExpression>nil(), cloneSelfType(returnType), builderArg, null);
+ List<JCExpression> builderArg = List.<JCExpression>of(maker.Ident(job.toName("this")));
+ call = maker.NewClass(null, List.<JCExpression>nil(), cloneSelfType(job.parentType), builderArg, null);
statements.append(maker.Return(call));
JCBlock body = maker.Block(0, statements.toList());
- JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(type, "Override"), List.<JCExpression>nil());
+ JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(job.builderType, "Override"), List.<JCExpression>nil());
List<JCAnnotation> annsOnMethod = List.of(overrideAnnotation);
- if (cfv.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(type, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
+ if (job.checkerFramework.generateSideEffectFree()) annsOnMethod = annsOnMethod.prepend(maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE), List.<JCExpression>nil()));
JCModifiers modifiers = maker.Modifiers(Flags.PUBLIC, annsOnMethod);
- List<JCVariableDecl> params = HandleBuilder.generateBuildArgs(cfv, type, builderFields);
- JCMethodDecl methodDef = maker.MethodDef(modifiers, type.toName(buildName), cloneSelfType(returnType), List.<JCTypeParameter>nil(), params, thrownExceptions, body, null);
- createRelevantNonNullAnnotation(type, methodDef);
+ JCVariableDecl recv = HandleBuilder.generateReceiver(job);
+ JCMethodDecl methodDef;
+ if (recv != null && maker.hasMethodDefWithRecvParam()) {
+ methodDef = maker.MethodDefWithRecvParam(modifiers, job.toName(job.buildMethodName), cloneSelfType(job.parentType), List.<JCTypeParameter>nil(), recv, List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ } else {
+ methodDef = maker.MethodDef(modifiers, job.toName(job.buildMethodName), cloneSelfType(job.parentType), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), thrownExceptions, body, null);
+ }
+ createRelevantNonNullAnnotation(job.builderType, methodDef);
return methodDef;
}
- private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
+ private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JavacNode source) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
@@ -839,7 +880,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName("$lombokClean"), maker.Type(Javac.createVoidType(type.getSymbolTable(), CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- private void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
+ private void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JavacNode source) {
int len = builderFields.size();
java.util.List<JavacNode> existing = new ArrayList<JavacNode>();
for (JavacNode child : builderType.down()) {
@@ -851,7 +892,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
for (int i = len - 1; i >= 0; i--) {
BuilderFieldData bfd = builderFields.get(i);
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source));
+ java.util.List<JavacNode> fields = bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source);
+ for (JavacNode field : fields) {
+ generated.add((JCVariableDecl) field.get());
+ }
+ bfd.createdFields.addAll(fields);
} else {
JavacNode field = null, setFlag = null;
for (JavacNode exists : existing) {
@@ -862,7 +907,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JavacTreeMaker maker = builderType.getTreeMaker();
if (field == null) {
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
- JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, source, builderType.getContext()), null);
+ JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, source), null);
field = injectFieldAndMarkGenerated(builderType, newField);
generated.add(newField);
}
@@ -875,32 +920,33 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
bfd.createdFields.add(field);
}
}
- for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
+ for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source);
}
- private void generateSetterMethodsForBuilder(CheckerFrameworkVersion cfv, final JavacNode builderType, BuilderFieldData fieldNode, JavacNode source, final String builderGenericName, String setterPrefix) {
+ private void generateSetterMethodsForBuilder(final SuperBuilderJob job, BuilderFieldData fieldNode, final String builderGenericName, String setterPrefix) {
boolean deprecate = isFieldDeprecated(fieldNode.originalFieldNode);
- final JavacTreeMaker maker = builderType.getTreeMaker();
+ final JavacTreeMaker maker = job.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
- return maker.Ident(builderType.toName(builderGenericName));
+ return maker.Ident(job.toName(builderGenericName));
}};
StatementMaker returnStatementMaker = new StatementMaker() { @Override public JCStatement make() {
- return maker.Return(maker.Apply(List.<JCExpression>nil(), maker.Ident(builderType.toName(SELF_METHOD)), List.<JCExpression>nil()));
+ return maker.Return(maker.Apply(List.<JCExpression>nil(), maker.Ident(job.toName(SELF_METHOD)), List.<JCExpression>nil()));
}};
if (fieldNode.singularData == null || fieldNode.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(cfv, builderType, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, source, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode, setterPrefix);
+ generateSimpleSetterMethodForBuilder(job, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode, setterPrefix);
} else {
- fieldNode.singularData.getSingularizer().generateMethods(cfv, fieldNode.singularData, deprecate, builderType, source.get(), true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
+ fieldNode.singularData.getSingularizer().generateMethods(job.checkerFramework, fieldNode.singularData, deprecate, job.builderType,
+ job.sourceNode, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
- private void generateSimpleSetterMethodForBuilder(CheckerFrameworkVersion cfv, JavacNode builderType, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JavacNode source, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, String setterPrefix) {
+ private void generateSimpleSetterMethodForBuilder(SuperBuilderJob job, boolean deprecate, JavacNode fieldNode, Name paramName, Name nameOfSetFlag, JCExpression returnType, JCStatement returnStatement, List<JCAnnotation> annosOnParam, JavacNode originalFieldNode, String setterPrefix) {
String setterName = HandlerUtil.buildAccessorName(setterPrefix, paramName.toString());
- Name setterName_ = builderType.toName(setterName);
+ Name setterName_ = job.builderType.toName(setterName);
- for (JavacNode child : builderType.down()) {
+ for (JavacNode child : job.builderType.down()) {
if (child.getKind() != Kind.METHOD) continue;
JCMethodDecl methodDecl = (JCMethodDecl) child.get();
Name existingName = methodDecl.name;
@@ -910,23 +956,24 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JavacTreeMaker maker = fieldNode.getTreeMaker();
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();
- JCExpression selfType = namePlusTypeParamsToTypeReference(maker, builderType, builderTypeNode.typarams);
- JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>of(ncAnno)), builderType.toName("this"), selfType, null);
- newMethod.params = List.of(recv, newMethod.params.get(0));
+ JCMethodDecl newMethod = null;
+ if (job.checkerFramework.generateCalledMethods() && maker.hasMethodDefWithRecvParam()) {
+ JCAnnotation ncAnno = maker.Annotation(genTypeRef(job.sourceNode, CheckerFrameworkVersion.NAME__NOT_CALLED), List.<JCExpression>of(maker.Literal(setterName.toString())));
+ JCClassDecl builderTypeNode = (JCClassDecl) job.builderType.get();
+ JCExpression selfType = namePlusTypeParamsToTypeReference(maker, job.builderType, builderTypeNode.typarams, List.<JCAnnotation>of(ncAnno));
+ JCVariableDecl recv = maker.VarDef(maker.Modifiers(0L, List.<JCAnnotation>nil()), job.toName("this"), selfType, null);
+ newMethod = HandleSetter.createSetterWithRecv(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, job.sourceNode, methodAnns, annosOnParam, recv);
}
- if (cfv.generateReturnsReceiver()) {
+ if (newMethod == null) newMethod = HandleSetter.createSetter(Flags.PUBLIC, deprecate, fieldNode, maker, setterName, paramName, nameOfSetFlag, returnType, returnStatement, job.sourceNode, methodAnns, annosOnParam);
+ if (job.checkerFramework.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());
+ JCAnnotation anno = maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
+ recursiveSetGeneratedBy(anno, job.sourceNode);
newMethod.mods.annotations = annotations.prepend(anno);
}
- injectMethod(builderType, newMethod);
+ injectMethod(job.builderType, newMethod);
}
private void addObtainVia(BuilderFieldData bfd, JavacNode node) {
@@ -1032,17 +1079,17 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return null;
}
- private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker, Context context) {
+ private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker, JavacNode source) {
ListBuffer<JCExpression> typeParamsForBuilderParameter = new ListBuffer<JCExpression>();
for (JCTree typeParam : typeParams) {
if (typeParam instanceof JCTypeParameter) {
- typeParamsForBuilderParameter.add(maker.Ident(((JCTypeParameter)typeParam).getName()));
+ typeParamsForBuilderParameter.append(maker.Ident(((JCTypeParameter)typeParam).getName()));
} else if (typeParam instanceof JCIdent) {
- typeParamsForBuilderParameter.add(maker.Ident(((JCIdent)typeParam).getName()));
+ typeParamsForBuilderParameter.append(maker.Ident(((JCIdent)typeParam).getName()));
} else if (typeParam instanceof JCFieldAccess) {
- typeParamsForBuilderParameter.add(copySelect(maker, (JCFieldAccess) typeParam));
+ typeParamsForBuilderParameter.append(copySelect(maker, (JCFieldAccess) typeParam));
} else if (typeParam instanceof JCTypeApply) {
- typeParamsForBuilderParameter.add(cloneType(maker, (JCTypeApply)typeParam, typeParam, context));
+ typeParamsForBuilderParameter.append(cloneType(maker, (JCTypeApply)typeParam, source));
}
}
return typeParamsForBuilderParameter;
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilderRemove.java b/src/core/lombok/javac/handlers/HandleSuperBuilderRemove.java
index cca69729..d3db5ef4 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilderRemove.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilderRemove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 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
@@ -23,8 +23,6 @@ package lombok.javac.handlers;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import lombok.core.AlreadyHandledAnnotations;
@@ -33,9 +31,10 @@ import lombok.core.HandlerPriority;
import lombok.experimental.SuperBuilder;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.spi.Provides;
-@ProviderFor(JavacAnnotationHandler.class)
-@HandlerPriority(65536)
+@Provides
+@HandlerPriority(32768)
@AlreadyHandledAnnotations
public class HandleSuperBuilderRemove extends JavacAnnotationHandler<SuperBuilder> {
@Override public void handle(AnnotationValues<SuperBuilder> annotation, JCAnnotation ast, JavacNode annotationNode) {
diff --git a/src/core/lombok/javac/handlers/HandleSynchronized.java b/src/core/lombok/javac/handlers/HandleSynchronized.java
index 85dc7e80..0bf7cbe8 100644
--- a/src/core/lombok/javac/handlers/HandleSynchronized.java
+++ b/src/core/lombok/javac/handlers/HandleSynchronized.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -33,8 +33,7 @@ import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
@@ -46,13 +45,12 @@ import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
/**
* Handles the {@code lombok.Synchronized} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it.
public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
private static final String INSTANCE_LOCK_NAME = "$lock";
@@ -93,7 +91,6 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
}
JavacTreeMaker maker = methodNode.getTreeMaker().at(ast.pos);
- Context context = methodNode.getContext();
MemberExistsResult exists = MemberExistsResult.NOT_EXISTS;
@@ -124,7 +121,7 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
List.<JCExpression>of(maker.Literal(CTC_INT, 0)), null);
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (isStatic[0] ? Flags.STATIC : 0)),
- methodNode.toName(lockName), objectType, newObjectArray), ast, context);
+ methodNode.toName(lockName), objectType, newObjectArray), annotationNode);
injectFieldAndMarkGenerated(methodNode.up(), fieldDecl);
}
@@ -137,8 +134,8 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
lockNode = maker.Select(maker.Ident(methodNode.toName("this")), methodNode.toName(lockName));
}
- recursiveSetGeneratedBy(lockNode, ast, context);
- method.body = setGeneratedBy(maker.Block(0, List.<JCStatement>of(setGeneratedBy(maker.Synchronized(lockNode, method.body), ast, context))), ast, context);
+ recursiveSetGeneratedBy(lockNode, annotationNode);
+ method.body = setGeneratedBy(maker.Block(0, List.<JCStatement>of(setGeneratedBy(maker.Synchronized(lockNode, method.body), annotationNode))), annotationNode);
methodNode.rebuild();
}
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java
index ff0016e4..3fc6a4e4 100644
--- a/src/core/lombok/javac/handlers/HandleToString.java
+++ b/src/core/lombok/javac/handlers/HandleToString.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,11 +38,9 @@ import lombok.core.handlers.InclusionExclusionUtils.Included;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
@@ -60,7 +58,7 @@ import com.sun.tools.javac.util.List;
/**
* Handles the {@code ToString} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleToString extends JavacAnnotationHandler<ToString> {
@Override public void handle(AnnotationValues<ToString> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.TO_STRING_FLAG_USAGE, "@ToString");
@@ -135,7 +133,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
}
}
}
- JCMethodDecl method = createToString(typeNode, members, includeFieldNames, callSuper, fieldAccess, source.get());
+ JCMethodDecl method = createToString(typeNode, members, includeFieldNames, callSuper, fieldAccess, source);
injectMethod(typeNode, method);
break;
case EXISTS_BY_LOMBOK:
@@ -150,7 +148,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
}
static JCMethodDecl createToString(JavacNode typeNode, Collection<Included<JavacNode, ToString.Include>> members,
- boolean includeNames, boolean callSuper, FieldAccess fieldAccess, JCTree source) {
+ boolean includeNames, boolean callSuper, FieldAccess fieldAccess, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -250,7 +248,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
JCMethodDecl methodDef = maker.MethodDef(mods, typeNode.toName("toString"), returnType,
List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
createRelevantNonNullAnnotation(typeNode, methodDef);
- return recursiveSetGeneratedBy(methodDef, source, typeNode.getContext());
+ return recursiveSetGeneratedBy(methodDef, source);
}
public static String getTypeName(JavacNode typeNode) {
diff --git a/src/core/lombok/javac/handlers/HandleUtilityClass.java b/src/core/lombok/javac/handlers/HandleUtilityClass.java
index 9ff33684..e006cc47 100644
--- a/src/core/lombok/javac/handlers/HandleUtilityClass.java
+++ b/src/core/lombok/javac/handlers/HandleUtilityClass.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -25,8 +25,6 @@ import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage;
import static lombok.javac.Javac.CTC_VOID;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -50,12 +48,13 @@ import lombok.javac.Javac;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
+import lombok.spi.Provides;
/**
* Handles the {@code @UtilityClass} annotation for javac.
*/
@HandlerPriority(-4096) //-2^12; to ensure @FieldDefaults picks up on the 'static' we set here.
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
@Override public void handle(AnnotationValues<UtilityClass> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.UTILITY_CLASS_FLAG_USAGE, "@UtilityClass");
@@ -69,7 +68,7 @@ public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
private static boolean checkLegality(JavacNode typeNode, JavacNode errorNode) {
if (!isClass(typeNode)) {
- errorNode.addError("@UtilityClass is only supported on a class (can't be an interface, enum, annotation, or record).");
+ errorNode.addError("@UtilityClass is only supported on a class.");
return false;
}
@@ -141,7 +140,7 @@ public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
Name name = typeNode.toName("<init>");
JCBlock block = maker.Block(0L, createThrowStatement(typeNode, maker));
JCMethodDecl methodDef = maker.MethodDef(mods, name, null, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), block, null);
- JCMethodDecl constructor = recursiveSetGeneratedBy(methodDef, typeNode.get(), typeNode.getContext());
+ JCMethodDecl constructor = recursiveSetGeneratedBy(methodDef, typeNode);
JavacHandlerUtil.injectMethod(typeNode, constructor, List.<Type>nil(), Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
}
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 23c27bc0..7a524ca3 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2018 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -33,8 +33,7 @@ import lombok.javac.JavacASTVisitor;
import lombok.javac.JavacNode;
import lombok.javac.JavacResolution;
import lombok.javac.ResolutionResetNeeded;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symtab;
@@ -49,7 +48,7 @@ import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
-@ProviderFor(JavacASTVisitor.class)
+@Provides(JavacASTVisitor.class)
@HandlerPriority(HANDLE_DELEGATE_PRIORITY + 100) // run slightly after HandleDelegate; resolution needs to work, so if the RHS expression is i.e. a call to a generated getter, we have to run after that getter has been generated.
@ResolutionResetNeeded
public class HandleVal extends JavacASTAdapter {
@@ -63,6 +62,7 @@ public class HandleVal extends JavacASTAdapter {
JCTree typeTree = local.vartype;
if (typeTree == null) return;
String typeTreeToString = typeTree.toString();
+ JavacNode typeNode = localNode.getNodeFor(typeTree);
if (!(eq(typeTreeToString, "val") || eq(typeTreeToString, "var"))) return;
boolean isVal = typeMatches(val.class, localNode, typeTree);
@@ -111,7 +111,7 @@ public class HandleVal extends JavacASTAdapter {
if (isVal) local.mods.flags |= Flags.FINAL;
if (!localNode.shouldDeleteLombokAnnotations()) {
- JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeTree, localNode.getContext());
+ JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeNode);
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
@@ -182,7 +182,7 @@ public class HandleVal extends JavacASTAdapter {
local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
throw e;
} finally {
- recursiveSetGeneratedBy(local.vartype, typeTree, localNode.getContext());
+ recursiveSetGeneratedBy(local.vartype, typeNode);
}
}
}
diff --git a/src/core/lombok/javac/handlers/HandleValue.java b/src/core/lombok/javac/handlers/HandleValue.java
index abc5a5ca..cff29801 100644
--- a/src/core/lombok/javac/handlers/HandleValue.java
+++ b/src/core/lombok/javac/handlers/HandleValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2018 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -33,8 +33,7 @@ import lombok.Value;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.handlers.HandleConstructor.SkipIfConstructorExists;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -45,7 +44,7 @@ import com.sun.tools.javac.util.List;
/**
* Handles the {@code lombok.Value} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
@HandlerPriority(-512) //-2^9; to ensure @EqualsAndHashCode and such pick up on this handler making the class final and messing with the fields' access levels, run earlier.
public class HandleValue extends JavacAnnotationHandler<Value> {
private HandleFieldDefaults handleFieldDefaults = new HandleFieldDefaults();
@@ -72,7 +71,6 @@ public class HandleValue extends JavacAnnotationHandler<Value> {
JCModifiers jcm = ((JCClassDecl) typeNode.get()).mods;
if ((jcm.flags & Flags.FINAL) == 0) {
jcm.flags |= Flags.FINAL;
- typeNode.rebuild();
}
}
handleFieldDefaults.generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true);
diff --git a/src/core/lombok/javac/handlers/HandleWith.java b/src/core/lombok/javac/handlers/HandleWith.java
index 4e35a574..f914b4c7 100644
--- a/src/core/lombok/javac/handlers/HandleWith.java
+++ b/src/core/lombok/javac/handlers/HandleWith.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2020 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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,8 +37,7 @@ import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Type;
@@ -62,7 +61,7 @@ import com.sun.tools.javac.util.Name;
/**
* Handles the {@code lombok.With} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleWith extends JavacAnnotationHandler<With> {
public void generateWithForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelWith) {
if (checkForTypeLevelWith) {
@@ -215,6 +214,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym;
Type returnType = sym == null ? null : sym.type;
+ recursiveSetGeneratedBy(createdWith, source);
injectMethod(typeNode, createdWith, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
}
@@ -234,7 +234,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
- JCExpression pType = cloneType(maker, fieldDecl.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(maker, fieldDecl.vartype, source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, pType, null);
if (!makeAbstract) {
@@ -289,7 +289,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
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());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
copyJavadoc(field, decl, CopyJavadoc.WITH);
return decl;
}
diff --git a/src/core/lombok/javac/handlers/HandleWithBy.java b/src/core/lombok/javac/handlers/HandleWithBy.java
index 19673172..f1f953b3 100644
--- a/src/core/lombok/javac/handlers/HandleWithBy.java
+++ b/src/core/lombok/javac/handlers/HandleWithBy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 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
@@ -41,8 +41,7 @@ import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.JavacTreeMaker.TypeTag;
import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Flags;
@@ -67,7 +66,7 @@ import com.sun.tools.javac.util.Name;
/**
* Handles the {@code lombok.With} annotation for javac.
*/
-@ProviderFor(JavacAnnotationHandler.class)
+@Provides
public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
public void generateWithByForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelWithBy) {
if (checkForTypeLevelWithBy) {
@@ -126,7 +125,6 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
@Override public void handle(AnnotationValues<WithBy> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHBY_FLAG_USAGE, "@WithBy");
- Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
deleteAnnotationIfNeccessary(annotationNode, WithBy.class);
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
JavacNode node = annotationNode.up();
@@ -138,7 +136,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
switch (node.getKind()) {
case FIELD:
- createWithByForFields(level, fields, annotationNode, true, onMethod);
+ createWithByForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod);
break;
case TYPE:
if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @WithBy on a type.");
@@ -209,6 +207,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym;
Type returnType = sym == null ? null : sym.type;
+ recursiveSetGeneratedBy(createdWithBy, source);
injectMethod(typeNode, createdWithBy, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
}
@@ -265,7 +264,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
}
if (functionalInterfaceName == null) {
functionalInterfaceName = NAME_JUF_FUNCTION;
- parameterizer = cloneType(maker, fieldDecl.vartype, source.get(), field.getContext());
+ parameterizer = cloneType(maker, fieldDecl.vartype, source);
}
if (functionalInterfaceName == NAME_JUF_INTOP) applyMethodName = "applyAsInt";
if (functionalInterfaceName == NAME_JUF_LONGOP) applyMethodName = "applyAsLong";
@@ -274,7 +273,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
JCExpression varType = chainDots(field, functionalInterfaceName);
if (parameterizer != null && superExtendsStyle) {
JCExpression parameterizer1 = parameterizer;
- JCExpression parameterizer2 = cloneType(maker, parameterizer, source.get(), field.getContext());
+ JCExpression parameterizer2 = cloneType(maker, parameterizer, source);
// TODO: Apply copyable annotations to 'parameterizer' and 'parameterizer2'.
JCExpression arg1 = maker.Wildcard(maker.TypeBoundKind(BoundKind.SUPER), parameterizer1);
JCExpression arg2 = maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), parameterizer2);
@@ -334,7 +333,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
if (makeAbstract) access = access | Flags.ABSTRACT;
createRelevantNonNullAnnotation(source, param);
JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType,
- methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
copyJavadoc(field, decl, CopyJavadoc.WITH_BY);
createRelevantNonNullAnnotation(source, decl);
return decl;
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index cd4bc70a..b4f2acc4 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -35,7 +35,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.element.Element;
@@ -103,7 +102,6 @@ import lombok.core.handlers.HandlerUtil.FieldAccess;
import lombok.delombok.LombokOptionsFactory;
import lombok.experimental.Accessors;
import lombok.experimental.Tolerate;
-import lombok.javac.Java14Flags;
import lombok.javac.Javac;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -118,17 +116,15 @@ public class JavacHandlerUtil {
}
private static class MarkingScanner extends TreeScanner {
- private final JCTree source;
- private final Context context;
+ private final JavacNode source;
- MarkingScanner(JCTree source, Context context) {
+ MarkingScanner(JavacNode source) {
this.source = source;
- this.context = context;
}
@Override public void scan(JCTree tree) {
if (tree == null) return;
- setGeneratedBy(tree, source, context);
+ setGeneratedBy(tree, source);
super.scan(tree);
}
}
@@ -146,12 +142,12 @@ public class JavacHandlerUtil {
Options options = Options.instance(context);
return (options.keySet().contains("ide") && !options.keySet().contains("backgroundCompilation"));
}
-
+
public static boolean inNetbeansCompileOnSave(Context context) {
Options options = Options.instance(context);
return (options.keySet().contains("ide") && options.keySet().contains("backgroundCompilation"));
}
-
+
public static JCTree getGeneratedBy(JCTree node) {
return JCTree_generatedNode.get(node);
}
@@ -160,20 +156,31 @@ public class JavacHandlerUtil {
return getGeneratedBy(node) != null;
}
- public static <T extends JCTree> T recursiveSetGeneratedBy(T node, JCTree source, Context context) {
+ public static <T extends JCTree> T recursiveSetGeneratedBy(T node, JavacNode source) {
if (node == null) return null;
- setGeneratedBy(node, source, context);
- node.accept(new MarkingScanner(source, context));
+ setGeneratedBy(node, source);
+ node.accept(new MarkingScanner(source));
return node;
}
- public static <T extends JCTree> T setGeneratedBy(T node, JCTree source, Context context) {
+ public static <T extends JCTree> T setGeneratedBy(T node, JavacNode sourceNode) {
if (node == null) return null;
- if (source == null) JCTree_generatedNode.clear(node);
- else JCTree_generatedNode.set(node, source);
- if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos;
+ if (sourceNode == null) {
+ JCTree_generatedNode.clear(node);
+ return node;
+ }
+ JCTree_generatedNode.set(node, sourceNode.get());
+
+ if (!inNetbeansEditor(sourceNode.getContext()) || isParameter(node)) {
+ node.pos = sourceNode.getStartPos();
+ storeEnd(node, sourceNode.getEndPosition(), (JCCompilationUnit) sourceNode.top().get());
+ }
return node;
}
+
+ public static boolean isParameter(JCTree node) {
+ return node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0;
+ }
public static boolean hasAnnotation(String type, JavacNode node) {
return hasAnnotation(type, node, false);
@@ -800,7 +807,7 @@ public class JavacHandlerUtil {
node = upToTypeNode(node);
if (node != null && node.get() instanceof JCClassDecl) {
- for (JCTree def : ((JCClassDecl)node.get()).defs) {
+ for (JCTree def : ((JCClassDecl) node.get()).defs) {
if (def instanceof JCMethodDecl) {
JCMethodDecl md = (JCMethodDecl) def;
if (md.name.contentEquals("<init>")) {
@@ -816,23 +823,21 @@ public class JavacHandlerUtil {
}
/**
- * Checks if there is a constructor generated by lombok.
+ * Checks if there is at least one constructor that is generated by lombok.
*
- * @param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.
+ * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.
*/
public static boolean lombokConstructorExists(JavacNode node) {
node = upToTypeNode(node);
if (node != null && node.get() instanceof JCClassDecl) {
- for (JCTree def : ((JCClassDecl)node.get()).defs) {
+ for (JCTree def : ((JCClassDecl) node.get()).defs) {
if (def instanceof JCMethodDecl) {
JCMethodDecl md = (JCMethodDecl) def;
if (md.name.contentEquals("<init>")) {
if ((md.mods.flags & Flags.GENERATEDCONSTR) != 0) continue;
if (isTolerate(node, md)) continue;
- if (getGeneratedBy(def) != null) {
- return true;
- }
+ if (getGeneratedBy(def) != null) return true;
}
}
}
@@ -1054,7 +1059,7 @@ public class JavacHandlerUtil {
public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field) {
return injectField(typeNode, field, false);
}
-
+
public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field, boolean addGenerated) {
return injectField(typeNode, field, addGenerated, false);
}
@@ -1063,8 +1068,8 @@ public class JavacHandlerUtil {
JCClassDecl type = (JCClassDecl) typeNode.get();
if (addGenerated) {
- addSuppressWarningsAll(field.mods, typeNode, field.pos, getGeneratedBy(field), typeNode.getContext());
- addGenerated(field.mods, typeNode, field.pos, getGeneratedBy(field), typeNode.getContext());
+ addSuppressWarningsAll(field.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(field)), typeNode.getContext());
+ addGenerated(field.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(field)), typeNode.getContext());
}
List<JCTree> insertAfter = null;
@@ -1104,6 +1109,17 @@ public class JavacHandlerUtil {
private static Constructor<?> CONSTRUCTOR;
private static Field ANNOTATIONS, UNDERLYING_TYPE;
+ private static void initByLoader(ClassLoader classLoader) {
+ if (TYPE != null) return;
+ Class<?> c;
+ try {
+ c = classLoader.loadClass("com.sun.tools.javac.tree.JCTree$JCAnnotatedType");
+ } catch (Exception e) {
+ return;
+ }
+ init(c);
+ }
+
private static void init(Class<?> in) {
if (TYPE != null) return;
if (!in.getName().equals("com.sun.tools.javac.tree.JCTree$JCAnnotatedType")) return;
@@ -1148,17 +1164,18 @@ public class JavacHandlerUtil {
}
static JCExpression create(List<JCAnnotation> annotations, JCExpression underlyingType) {
+ initByLoader(underlyingType.getClass().getClassLoader());
try {
return (JCExpression) CONSTRUCTOR.newInstance(annotations, underlyingType);
} catch (Exception e) {
- return null;
+ return underlyingType;
}
}
}
-
+
static class JCAnnotationReflect {
private static Field ATTRIBUTE;
-
+
static {
try {
ATTRIBUTE = Permit.getField(JCAnnotation.class, "attribute");
@@ -1199,7 +1216,7 @@ public class JavacHandlerUtil {
try {
Scope scope = (Scope) membersField.get(from);
if (scope == null) return;
- removeMethod.invoke(scope, toRemove);
+ Permit.invoke(removeMethod, scope, toRemove);
} catch (Exception e) {}
}
@@ -1208,7 +1225,7 @@ public class JavacHandlerUtil {
try {
Scope scope = (Scope) membersField.get(from);
if (scope == null) return;
- enterMethod.invoke(scope, toEnter);
+ Permit.invoke(enterMethod, scope, toEnter);
} catch (Exception e) {}
}
}
@@ -1227,7 +1244,7 @@ public class JavacHandlerUtil {
Context context = typeNode.getContext();
Symtab symtab = Symtab.instance(context);
JCClassDecl type = (JCClassDecl) typeNode.get();
-
+
if (method.getName().contentEquals("<init>")) {
//Scan for default constructor, and remove it.
int idx = 0;
@@ -1244,11 +1261,11 @@ public class JavacHandlerUtil {
idx++;
}
}
-
- addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
- addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
+
+ addSuppressWarningsAll(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
+ addGenerated(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
type.defs = type.defs.append(method);
-
+
List<Symbol.VarSymbol> params = null;
if (method.getParameters() != null && !method.getParameters().isEmpty()) {
ListBuffer<Symbol.VarSymbol> newParams = new ListBuffer<Symbol.VarSymbol>();
@@ -1257,6 +1274,7 @@ public class JavacHandlerUtil {
if (param.sym == null) {
Type paramType = paramTypes == null ? param.getType().type : paramTypes.get(i);
VarSymbol varSymbol = new VarSymbol(param.mods.flags, param.name, paramType, symtab.noSymbol);
+ varSymbol.adr = 1 << i;
List<JCAnnotation> annotations = param.getModifiers().getAnnotations();
if (annotations != null && !annotations.isEmpty()) {
ListBuffer<Attribute.Compound> newAnnotations = new ListBuffer<Attribute.Compound>();
@@ -1278,9 +1296,9 @@ public class JavacHandlerUtil {
params = newParams.toList();
if (params.length() != method.getParameters().length()) params = null;
}
-
+
fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, params, returnType);
-
+
typeNode.add(method, Kind.METHOD);
}
@@ -1290,6 +1308,9 @@ public class JavacHandlerUtil {
MethodSymbol methodSymbol = new MethodSymbol(access, methodName, new MethodType(paramTypes, returnType, List.<Type>nil(), Symtab.instance(context).methodClass), cs);
if (params != null && !params.isEmpty()) {
methodSymbol.params = params;
+ for (VarSymbol varSymbol : params) {
+ varSymbol.owner = methodSymbol;
+ }
}
ClassSymbolMembersField.enter(cs, methodSymbol);
}
@@ -1303,8 +1324,8 @@ public class JavacHandlerUtil {
*/
public static JavacNode injectType(JavacNode typeNode, final JCClassDecl type) {
JCClassDecl typeDecl = (JCClassDecl) typeNode.get();
- addSuppressWarningsAll(type.mods, typeNode, type.pos, getGeneratedBy(type), typeNode.getContext());
- addGenerated(type.mods, typeNode, type.pos, getGeneratedBy(type), typeNode.getContext());
+ addSuppressWarningsAll(type.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(type)), typeNode.getContext());
+ addGenerated(type.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(type)), typeNode.getContext());
typeDecl.defs = typeDecl.defs.append(type);
return typeNode.add(type, Kind.TYPE);
}
@@ -1343,7 +1364,7 @@ public class JavacHandlerUtil {
}
}
- public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
+ public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, JavacNode source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return;
boolean addJLSuppress = !Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS));
@@ -1359,27 +1380,27 @@ public class JavacHandlerUtil {
}
}
}
- if (addJLSuppress) addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));
+ if (addJLSuppress) addAnnotation(mods, node, source, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) {
JavacTreeMaker maker = node.getTreeMaker();
JCExpression arg = maker.Assign(maker.Ident(node.toName("justification")), maker.Literal("generated code"));
- addAnnotation(mods, node, pos, source, context, "edu.umd.cs.findbugs.annotations.SuppressFBWarnings", arg);
+ addAnnotation(mods, node, source, "edu.umd.cs.findbugs.annotations.SuppressFBWarnings", arg);
}
}
- public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
+ public static void addGenerated(JCModifiers mods, JavacNode node, JavacNode source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return;
if (HandlerUtil.shouldAddGenerated(node)) {
- addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
+ addAnnotation(mods, node, source, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
}
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) {
- addAnnotation(mods, node, pos, source, context, "lombok.Generated", null);
+ addAnnotation(mods, node, source, "lombok.Generated", null);
}
}
- public 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, JavacNode source, String annotationTypeFqn, JCExpression arg) {
boolean isJavaLangBased;
String simpleName; {
int idx = annotationTypeFqn.lastIndexOf('.');
@@ -1402,17 +1423,8 @@ public class JavacHandlerUtil {
JavacTreeMaker maker = node.getTreeMaker();
JCExpression annType = isJavaLangBased ? genJavaLangTypeRef(node, simpleName) : chainDotsString(node, annotationTypeFqn);
- annType.pos = pos;
- if (arg != null) {
- arg.pos = pos;
- if (arg instanceof JCAssign) {
- ((JCAssign) arg).lhs.pos = pos;
- ((JCAssign) arg).rhs.pos = pos;
- }
- }
List<JCExpression> argList = arg != null ? List.of(arg) : List.<JCExpression>nil();
- JCAnnotation annotation = recursiveSetGeneratedBy(maker.Annotation(annType, argList), source, context);
- annotation.pos = pos;
+ JCAnnotation annotation = recursiveSetGeneratedBy(maker.Annotation(annType, argList), source);
mods.annotations = mods.annotations.append(annotation);
}
@@ -1456,6 +1468,7 @@ public class JavacHandlerUtil {
}
return e;
}
+
/**
* In javac, dotted access of any kind, from {@code java.lang.String} to {@code var.methodName}
* is represented by a fold-left of {@code Select} nodes with the leftmost string represented by
@@ -1831,13 +1844,12 @@ public class JavacHandlerUtil {
if (params == null || params.isEmpty()) return params;
ListBuffer<JCTypeParameter> out = new ListBuffer<JCTypeParameter>();
JavacTreeMaker maker = source.getTreeMaker();
- Context context = source.getContext();
for (JCTypeParameter tp : params) {
List<JCExpression> bounds = tp.bounds;
if (bounds != null && !bounds.isEmpty()) {
ListBuffer<JCExpression> boundsCopy = new ListBuffer<JCExpression>();
for (JCExpression expr : tp.bounds) {
- boundsCopy.append(cloneType(maker, expr, source.get(), context));
+ boundsCopy.append(cloneType(maker, expr, source));
}
bounds = boundsCopy.toList();
}
@@ -1859,20 +1871,30 @@ public class JavacHandlerUtil {
public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode type, List<JCTypeParameter> params) {
JCClassDecl td = (JCClassDecl) type.get();
boolean instance = (td.mods.flags & Flags.STATIC) == 0;
- return namePlusTypeParamsToTypeReference(maker, type.up(), td.name, instance, params);
+ return namePlusTypeParamsToTypeReference(maker, type.up(), td.name, instance, params, List.<JCAnnotation>nil());
+ }
+
+ public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode type, List<JCTypeParameter> params, List<JCAnnotation> annotations) {
+ JCClassDecl td = (JCClassDecl) type.get();
+ boolean instance = (td.mods.flags & Flags.STATIC) == 0;
+ return namePlusTypeParamsToTypeReference(maker, type.up(), td.name, instance, params, annotations);
}
public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode parentType, Name typeName, boolean instance, List<JCTypeParameter> params) {
+ return namePlusTypeParamsToTypeReference(maker, parentType, typeName, instance, params, List.<JCAnnotation>nil());
+ }
+
+ public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode parentType, Name typeName, boolean instance, List<JCTypeParameter> params, List<JCAnnotation> annotations) {
JCExpression r = null;
-
if (parentType != null && parentType.getKind() == Kind.TYPE) {
JCClassDecl td = (JCClassDecl) parentType.get();
boolean outerInstance = instance && ((td.mods.flags & Flags.STATIC) == 0);
List<JCTypeParameter> outerParams = instance ? td.typarams : List.<JCTypeParameter>nil();
- r = namePlusTypeParamsToTypeReference(maker, parentType.up(), td.name, outerInstance, outerParams);
+ r = namePlusTypeParamsToTypeReference(maker, parentType.up(), td.name, outerInstance, outerParams, List.<JCAnnotation>nil());
}
r = r == null ? maker.Ident(typeName) : maker.Select(r, typeName);
+ if (!annotations.isEmpty()) r = JCAnnotatedTypeReflect.create(annotations, r);
if (!params.isEmpty()) r = maker.TypeApply(r, typeParameterNames(maker, params));
return r;
}
@@ -1926,17 +1948,30 @@ public class JavacHandlerUtil {
return out.toList();
}
- static boolean isClass(JavacNode typeNode) {
- return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ENUM | Flags.ANNOTATION | Java14Flags.RECORD);
+ /**
+ * Returns {@code true} if the provided node is an actual class and not some other type declaration (so, not an annotation definition, interface, enum, or record).
+ */
+ public static boolean isClass(JavacNode typeNode) {
+ return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ENUM | Flags.ANNOTATION | RECORD);
+ }
+
+ /**
+ * Returns {@code true} if the provided node is an actual class or enum and not some other type declaration (so, not an annotation definition, interface, or record).
+ */
+ public static boolean isClassOrEnum(JavacNode typeNode) {
+ return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | RECORD);
}
- static boolean isClassOrEnum(JavacNode typeNode) {
- return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | Java14Flags.RECORD);
+ /**
+ * Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
+ */
+ public static boolean isRecord(JavacNode typeNode) {
+ return typeNode.getKind() == Kind.TYPE && (((JCClassDecl) typeNode.get()).mods.flags & RECORD) != 0;
}
public static boolean isClassAndDoesNotHaveFlags(JavacNode typeNode, long flags) {
JCClassDecl typeDecl = null;
- if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl)typeNode.get();
+ if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
else return false;
long typeDeclflags = typeDecl == null ? 0 : typeDecl.mods.flags;
@@ -1950,11 +1985,11 @@ public class JavacHandlerUtil {
return node;
}
- public static List<JCExpression> cloneTypes(JavacTreeMaker maker, List<JCExpression> in, JCTree source, Context context) {
+ public static List<JCExpression> cloneTypes(JavacTreeMaker maker, List<JCExpression> in, JavacNode source) {
if (in.isEmpty()) return List.nil();
- if (in.size() == 1) return List.of(cloneType(maker, in.get(0), source, context));
+ if (in.size() == 1) return List.of(cloneType(maker, in.get(0), source));
ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>();
- for (JCExpression expr : in) lb.append(cloneType(maker, expr, source, context));
+ for (JCExpression expr : in) lb.append(cloneType(maker, expr, source));
return lb.toList();
}
@@ -1968,9 +2003,9 @@ public class JavacHandlerUtil {
* the class's own parameter, but as its a static method, the static method's notion of {@code T} is different from the class notion of {@code T}. If you're duplicating
* a type used in the class context, you need to use this method.
*/
- public static JCExpression cloneType(JavacTreeMaker maker, JCExpression in, JCTree source, Context context) {
+ public static JCExpression cloneType(JavacTreeMaker maker, JCExpression in, JavacNode source) {
JCExpression out = cloneType0(maker, in);
- if (out != null) recursiveSetGeneratedBy(out, source, context);
+ if (out != null) recursiveSetGeneratedBy(out, source);
return out;
}
@@ -2031,50 +2066,6 @@ public class JavacHandlerUtil {
return (JCExpression) in;
}
- private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITH(?:ER)?)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
- private static final Pattern LINE_BREAK_FINDER = Pattern.compile("(\\r?\\n)?");
-
- public static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) {
- Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
- Matcher m = p.matcher(javadoc);
- return m.replaceAll("");
- }
-
- public static String stripSectionsFromJavadoc(String javadoc) {
- Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
- if (!sectionMatcher.find()) return javadoc;
-
- return javadoc.substring(0, sectionMatcher.start());
- }
-
- public static String getJavadocSection(String javadoc, String sectionNameSpec) {
- String[] sectionNames = sectionNameSpec.split("\\|");
- Matcher sectionMatcher = SECTION_FINDER.matcher(javadoc);
- Matcher lineBreakMatcher = LINE_BREAK_FINDER.matcher(javadoc);
- int sectionStart = -1;
- int sectionEnd = -1;
- while (sectionMatcher.find()) {
- boolean found = false;
- for (String sectionName : sectionNames) if (sectionMatcher.group(1).equalsIgnoreCase(sectionName)) {
- found = true;
- break;
- }
- if (found) {
- lineBreakMatcher.find(sectionMatcher.end());
- sectionStart = lineBreakMatcher.end();
- } else if (sectionStart != -1) {
- sectionEnd = sectionMatcher.start();
- }
- }
-
- if (sectionStart != -1) {
- if (sectionEnd != -1) return javadoc.substring(sectionStart, sectionEnd);
- return javadoc.substring(sectionStart);
- }
-
- return null;
- }
-
public static enum CopyJavadoc {
VERBATIM {
@Override public String apply(final JCCompilationUnit cu, final JavacNode node) {
@@ -2089,7 +2080,7 @@ public class JavacHandlerUtil {
String out = getJavadocSection(javadoc, "GETTER");
final boolean sectionBased = out != null;
if (!sectionBased) {
- out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), "@param(?:eter)?\\s+.*");
+ out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.PARAM);
}
node.getAst().cleanupTask("javadocfilter-getter", n, new CleanupTask() {
@Override public void cleanup() {
@@ -2097,7 +2088,7 @@ public class JavacHandlerUtil {
if (javadoc == null || javadoc.isEmpty()) return;
javadoc = stripSectionsFromJavadoc(javadoc);
if (!sectionBased) {
- javadoc = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), "@returns?\\s+.*");
+ javadoc = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.RETURN);
}
Javac.setDocComment(cu, n, javadoc);
}
@@ -2130,7 +2121,7 @@ public class JavacHandlerUtil {
String out = getJavadocSection(javadoc, sectionName);
final boolean sectionBased = out != null;
if (!sectionBased) {
- out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), "@returns?\\s+.*");
+ out = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.RETURN);
}
node.getAst().cleanupTask("javadocfilter-setter", n, new CleanupTask() {
@Override public void cleanup() {
@@ -2138,7 +2129,7 @@ public class JavacHandlerUtil {
if (javadoc == null || javadoc.isEmpty()) return;
javadoc = stripSectionsFromJavadoc(javadoc);
if (!sectionBased) {
- javadoc = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), "@param(?:eter)?\\s+.*");
+ javadoc = stripLinesWithTagFromJavadoc(stripSectionsFromJavadoc(javadoc), JavadocTag.PARAM);
}
Javac.setDocComment(cu, n, javadoc);
}
@@ -2150,6 +2141,7 @@ public class JavacHandlerUtil {
public static void copyJavadoc(JavacNode from, JCTree to, CopyJavadoc copyMode) {
copyJavadoc(from, to, copyMode, false);
}
+
/**
* Copies javadoc on one node to the other.
*
@@ -2164,31 +2156,13 @@ public class JavacHandlerUtil {
try {
JCCompilationUnit cu = ((JCCompilationUnit) from.top().get());
String newJavadoc = copyMode.apply(cu, from);
- if (newJavadoc != null) {
- if (forceAddReturn) newJavadoc = addReturnsThisIfNeeded(newJavadoc);
- Javac.setDocComment(cu, to, newJavadoc);
+ if (forceAddReturn) {
+ newJavadoc = addReturnsThisIfNeeded(newJavadoc);
}
+ Javac.setDocComment(cu, to, newJavadoc);
} catch (Exception ignore) {}
}
- private static final Pattern FIND_RETURN = Pattern.compile("^\\s*\\**\\s*@returns?\\s+.*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
- static String addReturnsThisIfNeeded(String in) {
- if (FIND_RETURN.matcher(in).find()) return in;
-
- return addJavadocLine(in, "@return {@code this}.");
- }
-
- static String addReturnsUpdatedSelfIfNeeded(String in) {
- if (FIND_RETURN.matcher(in).find()) return in;
-
- return addJavadocLine(in, "@return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).");
- }
-
- static String addJavadocLine(String in, String line) {
- if (in.endsWith("\n")) return in + line + "\n";
- return in + "\n" + line;
- }
-
public static boolean isDirectDescendantOfObject(JavacNode typeNode) {
if (!(typeNode.get() instanceof JCClassDecl)) throw new IllegalArgumentException("not a type node");
JCTree extending = Javac.getExtendsClause((JCClassDecl) typeNode.get());
@@ -2232,6 +2206,10 @@ public class JavacHandlerUtil {
JCExpression resType = mth.restype;
if (resType instanceof JCTypeApply) {
JCTypeApply ta = (JCTypeApply) resType;
+ if (ta.clazz instanceof JCFieldAccess) {
+ mth.restype = maker.TypeApply(maker.AnnotatedType(List.of(m), ta.clazz), ta.arguments);
+ return;
+ }
resType = ta.clazz;
}
@@ -2287,8 +2265,4 @@ public class JavacHandlerUtil {
arg.mods.annotations = arg.mods.annotations == null ? List.of(m) : arg.mods.annotations.prepend(m);
}
}
-
- public static boolean isRecord(JavacNode typeNode) {
- return typeNode.getKind() == Kind.TYPE && (((JCClassDecl) typeNode.get()).mods.flags & Java14Flags.RECORD) != 0;
- }
}
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 7cd52c8c..4ca09b82 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2020 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -43,7 +43,6 @@ import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.JCTree.JCWildcard;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -57,6 +56,7 @@ import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.handlers.HandlerUtil;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
+import lombok.javac.handlers.HandleBuilder.BuilderJob;
public class JavacSingularsRecipes {
public interface ExpressionMaker {
@@ -235,7 +235,7 @@ public class JavacSingularsRecipes {
return Arrays.asList(p, s);
}
- public abstract java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source);
+ public abstract java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source);
/**
* Generates the singular, plural, and clear methods for the given {@link SingularData}.
@@ -243,36 +243,38 @@ 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(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, final JavacNode builderType, JCTree source, boolean fluent, final boolean chain, AccessLevel access) {
- final JavacTreeMaker maker = builderType.getTreeMaker();
+ public void generateMethods(final BuilderJob job, SingularData data, boolean deprecate) {
+ //job.checkerFramework, job.builderType, job.source, job.oldFluent, job.oldChain, job.accessInners
+ //CheckerFrameworkVersion cfv, final JavacNode builderType, JavacNode source, boolean fluent, final boolean chain, AccessLevel access) {
+ final JavacTreeMaker maker = job.builderType.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
- return chain ?
- cloneSelfType(builderType) :
- maker.Type(createVoidType(builderType.getSymbolTable(), CTC_VOID));
+ return job.oldChain ?
+ cloneSelfType(job.builderType) :
+ maker.Type(createVoidType(job.builderType.getSymbolTable(), CTC_VOID));
}};
StatementMaker returnStatementMaker = new StatementMaker() { @Override public JCStatement make() {
- return chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
+ return job.oldChain ? maker.Return(maker.Ident(job.builderType.toName("this"))) : null;
}};
- generateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
+ generateMethods(job.checkerFramework, data, deprecate, job.builderType, job.sourceNode, job.oldFluent, returnTypeMaker, returnStatementMaker, job.accessInners);
}
/**
* 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(CheckerFrameworkVersion cfv, 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, JavacNode 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) {
+ protected void doGenerateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
JavacTreeMaker maker = builderType.getTreeMaker();
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(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, List<JCAnnotation> methodAnnotations, AccessLevel access, Boolean ignoreNullCollections) {
+ private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JavacNode source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, List<JCAnnotation> methodAnnotations, AccessLevel access, Boolean ignoreNullCollections) {
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
JCModifiers mods = makeMods(maker, cfv, builderType, deprecate, access, methodAnnotations);
@@ -288,15 +290,15 @@ public class JavacSingularsRecipes {
}
JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, jcVariableDecls, thrown, body, null);
- recursiveSetGeneratedBy(method, source, builderType.getContext());
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, method);
+ recursiveSetGeneratedBy(method, source);
injectMethod(builderType, method);
}
- private void generateClearMethod(CheckerFrameworkVersion cfv, 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, JavacNode source, AccessLevel access) {
JCStatement clearStatement = generateClearStatements(maker, data, builderType);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- statements.add(clearStatement);
+ statements.append(clearStatement);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, methodName, List.<JCVariableDecl>nil(), List.<JCAnnotation>nil(), access, null);
@@ -304,7 +306,7 @@ public class JavacSingularsRecipes {
protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType);
- private void generateSingularMethod(CheckerFrameworkVersion cfv, 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, JavacNode 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();
@@ -317,7 +319,7 @@ public class JavacSingularsRecipes {
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, methodAnnotations, access, null);
}
- protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, Name name) {
+ protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source, Name name) {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
JCExpression type = cloneParamType(typeIndex, maker, data.getTypeArgs(), builderType, source);
List<JCAnnotation> typeUseAnns = getTypeUseAnnotations(type);
@@ -332,11 +334,11 @@ public class JavacSingularsRecipes {
return maker.Exec(invokeAdd);
}
- protected abstract ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- protected abstract List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- private void generatePluralMethod(CheckerFrameworkVersion cfv, 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, JavacNode source, boolean fluent, AccessLevel access) {
ListBuffer<JCStatement> statements = generatePluralMethodStatements(maker, data, builderType, source);
Name name = data.getPluralName();
@@ -355,7 +357,7 @@ public class JavacSingularsRecipes {
JCExpression incomingIsNotNull = maker.Binary(CTC_NOT_EQUAL, maker.Ident(data.getPluralName()), maker.Literal(CTC_BOT, null));
JCStatement onNotNull = maker.Block(0, statements.toList());
statements = new ListBuffer<JCStatement>();
- statements.add(maker.If(incomingIsNotNull, onNotNull, null));
+ statements.append(maker.If(incomingIsNotNull, onNotNull, null));
} else {
statements.prepend(JavacHandlerUtil.generateNullCheck(maker, null, data.getPluralName(), builderType, "%s cannot be null"));
}
@@ -365,7 +367,7 @@ public class JavacSingularsRecipes {
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), methodAnnotations, access, ignoreNullCollections);
}
- protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All");
@@ -377,9 +379,9 @@ public class JavacSingularsRecipes {
protected abstract JCExpression getPluralMethodParamType(JavacNode builderType);
- protected abstract JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- public abstract void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable);
+ public abstract void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable);
public boolean shadowedDuringBuild() {
return true;
@@ -393,7 +395,7 @@ public class JavacSingularsRecipes {
}
}
- public void appendCleaningCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements) {
+ public void appendCleaningCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements) {
}
// -- Utility methods --
@@ -409,16 +411,15 @@ public class JavacSingularsRecipes {
* @param typeArgs the list of type args to clone.
* @param source The source annotation that is the root cause of this code generation.
*/
- protected JCExpression addTypeArgs(int count, boolean addExtends, JavacNode node, JCExpression type, List<JCExpression> typeArgs, JCTree source) {
+ protected JCExpression addTypeArgs(int count, boolean addExtends, JavacNode node, JCExpression type, List<JCExpression> typeArgs, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
List<JCExpression> clonedAndFixedTypeArgs = createTypeArgs(count, addExtends, node, typeArgs, source);
return maker.TypeApply(type, clonedAndFixedTypeArgs);
}
- protected List<JCExpression> createTypeArgs(int count, boolean addExtends, JavacNode node, List<JCExpression> typeArgs, JCTree source) {
+ protected List<JCExpression> createTypeArgs(int count, boolean addExtends, JavacNode node, List<JCExpression> typeArgs, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
- Context context = node.getContext();
if (count < 0) throw new IllegalArgumentException("count is negative");
if (count == 0) return List.nil();
@@ -435,17 +436,17 @@ public class JavacSingularsRecipes {
} catch (Exception e) {
inner = genJavaLangTypeRef(node, "Object");
}
- arguments.append(cloneType(maker, inner, source, context));
+ arguments.append(cloneType(maker, inner, source));
} else {
- arguments.append(cloneType(maker, orig, source, context));
+ arguments.append(cloneType(maker, orig, source));
}
} else {
if (orig.getKind() == Kind.UNBOUNDED_WILDCARD || orig.getKind() == Kind.SUPER_WILDCARD) {
arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null));
} else if (orig.getKind() == Kind.EXTENDS_WILDCARD) {
- arguments.append(cloneType(maker, orig, source, context));
+ arguments.append(cloneType(maker, orig, source));
} else {
- arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), cloneType(maker, orig, source, context)));
+ arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), cloneType(maker, orig, source)));
}
}
if (--count == 0) break;
@@ -468,7 +469,7 @@ public class JavacSingularsRecipes {
JCExpression fn = maker.Select(maker.Select(maker.Ident(thisName), name), builderType.toName("size"));
JCExpression sizeInvoke = maker.Apply(List.<JCExpression>nil(), fn, List.<JCExpression>nil());
if (nullGuard) {
- JCExpression isNull = maker.Binary(CTC_EQUAL, maker.Select(maker.Ident(thisName), name), maker.Literal(CTC_BOT, 0));
+ JCExpression isNull = maker.Binary(CTC_EQUAL, maker.Select(maker.Ident(thisName), name), maker.Literal(CTC_BOT, null));
JCExpression out = maker.Conditional(isNull, maker.Literal(CTC_INT, 0), sizeInvoke);
if (parens) return maker.Parens(out);
return out;
@@ -476,7 +477,7 @@ public class JavacSingularsRecipes {
return sizeInvoke;
}
- protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JCTree source) {
+ protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JavacNode source) {
if (typeArgs == null || typeArgs.size() <= index) {
return genJavaLangTypeRef(builderType, "Object");
} else {
@@ -485,12 +486,12 @@ public class JavacSingularsRecipes {
return genJavaLangTypeRef(builderType, "Object");
} else if (originalType.getKind() == Kind.EXTENDS_WILDCARD) {
try {
- return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source, builderType.getContext());
+ return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source);
} catch (Exception e) {
return genJavaLangTypeRef(builderType, "Object");
}
} else {
- return cloneType(maker, originalType, source, builderType.getContext());
+ return cloneType(maker, originalType, source);
}
}
}
@@ -500,5 +501,11 @@ public class JavacSingularsRecipes {
protected abstract int getTypeArgumentsCount();
protected abstract String getEmptyMaker(String target);
+
+ public JCExpression getEmptyExpression(String target, JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
+ String emptyMaker = getEmptyMaker(target);
+ List<JCExpression> typeArgs = createTypeArgs(getTypeArgumentsCount(), false, builderType, data.getTypeArgs(), source);
+ return maker.Apply(typeArgs, chainDots(builderType, emptyMaker.split("\\.")), List.<JCExpression>nil());
+ }
}
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaMapSingularizer.java
index e0621cf7..84840799 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaMapSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -23,10 +23,9 @@ package lombok.javac.handlers.singulars;
import lombok.core.LombokImmutableList;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacGuavaMapSingularizer extends JavacGuavaSingularizer {
// TODO cgcc.ImmutableMultimap, cgcc.ImmutableListMultimap, cgcc.ImmutableSetMultimap
// TODO cgcc.ImmutableClassToInstanceMap
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSetListSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSetListSingularizer.java
index 5c7fcab5..44d6d15b 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSetListSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSetListSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,12 +21,11 @@
*/
package lombok.javac.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
+import lombok.spi.Provides;
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacGuavaSetListSingularizer extends JavacGuavaSingularizer {
// TODO com.google.common.collect.ImmutableRangeSet
// TODO com.google.common.collect.ImmutableMultiset and com.google.common.collect.ImmutableSortedMultiset
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index 7cd676c0..ce5aad5e 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -39,7 +39,6 @@ import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -62,7 +61,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return "builder";
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
String simpleTypeName = getSimpleTargetTypeName(data);
JCExpression type = JavacHandlerUtil.chainDots(builderType, "com", "google", "common", "collect", simpleTypeName, "Builder");
@@ -72,7 +71,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -83,7 +82,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name[] names = generateSingularMethodParameterNames(data, builderType);
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
for (int i = 0; i < names.length; i++) {
@@ -93,7 +92,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name[] names = generateSingularMethodParameterNames(data, builderType);
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName());
@@ -124,7 +123,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return genTypeRef(builderType, getAddAllTypeName());
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
List<JCExpression> jceBlank = List.nil();
@@ -151,12 +150,12 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
JCExpression init = maker.Conditional(isNull, empty, invokeBuild); // this.pluralName == null ? ImmutableX.of() : this.pluralName.build()
- JCStatement jcs = maker.VarDef(maker.Modifiers(0), data.getPluralName(), varType, init);
+ JCStatement jcs = maker.VarDef(maker.Modifiers(0L), data.getPluralName(), varType, init);
statements.append(jcs);
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName());
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaTableSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaTableSingularizer.java
index 080266b8..bdc5facc 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaTableSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaTableSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,12 +21,11 @@
*/
package lombok.javac.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
+import lombok.spi.Provides;
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacGuavaTableSingularizer extends JavacGuavaSingularizer {
private static final LombokImmutableList<String> SUFFIXES =
LombokImmutableList.of("rowKey", "columnKey", "value");
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 634a086d..dfc8c7b0 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -37,7 +37,6 @@ import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -58,7 +57,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return super.listMethodsToBeGenerated(data, builderType);
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
JCExpression type = JavacHandlerUtil.chainDots(builderType, "java", "util", "ArrayList");
type = addTypeArgs(1, false, builderType, type, data.getTypeArgs(), source);
@@ -67,7 +66,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -84,13 +83,13 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return new ListBuffer<JCStatement>()
.append(generateSingularMethodAddStatement(maker, builderType, data.getSingularName(), data.getPluralName().toString()));
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
JCVariableDecl param = generateSingularMethodParameter(0, maker, data, builderType, source, data.getSingularName());
return List.of(param);
}
@@ -101,7 +100,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return createConstructBuilderVarIfNeeded(maker, data, builderType, false, source);
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
index b4ad3428..10f1ddd1 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -24,15 +24,13 @@ package lombok.javac.handlers.singulars;
import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
+import lombok.spi.Provides;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCase;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -40,7 +38,7 @@ import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacJavaUtilListSingularizer extends JavacJavaUtilListSetSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.List", "java.util.Collection", "java.lang.Iterable");
@@ -50,7 +48,7 @@ public class JavacJavaUtilListSingularizer extends JavacJavaUtilListSetSingulari
return "java.util.Collections.emptyList";
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
@@ -89,12 +87,12 @@ public class JavacJavaUtilListSingularizer extends JavacJavaUtilListSetSingulari
JCStatement switchStat = maker.Switch(getSize(maker, builderType, data.getPluralName(), true, false, builderVariable), cases.toList());
JCExpression localShadowerType = chainDotsString(builderType, data.getTargetFqn());
localShadowerType = addTypeArgs(1, false, builderType, localShadowerType, data.getTypeArgs(), source);
- JCStatement varDefStat = maker.VarDef(maker.Modifiers(0), data.getPluralName(), localShadowerType, null);
+ JCStatement varDefStat = maker.VarDef(maker.Modifiers(0L), data.getPluralName(), localShadowerType, null);
statements.append(varDefStat);
statements.append(switchStat);
}
- private List<JCStatement> createListCopy(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, String builderVariable) {
+ private List<JCStatement> createListCopy(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
Name thisName = builderType.toName(builderVariable);
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 8dc7ecff..b8c931c7 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2019 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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
@@ -36,11 +36,9 @@ import lombok.javac.handlers.JavacSingularsRecipes.ExpressionMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -49,7 +47,7 @@ import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.Map", "java.util.SortedMap", "java.util.NavigableMap");
@@ -74,7 +72,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return super.listMethodsToBeGenerated(data, builderType);
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
JCVariableDecl buildKeyField; {
@@ -98,7 +96,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return Arrays.asList(keyFieldNode, valueFieldNode);
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -117,7 +115,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name keyName = builderType.toName(data.getSingularName().toString() + "Key");
Name valueName = builderType.toName(data.getSingularName().toString() + "Value");
@@ -130,7 +128,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name keyName = builderType.toName(data.getSingularName().toString() + "Key");
Name valueName = builderType.toName(data.getSingularName().toString() + "Value");
JCVariableDecl paramKey = generateSingularMethodParameter(0, maker, data, builderType, source, keyName);
@@ -139,7 +137,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
long baseFlags = JavacHandlerUtil.addFinalIfNeeded(0, builderType.getContext());
@@ -164,11 +162,11 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return createConstructBuilderVarIfNeeded(maker, data, builderType, true, source);
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
if (data.getTargetFqn().equals("java.util.Map")) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
index 7c870c0a..6d2e0655 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The Project Lombok Authors.
+ * Copyright (C) 2015-2021 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,20 +21,18 @@
*/
package lombok.javac.handlers.singulars;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.core.LombokImmutableList;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
+import lombok.spi.Provides;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
-@ProviderFor(JavacSingularizer.class)
+@Provides(JavacSingularizer.class)
public class JavacJavaUtilSetSingularizer extends JavacJavaUtilListSetSingularizer {
@Override public LombokImmutableList<String> getSupportedTypes() {
return LombokImmutableList.of("java.util.Set", "java.util.SortedSet", "java.util.NavigableSet");
@@ -46,7 +44,7 @@ public class JavacJavaUtilSetSingularizer extends JavacJavaUtilListSetSingulariz
return "java.util.Collections.emptySet";
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
if (data.getTargetFqn().equals("java.util.Set")) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
index 50950915..3b6113df 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
@@ -24,7 +24,6 @@ package lombok.javac.handlers.singulars;
import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCase;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -38,7 +37,7 @@ import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
- protected List<JCStatement> createJavaUtilSetMapInitialCapacitySwitchStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType, JCTree source, String builderVariable) {
+ protected List<JCStatement> createJavaUtilSetMapInitialCapacitySwitchStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
@@ -84,13 +83,13 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
JCStatement switchStat = maker.Switch(getSize(maker, builderType, mapMode ? builderType.toName(data.getPluralName() + "$key") : data.getPluralName(), true, false, builderVariable), cases.toList());
JCExpression localShadowerType = chainDotsString(builderType, data.getTargetFqn());
localShadowerType = addTypeArgs(mapMode ? 2 : 1, false, builderType, localShadowerType, data.getTypeArgs(), source);
- JCStatement varDefStat = maker.VarDef(maker.Modifiers(0), data.getPluralName(), localShadowerType, null);
+ JCStatement varDefStat = maker.VarDef(maker.Modifiers(0L), data.getPluralName(), localShadowerType, null);
return List.of(varDefStat, switchStat);
}
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
-
+
Name v1Name = mapMode ? builderType.toName(data.getPluralName() + "$key") : data.getPluralName();
Name v2Name = mapMode ? builderType.toName(data.getPluralName() + "$value") : null;
JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), v1Name);
@@ -117,7 +116,7 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
return maker.If(cond, thenPart, null);
}
- protected List<JCStatement> createJavaUtilSimpleCreationAndFillStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, boolean defineVar, boolean addInitialCapacityArg, boolean nullGuard, String targetType, JCTree source, String builderVariable) {
+ protected List<JCStatement> createJavaUtilSimpleCreationAndFillStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, boolean defineVar, boolean addInitialCapacityArg, boolean nullGuard, String targetType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
Name thisName = builderType.toName(builderVariable);
@@ -143,7 +142,7 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
if (defineVar) {
JCExpression localShadowerType = chainDotsString(builderType, data.getTargetFqn());
localShadowerType = addTypeArgs(mapMode ? 2 : 1, false, builderType, localShadowerType, data.getTypeArgs(), source);
- createStat = maker.VarDef(maker.Modifiers(0), data.getPluralName(), localShadowerType, constructorCall);
+ createStat = maker.VarDef(maker.Modifiers(0L), data.getPluralName(), localShadowerType, constructorCall);
} else {
createStat = maker.Exec(maker.Assign(maker.Ident(data.getPluralName()), constructorCall));
}
@@ -161,7 +160,7 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
// error: method put in interface Map<K#2,V#2> cannot be applied to given types;
arg2 = maker.TypeCast(createTypeArgs(2, false, builderType, data.getTypeArgs(), source).get(1), arg2);
JCStatement putStatement = maker.Exec(maker.Apply(jceBlank, pluralnameDotPut, List.of(arg1, arg2)));
- JCStatement forInit = maker.VarDef(maker.Modifiers(0), ivar, maker.TypeIdent(CTC_INT), maker.Literal(CTC_INT, 0));
+ JCStatement forInit = maker.VarDef(maker.Modifiers(0L), ivar, maker.TypeIdent(CTC_INT), maker.Literal(CTC_INT, 0));
JCExpression checkExpr = maker.Binary(CTC_LESS_THAN, maker.Ident(ivar), getSize(maker, builderType, keyVarName, nullGuard, true, builderVariable));
JCExpression incrementExpr = maker.Unary(CTC_POSTINC, maker.Ident(ivar));
fillStat = maker.ForLoop(List.of(forInit), checkExpr, List.of(maker.Exec(incrementExpr)), putStatement);
diff --git a/src/core9/module-info.java b/src/core9/module-info.java
index 293bc839..8e8bd891 100644
--- a/src/core9/module-info.java
+++ b/src/core9/module-info.java
@@ -27,11 +27,12 @@ module lombok {
exports lombok;
exports lombok.experimental;
exports lombok.extern.apachecommons;
+ exports lombok.extern.flogger;
+ exports lombok.extern.jackson;
exports lombok.extern.java;
exports lombok.extern.jbosslog;
exports lombok.extern.log4j;
exports lombok.extern.slf4j;
- exports lombok.extern.flogger;
exports lombok.launch to lombok.mapstruct;
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index a1fd0e56..10ec5015 100755
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -34,7 +34,6 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URLDecoder;
@@ -44,6 +43,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -52,6 +52,7 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
+import javax.annotation.processing.AbstractProcessor;
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -98,6 +99,7 @@ public class Delombok {
private LinkedHashMap<File, File> fileToBase = new LinkedHashMap<File, File>();
private List<File> filesToParse = new ArrayList<File>();
private Map<String, String> formatPrefs = new HashMap<String, String>();
+ private List<AbstractProcessor> additionalAnnotationProcessors = new ArrayList<AbstractProcessor>();
/** If null, output to standard out. */
private File output = null;
@@ -166,6 +168,10 @@ public class Delombok {
private boolean help;
}
+ static {
+ LombokProcessor.addOpensForLombok();
+ }
+
private static String indentAndWordbreak(String in, int indent, int maxLen) {
StringBuilder out = new StringBuilder();
StringBuilder line = new StringBuilder();
@@ -643,6 +649,10 @@ public class Delombok {
fileToBase.put(f, base);
}
+ public void addAdditionalAnnotationProcessor(AbstractProcessor processor) {
+ additionalAnnotationProcessors.add(processor);
+ }
+
private static <T> com.sun.tools.javac.util.List<T> toJavacList(List<T> list) {
com.sun.tools.javac.util.List<T> out = com.sun.tools.javac.util.List.nil();
ListIterator<T> li = list.listIterator(list.size());
@@ -701,8 +711,12 @@ public class Delombok {
if (!disablePreview && Javac.getJavaCompilerVersion() >= 11) argsList.add("--enable-preview");
- String[] argv = argsList.toArray(new String[0]);
- args.init("javac", argv);
+ if (Javac.getJavaCompilerVersion() < 15) {
+ String[] argv = argsList.toArray(new String[0]);
+ args.init("javac", argv);
+ } else {
+ args.init("javac", argsList);
+ }
options.put("diags.legacy", "TRUE");
options.put("allowStringFolding", "FALSE");
} else {
@@ -715,7 +729,9 @@ public class Delombok {
List<JCCompilationUnit> roots = new ArrayList<JCCompilationUnit>();
Map<JCCompilationUnit, File> baseMap = new IdentityHashMap<JCCompilationUnit, File>();
- Set<LombokProcessor> processors = Collections.singleton(new lombok.javac.apt.LombokProcessor());
+ Set<AbstractProcessor> processors = new HashSet<AbstractProcessor>();
+ processors.add(new lombok.javac.apt.LombokProcessor());
+ processors.addAll(additionalAnnotationProcessors);
if (Javac.getJavaCompilerVersion() >= 9) {
JavaFileManager jfm_ = context.get(JavaFileManager.class);
@@ -837,12 +853,8 @@ public class Delombok {
}
}
}
- try {
- return attributeMethod.invoke(compiler, arg);
- } catch (Exception e) {
- if (e instanceof InvocationTargetException) throw Lombok.sneakyThrow(e.getCause());
- throw Lombok.sneakyThrow(e);
- }
+
+ return Permit.invokeSneaky(attributeMethod, compiler, arg);
}
private static Method flowMethod;
@@ -859,12 +871,8 @@ public class Delombok {
}
}
}
- try {
- flowMethod.invoke(compiler, arg);
- } catch (Exception e) {
- if (e instanceof InvocationTargetException) throw Lombok.sneakyThrow(e.getCause());
- throw Lombok.sneakyThrow(e);
- }
+
+ Permit.invokeSneaky(flowMethod, compiler, arg);
}
private static String canonical(File dir) {
diff --git a/src/delombok/lombok/delombok/DelombokApp.java b/src/delombok/lombok/delombok/DelombokApp.java
index da1975b4..f5a5fc81 100644
--- a/src/delombok/lombok/delombok/DelombokApp.java
+++ b/src/delombok/lombok/delombok/DelombokApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,10 +37,9 @@ import java.util.jar.JarFile;
import lombok.core.LombokApp;
import lombok.permit.Permit;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(LombokApp.class)
+@Provides
public class DelombokApp extends LombokApp {
@Override public int runApp(List<String> args) throws Exception {
try {
@@ -53,11 +52,11 @@ public class DelombokApp extends LombokApp {
return 1;
}
try {
- Permit.getMethod(loadDelombok(args), "main", String[].class).invoke(null, new Object[] {args.toArray(new String[0])});
+ Permit.invoke(Permit.getMethod(loadDelombok(args), "main", String[].class), null, new Object[] {args.toArray(new String[0])});
} catch (InvocationTargetException e1) {
Throwable t = e1.getCause();
- if (t instanceof Error) throw (Error)t;
- if (t instanceof Exception) throw (Exception)t;
+ if (t instanceof Error) throw (Error) t;
+ if (t instanceof Exception) throw (Exception) t;
throw e1;
}
return 0;
diff --git a/src/delombok/lombok/delombok/DocCommentIntegrator.java b/src/delombok/lombok/delombok/DocCommentIntegrator.java
index bab0abd8..e61968a5 100644
--- a/src/delombok/lombok/delombok/DocCommentIntegrator.java
+++ b/src/delombok/lombok/delombok/DocCommentIntegrator.java
@@ -89,7 +89,7 @@ public class DocCommentIntegrator {
((Map<JCTree, String>) map_).put(node, docCommentContent);
return true;
} else if (Javac.instanceOfDocCommentTable(map_)) {
- CommentAttacher_8.attach(node, docCommentContent, map_);
+ CommentAttacher_8.attach(node, docCommentContent, cmt.pos, map_);
return true;
}
@@ -98,7 +98,7 @@ public class DocCommentIntegrator {
/* Container for code which will cause class loader exceptions on javac below 8. By being in a separate class, we avoid the problem. */
private static class CommentAttacher_8 {
- static void attach(final JCTree node, String docCommentContent, Object map_) {
+ static void attach(final JCTree node, String docCommentContent, final int pos, Object map_) {
final String docCommentContent_ = docCommentContent;
((DocCommentTable) map_).putComment(node, new Comment() {
@Override public String getText() {
@@ -106,7 +106,7 @@ public class DocCommentIntegrator {
}
@Override public int getSourcePos(int index) {
- return -1;
+ return pos + index;
}
@Override public CommentStyle getStyle() {
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index 6682b5a3..05904815 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 The Project Lombok Authors.
+ * Copyright (C) 2016-2021 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,7 +29,6 @@ import static lombok.javac.JavacTreeMaker.TypeTag.typeTag;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
@@ -97,7 +96,6 @@ import lombok.javac.PackageName;
import lombok.permit.Permit;
import lombok.javac.CommentInfo.EndConnection;
import lombok.javac.CommentInfo.StartConnection;
-import lombok.javac.Java14Flags;
import lombok.javac.JavacTreeMaker.TreeTag;
import lombok.javac.JavacTreeMaker.TypeTag;
@@ -280,7 +278,6 @@ public class PrettyPrinter extends JCTree.Visitor {
aligned = false;
}
-
private void println() {
try {
out.write(LINE_SEP);
@@ -517,7 +514,7 @@ public class PrettyPrinter extends JCTree.Visitor {
boolean isInterface = (tree.mods.flags & INTERFACE) != 0;
boolean isAnnotationInterface = isInterface && (tree.mods.flags & ANNOTATION) != 0;
boolean isEnum = (tree.mods.flags & ENUM) != 0;
- boolean isRecord = (tree.mods.flags & Java14Flags.RECORD) != 0;
+ boolean isRecord = (tree.mods.flags & RECORD) != 0;
if (isAnnotationInterface) print("@interface ");
else if (isInterface) print("interface ");
@@ -545,9 +542,7 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.implementing, ", ");
}
- if (isRecord) {
- printRecordConstructor(tree.defs);
- }
+ if (isRecord) printRecordConstructor(tree.defs);
println(" {");
indent++;
@@ -564,7 +559,7 @@ public class PrettyPrinter extends JCTree.Visitor {
for (JCTree member : members) {
if (member instanceof JCVariableDecl) {
JCVariableDecl variableDecl = (JCVariableDecl) member;
- if ((variableDecl.mods.flags & Java14Flags.GENERATED_MEMBER) != 0) {
+ if ((variableDecl.mods.flags & GENERATED_MEMBER) != 0) {
if (!first) print(", ");
first = false;
printAnnotations(variableDecl.mods.annotations, false);
@@ -574,7 +569,7 @@ public class PrettyPrinter extends JCTree.Visitor {
}
print(")");
}
-
+
private void printClassMembers(List<JCTree> members, boolean isEnum, boolean isInterface) {
Class<?> prefType = null;
int typeOfPrevEnumMember = isEnum ? 3 : 0; // 1 = normal, 2 = with body, 3 = no enum field yet.
@@ -604,7 +599,7 @@ public class PrettyPrinter extends JCTree.Visitor {
JCTree init = ((JCVariableDecl) member).init;
typeOfPrevEnumMember = init instanceof JCNewClass && ((JCNewClass) init).def != null ? 2 : 1;
} else if (member instanceof JCVariableDecl) {
- if ((((JCVariableDecl) member).mods.flags & Java14Flags.GENERATED_MEMBER) != 0) continue;
+ if ((((JCVariableDecl) member).mods.flags & GENERATED_MEMBER) != 0) continue;
if (prefType != null && prefType != JCVariableDecl.class) println();
if (isInterface) flagMod = -1L & ~(PUBLIC | STATIC | FINAL);
print(member);
@@ -1412,9 +1407,10 @@ public class PrettyPrinter extends JCTree.Visitor {
}
void printBindingPattern(JCTree tree) {
- print((JCExpression) readObject(tree, "vartype", null));
+ JCTree var = readObject(tree, "var", tree);
+ print((JCExpression) readObject(var, "vartype", null));
print(" ");
- print((Name) readObject(tree, "name", null));
+ print((Name) readObject(var, "name", null));
}
@Override public void visitTry(JCTry tree) {
@@ -1572,13 +1568,7 @@ public class PrettyPrinter extends JCTree.Visitor {
}
public static JCTree getExtendsClause(JCClassDecl decl) {
- try {
- return (JCTree) getExtendsClause.invoke(decl);
- } catch (IllegalAccessException e) {
- throw sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw sneakyThrow(e.getCause());
- }
+ return (JCTree) Permit.invokeSneaky(getExtendsClause, decl);
}
static RuntimeException sneakyThrow(Throwable t) {
diff --git a/src/delombok/lombok/delombok/ant/DelombokTask.java b/src/delombok/lombok/delombok/ant/DelombokTask.java
index defd1709..7c585836 100644
--- a/src/delombok/lombok/delombok/ant/DelombokTask.java
+++ b/src/delombok/lombok/delombok/ant/DelombokTask.java
@@ -177,9 +177,11 @@ class Tasks {
}
return Class.forName(name, true, shadowLoader);
- } catch (Exception e) {
- if (e instanceof RuntimeException) throw (RuntimeException) e;
- throw new RuntimeException(e);
+ } catch (Throwable t) {
+ if (t instanceof InvocationTargetException) t = t.getCause();
+ if (t instanceof RuntimeException) throw (RuntimeException) t;
+ if (t instanceof Error) throw (Error) t;
+ throw new RuntimeException(t);
}
}
@@ -207,10 +209,10 @@ class Tasks {
Method m = instance.getClass().getMethod("execute", Location.class);
m.invoke(instance, loc);
- } catch (Exception e) {
- Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
- if (t instanceof Error) throw (Error) t;
+ } catch (Throwable t) {
+ if (t instanceof InvocationTargetException) t = t.getCause();
if (t instanceof RuntimeException) throw (RuntimeException) t;
+ if (t instanceof Error) throw (Error) t;
throw new RuntimeException(t);
}
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipseLoaderPatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipseLoaderPatcher.java
index aa01c13d..25906c6b 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipseLoaderPatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipseLoaderPatcher.java
@@ -31,6 +31,12 @@ import lombok.patcher.scripts.ScriptBuilder;
public class EclipseLoaderPatcher {
private static final String TRANSPLANTS_CLASS_NAME = "lombok.eclipse.agent.EclipseLoaderPatcherTransplants";
+ static final String[] OSGI_TYPES = {
+ "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader",
+ "org/eclipse/osgi/framework/adapter/core/AbstractClassLoader",
+ "org/eclipse/osgi/internal/loader/ModuleClassLoader"
+ };
+
public static void patchEquinoxLoaders(ScriptManager sm, Class<?> launchingContext) {
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader", "loadClass",
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index c560f002..ce26c892 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -22,6 +22,7 @@
package lombok.eclipse.agent;
import static lombok.patcher.scripts.ScriptBuilder.*;
+import static lombok.eclipse.agent.EclipseLoaderPatcher.OSGI_TYPES;
import java.io.File;
import java.lang.instrument.Instrumentation;
@@ -49,34 +50,11 @@ import lombok.patcher.scripts.ScriptBuilder;
* transformed.
*/
public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
- // At some point I'd like the agent to be capable of auto-detecting if its on eclipse or on ecj. This class is a sure sign we're not in ecj but in eclipse. -ReinierZ
- @SuppressWarnings("unused")
- private static final String ECLIPSE_SIGNATURE_CLASS = "org/eclipse/core/runtime/adaptor/EclipseStarter";
-
@Override public void runAgent(String agentArgs, Instrumentation instrumentation, boolean injected, Class<?> launchingContext) throws Exception {
- String[] args = agentArgs == null ? new String[0] : agentArgs.split(":");
- boolean forceEcj = false;
- boolean forceEclipse = false;
-
- for (String arg : args) {
- if (arg.trim().equalsIgnoreCase("ECJ")) forceEcj = true;
- if (arg.trim().equalsIgnoreCase("ECLIPSE")) forceEclipse = true;
- }
- if (forceEcj && forceEclipse) {
- forceEcj = false;
- forceEclipse = false;
- }
-
- boolean ecj;
-
- if (forceEcj) ecj = true;
- else if (forceEclipse) ecj = false;
- else ecj = injected;
-
- registerPatchScripts(instrumentation, injected, ecj, launchingContext);
+ registerPatchScripts(instrumentation, injected, launchingContext);
}
- private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly, Class<?> launchingContext) {
+ private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, Class<?> launchingContext) {
ScriptManager sm = new ScriptManager();
sm.registerTransformer(instrumentation);
sm.setFilter(new Filter() {
@@ -97,33 +75,33 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
});
- if (!ecjOnly) {
- EclipseLoaderPatcher.patchEquinoxLoaders(sm, launchingContext);
- patchCatchReparse(sm);
- patchIdentifierEndReparse(sm);
- patchRetrieveEllipsisStartPosition(sm);
- patchRetrieveRightBraceOrSemiColonPosition(sm);
- patchRetrieveProperRightBracketPosition(sm);
- patchSetGeneratedFlag(sm);
- patchDomAstReparseIssues(sm);
- patchHideGeneratedNodes(sm);
- patchPostCompileHookEclipse(sm);
- patchFixSourceTypeConverter(sm);
- patchDisableLombokForCodeCleanup(sm);
- patchListRewriteHandleGeneratedMethods(sm);
- patchSyntaxAndOccurrencesHighlighting(sm);
- patchSortMembersOperation(sm);
- patchExtractInterface(sm);
- patchAboutDialog(sm);
- patchEclipseDebugPatches(sm);
- } else {
- patchPostCompileHookEcj(sm);
- }
+ EclipseLoaderPatcher.patchEquinoxLoaders(sm, launchingContext);
+ patchCatchReparse(sm);
+ patchIdentifierEndReparse(sm);
+ patchRetrieveEllipsisStartPosition(sm);
+ patchRetrieveRightBraceOrSemiColonPosition(sm);
+ patchRetrieveProperRightBracketPosition(sm);
+ patchRetrieveStartBlockPosition(sm);
+ patchSetGeneratedFlag(sm);
+ patchDomAstReparseIssues(sm);
+ patchHideGeneratedNodes(sm);
+ patchPostCompileHookEclipse(sm);
+ patchFixSourceTypeConverter(sm);
+ patchDisableLombokForCodeCleanup(sm);
+ patchListRewriteHandleGeneratedMethods(sm);
+ patchSyntaxAndOccurrencesHighlighting(sm);
+ patchSortMembersOperation(sm);
+ patchExtractInterface(sm);
+ patchAboutDialog(sm);
+ patchEclipseDebugPatches(sm);
+ patchJavadoc(sm);
+
+ patchPostCompileHookEcj(sm);
patchAvoidReparsingGeneratedCode(sm);
patchLombokizeAST(sm);
- patchEcjTransformers(sm, ecjOnly);
- patchExtensionMethod(sm, ecjOnly);
+ patchEcjTransformers(sm);
+ patchExtensionMethod(sm);
patchRenameField(sm);
patchNullCheck(sm);
@@ -158,7 +136,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
private static void patchExtractInterface(ScriptManager sm) {
/* Fix sourceEnding for generated nodes to avoid null pointer */
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.SourceElementNotifier", "notifySourceElementRequestor", "void", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "org.eclipse.jdt.internal.compiler.ast.ImportReference"))
.methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt", "get", "int", "java.lang.Object"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getSourceEndFixed", "int", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
@@ -166,7 +144,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.transplant().build());
/* Make sure the generated source element is found instead of the annotation */
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodDeclaration", "void",
"org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite",
"org.eclipse.jdt.core.dom.rewrite.ASTRewrite",
@@ -179,7 +157,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.transplant().build());
/* get real generated node in stead of a random one generated by the annotation */
- sm.addScript(ScriptBuilder.replaceMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.replaceMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMemberDeclarations"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodComments"))
.methodToReplace(new Hook("org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil", "getMethodDeclarationNode", "org.eclipse.jdt.core.dom.MethodDeclaration", "org.eclipse.jdt.core.IMethod", "org.eclipse.jdt.core.dom.CompilationUnit"))
@@ -187,14 +165,14 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.transplant().build());
/* Do not add @Override's for generated methods */
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ListRewrite", "insertFirst"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isListRewriteOnGeneratedNode", "boolean", "org.eclipse.jdt.core.dom.rewrite.ListRewrite"))
.request(StackRequest.THIS)
.transplant().build());
/* Do not add comments for generated methods */
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor", "createMethodComment"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode"))
.request(StackRequest.PARAM2)
@@ -207,7 +185,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
* This is doable without patching, but we intentionally patch it so that presence of the lombok info
* in the about dialog can be used to ascertain that patching in general is doing something.
*/
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.core.internal.runtime.Product", "getProperty", "java.lang.String", "java.lang.String"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "addLombokNotesToEclipseAboutDialog", "java.lang.String", "java.lang.String", "java.lang.String"))
.request(StackRequest.RETURN_VALUE, StackRequest.PARAM1)
@@ -218,7 +196,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
/*
* Skip generated nodes for "visual effects" (syntax highlighting && highlight occurrences)
*/
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addUsage"))
.target(new MethodTarget("org.eclipse.jdt.internal.ui.search.OccurrencesFinder", "addWrite"))
.target(new MethodTarget("org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingReconciler$PositionCollector", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName"))
@@ -229,7 +207,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchDisableLombokForCodeCleanup(ScriptManager sm) {
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.DoStatement"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.EnhancedForStatement"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.fix.ControlStatementsFix$ControlStatementFinder", "visit", "boolean", "org.eclipse.jdt.core.dom.ForStatement"))
@@ -256,7 +234,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchListRewriteHandleGeneratedMethods(ScriptManager sm) {
- sm.addScript(ScriptBuilder.replaceMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.replaceMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter", "rewriteList"))
.methodToReplace(new Hook("org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent", "getChildren", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent[]"))
.replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "listRewriteHandleGeneratedMethods", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent[]", "org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent"))
@@ -268,37 +246,37 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
* I would have liked to patch sortMembers, but kept getting a VerifyError: Illegal type in constant pool
* So now I just patch all calling methods
*/
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.CompilationUnit"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.CompilationUnit", "types", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.AnnotationTypeDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.AnnotationTypeDeclaration", "bodyDeclarations", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.AnonymousClassDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.AnonymousClassDeclaration", "bodyDeclarations", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.TypeDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.TypeDeclaration", "bodyDeclarations", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.EnumDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.EnumDeclaration", "bodyDeclarations", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.SortElementsOperation$2", "visit", "boolean", "org.eclipse.jdt.core.dom.EnumDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.EnumDeclaration", "enumConstants", "java.util.List"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedNodes", "java.util.List", "java.util.List"))
@@ -306,7 +284,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchDomAstReparseIssues(ScriptManager sm) {
- sm.addScript(ScriptBuilder.replaceMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.replaceMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer", "visit"))
.methodToReplace(new Hook("org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "getTokenEndOffset", "int", "int", "int"))
.replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getTokenEndOffsetFixed", "int", "org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "int", "int", "java.lang.Object"))
@@ -317,7 +295,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchPostCompileHookEclipse(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder", "writeClassFileContents"))
.target(new MethodTarget("org.eclipse.jdt.internal.core.builder.AbstractImageBuilder", "writeClassFileContents"))
.methodToWrap(new Hook("org.eclipse.jdt.internal.compiler.ClassFile", "getBytes", "byte[]"))
@@ -327,13 +305,13 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchPostCompileHookEcj(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfNotWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl", "outputClassFiles"))
.methodToWrap(new Hook("javax.tools.JavaFileObject", "openOutputStream", "java.io.OutputStream"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "runPostCompiler", "java.io.OutputStream", "java.io.OutputStream"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfNotWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.util.Util", "writeToDisk"))
.methodToWrap(new Hook("java.io.BufferedOutputStream", "<init>", "void", "java.io.OutputStream", "int"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$LombokDeps", "runPostCompiler", "java.io.BufferedOutputStream", "java.io.BufferedOutputStream", "java.lang.String", "java.lang.String"))
@@ -342,7 +320,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchHideGeneratedNodes(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByNode"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder", "findByBinding"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedSimpleNames", "org.eclipse.jdt.core.dom.SimpleName[]",
@@ -354,37 +332,37 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchFormatters(ScriptManager sm) {
- // before Eclipse Mars
- sm.addScript(ScriptBuilder.setSymbolDuringMethodCall()
- .target(new MethodTarget("org.eclipse.jdt.internal.formatter.DefaultCodeFormatter", "formatCompilationUnit"))
- .callToWrap(new Hook("org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil", "parseCompilationUnit", "org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration", "char[]", "java.util.Map", "boolean"))
- .symbol("lombok.disable")
- .build());
+ // before Eclipse Mars
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.setSymbolDuringMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.formatter.DefaultCodeFormatter", "formatCompilationUnit"))
+ .callToWrap(new Hook("org.eclipse.jdt.internal.core.util.CodeSnippetParsingUtil", "parseCompilationUnit", "org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration", "char[]", "java.util.Map", "boolean"))
+ .symbol("lombok.disable")
+ .build());
// Eclipse Mars and beyond
- sm.addScript(ScriptBuilder.setSymbolDuringMethodCall()
- .target(new MethodTarget("org.eclipse.jdt.internal.formatter.DefaultCodeFormatter", "parseSourceCode"))
- .callToWrap(new Hook("org.eclipse.jdt.core.dom.ASTParser", "createAST", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.core.runtime.IProgressMonitor"))
- .symbol("lombok.disable")
- .build());
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.setSymbolDuringMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.formatter.DefaultCodeFormatter", "parseSourceCode"))
+ .callToWrap(new Hook("org.eclipse.jdt.core.dom.ASTParser", "createAST", "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.core.runtime.IProgressMonitor"))
+ .symbol("lombok.disable")
+ .build());
}
private static void patchRefactorScripts(ScriptManager sm) {
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "replace"))
.target(new MethodTarget("org.eclipse.jdt.core.dom.rewrite.ASTRewrite", "remove"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "skipRewritingGeneratedNodes", "boolean",
"org.eclipse.jdt.core.dom.ASTNode"))
.transplant().request(StackRequest.PARAM1).build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor", "addConstructorRenames"))
.methodToWrap(new Hook("org.eclipse.jdt.core.IType", "getMethods", "org.eclipse.jdt.core.IMethod[]"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "removeGeneratedMethods", "org.eclipse.jdt.core.IMethod[]",
"org.eclipse.jdt.core.IMethod[]"))
.transplant().build());
- sm.addScript(ScriptBuilder.exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.TempOccurrenceAnalyzer", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName"))
.target(new MethodTarget("org.eclipse.jdt.internal.corext.refactoring.rename.RenameAnalyzeUtil$ProblemNodeFinder$NameNodeVisitor", "visit", "boolean", "org.eclipse.jdt.core.dom.SimpleName"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.core.dom.ASTNode"))
@@ -401,21 +379,28 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchIdentifierEndReparse(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveIdentifierEndPosition"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveIdentifierEndPosition", "int", "int", "int", "int"))
.transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM1, StackRequest.PARAM2).build());
}
private static void patchRetrieveEllipsisStartPosition(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveEllipsisStartPosition"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveEllipsisStartPosition", "int", "int", "int"))
.transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build());
}
+ private static void patchRetrieveStartBlockPosition(ScriptManager sm) {
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "retrieveStartBlockPosition"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveStartBlockPosition", "int", "int", "int"))
+ .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build());
+ }
+
private static void patchRetrieveRightBraceOrSemiColonPosition(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convert", "org.eclipse.jdt.core.dom.ASTNode", "boolean", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.ASTConverter", "retrieveRightBraceOrSemiColonPosition", "int", "int", "int"))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveRightBraceOrSemiColonPosition", "int", "int", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration"))
@@ -447,28 +432,36 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
}
private static void patchRetrieveProperRightBracketPosition(ScriptManager sm) {
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "extractSubArrayType", "org.eclipse.jdt.core.dom.ArrayType", "org.eclipse.jdt.core.dom.ArrayType", "int", "int"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.ASTConverter", "retrieveProperRightBracketPosition", "int", "int", "int"))
- .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveProperRightBracketPosition", "int", "int", "org.eclipse.jdt.core.dom.ArrayType"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveProperRightBracketPosition", "int", "int", "org.eclipse.jdt.core.dom.Type"))
+ .requestExtra(StackRequest.PARAM1)
+ .transplant()
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToArray", "org.eclipse.jdt.core.dom.ArrayType", "org.eclipse.jdt.core.dom.Type", "int", "int", "int", "org.eclipse.jdt.internal.compiler.ast.Annotation[][]"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.ASTConverter", "retrieveProperRightBracketPosition", "int", "int", "int"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveProperRightBracketPosition", "int", "int", "org.eclipse.jdt.core.dom.Type"))
.requestExtra(StackRequest.PARAM1)
.transplant()
.build());
}
private static void patchSetGeneratedFlag(ScriptManager sm) {
- sm.addScript(ScriptBuilder.addField()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
.targetClass("org.eclipse.jdt.internal.compiler.ast.ASTNode")
.fieldName("$generatedBy")
.fieldType("Lorg/eclipse/jdt/internal/compiler/ast/ASTNode;")
.setPublic().setTransient().build());
- sm.addScript(ScriptBuilder.addField()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
.targetClass("org.eclipse.jdt.core.dom.ASTNode")
.fieldName("$isGenerated").fieldType("Z")
.setPublic().setTransient().build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new TargetMatcher() {
@Override public boolean matches(String classSpec, String methodName, String descriptor) {
if (!"convert".equals(methodName)) return false;
@@ -480,6 +473,10 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
return true;
}
+ @Override public String describe() {
+ return "ASTConverter:[all relevant]";
+ }
+
@Override public Collection<String> getAffectedClasses() {
return Collections.singleton("org.eclipse.jdt.core.dom.ASTConverter");
}
@@ -488,14 +485,14 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convert", "org.eclipse.jdt.core.dom.ASTNode", "boolean", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration"))
.request(StackRequest.PARAM2, StackRequest.RETURN_VALUE)
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
"org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToFieldDeclaration", "org.eclipse.jdt.core.dom.FieldDeclaration", "org.eclipse.jdt.internal.compiler.ast.FieldDeclaration"))
/* Targets beneath are only patched because the resulting dom nodes should be marked if generated.
* However I couldn't find a usecase where these were actually used
@@ -507,6 +504,8 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToVariableDeclarationFragment", "org.eclipse.jdt.core.dom.VariableDeclarationFragment", "org.eclipse.jdt.internal.compiler.ast.FieldDeclaration"))
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToVariableDeclarationFragment", "org.eclipse.jdt.core.dom.VariableDeclarationFragment", "org.eclipse.jdt.internal.compiler.ast.LocalDeclaration"))
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertToVariableDeclarationStatement", "org.eclipse.jdt.core.dom.VariableDeclarationStatement", "org.eclipse.jdt.internal.compiler.ast.LocalDeclaration"))
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "createBaseType", "org.eclipse.jdt.core.dom.Type", "org.eclipse.jdt.internal.compiler.ast.TypeReference", "long[]", "org.eclipse.jdt.internal.compiler.ast.Annotation[][]", "char[][]", "int", "int", "boolean"))
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "createQualifiedType", "org.eclipse.jdt.core.dom.QualifiedType", "org.eclipse.jdt.internal.compiler.ast.TypeReference", "long[]", "org.eclipse.jdt.internal.compiler.ast.Annotation[][]", "char[][]", "int", "org.eclipse.jdt.core.dom.Type"))
/* Targets above are only patched because the resulting dom nodes should be marked if generated. */
.request(StackRequest.PARAM1, StackRequest.RETURN_VALUE)
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
@@ -514,7 +513,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.transplant().build());
/* Set generated flag for SimpleNames */
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new TargetMatcher() {
@Override public boolean matches(String classSpec, String methodName, String descriptor) {
if (!methodName.startsWith("convert")) return false;
@@ -526,6 +525,10 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
return true;
}
+ @Override public String describe() {
+ return "ASTConverter::(all relevant)";
+ }
+
@Override public Collection<String> getAffectedClasses() {
return Collections.singleton("org.eclipse.jdt.core.dom.ASTConverter");
}
@@ -535,16 +538,53 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convert", "org.eclipse.jdt.core.dom.ASTNode", "boolean", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM2)
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlagForName", "void",
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
+
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertType", "org.eclipse.jdt.core.dom.Type", "org.eclipse.jdt.internal.compiler.ast.TypeReference"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.PrimitiveType", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
+ .requestExtra(StackRequest.PARAM1)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
+ "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
+ .transplant()
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertType", "org.eclipse.jdt.core.dom.Type", "org.eclipse.jdt.internal.compiler.ast.TypeReference"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleType", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
+ .requestExtra(StackRequest.PARAM1)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
+ "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
+ .transplant()
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertType", "org.eclipse.jdt.core.dom.Type", "org.eclipse.jdt.internal.compiler.ast.TypeReference"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.ParameterizedType", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
+ .requestExtra(StackRequest.PARAM1)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
+ "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
+ .transplant()
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "convertType", "org.eclipse.jdt.core.dom.Type", "org.eclipse.jdt.internal.compiler.ast.TypeReference"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedType", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
+ .requestExtra(StackRequest.PARAM1)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "setIsGeneratedFlag", "void",
+ "org.eclipse.jdt.core.dom.ASTNode", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
+ .transplant()
+ .build());
/* Set generated flag for QualifiedNames */
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM4)
@@ -552,7 +592,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "int", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM4)
@@ -560,7 +600,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM3)
@@ -568,7 +608,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setQualifiedNameNameAndSourceRanges", "org.eclipse.jdt.core.dom.QualifiedName", "char[][]", "long[]", "org.eclipse.jdt.internal.compiler.ast.ASTNode"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM3)
@@ -576,7 +616,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setTypeNameForAnnotation", "void", "org.eclipse.jdt.internal.compiler.ast.Annotation", "org.eclipse.jdt.core.dom.Annotation"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.SimpleName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM1)
@@ -584,7 +624,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
"org.eclipse.jdt.core.dom.Name", "java.lang.Object"))
.transplant().build());
- sm.addScript(ScriptBuilder.wrapMethodCall()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
.target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "setTypeNameForAnnotation", "void", "org.eclipse.jdt.internal.compiler.ast.Annotation", "org.eclipse.jdt.core.dom.Annotation"))
.methodToWrap(new Hook("org.eclipse.jdt.core.dom.QualifiedName", "<init>", "void", "org.eclipse.jdt.core.dom.AST"))
.requestExtra(StackRequest.PARAM1)
@@ -629,25 +669,26 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String PARSER_SIG = "org.eclipse.jdt.internal.compiler.parser.Parser";
final String CUD_SIG = "org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration";
+ final String OBJECT_SIG = "java.lang.Object";
sm.addScript(ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(PARSER_SIG, "getMethodBodies", "void", CUD_SIG))
- .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Transform", "transform", "void", PARSER_SIG, CUD_SIG))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Transform", "transform", "void", OBJECT_SIG, OBJECT_SIG))
.request(StackRequest.THIS, StackRequest.PARAM1).build());
sm.addScript(ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(PARSER_SIG, "endParse", CUD_SIG, "int"))
- .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Transform", "transform_swapped", "void", CUD_SIG, PARSER_SIG))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Transform", "transform_swapped", "void", OBJECT_SIG, OBJECT_SIG))
.request(StackRequest.THIS, StackRequest.RETURN_VALUE).build());
}
- private static void patchEcjTransformers(ScriptManager sm, boolean ecj) {
- addPatchesForDelegate(sm, ecj);
+ private static void patchEcjTransformers(ScriptManager sm) {
+ addPatchesForDelegate(sm);
addPatchesForVal(sm);
- if (!ecj) addPatchesForValEclipse(sm);
+ addPatchesForValEclipse(sm);
}
- private static void addPatchesForDelegate(ScriptManager sm, boolean ecj) {
+ private static void addPatchesForDelegate(ScriptManager sm) {
final String CLASSSCOPE_SIG = "org.eclipse.jdt.internal.compiler.lookup.ClassScope";
sm.addScript(ScriptBuilder.exitEarly()
@@ -655,6 +696,26 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.request(StackRequest.THIS)
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$Delegate", "handleDelegateForType", "boolean", "java.lang.Object"))
.build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.setSymbolDuringMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.core.SelectionRequestor", "acceptSourceMethod"))
+ .callToWrap(new Hook("org.eclipse.jdt.core.IType", "getMethods", "org.eclipse.jdt.core.IMethod[]"))
+ .symbol("lombok.skipdelegates")
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
+ .fieldName("$delegateMethods")
+ .fieldType("Ljava/util/Map;")
+ .setPublic()
+ .setTransient()
+ .targetClass("org.eclipse.jdt.internal.core.CompilationUnit")
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
+ .target(new MethodTarget("org.eclipse.jdt.internal.core.SourceTypeElementInfo", "getChildren", "org.eclipse.jdt.core.IJavaElement[]"))
+ .request(StackRequest.RETURN_VALUE, StackRequest.THIS)
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Delegate", "addGeneratedDelegateMethods", "java.lang.Object[]", "java.lang.Object", "java.lang.Object"))
+ .build());
}
private static void addPatchesForValEclipse(ScriptManager sm) {
@@ -664,7 +725,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String SINGLEVARIABLEDECLARATION_SIG = "org.eclipse.jdt.core.dom.SingleVariableDeclaration";
final String ASTCONVERTER_SIG = "org.eclipse.jdt.core.dom.ASTConverter";
- sm.addScript(ScriptBuilder.addField()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
.fieldName("$initCopy")
.fieldType("Lorg/eclipse/jdt/internal/compiler/ast/ASTNode;")
.setPublic()
@@ -672,7 +733,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.targetClass("org.eclipse.jdt.internal.compiler.ast.LocalDeclaration")
.build());
- sm.addScript(ScriptBuilder.addField()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
.fieldName("$iterableCopy")
.fieldType("Lorg/eclipse/jdt/internal/compiler/ast/ASTNode;")
.setPublic()
@@ -680,25 +741,25 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.targetClass("org.eclipse.jdt.internal.compiler.ast.LocalDeclaration")
.build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(PARSER_SIG, "consumeExitVariableWithInitialization", "void"))
.request(StackRequest.THIS)
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$ValPortal", "copyInitializationOfLocalDeclaration", "void", "java.lang.Object"))
.build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(PARSER_SIG, "consumeEnhancedForStatementHeader", "void"))
.request(StackRequest.THIS)
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$ValPortal", "copyInitializationOfForEachIterable", "void", "java.lang.Object"))
.build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(ASTCONVERTER_SIG, "setModifiers", "void", VARIABLEDECLARATIONSTATEMENT_SIG, LOCALDECLARATION_SIG))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$ValPortal", "addFinalAndValAnnotationToVariableDeclarationStatement",
"void", "java.lang.Object", "java.lang.Object", "java.lang.Object"))
.request(StackRequest.THIS, StackRequest.PARAM1, StackRequest.PARAM2).build());
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(ASTCONVERTER_SIG, "setModifiers", "void", SINGLEVARIABLEDECLARATION_SIG, LOCALDECLARATION_SIG))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$ValPortal", "addFinalAndValAnnotationToSingleVariableDeclaration",
"void", "java.lang.Object", "java.lang.Object", "java.lang.Object"))
@@ -711,11 +772,12 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String EXPRESSION_SIG = "org.eclipse.jdt.internal.compiler.ast.Expression";
final String BLOCKSCOPE_SIG = "org.eclipse.jdt.internal.compiler.lookup.BlockScope";
final String TYPEBINDING_SIG = "org.eclipse.jdt.internal.compiler.lookup.TypeBinding";
+ final String OBJECT_SIG = "java.lang.Object";
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget(LOCALDECLARATION_SIG, "resolve", "void", BLOCKSCOPE_SIG))
.request(StackRequest.THIS, StackRequest.PARAM1)
- .decisionMethod(new Hook("lombok.launch.PatchFixesHider$Val", "handleValForLocalDeclaration", "boolean", LOCALDECLARATION_SIG, BLOCKSCOPE_SIG))
+ .decisionMethod(new Hook("lombok.launch.PatchFixesHider$Val", "handleValForLocalDeclaration", "boolean", OBJECT_SIG, OBJECT_SIG))
.build());
sm.addScript(ScriptBuilder.replaceMethodCall()
@@ -723,18 +785,20 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.methodToReplace(new Hook(EXPRESSION_SIG, "resolveType", TYPEBINDING_SIG, BLOCKSCOPE_SIG))
.requestExtra(StackRequest.THIS)
.replacementMethod(new Hook("lombok.launch.PatchFixesHider$Val", "skipResolveInitializerIfAlreadyCalled2", TYPEBINDING_SIG, EXPRESSION_SIG, BLOCKSCOPE_SIG, LOCALDECLARATION_SIG))
+ .transplant()
.build());
sm.addScript(ScriptBuilder.replaceMethodCall()
.target(new MethodTarget(FOREACHSTATEMENT_SIG, "resolve", "void", BLOCKSCOPE_SIG))
.methodToReplace(new Hook(EXPRESSION_SIG, "resolveType", TYPEBINDING_SIG, BLOCKSCOPE_SIG))
.replacementMethod(new Hook("lombok.launch.PatchFixesHider$Val", "skipResolveInitializerIfAlreadyCalled", TYPEBINDING_SIG, EXPRESSION_SIG, BLOCKSCOPE_SIG))
+ .transplant()
.build());
sm.addScript(ScriptBuilder.exitEarly()
.target(new MethodTarget(FOREACHSTATEMENT_SIG, "resolve", "void", BLOCKSCOPE_SIG))
.request(StackRequest.THIS, StackRequest.PARAM1)
- .decisionMethod(new Hook("lombok.launch.PatchFixesHider$Val", "handleValForForEach", "boolean", FOREACHSTATEMENT_SIG, BLOCKSCOPE_SIG))
+ .decisionMethod(new Hook("lombok.launch.PatchFixesHider$Val", "handleValForForEach", "boolean", OBJECT_SIG, OBJECT_SIG))
.build());
}
@@ -743,7 +807,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String I_ANNOTATABLE_SIG = "org.eclipse.jdt.core.IAnnotatable";
final String ANNOTATION_SIG = "org.eclipse.jdt.internal.compiler.ast.Annotation";
- sm.addScript(ScriptBuilder.wrapReturnValue()
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapReturnValue()
.target(new MethodTarget(SOURCE_TYPE_CONVERTER_SIG, "convertAnnotations", ANNOTATION_SIG + "[]", I_ANNOTATABLE_SIG))
.wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "convertAnnotations", ANNOTATION_SIG + "[]", ANNOTATION_SIG + "[]", I_ANNOTATABLE_SIG))
.request(StackRequest.PARAM1, StackRequest.RETURN_VALUE).build());
@@ -753,7 +817,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String ASTNODE_SIG = "org.eclipse.jdt.core.dom.ASTNode";
final String PATCH_DEBUG = "lombok.eclipse.agent.PatchDiagnostics";
- sm.addScript(exitEarly()
+ sm.addScriptIfWitness(OSGI_TYPES, exitEarly()
.target(new MethodTarget(ASTNODE_SIG, "setSourceRange", "void", "int", "int"))
.request(StackRequest.THIS)
.request(StackRequest.PARAM1)
@@ -762,7 +826,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.build());
}
- private static void patchExtensionMethod(ScriptManager sm, boolean ecj) {
+ private static void patchExtensionMethod(ScriptManager sm) {
final String PATCH_EXTENSIONMETHOD = "lombok.launch.PatchFixesHider$ExtensionMethod";
final String PATCH_EXTENSIONMETHOD_COMPLETIONPROPOSAL_PORTAL = "lombok.eclipse.agent.PatchExtensionMethodCompletionProposalPortal";
final String MESSAGE_SEND_SIG = "org.eclipse.jdt.internal.compiler.ast.MessageSend";
@@ -774,42 +838,50 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
final String METHOD_BINDING_SIG = "org.eclipse.jdt.internal.compiler.lookup.MethodBinding";
final String COMPLETION_PROPOSAL_COLLECTOR_SIG = "org.eclipse.jdt.ui.text.java.CompletionProposalCollector";
final String I_JAVA_COMPLETION_PROPOSAL_SIG = "org.eclipse.jdt.ui.text.java.IJavaCompletionProposal[]";
+ final String AST_NODE = "org.eclipse.jdt.internal.compiler.ast.ASTNode";
+ final String OBJECT_SIG = "java.lang.Object";
sm.addScript(wrapReturnValue()
.target(new MethodTarget(MESSAGE_SEND_SIG, "resolveType", TYPE_BINDING_SIG, BLOCK_SCOPE_SIG))
.request(StackRequest.RETURN_VALUE)
.request(StackRequest.THIS)
.request(StackRequest.PARAM1)
- .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD, "resolveType", TYPE_BINDING_SIG, TYPE_BINDING_SIG, MESSAGE_SEND_SIG, BLOCK_SCOPE_SIG))
+ .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD, "resolveType", OBJECT_SIG, OBJECT_SIG, OBJECT_SIG, OBJECT_SIG))
+ .cast()
.build());
sm.addScript(replaceMethodCall()
.target(new MethodTarget(MESSAGE_SEND_SIG, "resolveType", TYPE_BINDING_SIG, BLOCK_SCOPE_SIG))
.methodToReplace(new Hook(PROBLEM_REPORTER_SIG, "errorNoMethodFor", "void", MESSAGE_SEND_SIG, TYPE_BINDING_SIG, TYPE_BINDINGS_SIG))
- .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "errorNoMethodFor", "void", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, TYPE_BINDING_SIG, TYPE_BINDINGS_SIG))
+ .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "errorNoMethodFor", "void", OBJECT_SIG, OBJECT_SIG, OBJECT_SIG, OBJECT_SIG))
.build());
sm.addScript(replaceMethodCall()
.target(new MethodTarget(MESSAGE_SEND_SIG, "resolveType", TYPE_BINDING_SIG, BLOCK_SCOPE_SIG))
.methodToReplace(new Hook(PROBLEM_REPORTER_SIG, "invalidMethod", "void", MESSAGE_SEND_SIG, METHOD_BINDING_SIG))
- .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "invalidMethod", "void", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, METHOD_BINDING_SIG))
+ .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "invalidMethod", "void", OBJECT_SIG, OBJECT_SIG, OBJECT_SIG))
.build());
// Since eclipse mars; they added a param.
sm.addScript(replaceMethodCall()
.target(new MethodTarget(MESSAGE_SEND_SIG, "resolveType", TYPE_BINDING_SIG, BLOCK_SCOPE_SIG))
.methodToReplace(new Hook(PROBLEM_REPORTER_SIG, "invalidMethod", "void", MESSAGE_SEND_SIG, METHOD_BINDING_SIG, SCOPE_SIG))
- .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "invalidMethod", "void", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, METHOD_BINDING_SIG, SCOPE_SIG))
+ .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "invalidMethod", "void", OBJECT_SIG, OBJECT_SIG, OBJECT_SIG, OBJECT_SIG))
.build());
- if (!ecj) {
- sm.addScript(wrapReturnValue()
- .target(new MethodTarget(COMPLETION_PROPOSAL_COLLECTOR_SIG, "getJavaCompletionProposals", I_JAVA_COMPLETION_PROPOSAL_SIG))
- .request(StackRequest.RETURN_VALUE)
- .request(StackRequest.THIS)
- .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD_COMPLETIONPROPOSAL_PORTAL, "getJavaCompletionProposals", I_JAVA_COMPLETION_PROPOSAL_SIG, "java.lang.Object[]", "java.lang.Object"))
- .build());
- }
+ sm.addScript(replaceMethodCall()
+ .target(new MethodTarget(MESSAGE_SEND_SIG, "resolveType", TYPE_BINDING_SIG, BLOCK_SCOPE_SIG))
+ .methodToReplace(new Hook(PROBLEM_REPORTER_SIG, "nonStaticAccessToStaticMethod", "void", AST_NODE, METHOD_BINDING_SIG))
+ .replacementMethod(new Hook(PATCH_EXTENSIONMETHOD, "nonStaticAccessToStaticMethod", "void", OBJECT_SIG, OBJECT_SIG, OBJECT_SIG, OBJECT_SIG))
+ .requestExtra(StackRequest.THIS)
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, wrapReturnValue()
+ .target(new MethodTarget(COMPLETION_PROPOSAL_COLLECTOR_SIG, "getJavaCompletionProposals", I_JAVA_COMPLETION_PROPOSAL_SIG))
+ .request(StackRequest.RETURN_VALUE)
+ .request(StackRequest.THIS)
+ .wrapMethod(new Hook(PATCH_EXTENSIONMETHOD_COMPLETIONPROPOSAL_PORTAL, "getJavaCompletionProposals", I_JAVA_COMPLETION_PROPOSAL_SIG, "java.lang.Object[]", "java.lang.Object"))
+ .build());
}
private static void patchNullCheck(ScriptManager sm) {
@@ -830,5 +902,37 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.request(StackRequest.PARAM1)
.transplant().build());
}
+
+ private static void patchJavadoc(ScriptManager sm) {
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2", "getHTMLContent", "java.lang.String", "org.eclipse.jdt.core.IJavaElement", "boolean"))
+ .methodToWrap(new Hook("org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2", "getHTMLContentFromSource", "java.lang.String", "org.eclipse.jdt.core.IJavaElement"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Javadoc", "getHTMLContentFromSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.IJavaElement"))
+ .requestExtra(StackRequest.PARAM1)
+ .build());
+
+ /* This is an older version that uses IMember instead of IJavaElement */
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2", "getHTMLContent", "java.lang.String", "org.eclipse.jdt.core.IMember", "boolean"))
+ .methodToWrap(new Hook("org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2", "getHTMLContentFromSource", "java.lang.String", "org.eclipse.jdt.core.IMember"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Javadoc", "getHTMLContentFromSource", "java.lang.String", "java.lang.String", "org.eclipse.jdt.core.IJavaElement"))
+ .requestExtra(StackRequest.PARAM1)
+ .build());
+
+ sm.addScript(ScriptBuilder.replaceMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "printBody", "java.lang.StringBuffer", "int", "java.lang.StringBuffer"))
+ .methodToReplace(new Hook("org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "print", "java.lang.StringBuffer", "int", "java.lang.StringBuffer"))
+ .replacementMethod(new Hook("lombok.launch.PatchFixesHider$Javadoc", "printMethod", "java.lang.StringBuffer", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "int", "java.lang.StringBuffer", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration"))
+ .requestExtra(StackRequest.THIS)
+ .build());
+
+ sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.addField()
+ .fieldName("$javadoc")
+ .fieldType("Ljava/util/Map;")
+ .setPublic()
+ .setTransient()
+ .targetClass("org.eclipse.jdt.internal.core.CompilationUnit")
+ .build());
+ }
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/ExtensionMethodCompletionProposal.java b/src/eclipseAgent/lombok/eclipse/agent/ExtensionMethodCompletionProposal.java
index 46ce63f9..833a8226 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/ExtensionMethodCompletionProposal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/ExtensionMethodCompletionProposal.java
@@ -22,10 +22,15 @@
package lombok.eclipse.agent;
import static org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccStatic;
+import static org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.AccVarargs;
import java.util.Arrays;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.CompletionProposal;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
import org.eclipse.jdt.internal.codeassist.InternalCompletionProposal;
@@ -35,16 +40,29 @@ import org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameRefere
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.core.NameLookup;
public class ExtensionMethodCompletionProposal extends InternalCompletionProposal {
+ private char[] fullSignature;
+ private char[][] parameterNames;
+
public ExtensionMethodCompletionProposal(final int replacementOffset) {
super(CompletionProposal.METHOD_REF, replacementOffset - 1);
}
public void setMethodBinding(final MethodBinding method, final ASTNode node) {
+ // Add proposal parameter names, sometimes its empty...
+ if (method.parameterNames != null && method.parameterNames.length > 0) {
+ setParameterNames(Arrays.copyOfRange(method.parameterNames, 1, method.parameterNames.length));
+ } else {
+ // Copy signature for parameter name resolution, this is more reliable but slower
+ fullSignature = CompletionEngine.getSignature(method);
+ }
+
MethodBinding original = method.original();
TypeBinding[] parameters = Arrays.copyOf(method.parameters, method.parameters.length);
method.parameters = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
+
TypeBinding[] originalParameters = null;
if (original != method) {
originalParameters = Arrays.copyOf(method.original().parameters, method.original().parameters.length);
@@ -76,6 +94,10 @@ public class ExtensionMethodCompletionProposal extends InternalCompletionProposa
setName(method.selector);
setCompletion(completion);
setFlags(method.modifiers & (~AccStatic));
+ // Remove varargs flag if it is the only parameter
+ if (method.isVarargs() && length == 0) {
+ setFlags(getFlags() & (~AccVarargs));
+ }
int index = node.sourceEnd + 1;
if (node instanceof CompletionOnQualifiedNameReference) {
index -= ((CompletionOnQualifiedNameReference) node).completionIdentifier.length;
@@ -96,4 +118,58 @@ public class ExtensionMethodCompletionProposal extends InternalCompletionProposa
method.original().parameters = originalParameters;
}
}
+
+ @Override
+ public char[][] findParameterNames(IProgressMonitor monitor) {
+ if (parameterNames != null) {
+ return parameterNames;
+ }
+
+ NameLookup.Answer answer = this.nameLookup.findType(
+ new String(this.declarationTypeName),
+ new String(this.declarationPackageName),
+ false,
+ NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
+ true/* consider secondary types */,
+ false/* do NOT wait for indexes */,
+ false/*don't check restrictions*/,
+ null);
+
+ if (answer != null && answer.type != null) {
+ char[][] parameterTypes = Signature.getParameterTypes(fullSignature);
+
+ String[] args = new String[parameterTypes.length];
+ for (int i = 0; i < parameterTypes.length; i++) {
+ args[i] = new String(parameterTypes[i]);
+ }
+ IMethod method = answer.type.getMethod(new String(this.getName()), args);
+ IMethod[] methods = answer.type.findMethods(method);
+ if (methods != null && methods.length > 0) {
+ method = methods[0];
+ }
+ if (method != null) {
+ try {
+ String[] parameterNames = method.getParameterNames();
+ char[][] parameterNamesAsChar = new char[parameterNames.length - 1][];
+ for (int i = 0; i < parameterNamesAsChar.length; i++) {
+ parameterNamesAsChar[i] = parameterNames[i + 1].toCharArray();
+ }
+ setParameterNames(parameterNamesAsChar);
+ } catch (JavaModelException e) {
+ // Nope
+ }
+ }
+ }
+ // Seems like we failed, fallback
+ if (parameterNames == null) {
+ parameterNames = super.findParameterNames(monitor);
+ }
+ return parameterNames;
+ }
+
+ @Override
+ public void setParameterNames(char[][] parameterNames) {
+ this.parameterNames = parameterNames;
+ super.setParameterNames(parameterNames);
+ }
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
index 1a287d93..d7b17598 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2014 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -22,8 +22,8 @@
package lombok.eclipse.agent;
import static lombok.eclipse.Eclipse.*;
+import static lombok.eclipse.EcjAugments.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
-import static lombok.eclipse.EclipseAugments.Annotation_applied;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -34,14 +34,16 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
-import lombok.core.AST.Kind;
-import lombok.eclipse.Eclipse;
-import lombok.eclipse.EclipseAST;
-import lombok.eclipse.EclipseNode;
-import lombok.eclipse.TransformEclipseAST;
-import lombok.eclipse.handlers.SetGeneratedByVisitor;
-
+import org.eclipse.jdt.core.ElementChangedEvent;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -81,8 +83,28 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
+import org.eclipse.jdt.internal.core.CompilationUnit;
+import org.eclipse.jdt.internal.core.DeltaProcessor;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.JavaElementDelta;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.LocalVariable;
+import org.eclipse.jdt.internal.core.SourceMethod;
+import org.eclipse.jdt.internal.core.SourceMethodInfo;
+import org.eclipse.jdt.internal.core.SourceType;
+import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
+
+import lombok.core.AST.Kind;
+import lombok.eclipse.Eclipse;
+import lombok.eclipse.EclipseAST;
+import lombok.eclipse.EclipseNode;
+import lombok.eclipse.TransformEclipseAST;
+import lombok.eclipse.handlers.SetGeneratedByVisitor;
+import lombok.patcher.Symbols;
+import lombok.permit.Permit;
public class PatchDelegate {
+
private static class ClassScopeEntry {
ClassScopeEntry(ClassScope scope) {
this.scope = scope;
@@ -123,6 +145,14 @@ public class PatchDelegate {
public static boolean handleDelegateForType(ClassScope scope) {
if (TransformEclipseAST.disableLombok) return false;
+
+ CompilationUnitDeclaration cud = scope.compilationUnitScope().referenceContext;
+ if (scope == scope.compilationUnitScope().topLevelTypes[0].scope) {
+ if (eclipseAvailable) {
+ EclipseOnlyMethods.cleanupDelegateMethods(cud);
+ }
+ }
+
if (!hasDelegateMarkedFieldsOrMethods(scope.referenceContext)) return false;
List<ClassScopeEntry> stack = visited.get();
@@ -149,7 +179,6 @@ public class PatchDelegate {
try {
TypeDeclaration decl = scope.referenceContext;
if (decl != null) {
- CompilationUnitDeclaration cud = scope.compilationUnitScope().referenceContext;
EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
List<BindingTuple> methodsToDelegate = new ArrayList<BindingTuple>();
fillMethodBindingsForFields(cud, scope, methodsToDelegate);
@@ -168,6 +197,9 @@ public class PatchDelegate {
}
} finally {
stack.remove(stack.size() - 1);
+ if (stack.isEmpty() && eclipseAvailable) {
+ EclipseOnlyMethods.notifyDelegateMethodsAdded(cud);
+ }
}
}
@@ -419,6 +451,7 @@ public class PatchDelegate {
private static void generateDelegateMethods(EclipseNode typeNode, List<BindingTuple> methods, DelegateReceiver delegateReceiver) {
CompilationUnitDeclaration top = (CompilationUnitDeclaration) typeNode.top().get();
+ List<MethodDeclaration> addedMethods = new ArrayList<MethodDeclaration>();
for (BindingTuple pair : methods) {
EclipseNode annNode = typeNode.getAst().get(pair.responsible);
MethodDeclaration method = createDelegateMethod(pair.fieldName, typeNode, pair, top.compilationResult, annNode, delegateReceiver);
@@ -426,8 +459,12 @@ public class PatchDelegate {
SetGeneratedByVisitor visitor = new SetGeneratedByVisitor(annNode.get());
method.traverse(visitor, ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, method);
+ addedMethods.add(method);
}
}
+ if (eclipseAvailable) {
+ EclipseOnlyMethods.collectGeneratedDelegateMethods(top, typeNode, addedMethods);
+ }
}
public static void checkConflictOfTypeVarNames(BindingTuple binding, EclipseNode typeNode) throws CantMakeDelegates {
@@ -673,20 +710,177 @@ public class PatchDelegate {
return method;
}
+ private static boolean eclipseAvailable = true;
+ static {
+ try {
+ CompilationUnit.class.getName();
+ } catch (Throwable t) {
+ eclipseAvailable = false;
+ }
+ }
+
+ public static Object[] addGeneratedDelegateMethods(Object[] returnValue, Object javaElement) {
+ if (Symbols.hasSymbol("lombok.skipdelegates")) return returnValue;
+ if (!eclipseAvailable) return returnValue;
+
+ return EclipseOnlyMethods.addGeneratedDelegateMethodsToChildren(returnValue, javaElement);
+ }
+
+ public static class EclipseOnlyMethods {
+ private static void cleanupDelegateMethods(CompilationUnitDeclaration cud) {
+ CompilationUnit compilationUnit = getCompilationUnit(cud);
+ if (compilationUnit != null) {
+ EclipseAugments.CompilationUnit_delegateMethods.clear(compilationUnit);
+ }
+ }
+
+ public static void collectGeneratedDelegateMethods(CompilationUnitDeclaration top, EclipseNode typeNode, List<MethodDeclaration> addedMethods) {
+ String qualifiedName = new String(CharOperation.concatWith(getQualifiedInnerName(typeNode.up(), typeNode.getName().toCharArray()), '$'));
+ SourceType sourceType = getSourceType(top, qualifiedName);
+ List<SourceMethod> generatedMethods = getGeneratedMethods(sourceType);
+ if (generatedMethods == null) return;
+
+ for (MethodDeclaration md : addedMethods) {
+ generatedMethods.add(DelegateSourceMethod.forMethodDeclaration(sourceType, md));
+ }
+ }
+
+ public static Object[] addGeneratedDelegateMethodsToChildren(Object[] returnValue, Object javaElement) {
+ List<SourceMethod> delegateMethods = getGeneratedMethods((SourceType) ((SourceTypeElementInfo) javaElement).getHandle());
+ if (delegateMethods != null) {
+ return concat((IJavaElement[]) returnValue, delegateMethods.toArray(new IJavaElement[0]), IJavaElement.class);
+ }
+ return returnValue;
+ }
+
+ private static void notifyDelegateMethodsAdded(CompilationUnitDeclaration cud) {
+ CompilationUnit compilationUnit = getCompilationUnit(cud);
+ if (compilationUnit != null) {
+ DeltaProcessor deltaProcessor = JavaModelManager.getJavaModelManager().getDeltaProcessor();
+ deltaProcessor.fire(new JavaElementDelta(compilationUnit), ElementChangedEvent.POST_CHANGE);
+ }
+ }
+
+ private static CompilationUnit getCompilationUnit(Object iCompilationUnit) {
+ if (iCompilationUnit instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) iCompilationUnit;
+ return compilationUnit.originalFromClone();
+ }
+ return null;
+ }
+
+ private static CompilationUnit getCompilationUnit(CompilationUnitDeclaration cud) {
+ return getCompilationUnit(cud.compilationResult.compilationUnit);
+ }
+
+ private static final class DelegateSourceMethod extends SourceMethod {
+ private DelegateSourceMethodInfo sourceMethodInfo;
+
+ private static DelegateSourceMethod forMethodDeclaration(JavaElement parent, MethodDeclaration method) {
+ Argument[] arguments = method.arguments != null ? method.arguments : new Argument[0];
+ String[] parameterTypes = new String[arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ parameterTypes[i] = Signature.createTypeSignature(CharOperation.concatWith(arguments[i].type.getParameterizedTypeName(), '.'), false);
+ }
+ return new DelegateSourceMethod(parent, new String(method.selector), parameterTypes, method);
+ }
+
+ private DelegateSourceMethod(JavaElement parent, String name, String[] parameterTypes, MethodDeclaration md) {
+ super(parent, name, parameterTypes);
+ sourceMethodInfo = new DelegateSourceMethodInfo(this, md);
+ }
+
+ @Override public Object getElementInfo() throws JavaModelException {
+ return sourceMethodInfo;
+ }
+
+ /**
+ * Disable refactoring for delegate methods
+ */
+ @Override public boolean isReadOnly() {
+ return true;
+ }
+
+ /**
+ * This is required to prevent duplicate entries in the outline
+ */
+ @Override public boolean equals(Object o) {
+ return this == o;
+ }
+
+ public static final class DelegateSourceMethodInfo extends SourceMethodInfo {
+ DelegateSourceMethodInfo(DelegateSourceMethod delegateSourceMethod, MethodDeclaration md) {
+ int pS = md.sourceStart;
+ int pE = md.sourceEnd;
+
+ Argument[] methodArguments = md.arguments != null ? md.arguments : new Argument[0];
+ char[][] argumentNames = new char[methodArguments.length][];
+ arguments = new ILocalVariable[methodArguments.length];
+ for (int i = 0; i < methodArguments.length; i++) {
+ Argument argument = methodArguments[i];
+ argumentNames[i] = argument.name;
+ arguments[i] = new LocalVariable(delegateSourceMethod, new String(argument.name), pS, pE, pS, pS, delegateSourceMethod.getParameterTypes()[i], argument.annotations, argument.modifiers, true);
+ }
+ setArgumentNames(argumentNames);
+
+ setSourceRangeStart(pS);
+ setSourceRangeEnd(pE);
+ setNameSourceStart(pS);
+ setNameSourceEnd(pE);
+
+ setExceptionTypeNames(CharOperation.NO_CHAR_CHAR);
+ setReturnType(md.returnType == null ? new char[]{'v', 'o','i', 'd'} : CharOperation.concatWith(md.returnType.getParameterizedTypeName(), '.'));
+ setFlags(md.modifiers);
+ }
+ }
+ }
+
+ private static List<SourceMethod> getGeneratedMethods(SourceType sourceType) {
+ if (sourceType != null) {
+ CompilationUnit compilationUnit = getCompilationUnit(sourceType.getCompilationUnit());
+ if (compilationUnit != null) {
+ ConcurrentMap<String, List<SourceMethod>> map = EclipseAugments.CompilationUnit_delegateMethods.setIfAbsent(compilationUnit, new ConcurrentHashMap<String, List<SourceMethod>>());
+ List<SourceMethod> newList = new ArrayList<SourceMethod>();
+ List<SourceMethod> oldList = map.putIfAbsent(sourceType.getTypeQualifiedName(), newList);
+ return oldList != null ? oldList : newList;
+ }
+ }
+ return null;
+ }
+
+ private static SourceType getSourceType(CompilationUnitDeclaration cud, String typeName) {
+ CompilationUnit compilationUnit = getCompilationUnit(cud);
+ if (compilationUnit != null) {
+ try {
+ for (IType type : compilationUnit.getAllTypes()) {
+ if (type instanceof SourceType && type.getTypeQualifiedName().equals(typeName)) {
+ return (SourceType) type;
+ }
+ }
+ } catch (JavaModelException e) {
+ // Ignore
+ }
+ }
+ return null;
+ }
+ }
+
private static final class Reflection {
public static final Method classScopeBuildFieldsAndMethodsMethod;
-
+ public static final Throwable initCause;
static {
Method m = null;
+ Throwable c = null;
try {
- m = ClassScope.class.getDeclaredMethod("buildFieldsAndMethods");
- m.setAccessible(true);
+ m = Permit.getMethod(ClassScope.class, "buildFieldsAndMethods");
} catch (Throwable t) {
+ c = t;
// That's problematic, but as long as no local classes are used we don't actually need it.
// Better fail on local classes than crash altogether.
}
classScopeBuildFieldsAndMethodsMethod = m;
+ initCause = c;
}
}
@@ -723,16 +917,14 @@ public class PatchDelegate {
ClassScope cs = ((SourceTypeBinding)inner).scope;
if (cs != null) {
try {
- Reflection.classScopeBuildFieldsAndMethodsMethod.invoke(cs);
+ Permit.invoke(Reflection.initCause, Reflection.classScopeBuildFieldsAndMethodsMethod, cs);
} catch (Exception e) {
// See 'Reflection' class for why we ignore this exception.
}
}
}
- if (!(binding instanceof ReferenceBinding)) {
- return;
- }
+ if (!(binding instanceof ReferenceBinding)) return;
ReferenceBinding rb = (ReferenceBinding) binding;
MethodBinding[] availableMethods = rb.availableMethods();
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegatePortal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegatePortal.java
index 49083df0..01e4bb18 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegatePortal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegatePortal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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,52 +21,54 @@
*/
package lombok.eclipse.agent;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import lombok.Lombok;
+import lombok.permit.Permit;
public class PatchDelegatePortal {
static final String CLASS_SCOPE = "org.eclipse.jdt.internal.compiler.lookup.ClassScope";
+ static final String I_JAVA_ELEMENT_ARRAY = "[Lorg.eclipse.jdt.core.IJavaElement;";
+ static final String SOURCE_TYPE_ELEMENT_INFO = "org.eclipse.jdt.internal.core.SourceTypeElementInfo";
public static boolean handleDelegateForType(Object classScope) {
- try {
- return (Boolean) Reflection.handleDelegateForType.invoke(null, classScope);
- } catch (NoClassDefFoundError e) {
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- return false;
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
- } catch (NullPointerException e) {
- if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) {
- e.initCause(Reflection.problem);
- throw e;
- }
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- return false;
- }
+ Boolean v = (Boolean) Permit.invokeSneaky(Reflection.problemHandleDelegate, Reflection.handleDelegateForType, null, classScope);
+ if (v == null) return false;
+ return v.booleanValue();
+ }
+
+ public static Object[] addGeneratedDelegateMethods(Object returnValue, Object javaElement) {
+ return (Object[]) Permit.invokeSneaky(Reflection.problemAddGeneratedDelegateMethods, Reflection.addGeneratedDelegateMethods, null, returnValue, javaElement);
}
private static final class Reflection {
public static final Method handleDelegateForType;
- public static final Throwable problem;
+ public static final Method addGeneratedDelegateMethods;
+ public static final Throwable problemHandleDelegate;
+ public static final Throwable problemAddGeneratedDelegateMethods;
static {
- Method m = null;
- Throwable problem_ = null;
+ Method m = null, n = null;
+ Throwable problemHandleDelegate_ = null;
+ Throwable problemAddGeneratedDelegateMethods_ = null;
try {
- m = PatchDelegate.class.getMethod("handleDelegateForType", Class.forName(CLASS_SCOPE));
+ m = Permit.getMethod(PatchDelegate.class, "handleDelegateForType", Class.forName(CLASS_SCOPE));
} catch (Throwable t) {
// That's problematic, but as long as no local classes are used we don't actually need it.
// Better fail on local classes than crash altogether.
- problem_ = t;
+ problemHandleDelegate_ = t;
}
handleDelegateForType = m;
- problem = problem_;
+ problemHandleDelegate = problemHandleDelegate_;
+
+ try {
+ n = Permit.getMethod(PatchDelegate.class, "addGeneratedDelegateMethods", Object[].class, Object.class);
+ } catch (Throwable t) {
+ // That's problematic, but as long as no local classes are used we don't actually need it.
+ // Better fail on local classes than crash altogether.
+ problemAddGeneratedDelegateMethods_ = t;
+ }
+ addGeneratedDelegateMethods = n;
+ problemAddGeneratedDelegateMethods = problemAddGeneratedDelegateMethods_;
}
}
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
index fcc76059..2e540b5e 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2021 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
@@ -24,6 +24,7 @@ package lombok.eclipse.agent;
import static lombok.eclipse.handlers.EclipseHandlerUtil.createAnnotation;
import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -54,9 +55,9 @@ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.SuperReference;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -98,13 +99,13 @@ public class PatchExtensionMethod {
private static final Method shortMethod = getMethod("invalidMethod", MessageSend.class, MethodBinding.class);
private static final Method longMethod = getMethod("invalidMethod", MessageSend.class, MethodBinding.class, Scope.class);
+ private static Throwable initProblem;
private static Method getMethod(String name, Class<?>... types) {
try {
- Method m = ProblemReporter.class.getMethod(name, types);
- m.setAccessible(true);
- return m;
+ return Permit.getMethod(ProblemReporter.class, name, types);
} catch (Exception e) {
+ initProblem = e;
return null;
}
}
@@ -119,8 +120,9 @@ public class PatchExtensionMethod {
static void invoke(ProblemReporter problemReporter, MessageSend messageSend, MethodBinding method, Scope scope) {
if (messageSend != null) {
try {
- if (shortMethod != null) shortMethod.invoke(problemReporter, messageSend, method);
- else if (longMethod != null) longMethod.invoke(problemReporter, messageSend, method, scope);
+ if (shortMethod != null) Permit.invoke(initProblem, shortMethod, problemReporter, messageSend, method);
+ else if (longMethod != null) Permit.invoke(initProblem, longMethod, problemReporter, messageSend, method, scope);
+ else Permit.reportReflectionProblem(initProblem, "method named 'invalidMethod' not found in ProblemReporter.class");
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
@@ -138,6 +140,25 @@ public class PatchExtensionMethod {
}
}
+ private static class PostponedNonStaticAccessToStaticMethodError implements PostponedError {
+ private final ProblemReporter problemReporter;
+ private ASTNode location;
+ private MethodBinding method;
+ private ReferenceContext referenceContext;
+
+ PostponedNonStaticAccessToStaticMethodError(ProblemReporter problemReporter, ASTNode location, MethodBinding method) {
+ this.problemReporter = problemReporter;
+ this.location = location;
+ this.method = method;
+ this.referenceContext = problemReporter.referenceContext;
+ }
+
+ public void fire() {
+ problemReporter.referenceContext = this.referenceContext;
+ problemReporter.nonStaticAccessToStaticMethod(location, method);
+ }
+ }
+
private static interface PostponedError {
public void fire();
}
@@ -200,15 +221,12 @@ public class PatchExtensionMethod {
TypeBinding receiverType) {
List<MethodBinding> extensionMethods = new ArrayList<MethodBinding>();
- CompilationUnitScope cuScope = ((CompilationUnitDeclaration) typeNode.top().get()).scope;
for (MethodBinding method : extensionMethodProviderBinding.methods()) {
if (!method.isStatic()) continue;
if (!method.isPublic()) continue;
if (method.parameters == null || method.parameters.length == 0) continue;
TypeBinding firstArgType = method.parameters[0];
if (receiverType.isProvablyDistinct(firstArgType) && !receiverType.isCompatibleWith(firstArgType.erasure())) continue;
- TypeBinding[] argumentTypes = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
- if ((receiverType instanceof ReferenceBinding) && ((ReferenceBinding) receiverType).getExactMethod(method.selector, argumentTypes, cuScope) != null) continue;
extensionMethods.add(method);
}
return extensionMethods;
@@ -228,6 +246,10 @@ public class PatchExtensionMethod {
MessageSend_postponedErrors.set(messageSend, new PostponedInvalidMethodError(problemReporter, messageSend, method, scope));
}
+ public static void nonStaticAccessToStaticMethod(ProblemReporter problemReporter, ASTNode location, MethodBinding method, MessageSend messageSend) {
+ MessageSend_postponedErrors.set(messageSend, new PostponedNonStaticAccessToStaticMethodError(problemReporter, location, method));
+ }
+
public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend methodCall, BlockScope scope) {
List<Extension> extensions = new ArrayList<Extension>();
TypeDeclaration decl = scope.classScope().referenceContext;
@@ -250,6 +272,14 @@ public class PatchExtensionMethod {
Binding binding = ((NameReference)methodCall.receiver).binding;
if (binding instanceof TypeBinding) skip = true;
}
+ // It's impossible to resolve the right method without types
+ if (Reflection.argumentsHaveErrors != null) {
+ try {
+ if ((Boolean) Reflection.argumentsHaveErrors.get(methodCall)) skip = true;
+ } catch (IllegalAccessException ignore) {
+ // ignore
+ }
+ }
if (!skip) for (Extension extension : extensions) {
if (!extension.suppressBaseMethods && !(methodCall.binding instanceof ProblemMethodBinding)) continue;
@@ -262,13 +292,31 @@ public class PatchExtensionMethod {
List<Expression> arguments = new ArrayList<Expression>();
arguments.add(methodCall.receiver);
if (methodCall.arguments != null) arguments.addAll(Arrays.asList(methodCall.arguments));
+ Expression[] originalArgs = methodCall.arguments;
+ methodCall.arguments = arguments.toArray(new Expression[0]);
+
List<TypeBinding> argumentTypes = new ArrayList<TypeBinding>();
for (Expression argument : arguments) {
- if (argument.resolvedType != null) argumentTypes.add(argument.resolvedType);
- // TODO: Instead of just skipping nulls entirely, there is probably a 'unresolved type' placeholder. THAT is what we ought to be adding here!
+ TypeBinding argumentType = argument.resolvedType;
+ if (argumentType == null && Reflection.isFunctionalExpression(argument)) {
+ argumentType = Reflection.getPolyTypeBinding(argument);
+ }
+ if (argumentType == null) {
+ argumentType = TypeBinding.NULL;
+ }
+ argumentTypes.add(argumentType);
}
- Expression[] originalArgs = methodCall.arguments;
- methodCall.arguments = arguments.toArray(new Expression[0]);
+
+ if (methodCall.receiver instanceof MessageSend) {
+ if (Reflection.inferenceContexts != null) {
+ try {
+ Permit.set(Reflection.inferenceContexts, methodCall.receiver, null);
+ } catch (IllegalAccessException ignore) {
+ // ignore
+ }
+ }
+ }
+
MethodBinding fixedBinding = scope.getMethod(extensionMethod.declaringClass, methodCall.selector, argumentTypes.toArray(new TypeBinding[0]), methodCall);
if (fixedBinding instanceof ProblemMethodBinding) {
methodCall.arguments = originalArgs;
@@ -276,18 +324,33 @@ public class PatchExtensionMethod {
PostponedInvalidMethodError.invoke(scope.problemReporter(), methodCall, fixedBinding, scope);
}
} else {
+ // If the extension method uses varargs, the last fixed binding parameter is an array but
+ // the method arguments are not. Even thought we already know that the method is fine we still
+ // have to compare each parameter with the type of the array to support autoboxing/unboxing.
+ boolean isVarargs = fixedBinding.isVarargs();
for (int i = 0, iend = arguments.size(); i < iend; i++) {
Expression arg = arguments.get(i);
- if (fixedBinding.parameters[i].isArrayType() != arg.resolvedType.isArrayType()) break;
- if (arg instanceof MessageSend) {
- ((MessageSend) arg).valueCast = arg.resolvedType;
+ TypeBinding[] parameters = fixedBinding.parameters;
+ TypeBinding param;
+ if (isVarargs && i >= parameters.length - 1) {
+ // Extract the array element type for all vararg arguments
+ param = parameters[parameters.length - 1].leafComponentType();
+ } else {
+ param = parameters[i];
+ }
+ // Resolve types for lambdas
+ if (Reflection.isFunctionalExpression(arg)) {
+ arg.setExpectedType(param);
+ arg.resolveType(scope);
}
- if (!fixedBinding.parameters[i].isBaseType() && arg.resolvedType.isBaseType()) {
- int id = arg.resolvedType.id;
- arg.implicitConversion = TypeIds.BOXING | (id + (id << 4)); // magic see TypeIds
- } else if (fixedBinding.parameters[i].isBaseType() && !arg.resolvedType.isBaseType()) {
- int id = fixedBinding.parameters[i].id;
- arg.implicitConversion = TypeIds.UNBOXING | (id + (id << 4)); // magic see TypeIds
+ if (arg.resolvedType != null) {
+ if (!param.isBaseType() && arg.resolvedType.isBaseType()) {
+ int id = arg.resolvedType.id;
+ arg.implicitConversion = TypeIds.BOXING | (id + (id << 4)); // magic see TypeIds
+ } else if (param.isBaseType() && !arg.resolvedType.isBaseType()) {
+ int id = parameters[i].id;
+ arg.implicitConversion = TypeIds.UNBOXING | (id + (id << 4)); // magic see TypeIds
+ }
}
}
@@ -295,6 +358,7 @@ public class PatchExtensionMethod {
methodCall.actualReceiverType = extensionMethod.declaringClass;
methodCall.binding = fixedBinding;
methodCall.resolvedType = methodCall.binding.returnType;
+ methodCall.statementEnd = methodCall.sourceEnd;
if (Reflection.argumentTypes != null) {
try {
Reflection.argumentTypes.set(methodCall, argumentTypes.toArray(new TypeBinding[0]));
@@ -340,16 +404,42 @@ public class PatchExtensionMethod {
}
private static final class Reflection {
- public static final Field argumentTypes;
+ public static final Field argumentTypes = Permit.permissiveGetField(MessageSend.class, "argumentTypes");
+ public static final Field argumentsHaveErrors = Permit.permissiveGetField(MessageSend.class, "argumentsHaveErrors");
+ public static final Field inferenceContexts = Permit.permissiveGetField(MessageSend.class, "inferenceContexts");
+ private static final Class<?> functionalExpression;
+ private static final Constructor<?> polyTypeBindingConstructor;
static {
- Field a = null;
+ Class<?> a = null;
+ Constructor<?> b = null;
try {
- a = Permit.getField(MessageSend.class, "argumentTypes");
- } catch (Throwable t) {
- //ignore - old eclipse versions don't know this one
+ a = Class.forName("org.eclipse.jdt.internal.compiler.ast.FunctionalExpression");
+ } catch (Exception e) {
+ // Ignore
+ }
+ try {
+ b = Permit.getConstructor(Class.forName("org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding"), Expression.class);
+ } catch (Exception e) {
+ // Ignore
+ }
+ functionalExpression = a;
+ polyTypeBindingConstructor = b;
+ }
+
+ public static boolean isFunctionalExpression(Expression expression) {
+ if (functionalExpression == null) return false;
+ return functionalExpression.isInstance(expression);
+ }
+
+ public static TypeBinding getPolyTypeBinding(Expression expression) {
+ if (polyTypeBindingConstructor == null) return null;
+ try {
+ return (TypeBinding) polyTypeBindingConstructor.newInstance(expression);
+ } catch (Exception e) {
+ // Ignore
}
- argumentTypes = a;
+ return null;
}
}
}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
index 085c903f..1b94d1b9 100755
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodCompletionProposal.java
@@ -65,13 +65,14 @@ public class PatchExtensionMethodCompletionProposal {
CompletionProposalCollector completionProposalCollector) {
List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>(Arrays.asList(javaCompletionProposals));
- if (canExtendCodeAssist(proposals)) {
- IJavaCompletionProposal firstProposal = proposals.get(0);
- int replacementOffset = getReplacementOffset(firstProposal);
+ if (canExtendCodeAssist()) {
for (Extension extension : getExtensionMethods(completionProposalCollector)) {
for (MethodBinding method : extension.extensionMethods) {
- ExtensionMethodCompletionProposal newProposal = new ExtensionMethodCompletionProposal(replacementOffset);
- copyNameLookupAndCompletionEngine(completionProposalCollector, firstProposal, newProposal);
+ if (!isMatchingProposal(method, completionProposalCollector)) {
+ continue;
+ }
+ ExtensionMethodCompletionProposal newProposal = new ExtensionMethodCompletionProposal(0);
+ copyNameLookupAndCompletionEngine(completionProposalCollector, newProposal);
ASTNode node = getAssistNode(completionProposalCollector);
newProposal.setMethodBinding(method, node);
createAndAddJavaCompletionProposal(completionProposalCollector, newProposal, proposals);
@@ -81,7 +82,6 @@ public class PatchExtensionMethodCompletionProposal {
return proposals.toArray(new IJavaCompletionProposal[0]);
}
-
private static List<Extension> getExtensionMethods(CompletionProposalCollector completionProposalCollector) {
List<Extension> extensions = new ArrayList<Extension>();
ClassScope classScope = getClassScope(completionProposalCollector);
@@ -96,6 +96,17 @@ public class PatchExtensionMethodCompletionProposal {
return extensions;
}
+ private static boolean isMatchingProposal(MethodBinding method, CompletionProposalCollector completionProposalCollector) {
+ try {
+ InternalCompletionContext context = (InternalCompletionContext) Reflection.contextField.get(completionProposalCollector);
+ String searchToken = new String(context.getToken());
+ String extensionMethodName = new String(method.selector);
+ return extensionMethodName.contains(searchToken);
+ } catch (IllegalAccessException e) {
+ return true;
+ }
+ }
+
static TypeBinding getFirstParameterType(TypeDeclaration decl, CompletionProposalCollector completionProposalCollector) {
TypeBinding firstParameterType = null;
ASTNode node = getAssistNode(completionProposalCollector);
@@ -149,8 +160,7 @@ public class PatchExtensionMethodCompletionProposal {
return scope;
}
- private static void copyNameLookupAndCompletionEngine(CompletionProposalCollector completionProposalCollector, IJavaCompletionProposal proposal,
- InternalCompletionProposal newProposal) {
+ private static void copyNameLookupAndCompletionEngine(CompletionProposalCollector completionProposalCollector, InternalCompletionProposal newProposal) {
try {
InternalCompletionContext context = (InternalCompletionContext) Reflection.contextField.get(completionProposalCollector);
@@ -173,17 +183,10 @@ public class PatchExtensionMethodCompletionProposal {
}
}
- private static boolean canExtendCodeAssist(List<IJavaCompletionProposal> proposals) {
- return !proposals.isEmpty() && Reflection.isComplete();
- }
-
- private static int getReplacementOffset(Object proposal) {
- try {
- return Reflection.replacementOffsetField.getInt(proposal);
- } catch (Exception ignore) {
- return 0;
- }
+ private static boolean canExtendCodeAssist() {
+ return Reflection.isComplete();
}
+
static class Reflection {
public static final Field replacementOffsetField;
@@ -195,7 +198,7 @@ public class PatchExtensionMethodCompletionProposal {
public static final Field completionEngineField;
public static final Field nameLookupField;
public static final Method createJavaCompletionProposalMethod;
-
+
static {
replacementOffsetField = accessField(AbstractJavaCompletionProposal.class, "fReplacementOffset");
contextField = accessField(CompletionProposalCollector.class, "fContext");
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java
deleted file mode 100644
index b66bafbb..00000000
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package lombok.eclipse.agent;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import lombok.Lombok;
-
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-
-public class PatchExtensionMethodPortal {
- private static final String TYPE_BINDING = "org.eclipse.jdt.internal.compiler.lookup.TypeBinding";
- private static final String TYPE_BINDING_ARRAY = "[Lorg.eclipse.jdt.internal.compiler.lookup.TypeBinding;";
- private static final String MESSAGE_SEND = "org.eclipse.jdt.internal.compiler.ast.MessageSend";
- private static final String BLOCK_SCOPE = "org.eclipse.jdt.internal.compiler.lookup.BlockScope";
- private static final String METHOD_BINDING = "org.eclipse.jdt.internal.compiler.lookup.MethodBinding";
- private static final String PROBLEM_REPORTER = "org.eclipse.jdt.internal.compiler.problem.ProblemReporter";
-
- public static TypeBinding resolveType(Object resolvedType, Object methodCall, Object scope) {
- try {
- return (TypeBinding) Reflection.resolveType.invoke(null, resolvedType, methodCall, scope);
- } catch (NoClassDefFoundError e) {
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- return (TypeBinding) resolvedType;
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e);
- } catch (NullPointerException e) {
- if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) {
- e.initCause(Reflection.problem);
- throw e;
- }
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- return (TypeBinding)resolvedType;
- }
- }
-
- public static void errorNoMethodFor(Object problemReporter, Object messageSend, Object recType, Object params) {
- try {
- Reflection.errorNoMethodFor.invoke(null, problemReporter, messageSend, recType, params);
- } catch (NoClassDefFoundError e) {
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
- } catch (NullPointerException e) {
- if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) {
- e.initCause(Reflection.problem);
- throw e;
- }
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- }
- }
-
- public static void invalidMethod(Object problemReporter, Object messageSend, Object method) {
- try {
- Reflection.invalidMethod.invoke(null, problemReporter, messageSend, method);
- } catch (NoClassDefFoundError e) {
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- } catch (IllegalAccessException e) {
- throw Lombok.sneakyThrow(e);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
- } catch (NullPointerException e) {
- if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) {
- e.initCause(Reflection.problem);
- throw e;
- }
- //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
- //do anything useful here.
- }
- }
-
- private static final class Reflection {
- public static final Method resolveType, errorNoMethodFor, invalidMethod;
- public static final Throwable problem;
-
- static {
- Method m = null, n = null, o = null;
- Throwable problem_ = null;
- try {
- m = PatchExtensionMethod.class.getMethod("resolveType", Class.forName(TYPE_BINDING), Class.forName(MESSAGE_SEND), Class.forName(BLOCK_SCOPE));
- n = PatchExtensionMethod.class.getMethod("errorNoMethodFor", Class.forName(PROBLEM_REPORTER),
- Class.forName(MESSAGE_SEND), Class.forName(TYPE_BINDING), Class.forName(TYPE_BINDING_ARRAY));
- o = PatchExtensionMethod.class.getMethod("invalidMethod", Class.forName(PROBLEM_REPORTER), Class.forName(MESSAGE_SEND), Class.forName(METHOD_BINDING));
- } catch (Throwable t) {
- // That's problematic, but as long as no local classes are used we don't actually need it.
- // Better fail on local classes than crash altogether.
- problem_ = t;
- }
- resolveType = m;
- errorNoMethodFor = n;
- invalidMethod = o;
- problem = problem_;
- }
- }
-}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java b/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java
new file mode 100644
index 00000000..5b34917e
--- /dev/null
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2020 The Project Lombok Authors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package lombok.eclipse.agent;
+
+import static lombok.eclipse.EcjAugments.CompilationUnit_javadoc;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.core.CompilationUnit;
+import org.eclipse.jdt.internal.core.SourceMethod;
+import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
+
+import lombok.eclipse.handlers.EclipseHandlerUtil;
+import lombok.permit.Permit;
+
+public class PatchJavadoc {
+
+ public static String getHTMLContentFromSource(String original, Object member) {
+ if (original != null) {
+ return original;
+ }
+
+ if (member instanceof SourceMethod) {
+ SourceMethod sourceMethod = (SourceMethod) member;
+ ICompilationUnit iCompilationUnit = sourceMethod.getCompilationUnit();
+ if (iCompilationUnit instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) iCompilationUnit;
+ Map<String, String> docs = CompilationUnit_javadoc.get(compilationUnit);
+ if (docs == null) return null;
+
+ String signature = Signature.getSignature(sourceMethod);
+ String rawJavadoc = docs.get(signature);
+ if (rawJavadoc == null) return null;
+
+ return Reflection.javadoc2HTML((IMember) member, (IJavaElement) member, rawJavadoc);
+ }
+ }
+
+ return null;
+ }
+
+ public static StringBuffer printMethod(AbstractMethodDeclaration methodDeclaration, Integer tab, StringBuffer output, TypeDeclaration type) {
+ Map<String, String> docs = CompilationUnit_javadoc.get(methodDeclaration.compilationResult.compilationUnit);
+ if (docs != null) {
+ String signature = EclipseHandlerUtil.getSignature(type, methodDeclaration);
+ String rawJavadoc = docs.get(signature);
+ if (rawJavadoc != null) {
+ for (String line : rawJavadoc.split("\r?\n")) {
+ ASTNode.printIndent(tab, output).append(line).append("\n");
+ }
+ }
+ }
+ return methodDeclaration.print(tab, output);
+ }
+
+ private static class Signature {
+ static final String getSignature(SourceMethod sourceMethod) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(sourceMethod.getParent().getElementName());
+ sb.append(".");
+ sb.append(sourceMethod.getElementName());
+ sb.append("(");
+ for (String type : sourceMethod.getParameterTypes()) {
+ sb.append(org.eclipse.jdt.core.Signature.toString(type));
+ }
+ sb.append(")");
+
+ return sb.toString();
+ }
+ }
+
+ /**
+ * The method <code>javadoc2HTML</code> changed 2014-12 to accept an
+ * additional IJavaElement parameter. To support older versions, try to
+ * find that one too.
+ */
+ private static class Reflection {
+ private static final Method javadoc2HTML;
+ private static final Method oldJavadoc2HTML;
+ static {
+ Method a = null, b = null;
+
+ try {
+ a = Permit.getMethod(JavadocContentAccess2.class, "javadoc2HTML", IMember.class, IJavaElement.class, String.class);
+ } catch (Throwable t) {}
+ try {
+ b = Permit.getMethod(JavadocContentAccess2.class, "javadoc2HTML", IMember.class, String.class);
+ } catch (Throwable t) {}
+
+ javadoc2HTML = a;
+ oldJavadoc2HTML = b;
+ }
+
+ private static String javadoc2HTML(IMember member, IJavaElement element, String rawJavadoc) {
+ if (javadoc2HTML != null) {
+ try {
+ return (String) javadoc2HTML.invoke(null, member, element, rawJavadoc);
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+ if (oldJavadoc2HTML != null) {
+ try {
+ return (String) oldJavadoc2HTML.invoke(null, member, rawJavadoc);
+ } catch (Throwable t) {
+ return null;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index f22e78a8..9663f364 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -68,32 +68,7 @@ public class PatchVal {
// This is half of the work for 'val' support - the other half is in PatchValEclipse. This half is enough for ecj.
// Creates a copy of the 'initialization' field on a LocalDeclaration if the type of the LocalDeclaration is 'val', because the completion parser will null this out,
// which in turn stops us from inferring the intended type for 'val x = 5;'. We look at the copy.
- // Also patches local declaration to not call .resolveType() on the initializer expression if we've already done so (calling it twice causes weird errors),
- // and patches .resolve() on LocalDeclaration itself to just-in-time replace the 'val' vartype with the right one.
-
- public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
- if (expr.resolvedType != null) return expr.resolvedType;
- try {
- return expr.resolveType(scope);
- } catch (NullPointerException e) {
- return null;
- } catch (ArrayIndexOutOfBoundsException e) {
- // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
- return null;
- }
- }
-
- public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) {
- if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType;
- try {
- return expr.resolveType(scope);
- } catch (NullPointerException e) {
- return null;
- } catch (ArrayIndexOutOfBoundsException e) {
- // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
- return null;
- }
- }
+ // Also patches .resolve() on LocalDeclaration itself to just-in-time replace the 'val' vartype with the right one.
public static boolean matches(String key, char[] array) {
if (array == null || key.length() != array.length) return false;
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index deab0be1..02df3f5f 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2019 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -35,27 +35,22 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.ArrayType;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
+import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.jdt.internal.core.SourceField;
import org.eclipse.jdt.internal.core.dom.rewrite.NodeRewriteEvent;
import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEvent;
@@ -63,7 +58,7 @@ import org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner;
import org.eclipse.jdt.internal.corext.refactoring.SearchResultGroup;
import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
-import lombok.eclipse.EclipseAugments;
+import static lombok.eclipse.EcjAugments.ASTNode_generatedBy;
/** These contain a mix of the following:
* <ul>
@@ -84,20 +79,24 @@ final class PatchFixesHider {
public static final class Util {
private static ClassLoader shadowLoader;
+ public static ClassLoader getShadowLoader() {
+ if (shadowLoader == null) {
+ try {
+ Class.forName("lombok.core.LombokNode");
+ // If we get here, then lombok is already available.
+ shadowLoader = Util.class.getClassLoader();
+ } catch (ClassNotFoundException e) {
+ // If we get here, it isn't, and we should use the shadowloader.
+ shadowLoader = Main.getShadowClassLoader();
+ }
+ }
+
+ return shadowLoader;
+ }
+
public static Class<?> shadowLoadClass(String name) {
try {
- if (shadowLoader == null) {
- try {
- Class.forName("lombok.core.LombokNode");
- // If we get here, then lombok is already available.
- shadowLoader = Util.class.getClassLoader();
- } catch (ClassNotFoundException e) {
- // If we get here, it isn't, and we should use the shadowloader.
- shadowLoader = Main.getShadowClassLoader();
- }
- }
-
- return Class.forName(name, true, shadowLoader);
+ return Class.forName(name, true, getShadowLoader());
} catch (ClassNotFoundException e) {
throw sneakyThrow(e);
}
@@ -111,6 +110,20 @@ final class PatchFixesHider {
}
}
+ public static Method findMethod(Class<?> type, String name, String... parameterTypes) {
+ for (Method m : type.getDeclaredMethods()) {
+ if (name.equals(m.getName()) && sameTypes(m.getParameterTypes(), parameterTypes)) {
+ return m;
+ }
+ }
+ throw sneakyThrow(new NoSuchMethodException(type.getName() + "::" + name));
+ }
+
+ public static Method findMethodAnyArgs(Class<?> type, String name) {
+ for (Method m : type.getDeclaredMethods()) if (name.equals(m.getName())) return m;
+ throw sneakyThrow(new NoSuchMethodException(type.getName() + "::" + name));
+ }
+
public static Object invokeMethod(Method method, Object... args) {
try {
return method.invoke(null, args);
@@ -131,6 +144,14 @@ final class PatchFixesHider {
private static <T extends Throwable> void sneakyThrow0(Throwable t) throws T {
throw (T)t;
}
+
+ private static boolean sameTypes(Class<?>[] types, String[] typeNames) {
+ if (types.length != typeNames.length) return false;
+ for (int i = 0; i < types.length; i++) {
+ if (!types[i].getName().equals(typeNames[i])) return false;
+ }
+ return true;
+ }
}
/** Contains patch fixes that are dependent on lombok internals. */
@@ -170,20 +191,25 @@ final class PatchFixesHider {
}
public static final class Transform {
- private static final Method TRANSFORM;
- private static final Method TRANSFORM_SWAPPED;
+ private static Method TRANSFORM;
+ private static Method TRANSFORM_SWAPPED;
- static {
+ private static synchronized void init(ClassLoader prepend) {
+ if (TRANSFORM != null) return;
+
+ Main.prependClassLoader(prepend);
Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.TransformEclipseAST");
- TRANSFORM = Util.findMethod(shadowed, "transform", Parser.class, CompilationUnitDeclaration.class);
- TRANSFORM_SWAPPED = Util.findMethod(shadowed, "transform_swapped", CompilationUnitDeclaration.class, Parser.class);
+ TRANSFORM = Util.findMethodAnyArgs(shadowed, "transform");
+ TRANSFORM_SWAPPED = Util.findMethodAnyArgs(shadowed, "transform_swapped");
}
- public static void transform(Parser parser, CompilationUnitDeclaration ast) throws IOException {
+ public static void transform(Object parser, Object ast) throws IOException {
+ init(parser.getClass().getClassLoader());
Util.invokeMethod(TRANSFORM, parser, ast);
}
- public static void transform_swapped(CompilationUnitDeclaration ast, Parser parser) throws IOException {
+ public static void transform_swapped(Object ast, Object parser) throws IOException {
+ init(parser.getClass().getClassLoader());
Util.invokeMethod(TRANSFORM_SWAPPED, ast, parser);
}
}
@@ -191,15 +217,21 @@ final class PatchFixesHider {
/** Contains patch code to support {@code @Delegate} */
public static final class Delegate {
private static final Method HANDLE_DELEGATE_FOR_TYPE;
+ private static final Method ADD_GENERATED_DELEGATE_METHODS;
static {
Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchDelegatePortal");
HANDLE_DELEGATE_FOR_TYPE = Util.findMethod(shadowed, "handleDelegateForType", Object.class);
+ ADD_GENERATED_DELEGATE_METHODS = Util.findMethod(shadowed, "addGeneratedDelegateMethods", Object.class, Object.class);
}
public static boolean handleDelegateForType(Object classScope) {
return (Boolean) Util.invokeMethod(HANDLE_DELEGATE_FOR_TYPE, classScope);
}
+
+ public static Object[] addGeneratedDelegateMethods(Object returnValue, Object javaElement) {
+ return (Object[]) Util.invokeMethod(ADD_GENERATED_DELEGATE_METHODS, returnValue, javaElement);
+ }
}
/** Contains patch code to support {@code val} (eclipse specific) */
@@ -236,65 +268,120 @@ final class PatchFixesHider {
/** Contains patch code to support {@code val} (eclipse and ecj) */
public static final class Val {
- private static final Method SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED;
- private static final Method SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED2;
+ private static final String BLOCK_SCOPE_SIG = "org.eclipse.jdt.internal.compiler.lookup.BlockScope";
+ private static final String LOCAL_DECLARATION_SIG = "org.eclipse.jdt.internal.compiler.ast.LocalDeclaration";
+ private static final String FOREACH_STATEMENT_SIG = "org.eclipse.jdt.internal.compiler.ast.ForeachStatement";
+
private static final Method HANDLE_VAL_FOR_LOCAL_DECLARATION;
private static final Method HANDLE_VAL_FOR_FOR_EACH;
static {
Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchVal");
- SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED = Util.findMethod(shadowed, "skipResolveInitializerIfAlreadyCalled", Expression.class, BlockScope.class);
- SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED2 = Util.findMethod(shadowed, "skipResolveInitializerIfAlreadyCalled2", Expression.class, BlockScope.class, LocalDeclaration.class);
- HANDLE_VAL_FOR_LOCAL_DECLARATION = Util.findMethod(shadowed, "handleValForLocalDeclaration", LocalDeclaration.class, BlockScope.class);
- HANDLE_VAL_FOR_FOR_EACH = Util.findMethod(shadowed, "handleValForForEach", ForeachStatement.class, BlockScope.class);
+ HANDLE_VAL_FOR_LOCAL_DECLARATION = Util.findMethod(shadowed, "handleValForLocalDeclaration", LOCAL_DECLARATION_SIG, BLOCK_SCOPE_SIG);
+ HANDLE_VAL_FOR_FOR_EACH = Util.findMethod(shadowed, "handleValForForEach", FOREACH_STATEMENT_SIG, BLOCK_SCOPE_SIG);
}
- public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
- return (TypeBinding) Util.invokeMethod(SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED, expr, scope);
+ public static boolean handleValForLocalDeclaration(Object local, Object scope) {
+ return (Boolean) Util.invokeMethod(HANDLE_VAL_FOR_LOCAL_DECLARATION, local, scope);
}
- public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) {
- return (TypeBinding) Util.invokeMethod(SKIP_RESOLVE_INITIALIZER_IF_ALREADY_CALLED2, expr, scope, decl);
+ public static boolean handleValForForEach(Object forEach, Object scope) {
+ return (Boolean) Util.invokeMethod(HANDLE_VAL_FOR_FOR_EACH, forEach, scope);
}
- public static boolean handleValForLocalDeclaration(LocalDeclaration local, BlockScope scope) {
- return (Boolean) Util.invokeMethod(HANDLE_VAL_FOR_LOCAL_DECLARATION, local, scope);
+ /**
+ * Patches local declaration to not call .resolveType() on the initializer expression if we've already done so (calling it twice causes weird errors)
+ * This and the next method must be transplanted so that the return type is loaded in the correct class loader
+ */
+ public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
+ if (expr.resolvedType != null) return expr.resolvedType;
+ try {
+ return expr.resolveType(scope);
+ } catch (NullPointerException e) {
+ return null;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
+ return null;
+ }
}
- public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
- return (Boolean) Util.invokeMethod(HANDLE_VAL_FOR_FOR_EACH, forEach, scope);
+ public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) {
+ if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType;
+ try {
+ return expr.resolveType(scope);
+ } catch (NullPointerException e) {
+ return null;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
+ return null;
+ }
}
}
/** Contains patch code to support {@code @ExtensionMethod} */
public static final class ExtensionMethod {
+ private static final String MESSAGE_SEND_SIG = "org.eclipse.jdt.internal.compiler.ast.MessageSend";
+ private static final String TYPE_BINDING_SIG = "org.eclipse.jdt.internal.compiler.lookup.TypeBinding";
+ private static final String SCOPE_SIG = "org.eclipse.jdt.internal.compiler.lookup.Scope";
+ private static final String BLOCK_SCOPE_SIG = "org.eclipse.jdt.internal.compiler.lookup.BlockScope";
+ private static final String TYPE_BINDINGS_SIG = "[Lorg.eclipse.jdt.internal.compiler.lookup.TypeBinding;";
+ private static final String PROBLEM_REPORTER_SIG = "org.eclipse.jdt.internal.compiler.problem.ProblemReporter";
+ private static final String METHOD_BINDING_SIG = "org.eclipse.jdt.internal.compiler.lookup.MethodBinding";
+ private static final String AST_NODE_SIG = "org.eclipse.jdt.internal.compiler.ast.ASTNode";
+
private static final Method RESOLVE_TYPE;
private static final Method ERROR_NO_METHOD_FOR;
private static final Method INVALID_METHOD, INVALID_METHOD2;
+ private static final Method NON_STATIC_ACCESS_TO_STATIC_METHOD;
static {
Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchExtensionMethod");
- RESOLVE_TYPE = Util.findMethod(shadowed, "resolveType", TypeBinding.class, MessageSend.class, BlockScope.class);
- ERROR_NO_METHOD_FOR = Util.findMethod(shadowed, "errorNoMethodFor", ProblemReporter.class, MessageSend.class, TypeBinding.class, TypeBinding[].class);
- INVALID_METHOD = Util.findMethod(shadowed, "invalidMethod", ProblemReporter.class, MessageSend.class, MethodBinding.class);
- INVALID_METHOD2 = Util.findMethod(shadowed, "invalidMethod", ProblemReporter.class, MessageSend.class, MethodBinding.class, Scope.class);
+ RESOLVE_TYPE = Util.findMethod(shadowed, "resolveType", TYPE_BINDING_SIG, MESSAGE_SEND_SIG, BLOCK_SCOPE_SIG);
+ ERROR_NO_METHOD_FOR = Util.findMethod(shadowed, "errorNoMethodFor", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, TYPE_BINDING_SIG, TYPE_BINDINGS_SIG);
+ INVALID_METHOD = Util.findMethod(shadowed, "invalidMethod", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, METHOD_BINDING_SIG);
+ INVALID_METHOD2 = Util.findMethod(shadowed, "invalidMethod", PROBLEM_REPORTER_SIG, MESSAGE_SEND_SIG, METHOD_BINDING_SIG, SCOPE_SIG);
+ NON_STATIC_ACCESS_TO_STATIC_METHOD = Util.findMethod(shadowed, "nonStaticAccessToStaticMethod", PROBLEM_REPORTER_SIG, AST_NODE_SIG, METHOD_BINDING_SIG, MESSAGE_SEND_SIG);
}
- public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend methodCall, BlockScope scope) {
- return (TypeBinding) Util.invokeMethod(RESOLVE_TYPE, resolvedType, methodCall, scope);
+ public static Object resolveType(Object resolvedType, Object methodCall, Object scope) {
+ return Util.invokeMethod(RESOLVE_TYPE, resolvedType, methodCall, scope);
}
- public static void errorNoMethodFor(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
+ public static void errorNoMethodFor(Object problemReporter, Object messageSend, Object recType, Object params) {
Util.invokeMethod(ERROR_NO_METHOD_FOR, problemReporter, messageSend, recType, params);
}
- public static void invalidMethod(ProblemReporter problemReporter, MessageSend messageSend, MethodBinding method) {
+ public static void invalidMethod(Object problemReporter, Object messageSend, Object method) {
Util.invokeMethod(INVALID_METHOD, problemReporter, messageSend, method);
}
- public static void invalidMethod(ProblemReporter problemReporter, MessageSend messageSend, MethodBinding method, Scope scope) {
+ public static void invalidMethod(Object problemReporter, Object messageSend, Object method, Object scope) {
Util.invokeMethod(INVALID_METHOD2, problemReporter, messageSend, method, scope);
}
+
+ public static void nonStaticAccessToStaticMethod(Object problemReporter, Object location, Object method, Object messageSend) {
+ Util.invokeMethod(NON_STATIC_ACCESS_TO_STATIC_METHOD, problemReporter, location, method, messageSend);
+ }
+ }
+
+ /** Contains patch code to support Javadoc for generated methods */
+ public static final class Javadoc {
+ private static final Method GET_HTML;
+ private static final Method PRINT_METHOD;
+
+ static {
+ Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchJavadoc");
+ GET_HTML = Util.findMethod(shadowed, "getHTMLContentFromSource", String.class, Object.class);
+ PRINT_METHOD = Util.findMethod(shadowed, "printMethod", AbstractMethodDeclaration.class, Integer.class, StringBuffer.class, TypeDeclaration.class);
+ }
+
+ public static String getHTMLContentFromSource(String original, IJavaElement member) {
+ return (String) Util.invokeMethod(GET_HTML, original, member);
+ }
+
+ public static StringBuffer printMethod(AbstractMethodDeclaration methodDeclaration, int tab, StringBuffer output, TypeDeclaration type) {
+ return (StringBuffer) Util.invokeMethod(PRINT_METHOD, methodDeclaration, tab, output, type);
+ }
}
/**
@@ -497,6 +584,10 @@ final class PatchFixesHider {
return original == -1 ? end : original;
}
+ public static int fixRetrieveStartBlockPosition(int original, int start) {
+ return original == -1 ? start : original;
+ }
+
public static int fixRetrieveRightBraceOrSemiColonPosition(int original, int end) {
// if (original == -1) {
// Thread.dumpStack();
@@ -506,21 +597,21 @@ final class PatchFixesHider {
public static int fixRetrieveRightBraceOrSemiColonPosition(int retVal, AbstractMethodDeclaration amd) {
if (retVal != -1 || amd == null) return retVal;
- boolean isGenerated = EclipseAugments.ASTNode_generatedBy.get(amd) != null;
+ boolean isGenerated = ASTNode_generatedBy.get(amd) != null;
if (isGenerated) return amd.declarationSourceEnd;
return -1;
}
public static int fixRetrieveRightBraceOrSemiColonPosition(int retVal, FieldDeclaration fd) {
if (retVal != -1 || fd == null) return retVal;
- boolean isGenerated = EclipseAugments.ASTNode_generatedBy.get(fd) != null;
+ boolean isGenerated = ASTNode_generatedBy.get(fd) != null;
if (isGenerated) return fd.declarationSourceEnd;
return -1;
}
- public static int fixRetrieveProperRightBracketPosition(int retVal, ArrayType arrayType) {
- if (retVal != -1 || arrayType == null) return retVal;
- if (isGenerated(arrayType)) return arrayType.getStartPosition() + arrayType.getLength() - 1;
+ public static int fixRetrieveProperRightBracketPosition(int retVal, Type type) {
+ if (retVal != -1 || type == null) return retVal;
+ if (isGenerated(type)) return type.getStartPosition() + type.getLength() - 1;
return -1;
}
@@ -539,13 +630,13 @@ final class PatchFixesHider {
org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode) throws Exception {
if (internalNode == null || domNode == null) return;
- boolean isGenerated = EclipseAugments.ASTNode_generatedBy.get(internalNode) != null;
+ boolean isGenerated = ASTNode_generatedBy.get(internalNode) != null;
if (isGenerated) domNode.getClass().getField("$isGenerated").set(domNode, true);
}
public static void setIsGeneratedFlagForName(org.eclipse.jdt.core.dom.Name name, Object internalNode) throws Exception {
if (internalNode instanceof org.eclipse.jdt.internal.compiler.ast.ASTNode) {
- boolean isGenerated = EclipseAugments.ASTNode_generatedBy.get((org.eclipse.jdt.internal.compiler.ast.ASTNode) internalNode) != null;
+ boolean isGenerated = ASTNode_generatedBy.get((org.eclipse.jdt.internal.compiler.ast.ASTNode) internalNode) != null;
if (isGenerated) name.getClass().getField("$isGenerated").set(name, true);
}
}
diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java
index 94cc1a45..1ca77065 100644
--- a/src/installer/lombok/installer/Installer.java
+++ b/src/installer/lombok/installer/Installer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -40,8 +40,7 @@ import lombok.core.SpiLoadUtil;
import lombok.core.Version;
import lombok.installer.OsUtils.OS;
import lombok.patcher.ClassRootFinder;
-
-import org.mangosdk.spi.ProviderFor;
+import lombok.spi.Provides;
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
@@ -105,7 +104,7 @@ public class Installer {
return a.equals(b);
}
- @ProviderFor(LombokApp.class)
+ @Provides
public static class GraphicalInstallerApp extends LombokApp {
@Override public String getAppName() {
return "installer";
@@ -124,7 +123,7 @@ public class Installer {
}
}
- @ProviderFor(LombokApp.class)
+ @Provides
public static class CommandLineInstallerApp extends LombokApp {
@Override public String getAppName() {
return "install";
@@ -139,7 +138,7 @@ public class Installer {
}
}
- @ProviderFor(LombokApp.class)
+ @Provides
public static class CommandLineUninstallerApp extends LombokApp {
@Override public String getAppName() {
return "uninstall";
diff --git a/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java b/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java
index 6d580e13..0f0aac0d 100644
--- a/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/AngularIDELocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Project Lombok Authors.
+ * Copyright (C) 2018-2021 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
@@ -23,11 +23,10 @@ package lombok.installer.eclipse;
import java.util.Collections;
-import org.mangosdk.spi.ProviderFor;
-
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class AngularIDELocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor ANGULAR = new StandardProductDescriptor(
diff --git a/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java b/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java
index fa2ce958..317c95cb 100644
--- a/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/EclipseLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class EclipseLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor ECLIPSE = new StandardProductDescriptor(
diff --git a/src/installer/lombok/installer/eclipse/JbdsLocationProvider.java b/src/installer/lombok/installer/eclipse/JbdsLocationProvider.java
index 635f304a..75805f21 100644
--- a/src/installer/lombok/installer/eclipse/JbdsLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/JbdsLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2016 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class JbdsLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor JBDS = new StandardProductDescriptor(
diff --git a/src/installer/lombok/installer/eclipse/MyEclipseLocationProvider.java b/src/installer/lombok/installer/eclipse/MyEclipseLocationProvider.java
index 298cabd6..e923202d 100644
--- a/src/installer/lombok/installer/eclipse/MyEclipseLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/MyEclipseLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Project Lombok Authors.
+ * Copyright (C) 2016-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class MyEclipseLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor MY_ECLIPSE = new StandardProductDescriptor(
diff --git a/src/installer/lombok/installer/eclipse/RhcrLocationProvider.java b/src/installer/lombok/installer/eclipse/RhcrLocationProvider.java
index d4f39f3b..0731d5bd 100644
--- a/src/installer/lombok/installer/eclipse/RhcrLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/RhcrLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Project Lombok Authors.
+ * Copyright (C) 2020-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class RhcrLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor RHCR = new StandardProductDescriptor(
"Red Hat CodeReady Studio",
diff --git a/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java
index 5e1d303d..030b96bb 100644
--- a/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/RhdsLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2016 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class RhdsLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor RHDS = new StandardProductDescriptor(
diff --git a/src/installer/lombok/installer/eclipse/STS4LocationProvider.java b/src/installer/lombok/installer/eclipse/STS4LocationProvider.java
index 47a07bdd..068ec6e9 100644
--- a/src/installer/lombok/installer/eclipse/STS4LocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/STS4LocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Project Lombok Authors.
+ * Copyright (C) 2018-2021 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
@@ -25,10 +25,9 @@ import java.util.Arrays;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class STS4LocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor STS4 = new StandardProductDescriptor("Spring Tools Suite 4",
diff --git a/src/installer/lombok/installer/eclipse/STSLocationProvider.java b/src/installer/lombok/installer/eclipse/STSLocationProvider.java
index d2efb956..7c42cf62 100644
--- a/src/installer/lombok/installer/eclipse/STSLocationProvider.java
+++ b/src/installer/lombok/installer/eclipse/STSLocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -24,10 +24,9 @@ package lombok.installer.eclipse;
import java.util.Collections;
import lombok.installer.IdeLocationProvider;
+import lombok.spi.Provides;
-import org.mangosdk.spi.ProviderFor;
-
-@ProviderFor(IdeLocationProvider.class)
+@Provides(IdeLocationProvider.class)
public class STSLocationProvider extends EclipseProductLocationProvider {
private static final EclipseProductDescriptor STS = new StandardProductDescriptor("STS",
diff --git a/src/launch/lombok/launch/Main.java b/src/launch/lombok/launch/Main.java
index 08298cc2..af65bdf8 100644
--- a/src/launch/lombok/launch/Main.java
+++ b/src/launch/lombok/launch/Main.java
@@ -34,6 +34,11 @@ class Main {
return classLoader;
}
+ static synchronized void prependClassLoader(ClassLoader loader) {
+ getShadowClassLoader();
+ classLoader.prependParent(loader);
+ }
+
public static void main(String[] args) throws Throwable {
ClassLoader cl = getShadowClassLoader();
Class<?> mc = cl.loadClass("lombok.core.Main");
diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java
index da377ae4..929681ce 100644
--- a/src/launch/lombok/launch/ShadowClassLoader.java
+++ b/src/launch/lombok/launch/ShadowClassLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2018 The Project Lombok Authors.
+ * Copyright (C) 2014-2021 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 java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -102,6 +103,14 @@ class ShadowClassLoader extends ClassLoader {
private final List<String> parentExclusion = new ArrayList<String>();
private final List<String> highlanders = new ArrayList<String>();
+ private final Set<ClassLoader> prependedParentLoaders = Collections.newSetFromMap(new IdentityHashMap<ClassLoader, Boolean>());
+
+ public void prependParent(ClassLoader loader) {
+ if (loader == null) return;
+ if (loader == getParent()) return;
+ prependedParentLoaders.add(loader);
+ }
+
/**
* @param source The 'parent' classloader.
* @param sclSuffix The suffix of the shadowed class files in our own jar. For example, if this is {@code lombok}, then the class files in your jar should be {@code foo/Bar.SCL.lombok} and not {@code foo/Bar.class}.
@@ -531,15 +540,31 @@ class ShadowClassLoader extends ClassLoader {
String fileNameOfClass = name.replace(".", "/") + ".class";
URL res = getResource_(fileNameOfClass, true);
if (res == null) {
- if (!exclusionListMatch(fileNameOfClass)) try {
- return super.loadClass(name, resolve);
- } catch (ClassNotFoundException cnfe) {
- res = getResource_("secondaryLoading.SCL." + sclSuffix + "/" + name.replace(".", "/") + ".SCL." + sclSuffix, true);
- if (res == null) throw cnfe;
+ if (!exclusionListMatch(fileNameOfClass)) {
+ try {
+ // First search in the prepended classloaders, the class might be their already
+ for (ClassLoader pre : prependedParentLoaders) {
+ try {
+ Class<?> loadClass = pre.loadClass(name);
+ if (loadClass != null) return loadClass;
+ } catch (Throwable e) {
+ continue;
+ }
+ }
+
+ return super.loadClass(name, resolve);
+ } catch (ClassNotFoundException cnfe) {
+ res = getResource_("secondaryLoading.SCL." + sclSuffix + "/" + name.replace(".", "/") + ".SCL." + sclSuffix, true);
+ if (res == null) throw cnfe;
+ }
}
}
if (res == null) throw new ClassNotFoundException(name);
+ return urlToDefineClass(name, res, resolve);
+ }
+
+ private Class<?> urlToDefineClass(String name, URL res, boolean resolve) throws ClassNotFoundException {
byte[] b;
int p = 0;
try {
diff --git a/src/spiProcessor/lombok/spi/Provides.java b/src/spiProcessor/lombok/spi/Provides.java
new file mode 100644
index 00000000..de930819
--- /dev/null
+++ b/src/spiProcessor/lombok/spi/Provides.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 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.spi;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+public @interface Provides {
+ Class<?>[] value() default {};
+}
diff --git a/src/spiProcessor/lombok/spi/SpiProcessor.java b/src/spiProcessor/lombok/spi/SpiProcessor.java
new file mode 100644
index 00000000..4ad27bbe
--- /dev/null
+++ b/src/spiProcessor/lombok/spi/SpiProcessor.java
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2021 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.spi;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeMirror;
+
+import javax.tools.Diagnostic.Kind;
+
+@SupportedAnnotationTypes("*")
+public class SpiProcessor extends AbstractProcessor {
+ private SpiProcessorCollector data;
+ private SpiProcessorPersistence persistence;
+
+ static String getRootPathOfServiceFiles() {
+ return "META-INF/services/";
+ }
+
+ @Override public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ static String toErrorMsg(Exception e, String pathName) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Exception applying SPI processor on ").append(pathName).append(": ").append(toStringLong(e));
+ return sb.toString();
+ }
+
+ private static String toStringLong(Throwable t) {
+ if (t == null) return "NULL";
+ StringBuilder out = new StringBuilder();
+
+ String msg = t.getMessage();
+ out.append(t.getClass().getName());
+ if (msg != null) out.append(": ").append(msg);
+ String indent = " ";
+
+ StackTraceElement[] elems = t.getStackTrace();
+ if (elems != null) for (int i = 0; i < elems.length; i++) {
+ out.append("\n").append(indent).append(elems[i]);
+ }
+ Throwable cause = t.getCause();
+ while (cause != null) {
+ indent = indent + " ";
+ out.append("\n").append(indent).append("Caused by: ").append(cause.getClass().getName());
+ msg = cause.getMessage();
+ if (msg != null) out.append(": ").append(msg);
+ elems = cause.getStackTrace();
+ indent = indent + " ";
+ if (elems != null) for (int i = 0; i < elems.length; i++) {
+ out.append("\n").append(indent).append(elems[i]);
+ }
+ cause = cause.getCause();
+ }
+ return out.toString();
+ }
+
+ @Override public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ persistence = new SpiProcessorPersistence("SpiProcessor", processingEnv.getFiler(), processingEnv.getMessager());
+ data = new SpiProcessorCollector(processingEnv);
+ for (String serviceName : persistence.tryFind()) data.getService(serviceName);
+ data.stripProvidersWithoutSourceFile();
+ }
+
+ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ removeStaleData(roundEnv);
+ handleAnnotations(roundEnv);
+ if (roundEnv.processingOver()) writeData();
+
+ return false;
+ }
+
+ private void writeData() {
+ for (SpiProcessorService service : data.services()) {
+ try {
+ persistence.write(service.getName(), service.toProvidersListFormat());
+ }
+ catch (IOException e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage());
+ }
+ }
+ }
+
+ private void removeStaleData(RoundEnvironment roundEnv) {
+ for (Element e : roundEnv.getRootElements()) {
+ if (e instanceof TypeElement) {
+ TypeElement currentClass = (TypeElement) e;
+ data.removeProvider(createProperQualifiedName(currentClass));
+ }
+ }
+ }
+
+ private void handleAnnotations(RoundEnvironment roundEnv) {
+ Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Provides.class);
+ for (Element e : elements) handleProvidingElement(e);
+ }
+
+ private void handleProvidingElement(Element element) {
+ if (element.getKind() != ElementKind.CLASS) {
+ report(element, "is not a class definition");
+ return;
+ }
+
+ TypeElement elem = (TypeElement) element;
+
+ Element enclosing = elem.getEnclosingElement();
+ if (enclosing != null && enclosing.getKind() == ElementKind.CLASS && !elem.getModifiers().contains(Modifier.STATIC)) {
+ report(elem, "is a non-static inner class");
+ return;
+ }
+
+ boolean hasConstructors = false;
+ boolean hasNoArgsConstructor = false;
+ for (Element child : elem.getEnclosedElements()) {
+ if (child.getKind() != ElementKind.CONSTRUCTOR) continue;
+ ExecutableElement ee = (ExecutableElement) child;
+ hasConstructors = true;
+ if (ee.getParameters().isEmpty()) {
+ hasNoArgsConstructor = true;
+ break;
+ }
+ }
+
+ if (hasConstructors && !hasNoArgsConstructor) {
+ report(elem, "has no no-args constructor");
+ return;
+ }
+
+ List<TypeMirror> spiTypes = new ArrayList<TypeMirror>();
+
+ for (AnnotationMirror annMirror : element.getAnnotationMirrors()) {
+ if (!getQualifiedTypeName(annMirror).contentEquals(Provides.class.getName())) continue;
+ for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annMirror.getElementValues().entrySet()) {
+ if (!entry.getKey().getSimpleName().contentEquals("value")) continue;
+ Object list = entry.getValue().getValue();
+ if (list instanceof TypeMirror) spiTypes.add((TypeMirror) list);
+ else if (list instanceof List<?>) {
+ for (Object tm : (List<?>) list) {
+ if (tm instanceof AnnotationValue) tm = ((AnnotationValue) tm).getValue();
+ if (tm instanceof TypeMirror) {
+ TypeMirror mirror = (TypeMirror) tm;
+ mirror = processingEnv.getTypeUtils().erasure(mirror);
+ spiTypes.add(mirror);
+ }
+ }
+ }
+ }
+ }
+
+ TypeMirror superclass = elem.getSuperclass();
+ if (spiTypes.isEmpty()) {
+ List<TypeMirror> qualifying = new ArrayList<TypeMirror>();
+ qualifying.addAll(elem.getInterfaces());
+ if (superclass != null && !toElement(superclass).getQualifiedName().contentEquals("java.lang.Object")) qualifying.add(superclass);
+
+ if (qualifying.isEmpty()) {
+ report(elem, "is marked @Provides but implements/extends nothing");
+ return;
+ }
+ if (qualifying.size() > 1) {
+ report(elem, "is marked @Provides but implements/extends multiple types; explicitly specify which interface(s) this provides for");
+ return;
+ }
+ spiTypes.add(qualifying.get(0));
+ } else {
+ Deque<TypeMirror> parentage = new ArrayDeque<TypeMirror>();
+ parentage.addAll(elem.getInterfaces());
+ parentage.add(superclass);
+ List<TypeMirror> needed = new ArrayList<TypeMirror>();
+ needed.addAll(spiTypes);
+ while (!parentage.isEmpty() && !spiTypes.isEmpty()) {
+ TypeMirror parent = parentage.pollFirst();
+ if (parent == null) continue;
+ needed.remove(parent);
+ parentage.addAll(processingEnv.getTypeUtils().directSupertypes(parent));
+ }
+ if (!needed.isEmpty()) {
+ report(elem, "is marked as providing " + needed + " but does not implement it");
+ return;
+ }
+ }
+
+ for (TypeMirror spiType : spiTypes) {
+ String spiTypeName = createProperQualifiedName(toElement(spiType));
+ String createProperQualifiedName = createProperQualifiedName(elem);
+ data.getService(spiTypeName).addProvider(createProperQualifiedName);
+ }
+ }
+
+ private Name getQualifiedTypeName(AnnotationMirror mirror) {
+ Element elem = mirror.getAnnotationType().asElement();
+ if (!(elem instanceof TypeElement)) return null;
+ return ((TypeElement) elem).getQualifiedName();
+ }
+
+ private TypeElement toElement(TypeMirror typeMirror) {
+ if (typeMirror instanceof DeclaredType) {
+ Element asElement = ((DeclaredType) typeMirror).asElement();
+ if (asElement instanceof TypeElement) return (TypeElement) asElement;
+ }
+ return null;
+ }
+
+ private void report(Element elem, String message) {
+ /* In eclipse, messages just seem to get ignored, so we throw instead. */
+ if (Boolean.TRUE) throw new RuntimeException(elem.getSimpleName() + " " + message);
+ processingEnv.getMessager().printMessage(Kind.ERROR, elem.getSimpleName() + " " + message, elem);
+ }
+
+ private String createProperQualifiedName(TypeElement provider) {
+ return processingEnv.getElementUtils().getBinaryName(provider).toString();
+ }
+}
diff --git a/src/spiProcessor/lombok/spi/SpiProcessorCollector.java b/src/spiProcessor/lombok/spi/SpiProcessorCollector.java
new file mode 100644
index 00000000..52e557f6
--- /dev/null
+++ b/src/spiProcessor/lombok/spi/SpiProcessorCollector.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2021 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.spi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+
+class SpiProcessorCollector {
+ private final Map<String, SpiProcessorService> services = new HashMap<String, SpiProcessorService>();
+ private final List<String> removed = new ArrayList<String>();
+
+ private final Elements elements;
+ private final Messager logger;
+ private final Filer filer;
+
+ SpiProcessorCollector(ProcessingEnvironment processingEnv) {
+ this.elements = processingEnv.getElementUtils();
+ this.logger = processingEnv.getMessager();
+ this.filer = processingEnv.getFiler();
+ }
+
+ SpiProcessorCollector(Elements elements, Messager logger, Filer filer) {
+ if (elements == null) throw new NullPointerException("elements");
+ if (logger == null) throw new NullPointerException("logger");
+ if (filer == null) throw new NullPointerException("filer");
+ this.elements = elements;
+ this.logger = logger;
+ this.filer = filer;
+ }
+
+ SpiProcessorService getService(String serviceName) {
+ if (serviceName == null) throw new NullPointerException("serviceName");
+ if (!services.containsKey(serviceName)) {
+ SpiProcessorService newService = new SpiProcessorService(serviceName);
+ CharSequence initialData = readInitialData(serviceName);
+ if (initialData != null) {
+ newService.addAllFromProvidersNameList(initialData.toString());
+ for (String provider : removed) newService.removeProvider(provider);
+ }
+ services.put(serviceName, newService);
+ }
+ return services.get(serviceName);
+ }
+
+ Collection<SpiProcessorService> services() {
+ return Collections.unmodifiableMap(services).values();
+ }
+
+ void removeProvider(String provider) {
+ if (provider == null) throw new NullPointerException("provider");
+ removed.add(provider);
+ for (SpiProcessorService service : services.values()) service.removeProvider(provider);
+ }
+
+ @Override public String toString() {
+ return services.values().toString();
+ }
+
+ private CharSequence readInitialData(String serviceName) {
+ String pathName = SpiProcessor.getRootPathOfServiceFiles() + serviceName;
+ FileObject resource;
+
+ try {
+ resource = filer.getResource(StandardLocation.CLASS_OUTPUT, "", pathName);
+ } catch (Exception e) {
+ logger.printMessage(Kind.ERROR, SpiProcessor.toErrorMsg(e, pathName));
+ return null;
+ }
+
+ return SpiProcessorPersistence.readFilerResource(resource, logger, pathName);
+ }
+
+ void stripProvidersWithoutSourceFile() {
+ for (SpiProcessorService s : services.values()) s.stripProvidersWithoutSourceFile(elements);
+ }
+}
diff --git a/src/spiProcessor/lombok/spi/SpiProcessorPersistence.java b/src/spiProcessor/lombok/spi/SpiProcessorPersistence.java
new file mode 100644
index 00000000..c9bd745f
--- /dev/null
+++ b/src/spiProcessor/lombok/spi/SpiProcessorPersistence.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2021 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.spi;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+
+class SpiProcessorPersistence {
+ private final String name;
+ private final String path;
+ final Filer filer;
+ private final Messager logger;
+
+ SpiProcessorPersistence(String name, Filer filer, Messager logger) {
+ this.name = name;
+ this.logger = logger;
+ this.path = SpiProcessor.getRootPathOfServiceFiles();
+ this.filer = filer;
+ }
+
+ static CharSequence readFilerResource(FileObject resource, Messager logger, String pathName) {
+ try {
+ // Eclipse can't handle getCharContent, so we must use a reader...
+ return tryWithReader(resource);
+ } catch (FileNotFoundException e) {
+ return null;
+ } catch (IOException e) {
+ if (
+ e.getClass().getName().equals("org.eclipse.core.internal.resources.ResourceException") &&
+ e.getMessage() != null &&
+ e.getMessage().endsWith("does not exist.")) {
+
+ return null;
+ }
+
+ logger.printMessage(Kind.ERROR, SpiProcessor.toErrorMsg(e, pathName));
+ return null;
+ } catch (Exception other) {
+ // otherwise, probably javac: Some versions don't support the `openReader` method.
+ try {
+ return resource.getCharContent(true);
+ } catch (FileNotFoundException e) {
+ return null;
+ } catch (IOException e) {
+ logger.printMessage(Kind.ERROR, SpiProcessor.toErrorMsg(e, pathName));
+ return null;
+ }
+ }
+ }
+
+ private static CharSequence tryWithReader(FileObject resource) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ Reader raw = resource.openReader(true);
+ try {
+ BufferedReader in = new BufferedReader(raw);
+ for (String line = in.readLine(); line != null; line = in.readLine()) sb.append(line).append('\n');
+ return sb;
+ } finally {
+ if (raw != null) raw.close();
+ }
+ }
+
+ Collection<String> tryFind() {
+ File dir = determineOutputLocation();
+ if (dir == null || !dir.isDirectory()) return Collections.emptyList();
+ List<String> out = new ArrayList<String>();
+ for (File p : dir.listFiles()) {
+ if (!p.isFile()) continue;
+ out.add(p.getName());
+ }
+ return out;
+ }
+
+ private File determineOutputLocation() {
+ FileObject resource;
+ try {
+ resource = filer.createResource(StandardLocation.CLASS_OUTPUT, "META-INF", "locator.tmp");
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ // Could happen
+ return null;
+ } catch (IOException e) {
+ e.printStackTrace();
+ logger.printMessage(Kind.NOTE, "IOException while determining output location: " + e.getMessage());
+ return null;
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ // Happens when the path is invalid. For instance absolute or relative to a path
+ // not part of the class output folder.
+ //
+ // Due to a bug in javac for Linux, this also occurs when no output path is specified
+ // for javac using the -d parameter.
+ // See http://forums.sun.com/thread.jspa?threadID=5240999&tstart=45
+ // and http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6647996
+
+ return null;
+ }
+
+ URI uri = resource.toUri();
+ return new File(new File(uri).getParentFile(), "services");
+ }
+
+ void write(String serviceName, String value) throws IOException {
+ FileObject output = filer.createResource(StandardLocation.CLASS_OUTPUT, "", path + serviceName);
+ Writer writer = output.openWriter();
+ writer.write("# Generated by " + name + "\n");
+ writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date()) + "\n");
+ writer.write(value);
+ writer.close();
+ }
+}
diff --git a/src/spiProcessor/lombok/spi/SpiProcessorService.java b/src/spiProcessor/lombok/spi/SpiProcessorService.java
new file mode 100644
index 00000000..be8d5a21
--- /dev/null
+++ b/src/spiProcessor/lombok/spi/SpiProcessorService.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2021 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.spi;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+
+import javax.lang.model.util.Elements;
+
+final class SpiProcessorService {
+ private final String name;
+ private final Set<String> providers = new TreeSet<String>();
+
+ SpiProcessorService(String name) {
+ if (name == null) throw new NullPointerException("name");
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ void addProvider(String className) {
+ if (className == null) throw new NullPointerException("className");
+ providers.add(className);
+ }
+
+ boolean removeProvider(String provider) {
+ return providers.remove(provider);
+ }
+
+ String toProvidersListFormat() {
+ return providers.stream().collect(Collectors.joining("\n"));
+ }
+
+ void addAllFromProvidersNameList(String in) {
+ for (String line : in.split("\\n")) {
+ String[] content = line.split("#", 2);
+ if (content.length == 0) continue;
+ String trimmed = content[0].trim();
+ String[] elems = trimmed.split("\\s+", 2);
+ if (elems.length == 0 || elems[0].isEmpty()) continue;
+ String cn = elems[0];
+ addProvider(cn);
+ }
+ }
+
+ void stripProvidersWithoutSourceFile(Elements elements) {
+ Iterator<String> it = providers.iterator();
+ while (it.hasNext()) {
+ if (!sourceExists(elements, it.next())) it.remove();
+ }
+ }
+
+ private boolean sourceExists(Elements elements, String typeName) {
+ return elements.getTypeElement(typeName) != null;
+ }
+
+ @Override public String toString() {
+ return name + " = " + providers;
+ }
+}
diff --git a/src/stubs/com/sun/tools/javac/code/Symbol.java b/src/stubs/com/sun/tools/javac/code/Symbol.java
index 15b04148..f389f1a8 100644
--- a/src/stubs/com/sun/tools/javac/code/Symbol.java
+++ b/src/stubs/com/sun/tools/javac/code/Symbol.java
@@ -24,6 +24,7 @@ import com.sun.tools.javac.util.Name;
public abstract class Symbol implements Element {
public Type type;
public Name name;
+ public Symbol owner;
public long flags() { return 0; }
public boolean isStatic() { return false; }
@@ -62,6 +63,7 @@ public abstract class Symbol implements Element {
public static class VarSymbol extends Symbol implements VariableElement {
public Type type;
+ public int adr;
public VarSymbol(long flags, Name name, Type type, Symbol owner) {
}
@Override public ElementKind getKind() { return null; }
diff --git a/src/stubs/com/sun/tools/javac/main/Arguments.java b/src/stubs/com/sun/tools/javac/main/Arguments.java
index ea866b6e..3d91734c 100644
--- a/src/stubs/com/sun/tools/javac/main/Arguments.java
+++ b/src/stubs/com/sun/tools/javac/main/Arguments.java
@@ -10,4 +10,7 @@ public class Arguments {
public void init(String ownName, String... argv) {}
public Map<Option, String> getDeferredFileManagerOptions() { return null; }
public boolean validate() { return false; }
+
+ // JDK15
+ public void init(String ownName, Iterable<String> args) {}
}
diff --git a/src/stubs/com/sun/tools/javac/parser/JavaTokenizer.java b/src/stubs/com/sun/tools/javac/parser/JavaTokenizer.java
index 7d5bbcb1..cde6b325 100644
--- a/src/stubs/com/sun/tools/javac/parser/JavaTokenizer.java
+++ b/src/stubs/com/sun/tools/javac/parser/JavaTokenizer.java
@@ -1,11 +1,15 @@
package com.sun.tools.javac.parser;
+import java.nio.CharBuffer;
+
import com.sun.tools.javac.parser.Tokens.Comment;
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
public class JavaTokenizer {
+ // used before java 16
protected UnicodeReader reader;
+ // used before java 16
protected JavaTokenizer(ScannerFactory fac, UnicodeReader reader) {
}
@@ -16,4 +20,17 @@ public class JavaTokenizer {
protected Comment processComment(int pos, int endPos, CommentStyle style) {
return null;
}
+
+ // used in java 16
+ protected JavaTokenizer(ScannerFactory fac, char[] buf, int inputLength) {
+ }
+
+ // used in java 16
+ protected JavaTokenizer(ScannerFactory fac, CharBuffer buf) {
+ }
+
+ // introduced in java 16
+ protected int position() {
+ return -1;
+ }
}
diff --git a/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java b/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java
index e5e48c49..f54a5988 100644
--- a/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java
+++ b/src/support/lombok/eclipseCreate/CreateEclipseDebugTarget.java
@@ -95,10 +95,12 @@ public class CreateEclipseDebugTarget {
String bootpath = getBootPath();
- launchContent.append("\t\t<listEntry value=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/bin&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;\"/>\n");
+ launchContent.append("\t\t<listEntry value=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lombok/bin/main&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;\"/>\n");
for (Map.Entry<String, String> entry : args.entrySet()) {
if (!entry.getKey().startsWith("conf.")) continue;
- String[] files = entry.getValue().split(Pattern.quote(File.pathSeparator));
+ String v = entry.getValue();
+ if (v.equals("NONE")) continue;
+ String[] files = v.split(Pattern.quote(File.pathSeparator));
for (String file : files) {
String n;
try {
@@ -128,7 +130,7 @@ public class CreateEclipseDebugTarget {
launchContent.append("\t<listAttribute key=\"org.eclipse.jdt.launching.MODULEPATH\"/>\n");
launchContent.append("\t<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"lombok\"/>\n");
if (getArgBoolean("shadowLoaderBased")) {
- launchContent.append("<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-javaagent:dist/lombok.jar -Dshadow.override.lombok=${project_loc:lombok}/bin");
+ launchContent.append("<stringAttribute key=\"org.eclipse.jdt.launching.VM_ARGUMENTS\" value=\"-javaagent:dist/lombok.jar -Dshadow.override.lombok=${project_loc:lombok}/bin/main");
for (Map.Entry<String, String> entry : args.entrySet()) {
if (!entry.getKey().startsWith("conf.")) continue;
launchContent.append(File.pathSeparator).append(entry.getValue());
diff --git a/src/utils/lombok/core/FieldAugment.java b/src/utils/lombok/core/FieldAugment.java
index 4a32ad04..0982bcb5 100644
--- a/src/utils/lombok/core/FieldAugment.java
+++ b/src/utils/lombok/core/FieldAugment.java
@@ -24,6 +24,7 @@ package lombok.core;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -69,6 +70,10 @@ public abstract class FieldAugment<T, F> {
checkNotNull(fieldType, "fieldType");
checkNotNull(name, "name");
+ if (type.isInterface()) {
+ return new InterfaceFieldAugment<T, F>(name, fieldType);
+ }
+
@SuppressWarnings("unchecked")
F defaultValue = (F) getDefaultValue(fieldType);
FieldAugment<T, F> ret = tryCreateReflectionAugment(type, fieldType, name, defaultValue);
@@ -175,6 +180,54 @@ public abstract class FieldAugment<T, F> {
*/
public abstract F compareAndSet(T object, F expected, F value);
+ private static final class InterfaceFieldAugment<T, F> extends FieldAugment<T, F> {
+ private final String name;
+ private final Class<? super F> fieldType;
+
+ private Map<Class<T>, FieldAugment<T, F>> map = new HashMap<Class<T>, FieldAugment<T,F>>();
+
+ private InterfaceFieldAugment(String name, Class<? super F> fieldType) {
+ this.name = name;
+ this.fieldType = fieldType;
+ }
+
+ private synchronized FieldAugment<T, F> getDelegate(T object) {
+ @SuppressWarnings("unchecked")
+ Class<T> c = (Class<T>) object.getClass();
+
+ FieldAugment<T,F> fieldAugment = map.get(c);
+ if (fieldAugment == null) {
+ fieldAugment = augment(c, fieldType, name);
+ map.put(c, fieldAugment);
+ }
+ return fieldAugment;
+ }
+
+ @Override public F get(T object) {
+ return getDelegate(object).get(object);
+ }
+
+ @Override public F getAndSet(T object, F value) {
+ return getDelegate(object).getAndSet(object, value);
+ }
+
+ @Override public F clear(T object) {
+ return getDelegate(object).clear(object);
+ }
+
+ @Override public F compareAndClear(T object, F expected) {
+ return getDelegate(object).compareAndClear(object, expected);
+ }
+
+ @Override public F setIfAbsent(T object, F value) {
+ return getDelegate(object).setIfAbsent(object, value);
+ }
+
+ @Override public F compareAndSet(T object, F expected, F value) {
+ return getDelegate(object).compareAndSet(object, expected, value);
+ }
+ }
+
private static class ReflectionFieldAugment<T, F> extends FieldAugment<T, F> {
private final Object lock = new Object();
private final Field field;
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java
index cda75da5..ac15f90b 100644
--- a/src/utils/lombok/eclipse/Eclipse.java
+++ b/src/utils/lombok/eclipse/Eclipse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,11 @@ public class Eclipse {
*/
public static final int ECLIPSE_DO_NOT_TOUCH_FLAG = ASTNode.Bit24;
+ /* This section includes flags that would ordinarily be in ClassFileConstants, but which are 'too new' (we don't compile against older versions of ecj/eclipse for compatibility). */
+ public static final int AccRecord = ASTNode.Bit25;
+ public static final int IsCanonicalConstructor = ASTNode.Bit10; // For record declarations, and presumably later on any constructor matching the destructor.
+ public static final int IsImplicit = ASTNode.Bit11; // the generated statements in the compact constructor of a record.
+
private static final Pattern SPLIT_AT_DOT = Pattern.compile("\\.");
private Eclipse() {
@@ -239,18 +244,14 @@ public class Eclipse {
for (Field f : CompilerOptions.class.getDeclaredFields()) {
try {
- if (f.getName().startsWith("VERSION_")) {
- String version = f.getName().substring("VERSION_".length());
- Integer versionNumber = null;
- if (version.startsWith("1_")) {
- versionNumber = Integer.parseInt(version.substring("1_".length()));
- } else if (version.length() <= 2) {
- versionNumber = Integer.parseInt(version);
- }
- if (versionNumber != null) {
- ecjCompilerVersionCached = Math.max(ecjCompilerVersionCached, versionNumber);
- }
- }
+ String fName = f.getName();
+ String versionNumber = null;
+ if (fName.startsWith("VERSION_1_")) {
+ versionNumber = fName.substring("VERSION_1_".length());
+ } else if (fName.startsWith("VERSION_")) {
+ versionNumber = fName.substring("VERSION_".length());
+ } else continue;
+ ecjCompilerVersionCached = Math.max(ecjCompilerVersionCached, Integer.parseInt(versionNumber));
} catch (Exception ignore) {}
}
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java
index cec43705..c0bda93c 100644
--- a/src/utils/lombok/javac/Javac.java
+++ b/src/utils/lombok/javac/Javac.java
@@ -75,6 +75,12 @@ public class Javac {
private static final AtomicInteger compilerVersion = new AtomicInteger(-1);
+ /* This section includes flags that would ordinarily be in Flags, but which are 'too new' (we don't compile against older versions of javac for compatibility). */
+ public static final long RECORD = 1L << 61; // ClassSymbols, MethodSymbols, VarSymbols (Marks types as being records, as well as the 'fields' in the compact declaration, and the canonical constructor)
+ public static final long COMPACT_RECORD_CONSTRUCTOR = 1L << 51; // MethodSymbols (the 'implicit' many-args constructor that records have)
+ public static final long UNINITIALIZED_FIELD = 1L << 51; // VarSymbols (To identify fields that the compact record constructor won't initialize)
+ public static final long GENERATED_MEMBER = 1L << 24; // MethodSymbols, VarSymbols (marks methods and the constructor generated in records)
+
/**
* Returns the version of this java compiler, i.e. the JDK that it shipped in. For example, for javac v1.7, this returns {@code 7}.
*/
@@ -279,8 +285,20 @@ public class Javac {
return null;
}
+ /**
+ * Checks if the javadoc comment associated with {@code tree} has a position set.
+ *
+ * Returns true if there is no javadoc comment on the node, or it has position (position isn't -1).
+ */
+ public static boolean validateDocComment(JCCompilationUnit cu, JCTree tree) {
+ Object dc = getDocComments(cu);
+ if (!instanceOfDocCommentTable(dc)) return true;
+ return JavadocOps_8.validateJavadoc(dc, tree);
+ }
+
@SuppressWarnings("unchecked")
public static void setDocComment(JCCompilationUnit cu, JCTree node, String javadoc) {
+ if (javadoc == null) return;
Object dc = getDocComments(cu);
if (dc instanceof Map) {
((Map<JCTree, String>) dc).put(node, javadoc);
@@ -301,6 +319,12 @@ public class Javac {
return javadoc.getText();
}
+ public static boolean validateJavadoc(Object dc, JCTree node) {
+ DocCommentTable dct = (DocCommentTable) dc;
+ Comment javadoc = dct.getComment(node);
+ return javadoc == null || javadoc.getText() == null || javadoc.getSourcePos(0) >= 0;
+ }
+
static void setJavadoc(Object dc, JCTree node, String javadoc) {
DocCommentTable dct = (DocCommentTable) dc;
Comment newCmt = createJavadocComment(javadoc, node);
@@ -314,7 +338,7 @@ public class Javac {
}
@Override public int getSourcePos(int index) {
- return -1;
+ return field == null ? -1 : field.getStartPosition();
}
@Override public CommentStyle getStyle() {
diff --git a/src/utils/lombok/javac/JavacTreeMaker.java b/src/utils/lombok/javac/JavacTreeMaker.java
index 15a11151..30d71606 100644
--- a/src/utils/lombok/javac/JavacTreeMaker.java
+++ b/src/utils/lombok/javac/JavacTreeMaker.java
@@ -24,6 +24,7 @@ package lombok.javac;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -106,7 +107,19 @@ public class JavacTreeMaker {
return this;
}
- private static class MethodId<J> {
+ private static final class FieldId<J> {
+ private final Class<?> owner;
+ private final String name;
+ private final Class<J> fieldType;
+
+ FieldId(Class<?> owner, String name, Class<J> fieldType) {
+ this.owner = owner;
+ this.name = name;
+ this.fieldType = fieldType;
+ }
+ }
+
+ private static final class MethodId<J> {
private final Class<?> owner;
private final String name;
private final Class<J> returnType;
@@ -332,9 +345,79 @@ public class JavacTreeMaker {
throw new InternalError("Not found: " + name);
}
- private static final Object METHOD_NOT_FOUND = new Object[0];
- private static final Object METHOD_MULTIPLE_FOUND = new Object[0];
+ static <J> FieldId<J> FieldId(Class<?> owner, String name, Class<J> fieldType) {
+ return new FieldId<J>(owner, name, fieldType);
+ }
+
+ private static final ConcurrentHashMap<FieldId<?>, Object> FIELD_CACHE = new ConcurrentHashMap<FieldId<?>, Object>();
+
+ private static boolean has(FieldId<?> f) {
+ Object field = FIELD_CACHE.get(f);
+ if (field == REFLECTIVE_ITEM_NOT_FOUND) return false;
+ if (field instanceof Field) return true;
+
+ try {
+ return getFromCache(f) != REFLECTIVE_ITEM_NOT_FOUND;
+ } catch (IllegalStateException e) {
+ return false;
+ }
+ }
+
+ private static <J> J get(Object owner, FieldId<J> f) {
+ Field field = getFromCache(f);
+ try {
+ return f.fieldType.cast(field.get(owner));
+ } catch (IllegalAccessException e) {
+ throw Javac.sneakyThrow(e);
+ }
+ }
+
+ private static <J> void set(Object owner, FieldId<J> f, J val) {
+ Field field = getFromCache(f);
+ try {
+ field.set(owner, val);
+ } catch (IllegalAccessException e) {
+ throw Javac.sneakyThrow(e);
+ } catch (IllegalArgumentException e) {
+ System.err.println("Type mismatch for: " + field);
+ throw e;
+ }
+ }
+
+ private static Field getFromCache(FieldId<?> f) {
+ Object s = FIELD_CACHE.get(f);
+ if (s == null) s = addToCache(f);
+ if (s == REFLECTIVE_ITEM_NOT_FOUND) throw new IllegalStateException("Lombok TreeMaker frontend issue: no match when looking for field: " + f);
+ return (Field) s;
+ }
+
+ private static Object addToCache(FieldId<?> f) {
+ for (Field field : f.owner.getDeclaredFields()) {
+ if (f.name.equals(field.getName())) {
+ if (!Modifier.isPublic(field.getModifiers())) field.setAccessible(true);
+ return FIELD_CACHE.putIfAbsent(f, field);
+ }
+ }
+
+ return FIELD_CACHE.putIfAbsent(f, REFLECTIVE_ITEM_NOT_FOUND);
+ }
+
+ private static final Object REFLECTIVE_ITEM_NOT_FOUND = new Object[0];
+ private static final Object REFLECTIVE_ITEM_MULTIPLE_FOUND = new Object[0];
private static final ConcurrentHashMap<MethodId<?>, Object> METHOD_CACHE = new ConcurrentHashMap<MethodId<?>, Object>();
+
+ private boolean has(MethodId<?> m) {
+ Object method = METHOD_CACHE.get(m);
+ if (method == REFLECTIVE_ITEM_NOT_FOUND) return false;
+ if (method instanceof Method) return true;
+
+ try {
+ return getFromCache(m) != REFLECTIVE_ITEM_NOT_FOUND;
+ } catch (IllegalStateException e) {
+ return false;
+ }
+ }
+
private <J> J invoke(MethodId<J> m, Object... args) {
return invokeAny(tm, m, args);
}
@@ -351,8 +434,8 @@ public class JavacTreeMaker {
} catch (IllegalAccessException e) {
throw Javac.sneakyThrow(e);
} catch (IllegalArgumentException e) {
- System.err.println(method);
- throw Javac.sneakyThrow(e);
+ System.err.println("Type mismatch for: " + method);
+ throw e;
}
}
@@ -366,8 +449,8 @@ public class JavacTreeMaker {
private static Method getFromCache(MethodId<?> m) {
Object s = METHOD_CACHE.get(m);
if (s == null) s = addToCache(m);
- if (s == METHOD_MULTIPLE_FOUND) throw new IllegalStateException("Lombok TreeMaker frontend issue: multiple matches when looking for method: " + m);
- if (s == METHOD_NOT_FOUND) throw new IllegalStateException("Lombok TreeMaker frontend issue: no match when looking for method: " + m);
+ if (s == REFLECTIVE_ITEM_MULTIPLE_FOUND) throw new IllegalStateException("Lombok TreeMaker frontend issue: multiple matches when looking for method: " + m);
+ if (s == REFLECTIVE_ITEM_NOT_FOUND) throw new IllegalStateException("Lombok TreeMaker frontend issue: no match when looking for method: " + m);
return (Method) s;
}
@@ -391,13 +474,13 @@ public class JavacTreeMaker {
}
if (found == null) found = method;
else {
- METHOD_CACHE.putIfAbsent(m, METHOD_MULTIPLE_FOUND);
- return METHOD_MULTIPLE_FOUND;
+ METHOD_CACHE.putIfAbsent(m, REFLECTIVE_ITEM_MULTIPLE_FOUND);
+ return REFLECTIVE_ITEM_MULTIPLE_FOUND;
}
}
if (found == null) {
- METHOD_CACHE.putIfAbsent(m, METHOD_NOT_FOUND);
- return METHOD_NOT_FOUND;
+ METHOD_CACHE.putIfAbsent(m, REFLECTIVE_ITEM_NOT_FOUND);
+ return REFLECTIVE_ITEM_NOT_FOUND;
}
Permit.setAccessible(found);
Object marker = METHOD_CACHE.putIfAbsent(m, found);
@@ -431,8 +514,12 @@ public class JavacTreeMaker {
//javac versions: 8
private static final MethodId<JCMethodDecl> MethodDefWithRecvParam = MethodId("MethodDef", JCMethodDecl.class, JCModifiers.class, Name.class, JCExpression.class, List.class, JCVariableDecl.class, List.class, List.class, JCBlock.class, JCExpression.class);
- public JCMethodDecl MethodDef(JCModifiers mods, Name name, JCExpression resType, List<JCTypeParameter> typarams, JCVariableDecl recvparam, List<JCVariableDecl> params, List<JCExpression> thrown, JCBlock body, JCExpression defaultValue) {
- return invoke(MethodDefWithRecvParam, mods, name, resType, recvparam, typarams, params, thrown, body, defaultValue);
+ public boolean hasMethodDefWithRecvParam() {
+ return has(MethodDefWithRecvParam);
+ }
+
+ public JCMethodDecl MethodDefWithRecvParam(JCModifiers mods, Name name, JCExpression resType, List<JCTypeParameter> typarams, JCVariableDecl recvparam, List<JCVariableDecl> params, List<JCExpression> thrown, JCBlock body, JCExpression defaultValue) {
+ return invoke(MethodDefWithRecvParam, mods, name, resType, typarams, recvparam, params, thrown, body, defaultValue);
}
//javac versions: 6-8
@@ -878,4 +965,18 @@ public class JavacTreeMaker {
public JCExpression Type(Type type) {
return invoke(Type, type);
}
+
+ private static final FieldId<JCVariableDecl> MethodDecl_recvParam = FieldId(JCMethodDecl.class, "recvparam", JCVariableDecl.class);
+ //javac versions: 8+
+ public boolean hasReceiverParameter() {
+ return has(MethodDecl_recvParam);
+ }
+
+ public JCVariableDecl getReceiverParameter(JCMethodDecl method) {
+ return get(method, MethodDecl_recvParam);
+ }
+
+ public void setReceiverParameter(JCMethodDecl method, JCVariableDecl param) {
+ set(method, MethodDecl_recvParam, param);
+ }
} \ No newline at end of file
diff --git a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
index cb0d2e12..f29f501b 100644
--- a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
+++ b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2019 The Project Lombok Authors.
+ * Copyright (C) 2011-2021 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
@@ -72,18 +72,31 @@ public class CommentCollectingScannerFactory extends ScannerFactory {
super(context);
}
+ @SuppressWarnings("all")
@Override
public Scanner newScanner(CharSequence input, boolean keepDocComments) {
- if (input instanceof CharBuffer) {
- CharBuffer buf = (CharBuffer) input;
- return new CommentCollectingScanner(this, new CommentCollectingTokenizer(this, buf, findTextBlocks));
+ char[] array;
+ int limit;
+ if (input instanceof CharBuffer && ((CharBuffer) input).hasArray()) {
+ CharBuffer cb = (CharBuffer) input;
+ cb.compact().flip();
+ array = cb.array();
+ limit = cb.limit();
+ } else {
+ array = input.toString().toCharArray();
+ limit = array.length;
+ }
+ if (array.length == limit) {
+ // work around a bug where the last comment in a file falls away in this case.
+ char[] d = new char[limit + 1];
+ System.arraycopy(array, 0, d, 0, limit);
+ array = d;
}
- char[] array = input.toString().toCharArray();
- return newScanner(array, array.length, keepDocComments);
+ return newScanner(array, limit, keepDocComments);
}
@Override
public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
- return new CommentCollectingScanner(this, new CommentCollectingTokenizer(this, input, inputLength, findTextBlocks));
+ return new CommentCollectingScanner(this, CommentCollectingTokenizer.create(this, input, inputLength, findTextBlocks));
}
}
diff --git a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
index d7b1d569..4a31fc81 100644
--- a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
+++ b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2020 The Project Lombok Authors.
+ * Copyright (C) 2013-2021 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
@@ -23,36 +23,51 @@ package lombok.javac.java8;
import java.nio.CharBuffer;
-import lombok.javac.CommentInfo;
-import lombok.javac.CommentInfo.EndConnection;
-import lombok.javac.CommentInfo.StartConnection;
-
import com.sun.tools.javac.parser.JavaTokenizer;
import com.sun.tools.javac.parser.ScannerFactory;
import com.sun.tools.javac.parser.Tokens.Comment;
-import com.sun.tools.javac.parser.Tokens.Token;
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
+import com.sun.tools.javac.parser.Tokens.Token;
import com.sun.tools.javac.parser.UnicodeReader;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
+import lombok.javac.CommentInfo;
+import lombok.javac.CommentInfo.EndConnection;
+import lombok.javac.CommentInfo.StartConnection;
+
class CommentCollectingTokenizer extends JavaTokenizer {
+
+ private static final boolean tokenizerIsUnicodeReader = JavaTokenizer.class.getSuperclass().getSimpleName().equals("UnicodeReader");
+
private int prevEndPosition = 0;
private final ListBuffer<CommentInfo> comments = new ListBuffer<CommentInfo>();
private final ListBuffer<Integer> textBlockStarts;
private int endComment = 0;
- CommentCollectingTokenizer(ScannerFactory fac, char[] buf, int inputLength, boolean findTextBlocks) {
+ static CommentCollectingTokenizer create(ScannerFactory fac, char[] buf, int inputLength, boolean findTextBlocks) {
+ if (tokenizerIsUnicodeReader) {
+ return new CommentCollectingTokenizer(fac, buf, inputLength, findTextBlocks, true);
+ }
+ return new CommentCollectingTokenizer(fac, buf, inputLength, findTextBlocks);
+ }
+
+ // pre java 16
+ private CommentCollectingTokenizer(ScannerFactory fac, char[] buf, int inputLength, boolean findTextBlocks) {
super(fac, new PositionUnicodeReader(fac, buf, inputLength));
textBlockStarts = findTextBlocks ? new ListBuffer<Integer>() : null;
}
- CommentCollectingTokenizer(ScannerFactory fac, CharBuffer buf, boolean findTextBlocks) {
- super(fac, new PositionUnicodeReader(fac, buf));
+ // from java 16
+ private CommentCollectingTokenizer(ScannerFactory fac, char[] buf, int inputLength, boolean findTextBlocks, boolean java16Signature) {
+ super(fac, buf, inputLength);
textBlockStarts = findTextBlocks ? new ListBuffer<Integer>() : null;
}
int pos() {
+ if (tokenizerIsUnicodeReader) {
+ return position();
+ }
return ((PositionUnicodeReader) reader).pos();
}
@@ -60,8 +75,8 @@ class CommentCollectingTokenizer extends JavaTokenizer {
Token token = super.readToken();
prevEndPosition = pos();
if (textBlockStarts != null && (prevEndPosition - token.pos > 5) && token.getClass().getName().endsWith("$StringToken")) {
- char[] start = reader.getRawCharacters(token.pos, token.pos + 3);
- if (start[0] == '"' && start[1] == '"' && start[2] == '"') textBlockStarts.add(token.pos);
+ char[] start = reader().getRawCharacters(token.pos, token.pos + 3);
+ if (start[0] == '"' && start[1] == '"' && start[2] == '"') textBlockStarts.append(token.pos);
}
return token;
}
@@ -70,7 +85,7 @@ class CommentCollectingTokenizer extends JavaTokenizer {
protected Comment processComment(int pos, int endPos, CommentStyle style) {
int prevEndPos = Math.max(prevEndPosition, endComment);
endComment = endPos;
- String content = new String(reader.getRawCharacters(pos, endPos));
+ String content = new String(reader().getRawCharacters(pos, endPos));
StartConnection start = determineStartConnection(prevEndPos, pos);
EndConnection end = determineEndConnection(endPos);
@@ -85,7 +100,7 @@ class CommentCollectingTokenizer extends JavaTokenizer {
for (int i = pos;; i++) {
char c;
try {
- c = reader.getRawCharacters(i, i + 1)[0];
+ c = reader().getRawCharacters(i, i + 1)[0];
} catch (IndexOutOfBoundsException e) {
c = '\n';
}
@@ -104,7 +119,7 @@ class CommentCollectingTokenizer extends JavaTokenizer {
if (from == to) {
return StartConnection.DIRECT_AFTER_PREVIOUS;
}
- char[] between = reader.getRawCharacters(from, to);
+ char[] between = reader().getRawCharacters(from, to);
if (isNewLine(between[between.length - 1])) {
return StartConnection.START_OF_LINE;
}
@@ -128,6 +143,13 @@ class CommentCollectingTokenizer extends JavaTokenizer {
return textBlockStarts == null ? List.<Integer>nil() : textBlockStarts.toList();
}
+ private UnicodeReader reader() {
+ if (tokenizerIsUnicodeReader) {
+ return (UnicodeReader) (Object) this;
+ }
+ return reader;
+ }
+
static class PositionUnicodeReader extends UnicodeReader {
protected PositionUnicodeReader(ScannerFactory sf, char[] input, int inputLength) {
super(sf, input, inputLength);
diff --git a/src/utils/lombok/permit/Permit.java b/src/utils/lombok/permit/Permit.java
index 407c3922..2854706e 100644
--- a/src/utils/lombok/permit/Permit.java
+++ b/src/utils/lombok/permit/Permit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018-20199 The Project Lombok Authors.
+ * Copyright (C) 2018-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
@@ -24,8 +24,17 @@ package lombok.permit;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.URL;
+import javax.tools.JavaFileManager;
+
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+
+import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.util.List;
@@ -113,6 +122,14 @@ public class Permit {
return setAccessible(m);
}
+ public static Method permissiveGetMethod(Class<?> c, String mName, Class<?>... parameterTypes) {
+ try {
+ return getMethod(c, mName, parameterTypes);
+ } catch (Exception ignore) {
+ return null;
+ }
+ }
+
public static Field getField(Class<?> c, String fName) throws NoSuchFieldException {
Field f = null;
Class<?> oc = c;
@@ -158,4 +175,175 @@ public class Permit {
return null;
}
}
+
+ public static boolean isDebugReflection() {
+ return !"false".equals(System.getProperty("lombok.debug.reflection", "false"));
+ }
+
+ public static void handleReflectionDebug(Throwable t, Throwable initError) {
+ if (!isDebugReflection()) return;
+
+ System.err.println("** LOMBOK REFLECTION exception: " + t.getClass() + ": " + (t.getMessage() == null ? "(no message)" : t.getMessage()));
+ t.printStackTrace(System.err);
+ if (initError != null) {
+ System.err.println("*** ADDITIONALLY, exception occurred setting up reflection: ");
+ initError.printStackTrace(System.err);
+ }
+ }
+
+ public static Object invoke(Method m, Object receiver, Object... args) throws IllegalAccessException, InvocationTargetException {
+ return invoke(null, m, receiver, args);
+ }
+
+ public static Object invoke(Throwable initError, Method m, Object receiver, Object... args) throws IllegalAccessException, InvocationTargetException {
+ try {
+ return m.invoke(receiver, args);
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ }
+ }
+
+ public static Object invokeSneaky(Method m, Object receiver, Object... args) {
+ return invokeSneaky(null, m, receiver, args);
+ }
+
+ public static Object invokeSneaky(Throwable initError, Method m, Object receiver, Object... args) {
+ try {
+ return m.invoke(receiver, args);
+ } catch (NoClassDefFoundError e) {
+ handleReflectionDebug(e, initError);
+ //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
+ //do anything useful here.
+ return null;
+ } catch (NullPointerException e) {
+ handleReflectionDebug(e, initError);
+ //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
+ //do anything useful here.
+ return null;
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, initError);
+ throw sneakyThrow(e);
+ } catch (InvocationTargetException e) {
+ throw sneakyThrow(e.getCause());
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ }
+ }
+
+ public static <T> T newInstance(Constructor<T> c, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
+ return newInstance(null, c, args);
+ }
+
+ public static <T> T newInstance(Throwable initError, Constructor<T> c, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
+ try {
+ return c.newInstance(args);
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (InstantiationException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ }
+ }
+
+ public static <T> T newInstanceSneaky(Constructor<T> c, Object... args) {
+ return newInstanceSneaky(null, c, args);
+ }
+
+ public static <T> T newInstanceSneaky(Throwable initError, Constructor<T> c, Object... args) {
+ try {
+ return c.newInstance(args);
+ } catch (NoClassDefFoundError e) {
+ handleReflectionDebug(e, initError);
+ //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
+ //do anything useful here.
+ return null;
+ } catch (NullPointerException e) {
+ handleReflectionDebug(e, initError);
+ //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly
+ //do anything useful here.
+ return null;
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, initError);
+ throw sneakyThrow(e);
+ } catch (InstantiationException e) {
+ handleReflectionDebug(e, initError);
+ throw sneakyThrow(e);
+ } catch (InvocationTargetException e) {
+ throw sneakyThrow(e.getCause());
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, initError);
+ throw e;
+ }
+ }
+
+ public static Object get(Field f, Object receiver) throws IllegalAccessException {
+ try {
+ return f.get(receiver);
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ }
+ }
+
+ public static void set(Field f, Object receiver, Object newValue) throws IllegalAccessException {
+ try {
+ f.set(receiver, newValue);
+ } catch (IllegalAccessException e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ } catch (RuntimeException e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ } catch (Error e) {
+ handleReflectionDebug(e, null);
+ throw e;
+ }
+ }
+
+ public static void reportReflectionProblem(Throwable initError, String msg) {
+ if (!isDebugReflection()) return;
+ System.err.println("** LOMBOK REFLECTION issue: " + msg);
+ if (initError != null) {
+ System.err.println("*** ADDITIONALLY, exception occurred setting up reflection: ");
+ initError.printStackTrace(System.err);
+ }
+ }
+
+ public static RuntimeException sneakyThrow(Throwable t) {
+ if (t == null) throw new NullPointerException("t");
+ return Permit.<RuntimeException>sneakyThrow0(t);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T extends Throwable> T sneakyThrow0(Throwable t) throws T {
+ throw (T)t;
+ }
+
}
diff --git a/src/utils/lombok/permit/dummy/Child.java b/src/utils/lombok/permit/dummy/Child.java
new file mode 100644
index 00000000..c189ee37
--- /dev/null
+++ b/src/utils/lombok/permit/dummy/Child.java
@@ -0,0 +1,9 @@
+package lombok.permit.dummy;
+
+@SuppressWarnings("all")
+public abstract class Child extends Parent {
+ private transient volatile boolean foo;
+ private transient volatile Object[] bar;
+ private transient volatile Object baz;
+
+}
diff --git a/src/utils/lombok/permit/dummy/GrandChild.java b/src/utils/lombok/permit/dummy/GrandChild.java
new file mode 100644
index 00000000..ef182aa7
--- /dev/null
+++ b/src/utils/lombok/permit/dummy/GrandChild.java
@@ -0,0 +1,19 @@
+package lombok.permit.dummy;
+
+@SuppressWarnings("all")
+public final class GrandChild extends Child {
+ private Class<?> a;
+ private int b;
+ private String c;
+ private Class<?> d;
+ private Class<?>[] e;
+ private Class<?>[] f;
+ private int g;
+ private transient String h;
+ private transient Object i;
+ private byte[] j;
+ private byte[] k;
+ private byte[] l;
+ private volatile Object m;
+ private Object n;
+}
diff --git a/src/utils/lombok/permit/dummy/Parent.java b/src/utils/lombok/permit/dummy/Parent.java
new file mode 100644
index 00000000..33928aeb
--- /dev/null
+++ b/src/utils/lombok/permit/dummy/Parent.java
@@ -0,0 +1,12 @@
+package lombok.permit.dummy;
+
+import java.io.OutputStream;
+
+@SuppressWarnings("all")
+public class Parent {
+ boolean first;
+ static final Object staticObj = OutputStream.class;
+ volatile Object second;
+ private static volatile boolean staticSecond;
+ private static volatile boolean staticThird;
+}
diff --git a/src/utils/lombok/permit/dummy/package-info.java b/src/utils/lombok/permit/dummy/package-info.java
new file mode 100644
index 00000000..87ca839a
--- /dev/null
+++ b/src/utils/lombok/permit/dummy/package-info.java
@@ -0,0 +1,8 @@
+/**
+ * This package recreates the type hierarchy of {@code java.lang.reflect.AccessibleObject} and friends (such as {@code java.lang.reflect.Method});
+ * its purpose is to allow us to ask {@code sun.misc.internal.Unsafe} about the exact offset of the {@code override} field of {@code AccessibleObject};
+ * asking about that field directly doesn't work after jdk14, presumably because the fields of AO are expressly hidden somehow.
+ *
+ * NB: It's usually 12, on the vast majority of OS, VM, and architecture combos.
+ */
+package lombok.permit.dummy;
diff --git a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
index 335455fd..7aef0d51 100644
--- a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
+++ b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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,7 +56,7 @@ public class TestClassFileMetaData {
public void testGetClassName() {
assertTrue(foo.containsUtf8("Foo"));
assertEquals("Foo", foo.getClassName());
-
+
assertTrue(bar.containsUtf8("Bar"));
assertEquals("Bar", bar.getClassName());
@@ -68,15 +68,13 @@ public class TestClassFileMetaData {
public void testGetSuperClassName() {
assertTrue(foo.containsUtf8("java/lang/Object"));
assertEquals("java/lang/Object", foo.getSuperClassName());
-
+
assertEquals("java/lang/Object", bar.getSuperClassName());
assertEquals("java/lang/Object", baz.getSuperClassName());
assertEquals("java/util/ArrayList", buux.getSuperClassName());
}
-
-
@Test
public void testUsesClass() {
assertTrue(foo.usesClass("java/lang/System"));
@@ -185,6 +183,22 @@ public class TestClassFileMetaData {
static byte[] compile(File file) {
try {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ if (compiler == null) {
+ // The 'auto-find my compiler' code in java6 works because it hard-codes `c.s.t.j.a.JavacTool`, which we put on the classpath.
+ // On java8, it fails, because it looks for tools.jar, which won't be there.
+ // on J11+ place it succeeds again, as we run those on the real JDKs.
+
+ // Thus, let's try this, in cae we're on java 8:
+
+ try {
+ compiler = (JavaCompiler) Class.forName("com.sun.tools.javac.api.JavacTool").getConstructor().newInstance();
+ } catch (Exception e) {
+ compiler = null;
+ }
+ }
+
+ if (compiler == null) throw new RuntimeException("No javac tool is available in this distribution. Using an old JRE perhaps?");
+
File tempDir = getTempDir();
tempDir.mkdirs();
List<String> options = Arrays.asList("-proc:none", "-d", tempDir.getAbsolutePath());
@@ -199,7 +213,7 @@ public class TestClassFileMetaData {
CompilationTask task = compiler.getTask(captureWarnings, null, diagnostics, options, null, Collections.singleton(new ContentBasedJavaFileObject(file.getPath(), readFileAsString(file))));
Boolean taskResult = task.call();
- assertTrue("Compilation task didn't succeed: \n<Warnings and Errors>\n" + compilerErrors.toString() + "\n</Warnings and Errors>", taskResult);
+ assertTrue("Compilation task didn't succeed: \n<Warnings and Errors>\n" + compilerErrors.toString() + "\n" + captureWarnings.toString() + "\n</Warnings and Errors>", taskResult);
return PostCompilerApp.readFile(new File(tempDir, file.getName().replaceAll("\\.java$", ".class")));
} catch (Exception e) {
throw Lombok.sneakyThrow(e);
diff --git a/test/configuration/src/lombok/core/configuration/TestConfiguration.java b/test/configuration/src/lombok/core/configuration/TestConfiguration.java
index 504c36b2..ebb556de 100644
--- a/test/configuration/src/lombok/core/configuration/TestConfiguration.java
+++ b/test/configuration/src/lombok/core/configuration/TestConfiguration.java
@@ -65,8 +65,8 @@ public class TestConfiguration {
outStream.flush();
errStream.flush();
- String out = new String(rawOut.toByteArray()).replace('\\', '/').replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
- String err = new String(rawErr.toByteArray()).replace('\\', '/').replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
+ String out = new String(rawOut.toByteArray()).replace('\\', '/').replace("\r", "").replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
+ String err = new String(rawErr.toByteArray()).replace('\\', '/').replace("\r", "").replaceAll(Pattern.quote(normalizedName) + "|" + Pattern.quote(baseName), "BASE/").trim();
checkContent(directory, out, "out");
checkContent(directory, err, "err");
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 448f77ab..51ec41c5 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -48,6 +48,7 @@ import lombok.core.configuration.ConfigurationResolver;
import lombok.core.configuration.ConfigurationResolverFactory;
import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
import lombok.transform.TestLombokFilesIdempotent;
+import lombok.transform.TestSourceFiles;
public abstract class AbstractRunTests {
private final File dumpActualFilesHere;
@@ -91,7 +92,9 @@ public abstract class AbstractRunTests {
}
});
- boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences(), sourceDirectives_.minVersion());
+ boolean checkPositions = !(params instanceof TestLombokFilesIdempotent || params instanceof TestSourceFiles) && !sourceDirectives_.isSkipCompareContent();
+
+ boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences(), sourceDirectives_.minVersion(), checkPositions);
boolean forceUnchanged = sourceDirectives_.forceUnchanged() || sourceDirectives_.isSkipCompareContent();
if (params.expectChanges() && !forceUnchanged && !changed) messages.add(new CompilerMessage(-1, -1, true, "not flagged modified"));
if (!params.expectChanges() && changed) messages.add(new CompilerMessage(-1, -1, true, "unexpected modification"));
@@ -101,7 +104,7 @@ public abstract class AbstractRunTests {
};
}
- protected abstract boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion) throws Throwable;
+ protected abstract boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion, boolean checkPositions) throws Throwable;
protected String readFile(File file) throws IOException {
BufferedReader reader;
diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java
index a174355d..b041c42e 100644
--- a/test/core/src/lombok/DirectoryRunner.java
+++ b/test/core/src/lombok/DirectoryRunner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2020 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -78,6 +78,9 @@ public class DirectoryRunner extends Runner {
}
public abstract boolean expectChanges();
+ public String testNamePrefix() {
+ return "";
+ }
}
private static final FileFilter JAVA_FILE_FILTER = new FileFilter() {
@@ -114,8 +117,7 @@ public class DirectoryRunner extends Runner {
Throwable error = null;
try {
addTests(testClass);
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
error = t;
}
this.failure = error;
@@ -124,7 +126,7 @@ public class DirectoryRunner extends Runner {
private void addTests(Class<?> testClass) throws Exception {
for (File file : params.getBeforeDirectory().listFiles(JAVA_FILE_FILTER)) {
if (!params.accept(file)) continue;
- Description testDescription = Description.createTestDescription(testClass, file.getName());
+ Description testDescription = Description.createTestDescription(testClass, this.params.testNamePrefix() + file.getName());
description.addChild(testDescription);
tests.put(file.getName(), testDescription);
}
@@ -180,7 +182,8 @@ public class DirectoryRunner extends Runner {
case DELOMBOK:
return new RunTestsViaDelombok().createTester(params, file, "javac", params.getVersion());
case ECJ:
- return new RunTestsViaEcj().createTester(params, file, "ecj", params.getVersion());
+ String platform = RunTestsViaEcj.eclipseAvailable() ? "eclipse" : "ecj";
+ return new RunTestsViaEcj().createTester(params, file, platform, params.getVersion());
default:
case JAVAC:
throw new UnsupportedOperationException();
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index 57a32333..0326dee9 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -65,8 +65,20 @@ public class LombokTestSource {
public boolean runOnPlatform(String platform) {
if (platforms == null || platforms.isEmpty()) return true;
- for (String pl : platforms) if (pl.equalsIgnoreCase(platform)) return true;
- return false;
+ int inclusiveCount = 0;
+ for (String pl : platforms) {
+ if (pl.startsWith("!")) continue;
+ inclusiveCount++;
+ if (pl.equalsIgnoreCase(platform)) return true;
+ }
+ if (inclusiveCount == platforms.size()) {
+ return false;
+ }
+ for (String pl : platforms) {
+ if (!pl.startsWith("!")) continue;
+ if (pl.regionMatches(true, 1, platform, 0, platform.length())) return false;
+ }
+ return true;
}
public boolean versionWithinLimit(int version) {
@@ -113,10 +125,10 @@ public class LombokTestSource {
return formatPreferences;
}
- private static final Pattern VERSION_STYLE_1 = Pattern.compile("^(\\d+)$");
- private static final Pattern VERSION_STYLE_2 = Pattern.compile("^\\:(\\d+)$");
- private static final Pattern VERSION_STYLE_3 = Pattern.compile("^(\\d+):$");
- private static final Pattern VERSION_STYLE_4 = Pattern.compile("^(\\d+):(\\d+)$");
+ private static final Pattern VERSION_STYLE_1 = Pattern.compile("^(\\d+)(?:\\s+.*)?$");
+ private static final Pattern VERSION_STYLE_2 = Pattern.compile("^\\:(\\d+)(?:\\s+.*)?$");
+ private static final Pattern VERSION_STYLE_3 = Pattern.compile("^(\\d+):(?:\\s+.*)?$");
+ private static final Pattern VERSION_STYLE_4 = Pattern.compile("^(\\d+):(\\d+)(?:\\s+.*)?$");
private int[] parseVersionLimit(String spec) {
/* Single version: '5' */ {
@@ -362,4 +374,8 @@ public class LombokTestSource {
public int minVersion() {
return Math.max(6, versionLowerLimit);
}
+
+ public int maxVersion() {
+ return versionUpperLimit;
+ }
}
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index ffac8372..13acdf55 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2014 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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,24 +21,53 @@
*/
package lombok;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayDeque;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.tree.JCTree.JCAnnotation;
+import com.sun.tools.javac.tree.JCTree.JCAssign;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCModifiers;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.JCTree.TypeBoundKind;
import lombok.delombok.Delombok;
import lombok.javac.CapturingDiagnosticListener;
+import lombok.javac.Javac;
import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
@Override
- public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences, int version) throws Throwable {
+ public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences, int version, boolean checkPositions) throws Throwable {
delombok.setVerbose(true);
ChangedChecker cc = new ChangedChecker();
delombok.setFeedback(cc.feedback);
@@ -48,6 +77,8 @@ public class RunTestsViaDelombok extends AbstractRunTests {
delombok.setDiagnosticsListener(new CapturingDiagnosticListener(file, messages));
+ if (checkPositions) delombok.addAdditionalAnnotationProcessor(new ValidatePositionProcessor(version));
+
delombok.addFile(file.getAbsoluteFile().getParentFile(), file.getName());
delombok.setSourcepath(file.getAbsoluteFile().getParent());
String bcp = System.getProperty("delombok.bootclasspath");
@@ -63,6 +94,128 @@ public class RunTestsViaDelombok extends AbstractRunTests {
}
}
+ public static class ValidatePositionProcessor extends TreeProcessor {
+ private final int version;
+
+ public ValidatePositionProcessor(int version) {
+ this.version = version;
+ }
+
+ private String craftFailMsg(String problematicNode, Deque<JCTree> astContext) {
+ StringBuilder msg = new StringBuilder(problematicNode).append(" position of node not set: ");
+ for (JCTree t : astContext) {
+ msg.append("\n ").append(t.getClass().getSimpleName());
+ String asStr = t.toString();
+ if (asStr.length() < 80) msg.append(": ").append(asStr);
+ else if (t instanceof JCClassDecl) msg.append(": ").append(((JCClassDecl) t).name);
+ else if (t instanceof JCMethodDecl) msg.append(": ").append(((JCMethodDecl) t).name);
+ else if (t instanceof JCVariableDecl) msg.append(": ").append(((JCVariableDecl) t).name);
+ }
+ return msg.append("\n-------").toString();
+ }
+
+ @Override void processCompilationUnit(final JCCompilationUnit unit) {
+ final Deque<JCTree> astContext = new ArrayDeque<JCTree>();
+ unit.accept(new TreeScanner() {
+ @Override public void scan(JCTree tree) {
+ if (tree == null) return;
+ if (tree instanceof JCMethodDecl && (((JCMethodDecl) tree).mods.flags & Flags.GENERATEDCONSTR) != 0) return;
+ try {
+ if (tree instanceof JCModifiers) return;
+
+ if (!Javac.validateDocComment(unit, tree)) {
+ fail("Start position of doc comment (" + Javac.getDocComment(unit, tree) + ") of " + tree + " not set");
+ }
+
+ boolean check = true;
+ if (version < 8 && tree instanceof TypeBoundKind) {
+ // TypeBoundKind works differently in java6, and as a consequence,
+ // the position is not set properly.
+ // Given status of j6/j7, not worth properly testing.
+ check = false;
+ }
+ if (version < 8 && tree instanceof JCIdent) {
+ // explicit `super()` invocations do not appear to have end pos in j6/7.
+ if ("super".equals("" + ((JCIdent) tree).name)) check = false;
+ }
+
+ if (check && tree.pos == -1) fail(craftFailMsg("Start", astContext));
+ if (check && Javac.getEndPosition(tree, unit) == -1) {
+ fail(craftFailMsg("End", astContext));
+ }
+ } finally {
+ astContext.push(tree);
+ super.scan(tree);
+ astContext.pop();
+ }
+ }
+
+ @Override public void visitMethodDef(JCMethodDecl tree) {
+ super.visitMethodDef(tree);
+ }
+
+ @Override public void visitVarDef(JCVariableDecl tree) {
+ if ((tree.mods.flags & Flags.ENUM) != 0) return;
+ super.visitVarDef(tree);
+ }
+
+ @Override public void visitAnnotation(JCAnnotation tree) {
+ scan(tree.annotationType);
+ // Javac parser maps @Annotation("val") to @Annotation(value = "val") but does not add an end position for the new JCIdent...
+ if (tree.args.length() == 1 && tree.args.head instanceof JCAssign && ((JCIdent)((JCAssign) tree.args.head).lhs).name.toString().equals("value")) {
+ scan(((JCAssign) tree.args.head).rhs);
+ } else {
+ scan(tree.args);
+ }
+ }
+ });
+ }
+ }
+
+ public static abstract class TreeProcessor extends AbstractProcessor {
+ private Trees trees;
+ @Override public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ trees = Trees.instance(processingEnv);
+ }
+
+ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ for (Element element : roundEnv.getRootElements()) {
+ JCCompilationUnit unit = toUnit(element);
+ if (unit != null) {
+ processCompilationUnit(unit);
+ }
+ }
+ return false;
+ }
+
+ abstract void processCompilationUnit(JCCompilationUnit unit);
+
+ @Override public Set<String> getSupportedAnnotationTypes() {
+ return Collections.singleton("*");
+ }
+
+ @Override public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ private JCCompilationUnit toUnit(Element 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();
+ }
+ }
+
static class ChangedChecker {
private final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
private final PrintStream feedback;
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index 7f4c2a0f..1c2be160 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2020 The Project Lombok Authors.
+ * Copyright (C) 2010-2021 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
@@ -23,26 +23,29 @@ package lombok;
import java.io.File;
import java.io.StringWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import lombok.eclipse.Eclipse;
import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
+import org.eclipse.core.internal.registry.ExtensionRegistry;
+import org.eclipse.core.internal.runtime.Activator;
+import org.eclipse.core.internal.runtime.PlatformActivator;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.core.runtime.spi.IRegistryProvider;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -54,6 +57,9 @@ import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
public class RunTestsViaEcj extends AbstractRunTests {
protected CompilerOptions ecjCompilerOptions() {
@@ -77,6 +83,8 @@ public class RunTestsViaEcj extends AbstractRunTests {
warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore");
warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore");
warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore");
+ warnings.put(CompilerOptions.OPTION_ReportIndirectStaticAccess, "warning");
+ warnings.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, "warning");
warnings.put("org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures", "enabled");
warnings.put("org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures", "ignore");
int ecjVersion = Eclipse.getEcjCompilerVersion();
@@ -103,7 +111,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
@Override
- public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion) throws Throwable {
+ public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion, boolean checkPositions) throws Throwable {
final AtomicReference<CompilationResult> compilationResult_ = new AtomicReference<CompilationResult>();
final AtomicReference<CompilationUnitDeclaration> compilationUnit_ = new AtomicReference<CompilationUnitDeclaration>();
ICompilerRequestor bitbucketRequestor = new ICompilerRequestor() {
@@ -114,7 +122,17 @@ public class RunTestsViaEcj extends AbstractRunTests {
String source = readFile(file);
char[] sourceArray = source.toCharArray();
- final org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit = new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(sourceArray, file.getName(), encoding == null ? "UTF-8" : encoding);
+ final ICompilationUnit sourceUnit;
+ try {
+ if (eclipseAvailable()) {
+ sourceUnit = new TestCompilationUnitEclipse(file.getName(), source);
+ } else {
+ sourceUnit = new TestCompilationUnitEcj(file.getName(), source);
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ return false;
+ }
Compiler ecjCompiler = new Compiler(createFileSystem(file, minVersion), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) {
@Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) {
@@ -123,6 +141,8 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
};
+ // initializeEclipseBundles();
+
ecjCompiler.compile(new ICompilationUnit[] {sourceUnit});
CompilationResult compilationResult = compilationResult_.get();
@@ -144,7 +164,37 @@ public class RunTestsViaEcj extends AbstractRunTests {
return true;
}
- private boolean eclipseAvailable() {
+ @SuppressWarnings("unused")
+ private static class EclipseInitializer {
+ static void initializeEclipseBundles() throws Exception {
+ // This code does not work yet, it's research-in-progress.
+ // The problem is that parts of the eclipse handler (in `PatchValEclipse` and friends) do not work unless
+ // an actual eclipse exists; PatchVal causes code to run that will end up running `ResourcesPlugin.getWorkspace()`, which
+ // goes down a rabbit hole of pinging off of various static fields (or `getX()` calls which return static fields), all
+ // of which are `null` until the plugin they belong to is properly initialized.
+ // This code is work in progress to 'hack' the initialization of each plugin one-by-one, but I doubt this is the right
+ // way to do it, as I bet it's fragile (will break when eclipse updates rather easily), and who knows how many fields
+ // and things need to be initialized.
+ // A better plan would be to start an actual, real eclipse, by telling `EclipseStarter.startup` to launch some sort of
+ // application (or at least a bunch of bundles/products/apps, including the JDT). This will then take long enough that
+ // it'll need to be cached and re-used for each test or the Eclipse test run would take far too long.
+
+ BundleContext context = EclipseStarter.startup(new String[0], null);
+ RegistryFactory.setDefaultRegistryProvider(new IRegistryProvider() {
+ private final ExtensionRegistry REG = new ExtensionRegistry(null, null, null);
+ @Override public IExtensionRegistry getRegistry() {
+ return REG;
+ }
+ });
+ new Activator().start(context);
+ new PlatformActivator().start(context);
+ for (Bundle b : context.getBundles()) System.out.println("BUNDLE: " + b.getSymbolicName());
+ new ResourcesPlugin().start(context);
+ JavaModelManager.getJavaModelManager().startup();
+ }
+ }
+
+ static boolean eclipseAvailable() {
try {
Class.forName("org.eclipse.jdt.core.dom.CompilationUnit");
} catch (Throwable t) {
@@ -161,48 +211,13 @@ public class RunTestsViaEcj extends AbstractRunTests {
Map<String, String> options = new HashMap<String, String>();
options.put(JavaCore.COMPILER_SOURCE, "11");
options.put("org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures", "enabled");
- try {
- org.eclipse.jdt.internal.core.CompilationUnit ccu = new org.eclipse.jdt.internal.core.CompilationUnit(null, null, null) {
- @Override public char[] getContents() {
- return source;
- }
- };
- return AST.convertCompilationUnit(4, cud, options, false, ccu, 0, null);
- } catch (SecurityException e) {
- try {
- debugClasspathConflicts("org/eclipse/jdt/internal/compiler");
- } catch (Exception e2) {
- throw Lombok.sneakyThrow(e2);
- }
- throw e;
- }
- }
- }
-
- @SuppressWarnings({"all"})
- private static void debugClasspathConflicts(String prefixToLookFor) throws Exception {
- String[] paths = System.getProperty("java.class.path").split(":");
- for (String p : paths) {
- Path cp = Paths.get(p);
- if (Files.isDirectory(cp)) {
- if (Files.isDirectory(cp.resolve(prefixToLookFor))) System.out.println("** DIR-BASED: " + cp);
- } else if (Files.isRegularFile(cp)) {
- JarFile jf = new JarFile(cp.toFile());
- try {
- Enumeration<JarEntry> jes = jf.entries();
- while (jes.hasMoreElements()) {
- JarEntry je = jes.nextElement();
- if (je.getName().startsWith(prefixToLookFor)) {
- System.out.println("** JAR-BASED: " + cp);
- break;
- }
- }
- } finally {
- jf.close();
+
+ org.eclipse.jdt.internal.core.CompilationUnit ccu = new org.eclipse.jdt.internal.core.CompilationUnit(null, null, null) {
+ @Override public char[] getContents() {
+ return source;
}
- } else {
- System.out.println("** MISSING: " + cp);
- }
+ };
+ return AST.convertCompilationUnit(4, cud, options, false, ccu, 0, null);
}
}
@@ -213,8 +228,9 @@ public class RunTestsViaEcj extends AbstractRunTests {
i.remove();
}
}
- if (new File("bin").exists()) classpath.add("bin");
+ if (new File("bin/main").exists()) classpath.add("bin/main");
classpath.add("dist/lombok.jar");
+ classpath.add("build/teststubs");
if (bootRuntimePath == null || bootRuntimePath.isEmpty()) throw new IllegalStateException("System property delombok.bootclasspath is not set; set it to the rt of java6 or java8");
classpath.add(bootRuntimePath);
for (File f : new File("lib/test").listFiles()) {
@@ -225,4 +241,75 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
}
+
+ private static final class TestCompilationUnitEcj implements ICompilationUnit {
+ private final char[] name, source, mainTypeName;
+
+ TestCompilationUnitEcj(String name, String source) {
+ this.source = source.toCharArray();
+ this.name = name.toCharArray();
+
+ char[] fileNameCharArray = getFileName();
+ int start = CharOperation.lastIndexOf(File.separatorChar, fileNameCharArray) + 1;
+ int end = CharOperation.lastIndexOf('.', fileNameCharArray);
+ if (end == -1) {
+ end = fileNameCharArray.length;
+ }
+ mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
+ }
+
+ @Override public char[] getFileName() {
+ return name;
+ }
+
+ @Override public char[] getContents() {
+ return source;
+ }
+
+ @Override public char[] getMainTypeName() {
+ return mainTypeName;
+ }
+
+ @Override public char[][] getPackageName() {
+ return null;
+ }
+ }
+
+ private static final class TestCompilationUnitEclipse extends org.eclipse.jdt.internal.core.CompilationUnit {
+ private final char[] source;
+ private final char[] mainTypeName;
+
+ private TestCompilationUnitEclipse(String name, String source) {
+ super(null, name, null);
+ this.source = source.toCharArray();
+
+ char[] fileNameCharArray = getFileName();
+ int start = CharOperation.lastIndexOf(File.separatorChar, fileNameCharArray) + 1;
+ int end = CharOperation.lastIndexOf('.', fileNameCharArray);
+ if (end == -1) {
+ end = fileNameCharArray.length;
+ }
+ mainTypeName = CharOperation.subarray(fileNameCharArray, start, end);
+ }
+
+ @Override public char[] getContents() {
+ return source;
+ }
+
+ @Override public char[] getMainTypeName() {
+ return mainTypeName;
+ }
+
+ @Override public boolean ignoreOptionalProblems() {
+ return false;
+ }
+
+ @Override public char[][] getPackageName() {
+ return null;
+ }
+
+ @Override public char[] getModuleName() {
+ return null;
+ }
+ }
}
diff --git a/test/pretty/resource/after/tryWithResourcesVarRef.java b/test/pretty/resource/after/TryWithResourcesVarRef.java
index 5117f706..5117f706 100644
--- a/test/pretty/resource/after/tryWithResourcesVarRef.java
+++ b/test/pretty/resource/after/TryWithResourcesVarRef.java
diff --git a/test/pretty/resource/before/ThisParameter.java b/test/pretty/resource/before/ThisParameter.java
index d95c0261..e37651cb 100644
--- a/test/pretty/resource/before/ThisParameter.java
+++ b/test/pretty/resource/before/ThisParameter.java
@@ -1,3 +1,4 @@
+// version 9: the 'this' param option exists in java8, but is bugged, in that annotations are not allowed on them, even without a @Target. The only purpose of the this param is annotations, so, boy, isn't that a punch in the face?
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/test/stubs/org/checkerframework/checker/calledmethods/qual/CalledMethods.java b/test/stubs/org/checkerframework/checker/calledmethods/qual/CalledMethods.java
new file mode 100644
index 00000000..514e8c6b
--- /dev/null
+++ b/test/stubs/org/checkerframework/checker/calledmethods/qual/CalledMethods.java
@@ -0,0 +1,17 @@
+package org.checkerframework.checker.calledmethods.qual;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+public @interface CalledMethods {
+ /**
+ * Methods that have been called, on any expression whose type is annotated.
+ *
+ * @return methods that have been called
+ */
+ public String[] value() default {};
+} \ No newline at end of file
diff --git a/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java b/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java
new file mode 100644
index 00000000..7a9ef37c
--- /dev/null
+++ b/test/stubs/org/checkerframework/checker/calledmethods/qual/NotCalledMethods.java
@@ -0,0 +1,17 @@
+package org.checkerframework.checker.calledmethods.qual;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+public @interface NotCalledMethods {
+ /**
+ * Methods that have been called, on any expression whose type is annotated.
+ *
+ * @return methods that have been called
+ */
+ public String[] value() default {};
+} \ No newline at end of file
diff --git a/test/stubs/org/checkerframework/common/aliasing/qual/Unique.java b/test/stubs/org/checkerframework/common/aliasing/qual/Unique.java
new file mode 100644
index 00000000..fe7acfca
--- /dev/null
+++ b/test/stubs/org/checkerframework/common/aliasing/qual/Unique.java
@@ -0,0 +1,12 @@
+package org.checkerframework.common.aliasing.qual;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+public @interface Unique {} \ No newline at end of file
diff --git a/test/stubs/org/checkerframework/common/returnsreceiver/qual/This.java b/test/stubs/org/checkerframework/common/returnsreceiver/qual/This.java
new file mode 100644
index 00000000..8ae1cd59
--- /dev/null
+++ b/test/stubs/org/checkerframework/common/returnsreceiver/qual/This.java
@@ -0,0 +1,12 @@
+package org.checkerframework.common.returnsreceiver.qual;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Inherited
+public @interface This {} \ No newline at end of file
diff --git a/test/stubs/org/checkerframework/dataflow/qual/Pure.java b/test/stubs/org/checkerframework/dataflow/qual/Pure.java
new file mode 100644
index 00000000..d9bb1bf4
--- /dev/null
+++ b/test/stubs/org/checkerframework/dataflow/qual/Pure.java
@@ -0,0 +1,12 @@
+package org.checkerframework.dataflow.qual;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
+public @interface Pure {} \ No newline at end of file
diff --git a/test/stubs/org/checkerframework/dataflow/qual/SideEffectFree.java b/test/stubs/org/checkerframework/dataflow/qual/SideEffectFree.java
new file mode 100644
index 00000000..9c32d369
--- /dev/null
+++ b/test/stubs/org/checkerframework/dataflow/qual/SideEffectFree.java
@@ -0,0 +1,12 @@
+package org.checkerframework.dataflow.qual;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
+public @interface SideEffectFree {} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/Accessors.java b/test/transform/resource/after-delombok/Accessors.java
index 2773a17b..0e148b88 100644
--- a/test/transform/resource/after-delombok/Accessors.java
+++ b/test/transform/resource/after-delombok/Accessors.java
@@ -4,6 +4,9 @@ class AccessorsFluent {
public String fieldName() {
return this.fieldName;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public AccessorsFluent fieldName(final String fieldName) {
this.fieldName = fieldName;
@@ -21,6 +24,9 @@ class AccessorsFluentOnClass {
public String getOtherFieldWithOverride() {
return this.otherFieldWithOverride;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public AccessorsFluentOnClass fieldName(final String fieldName) {
this.fieldName = fieldName;
@@ -29,6 +35,9 @@ class AccessorsFluentOnClass {
}
class AccessorsChain {
private boolean isRunning;
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public AccessorsChain setRunning(final boolean isRunning) {
this.isRunning = isRunning;
@@ -93,6 +102,9 @@ class AccessorsPrefix3 {
}
class AccessorsFluentGenerics<T extends Number> {
private String name;
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public AccessorsFluentGenerics<T> name(final String name) {
this.name = name;
diff --git a/test/transform/resource/after-delombok/AccessorsConfiguration.java b/test/transform/resource/after-delombok/AccessorsConfiguration.java
index f6604970..f52ff307 100644
--- a/test/transform/resource/after-delombok/AccessorsConfiguration.java
+++ b/test/transform/resource/after-delombok/AccessorsConfiguration.java
@@ -18,6 +18,9 @@ class AccessorsConfiguration2 {
}
class AccessorsConfiguration3 {
private String fFieldName = "";
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public AccessorsConfiguration3 setFieldName(final String fFieldName) {
this.fFieldName = fFieldName;
diff --git a/test/transform/resource/after-delombok/BuilderAccessWithGetter.java b/test/transform/resource/after-delombok/BuilderAccessWithGetter.java
new file mode 100644
index 00000000..f36403bf
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderAccessWithGetter.java
@@ -0,0 +1,49 @@
+public final class BuilderAccessWithGetter {
+ private final String string;
+
+ @java.lang.SuppressWarnings("all")
+ BuilderAccessWithGetter(final String string) {
+ this.string = string;
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ private static class BuilderAccessWithGetterBuilder {
+ @java.lang.SuppressWarnings("all")
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ BuilderAccessWithGetterBuilder() {
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ private BuilderAccessWithGetter.BuilderAccessWithGetterBuilder string(final String string) {
+ this.string = string;
+ return this;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ private BuilderAccessWithGetter build() {
+ return new BuilderAccessWithGetter(this.string);
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "BuilderAccessWithGetter.BuilderAccessWithGetterBuilder(string=" + this.string + ")";
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ private static BuilderAccessWithGetter.BuilderAccessWithGetterBuilder builder() {
+ return new BuilderAccessWithGetter.BuilderAccessWithGetterBuilder();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+}
diff --git a/test/transform/resource/after-delombok/BuilderComplex.java b/test/transform/resource/after-delombok/BuilderComplex.java
index 009ebe6c..591c2b4d 100644
--- a/test/transform/resource/after-delombok/BuilderComplex.java
+++ b/test/transform/resource/after-delombok/BuilderComplex.java
@@ -15,21 +15,33 @@ class BuilderComplex {
@java.lang.SuppressWarnings("all")
TestVoidName() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderComplex.TestVoidName<T> number(final T number) {
this.number = number;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderComplex.TestVoidName<T> arg2(final int arg2) {
this.arg2 = arg2;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderComplex.TestVoidName<T> arg3(final String arg3) {
this.arg3 = arg3;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderComplex.TestVoidName<T> selfRef(final BuilderComplex selfRef) {
this.selfRef = selfRef;
diff --git a/test/transform/resource/after-delombok/BuilderCustomName.java b/test/transform/resource/after-delombok/BuilderCustomName.java
index 4b423ee0..2e5924d3 100644
--- a/test/transform/resource/after-delombok/BuilderCustomName.java
+++ b/test/transform/resource/after-delombok/BuilderCustomName.java
@@ -9,6 +9,9 @@ class BuilderCustomName<T> {
protected abstract B self();
@java.lang.SuppressWarnings("all")
public abstract C build();
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B field(final int field) {
this.field = field;
diff --git a/test/transform/resource/after-delombok/BuilderDefaults.java b/test/transform/resource/after-delombok/BuilderDefaults.java
index 42b751ce..2170eed5 100644
--- a/test/transform/resource/after-delombok/BuilderDefaults.java
+++ b/test/transform/resource/after-delombok/BuilderDefaults.java
@@ -31,17 +31,26 @@ public final class BuilderDefaults {
@java.lang.SuppressWarnings("all")
BuilderDefaultsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaults.BuilderDefaultsBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaults.BuilderDefaultsBuilder name(final String name) {
this.name = name;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaults.BuilderDefaultsBuilder z(final long z) {
this.z$value = z;
diff --git a/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java b/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
index 71dc7c5f..44d9491f 100644
--- a/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
+++ b/test/transform/resource/after-delombok/BuilderDefaultsGenerics.java
@@ -38,18 +38,27 @@ public class BuilderDefaultsGenerics<N extends Number, T, R extends List<T>> {
@java.lang.SuppressWarnings("all")
BuilderDefaultsGenericsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> callable(final java.util.concurrent.Callable<N> callable) {
this.callable$value = callable;
callable$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> tee(final T tee) {
this.tee$value = tee;
tee$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> arrr(final R arrr) {
this.arrr$value = arrr;
diff --git a/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java
index 356e072e..c7e37abe 100644
--- a/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java
+++ b/test/transform/resource/after-delombok/BuilderDefaultsWarnings.java
@@ -1,6 +1,4 @@
//skip-idempotent
-import lombok.Builder;
-@Builder
public class BuilderDefaultsWarnings {
long x = System.currentTimeMillis();
final int y = 5;
@@ -23,11 +21,17 @@ public class BuilderDefaultsWarnings {
@java.lang.SuppressWarnings("all")
BuilderDefaultsWarningsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder x(final long x) {
this.x = x;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder z(final int z) {
this.z = z;
@@ -81,7 +85,6 @@ public class BuilderDefaultsWarnings {
}
class NoBuilderButHasDefaults {
private final long z = 5;
- @Builder
public NoBuilderButHasDefaults() {
}
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/BuilderGenericMethod.java b/test/transform/resource/after-delombok/BuilderGenericMethod.java
index d57f6415..36375952 100644
--- a/test/transform/resource/after-delombok/BuilderGenericMethod.java
+++ b/test/transform/resource/after-delombok/BuilderGenericMethod.java
@@ -13,11 +13,17 @@ class BuilderGenericMethod<T> {
@java.lang.SuppressWarnings("all")
MapBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderGenericMethod<T>.MapBuilder<N> a(final int a) {
this.a = a;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderGenericMethod<T>.MapBuilder<N> b(final long b) {
this.b = b;
diff --git a/test/transform/resource/after-delombok/BuilderInstanceMethod.java b/test/transform/resource/after-delombok/BuilderInstanceMethod.java
index d0d5833f..2ee81dcb 100644
--- a/test/transform/resource/after-delombok/BuilderInstanceMethod.java
+++ b/test/transform/resource/after-delombok/BuilderInstanceMethod.java
@@ -16,21 +16,33 @@ class BuilderInstanceMethod<T> {
@java.lang.SuppressWarnings("all")
StringBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderInstanceMethod<T>.StringBuilder show(final int show) {
this.show = show;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderInstanceMethod<T>.StringBuilder yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderInstanceMethod<T>.StringBuilder also(final List<T> also) {
this.also = also;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderInstanceMethod<T>.StringBuilder $andMe(final int $andMe) {
this.$andMe = $andMe;
diff --git a/test/transform/resource/after-delombok/BuilderJavadoc.java b/test/transform/resource/after-delombok/BuilderJavadoc.java
index c99bfe90..f7caa2d6 100644
--- a/test/transform/resource/after-delombok/BuilderJavadoc.java
+++ b/test/transform/resource/after-delombok/BuilderJavadoc.java
@@ -3,7 +3,6 @@ class BuilderJavadoc<T> {
/**
* basic gets only a builder setter.
* @see #getsetwith
- *
* @return tag is removed from the setter.
*/
private final int basic;
@@ -92,7 +91,6 @@ class BuilderJavadoc<T> {
}
/**
* getsetwith gets a builder setter, an instance getter and setter, and a wither.
- *
* @return tag is moved to the getter.
*/
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/BuilderSimple.java b/test/transform/resource/after-delombok/BuilderSimple.java
index 925d0dd3..a43567b3 100644
--- a/test/transform/resource/after-delombok/BuilderSimple.java
+++ b/test/transform/resource/after-delombok/BuilderSimple.java
@@ -18,11 +18,17 @@ class BuilderSimple<T> {
@java.lang.SuppressWarnings("all")
BuilderSimpleBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderSimple.BuilderSimpleBuilder<T> yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderSimple.BuilderSimpleBuilder<T> also(final List<T> also) {
this.also = also;
diff --git a/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java
index ef0d8fc6..3038fe39 100644
--- a/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderSimpleWithSetterPrefix.java
@@ -12,6 +12,9 @@ class BuilderSimpleWithSetterPrefix<T> {
@java.lang.SuppressWarnings("all")
BuilderSimpleWithSetterPrefixBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderSimpleWithSetterPrefix.BuilderSimpleWithSetterPrefixBuilder<T> withUnprefixed(final int unprefixed) {
this.unprefixed = unprefixed;
diff --git a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java
index f6fa22de..7568d812 100644
--- a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java
+++ b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypes.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Set;
diff --git a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java
index 6dbbeee4..d58caf4d 100644
--- a/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderSingularAnnotatedTypesWithSetterPrefix.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Set;
diff --git a/test/transform/resource/after-delombok/BuilderSingularNoAuto.java b/test/transform/resource/after-delombok/BuilderSingularNoAuto.java
index 8c30f926..de86383f 100644
--- a/test/transform/resource/after-delombok/BuilderSingularNoAuto.java
+++ b/test/transform/resource/after-delombok/BuilderSingularNoAuto.java
@@ -1,6 +1,5 @@
//skip-idempotent
import java.util.List;
-@lombok.Builder
class BuilderSingularNoAuto {
private List<String> things;
private List<String> widgets;
diff --git a/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java
index 4207cf74..8858f145 100644
--- a/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderSingularNoAutoWithSetterPrefix.java
@@ -1,6 +1,5 @@
//skip-idempotent
import java.util.List;
-@lombok.Builder(setterPrefix = "with")
class BuilderSingularNoAutoWithSetterPrefix {
private List<String> things;
private List<String> widgets;
diff --git a/test/transform/resource/after-delombok/BuilderSingularNullBehavior1.java b/test/transform/resource/after-delombok/BuilderSingularNullBehavior1.java
index 32ad0a68..45ff97fa 100644
--- a/test/transform/resource/after-delombok/BuilderSingularNullBehavior1.java
+++ b/test/transform/resource/after-delombok/BuilderSingularNullBehavior1.java
@@ -1,3 +1,4 @@
+//version 8:
import java.util.List;
import java.util.Collection;
class BuilderSingularNullBehavior1 {
diff --git a/test/transform/resource/after-delombok/BuilderSingularNullBehavior2.java b/test/transform/resource/after-delombok/BuilderSingularNullBehavior2.java
index e70877bf..5f605de4 100644
--- a/test/transform/resource/after-delombok/BuilderSingularNullBehavior2.java
+++ b/test/transform/resource/after-delombok/BuilderSingularNullBehavior2.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
import java.util.List;
class BuilderSingularNullBehavior2 {
private List<String> locations;
diff --git a/test/transform/resource/after-delombok/BuilderTypeAnnos.java b/test/transform/resource/after-delombok/BuilderTypeAnnos.java
index bd450d5b..f5ef42f7 100644
--- a/test/transform/resource/after-delombok/BuilderTypeAnnos.java
+++ b/test/transform/resource/after-delombok/BuilderTypeAnnos.java
@@ -22,6 +22,9 @@ class BuilderTypeAnnos {
@java.lang.SuppressWarnings("all")
BuilderTypeAnnosBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderTypeAnnos.BuilderTypeAnnosBuilder foo(@TA final List<String> foo) {
this.foo = foo;
diff --git a/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java
index b221e69d..1fb7798a 100644
--- a/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderTypeAnnosWithSetterPrefix.java
@@ -22,6 +22,9 @@ class BuilderTypeAnnosWithSetterPrefix {
@java.lang.SuppressWarnings("all")
BuilderTypeAnnosWithSetterPrefixBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderTypeAnnosWithSetterPrefix.BuilderTypeAnnosWithSetterPrefixBuilder withFoo(@TA final List<String> foo) {
this.foo = foo;
diff --git a/test/transform/resource/after-delombok/BuilderWithAccessors.java b/test/transform/resource/after-delombok/BuilderWithAccessors.java
index 3fa47034..a8a9bc11 100644
--- a/test/transform/resource/after-delombok/BuilderWithAccessors.java
+++ b/test/transform/resource/after-delombok/BuilderWithAccessors.java
@@ -23,21 +23,33 @@ class BuilderWithAccessors {
@java.lang.SuppressWarnings("all")
BuilderWithAccessorsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithAccessors.BuilderWithAccessorsBuilder plower(final int plower) {
this.plower = plower;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithAccessors.BuilderWithAccessorsBuilder upper(final int upper) {
this.upper = upper;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithAccessors.BuilderWithAccessorsBuilder foo(final int foo) {
this.foo = foo;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithAccessors.BuilderWithAccessorsBuilder _bar(final int _bar) {
this._bar = _bar;
diff --git a/test/transform/resource/after-delombok/BuilderWithBadNames.java b/test/transform/resource/after-delombok/BuilderWithBadNames.java
index d77ca71c..c96fbc58 100644
--- a/test/transform/resource/after-delombok/BuilderWithBadNames.java
+++ b/test/transform/resource/after-delombok/BuilderWithBadNames.java
@@ -15,11 +15,17 @@ public class BuilderWithBadNames {
@java.lang.SuppressWarnings("all")
BuilderWithBadNamesBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithBadNames.BuilderWithBadNamesBuilder build(final String build) {
this.build = build;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithBadNames.BuilderWithBadNamesBuilder toString(final String toString) {
this.toString = toString;
diff --git a/test/transform/resource/after-delombok/BuilderWithDeprecated.java b/test/transform/resource/after-delombok/BuilderWithDeprecated.java
index b6a09376..f0729649 100644
--- a/test/transform/resource/after-delombok/BuilderWithDeprecated.java
+++ b/test/transform/resource/after-delombok/BuilderWithDeprecated.java
@@ -40,6 +40,9 @@ public class BuilderWithDeprecated {
this.dep1 = dep1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.Deprecated
@java.lang.SuppressWarnings("all")
public BuilderWithDeprecated.BuilderWithDeprecatedBuilder dep2(final int dep2) {
diff --git a/test/transform/resource/after-delombok/BuilderWithDeprecatedAnnOnly.java b/test/transform/resource/after-delombok/BuilderWithDeprecatedAnnOnly.java
new file mode 100644
index 00000000..d5c06465
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderWithDeprecatedAnnOnly.java
@@ -0,0 +1,107 @@
+import com.google.common.collect.ImmutableList;
+public class BuilderWithDeprecatedAnnOnly {
+ @Deprecated
+ int dep1;
+ @Deprecated
+ java.util.List<String> strings;
+ @Deprecated
+ ImmutableList<Integer> numbers;
+ @java.lang.SuppressWarnings("all")
+ BuilderWithDeprecatedAnnOnly(final int dep1, final java.util.List<String> strings, final ImmutableList<Integer> numbers) {
+ this.dep1 = dep1;
+ this.strings = strings;
+ this.numbers = numbers;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static class BuilderWithDeprecatedAnnOnlyBuilder {
+ @java.lang.SuppressWarnings("all")
+ private int dep1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> strings;
+ @java.lang.SuppressWarnings("all")
+ private com.google.common.collect.ImmutableList.Builder<Integer> numbers;
+ @java.lang.SuppressWarnings("all")
+ BuilderWithDeprecatedAnnOnlyBuilder() {
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder dep1(final int dep1) {
+ this.dep1 = dep1;
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder string(final String string) {
+ if (this.strings == null) this.strings = new java.util.ArrayList<String>();
+ this.strings.add(string);
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder strings(final java.util.Collection<? extends String> strings) {
+ if (strings == null) {
+ throw new java.lang.NullPointerException("strings cannot be null");
+ }
+ if (this.strings == null) this.strings = new java.util.ArrayList<String>();
+ this.strings.addAll(strings);
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder clearStrings() {
+ if (this.strings != null) this.strings.clear();
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder number(final Integer number) {
+ if (this.numbers == null) this.numbers = com.google.common.collect.ImmutableList.builder();
+ this.numbers.add(number);
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder numbers(final java.lang.Iterable<? extends Integer> numbers) {
+ if (numbers == null) {
+ throw new java.lang.NullPointerException("numbers cannot be null");
+ }
+ if (this.numbers == null) this.numbers = com.google.common.collect.ImmutableList.builder();
+ this.numbers.addAll(numbers);
+ return this;
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder clearNumbers() {
+ this.numbers = null;
+ return this;
+ }
+ @java.lang.SuppressWarnings("all")
+ public BuilderWithDeprecatedAnnOnly build() {
+ java.util.List<String> strings;
+ switch (this.strings == null ? 0 : this.strings.size()) {
+ case 0:
+ strings = java.util.Collections.emptyList();
+ break;
+ case 1:
+ strings = java.util.Collections.singletonList(this.strings.get(0));
+ break;
+ default:
+ strings = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.strings));
+ }
+ com.google.common.collect.ImmutableList<Integer> numbers = this.numbers == null ? com.google.common.collect.ImmutableList.<Integer>of() : this.numbers.build();
+ return new BuilderWithDeprecatedAnnOnly(this.dep1, strings, numbers);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder(dep1=" + this.dep1 + ", strings=" + this.strings + ", numbers=" + this.numbers + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ public static BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder builder() {
+ return new BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder();
+ }
+}
diff --git a/test/transform/resource/after-delombok/BuilderWithExistingBuilderClass.java b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClass.java
index 88eeee64..9c7ac1ad 100644
--- a/test/transform/resource/after-delombok/BuilderWithExistingBuilderClass.java
+++ b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClass.java
@@ -13,11 +13,17 @@ class BuilderWithExistingBuilderClass<T, K extends Number> {
@java.lang.SuppressWarnings("all")
BuilderWithExistingBuilderClassBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithExistingBuilderClass.BuilderWithExistingBuilderClassBuilder<Z> arg1(final Z arg1) {
this.arg1 = arg1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithExistingBuilderClass.BuilderWithExistingBuilderClassBuilder<Z> arg3(final String arg3) {
this.arg3 = arg3;
diff --git a/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java
index b1ed5fef..c7da67f8 100644
--- a/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderWithExistingBuilderClassWithSetterPrefix.java
@@ -13,11 +13,17 @@ class BuilderWithExistingBuilderClassWithSetterPrefix<T, K extends Number> {
@java.lang.SuppressWarnings("all")
BuilderWithExistingBuilderClassWithSetterPrefixBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z> withArg1(final Z arg1) {
this.arg1 = arg1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z> withArg3(final String arg3) {
this.arg3 = arg3;
diff --git a/test/transform/resource/after-delombok/BuilderWithNoBuilderMethod.java b/test/transform/resource/after-delombok/BuilderWithNoBuilderMethod.java
index d555ab06..61df4427 100644
--- a/test/transform/resource/after-delombok/BuilderWithNoBuilderMethod.java
+++ b/test/transform/resource/after-delombok/BuilderWithNoBuilderMethod.java
@@ -11,6 +11,9 @@ class BuilderWithNoBuilderMethod {
@java.lang.SuppressWarnings("all")
BuilderWithNoBuilderMethodBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithNoBuilderMethod.BuilderWithNoBuilderMethodBuilder a(final String a) {
this.a = a;
diff --git a/test/transform/resource/after-delombok/BuilderWithNonNull.java b/test/transform/resource/after-delombok/BuilderWithNonNull.java
index 9858d5bd..00728ea7 100644
--- a/test/transform/resource/after-delombok/BuilderWithNonNull.java
+++ b/test/transform/resource/after-delombok/BuilderWithNonNull.java
@@ -1,3 +1,4 @@
+//version 8:
class BuilderWithNonNull {
@lombok.NonNull
private final String id;
@@ -15,6 +16,9 @@ class BuilderWithNonNull {
@java.lang.SuppressWarnings("all")
BuilderWithNonNullBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithNonNull.BuilderWithNonNullBuilder id(@lombok.NonNull final String id) {
if (id == null) {
diff --git a/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java
index 8a27f443..f6dfed67 100644
--- a/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/BuilderWithNonNullWithSetterPrefix.java
@@ -1,3 +1,4 @@
+//version 8:
class BuilderWithNonNullWithSetterPrefix {
@lombok.NonNull
private final String id;
@@ -15,6 +16,9 @@ class BuilderWithNonNullWithSetterPrefix {
@java.lang.SuppressWarnings("all")
BuilderWithNonNullWithSetterPrefixBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithNonNullWithSetterPrefix.BuilderWithNonNullWithSetterPrefixBuilder withId(@lombok.NonNull final String id) {
if (id == null) {
diff --git a/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java b/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java
index 33dd7d10..a96fe1cc 100644
--- a/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java
+++ b/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java
@@ -19,11 +19,17 @@ public class BuilderWithRecursiveGenerics {
@java.lang.SuppressWarnings("all")
TestBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithRecursiveGenerics.Test.TestBuilder<Foo, Bar, Quz> foo(final Foo foo) {
this.foo = foo;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithRecursiveGenerics.Test.TestBuilder<Foo, Bar, Quz> bar(final Bar bar) {
this.bar = bar;
diff --git a/test/transform/resource/after-delombok/BuilderWithToBuilder.java b/test/transform/resource/after-delombok/BuilderWithToBuilder.java
index d98d09f6..0df43609 100644
--- a/test/transform/resource/after-delombok/BuilderWithToBuilder.java
+++ b/test/transform/resource/after-delombok/BuilderWithToBuilder.java
@@ -27,16 +27,25 @@ class BuilderWithToBuilder<T> {
@java.lang.SuppressWarnings("all")
BuilderWithToBuilderBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> one(final String one) {
this.one = one;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> two(final String two) {
this.two = two;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> foo(final T foo) {
this.foo = foo;
@@ -114,16 +123,25 @@ class ConstructorWithToBuilder<T> {
@java.lang.SuppressWarnings("all")
ConstructorWithToBuilderBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> mOne(final String mOne) {
this.mOne = mOne;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> baz(final T baz) {
this.baz = baz;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> bars(final com.google.common.collect.ImmutableList<T> bars) {
this.bars = bars;
@@ -147,4 +165,54 @@ class ConstructorWithToBuilder<T> {
public ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> toBuilder() {
return new ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).baz(this.foo).bars(this.bars);
}
+}
+class StaticMethodWithToBuilder<T> {
+ private T foo;
+
+ public StaticMethodWithToBuilder(T foo) {
+ this.foo = foo;
+ }
+
+ public static <T> StaticMethodWithToBuilder<T> of(T foo) {
+ return new StaticMethodWithToBuilder<T>(foo);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static class StaticMethodWithToBuilderBuilder<T> {
+ @java.lang.SuppressWarnings("all")
+ private T foo;
+
+ @java.lang.SuppressWarnings("all")
+ StaticMethodWithToBuilderBuilder() {
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> foo(final T foo) {
+ this.foo = foo;
+ return this;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public StaticMethodWithToBuilder<T> build() {
+ return StaticMethodWithToBuilder.<T>of(this.foo);
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder(foo=" + this.foo + ")";
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static <T> StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> builder() {
+ return new StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T>();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> toBuilder() {
+ return new StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T>().foo(this.foo);
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/BuilderWithTolerate.java b/test/transform/resource/after-delombok/BuilderWithTolerate.java
index daa02ac3..79494c49 100644
--- a/test/transform/resource/after-delombok/BuilderWithTolerate.java
+++ b/test/transform/resource/after-delombok/BuilderWithTolerate.java
@@ -14,6 +14,9 @@ public class BuilderWithTolerate {
@java.lang.SuppressWarnings("all")
BuilderWithTolerateBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public BuilderWithTolerate.BuilderWithTolerateBuilder value(final int value) {
this.value = value;
diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBasic.java b/test/transform/resource/after-delombok/CheckerFrameworkBasic.java
index 3077728c..2beafc4c 100644
--- a/test/transform/resource/after-delombok/CheckerFrameworkBasic.java
+++ b/test/transform/resource/after-delombok/CheckerFrameworkBasic.java
@@ -1,13 +1,8 @@
+//version 8:
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.Pure
@java.lang.SuppressWarnings("all")
public int getX() {
@@ -23,7 +18,10 @@ class CheckerFrameworkBasic {
public int getZ() {
return this.z;
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public CheckerFrameworkBasic setZ(final int z) {
this.z = z;
@@ -64,6 +62,15 @@ class CheckerFrameworkBasic {
public java.lang.String toString() {
return "CheckerFrameworkBasic(x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + ")";
}
+ @java.lang.SuppressWarnings("all")
+ public CheckerFrameworkBasic(final int x, final int y, final int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+ /**
+ * @return {@code this}.
+ */
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.SuppressWarnings("all")
public CheckerFrameworkBasic withX(final int x) {
diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
index ace3adad..99272bd5 100644
--- a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
+++ b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java
@@ -9,7 +9,6 @@ class CheckerFrameworkBuilder {
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;
@@ -29,37 +28,45 @@ class CheckerFrameworkBuilder {
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
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(@org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int x) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") CheckerFrameworkBuilderBuilder this, final int x) {
this.x$value = x;
x$set = true;
return this;
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(@org.checkerframework.checker.builder.qual.NotCalledMethods("y") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int y) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) {
this.y = y;
return this;
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(@org.checkerframework.checker.builder.qual.NotCalledMethods("z") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int z) {
+ public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) {
this.z = z;
return this;
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public CheckerFrameworkBuilder.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
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder names(final java.util.Collection<? extends String> names) {
if (names == null) {
@@ -69,7 +76,7 @@ class CheckerFrameworkBuilder {
this.names.addAll(names);
return this;
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder clearNames() {
if (this.names != null) this.names.clear();
@@ -77,7 +84,7 @@ class CheckerFrameworkBuilder {
}
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkBuilder build(@org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this) {
+ public CheckerFrameworkBuilder build(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) CheckerFrameworkBuilderBuilder this) {
java.util.List<String> names;
switch (this.names == null ? 0 : this.names.size()) {
case 0:
@@ -100,10 +107,10 @@ class CheckerFrameworkBuilder {
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 CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder builder() {
+ public static CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder builder() {
return new CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder();
}
}
diff --git a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
index 30408c3b..8dcdaf10 100644
--- a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
+++ b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java
@@ -1,4 +1,4 @@
-// skip-idempotent
+//version 8:
import java.util.List;
class CheckerFrameworkSuperBuilder {
public static class Parent {
@@ -22,40 +22,49 @@ class CheckerFrameworkSuperBuilder {
private int z;
@java.lang.SuppressWarnings("all")
private java.util.ArrayList<String> names;
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@org.checkerframework.dataflow.qual.Pure
@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"}) CheckerFrameworkSuperBuilder.Parent this);
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ public abstract C build(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilder<C, B> this);
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B x(@org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkSuperBuilder.Parent.ParentBuilder<C, B> this, final int x) {
+ public B x(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") ParentBuilder<C, B> this, final int x) {
this.x$value = x;
x$set = true;
return self();
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B y(@org.checkerframework.checker.builder.qual.NotCalledMethods("y") CheckerFrameworkSuperBuilder.Parent.ParentBuilder<C, B> this, final int y) {
+ public B y(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") ParentBuilder<C, B> this, final int y) {
this.y = y;
return self();
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B z(@org.checkerframework.checker.builder.qual.NotCalledMethods("z") CheckerFrameworkSuperBuilder.Parent.ParentBuilder<C, B> this, final int z) {
+ public B z(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") ParentBuilder<C, B> this, final int z) {
this.z = z;
return self();
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@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
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public B names(final java.util.Collection<? extends String> names) {
if (names == null) {
@@ -65,7 +74,7 @@ class CheckerFrameworkSuperBuilder {
this.names.addAll(names);
return self();
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
public B clearNames() {
if (this.names != null) this.names.clear();
@@ -80,12 +89,11 @@ class CheckerFrameworkSuperBuilder {
}
@java.lang.SuppressWarnings("all")
private static final class ParentBuilderImpl extends CheckerFrameworkSuperBuilder.Parent.ParentBuilder<CheckerFrameworkSuperBuilder.Parent, CheckerFrameworkSuperBuilder.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.common.returnsreceiver.qual.This
@org.checkerframework.dataflow.qual.Pure
@java.lang.SuppressWarnings("all")
protected CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl self() {
@@ -94,7 +102,7 @@ class CheckerFrameworkSuperBuilder {
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.Override
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkSuperBuilder.Parent build(@org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl this) {
+ public CheckerFrameworkSuperBuilder.Parent build(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilderImpl this) {
return new CheckerFrameworkSuperBuilder.Parent(this);
}
}
@@ -120,7 +128,7 @@ class CheckerFrameworkSuperBuilder {
}
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.SuppressWarnings("all")
- public static CheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> builder() {
+ public static CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.common.aliasing.qual.Unique ParentBuilder<?, ?> builder() {
return new CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl();
}
}
@@ -140,24 +148,30 @@ class CheckerFrameworkSuperBuilder {
@java.lang.SuppressWarnings("all")
private int b;
@java.lang.Override
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@org.checkerframework.dataflow.qual.Pure
@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") CheckerFrameworkSuperBuilder.ZChild this);
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ public abstract C build(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilder<C, B> this);
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B a(@org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<C, B> this, final int a) {
+ public B a(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("a") ZChildBuilder<C, B> this, final int a) {
this.a$value = a;
a$set = true;
return self();
}
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.common.returnsreceiver.qual.This
@java.lang.SuppressWarnings("all")
- public B b(@org.checkerframework.checker.builder.qual.NotCalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<C, B> this, final int b) {
+ public B b(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("b") ZChildBuilder<C, B> this, final int b) {
this.b = b;
return self();
}
@@ -170,12 +184,11 @@ class CheckerFrameworkSuperBuilder {
}
@java.lang.SuppressWarnings("all")
private static final class ZChildBuilderImpl extends CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<CheckerFrameworkSuperBuilder.ZChild, CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl> {
- @org.checkerframework.common.aliasing.qual.Unique
@java.lang.SuppressWarnings("all")
private ZChildBuilderImpl() {
}
@java.lang.Override
- @org.checkerframework.checker.builder.qual.ReturnsReceiver
+ @org.checkerframework.common.returnsreceiver.qual.This
@org.checkerframework.dataflow.qual.Pure
@java.lang.SuppressWarnings("all")
protected CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() {
@@ -184,7 +197,7 @@ class CheckerFrameworkSuperBuilder {
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.Override
@java.lang.SuppressWarnings("all")
- public CheckerFrameworkSuperBuilder.ZChild build(@org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl this) {
+ public CheckerFrameworkSuperBuilder.ZChild build(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilderImpl this) {
return new CheckerFrameworkSuperBuilder.ZChild(this);
}
}
@@ -198,7 +211,7 @@ class CheckerFrameworkSuperBuilder {
}
@org.checkerframework.dataflow.qual.SideEffectFree
@java.lang.SuppressWarnings("all")
- public static CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> builder() {
+ public static CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.common.aliasing.qual.Unique ZChildBuilder<?, ?> builder() {
return new CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl();
}
}
diff --git a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java
index 3614d682..7097d5a2 100644
--- a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java
+++ b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java
@@ -1,3 +1,4 @@
+//version 8:
class ConstructorsWithAccessors {
int plower;
int pUpper;
diff --git a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java
index d5ac9bad..bcc9a57e 100644
--- a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java
+++ b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults.java
@@ -16,12 +16,18 @@ final class ConstructorsWithBuilderDefaults {
@java.lang.SuppressWarnings("all")
ConstructorsWithBuilderDefaultsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder y(final int y) {
this.y = y;
diff --git a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java
index 9609f62b..f62167c6 100644
--- a/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java
+++ b/test/transform/resource/after-delombok/ConstructorsWithBuilderDefaults2.java
@@ -33,18 +33,27 @@ final class ConstructorsWithBuilderDefaults<T> {
@java.lang.SuppressWarnings("all")
ConstructorsWithBuilderDefaultsBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> z(final java.util.List<T> z) {
this.z$value = z;
z$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> x(final T x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> q(final T q) {
this.q = q;
diff --git a/test/transform/resource/after-delombok/DataOnLocalClass.java b/test/transform/resource/after-delombok/DataOnLocalClass.java
index 80f3ca83..0d863f4f 100644
--- a/test/transform/resource/after-delombok/DataOnLocalClass.java
+++ b/test/transform/resource/after-delombok/DataOnLocalClass.java
@@ -1,3 +1,4 @@
+//version 8:
class DataOnLocalClass1 {
public static void main(String[] args) {
class Local {
diff --git a/test/transform/resource/after-delombok/DataWithOverrideEqualsAndHashCode.java b/test/transform/resource/after-delombok/DataWithOverrideEqualsAndHashCode.java
new file mode 100644
index 00000000..7e84dda4
--- /dev/null
+++ b/test/transform/resource/after-delombok/DataWithOverrideEqualsAndHashCode.java
@@ -0,0 +1,25 @@
+class DataWithOverrideEqualsAndHashCode {
+
+ class Data1 {
+ }
+
+ class Data2 extends Data1 {
+ public int hashCode() {
+ return 42;
+ }
+
+ public boolean equals(Object other) {
+ return false;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public Data2() {
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "DataWithOverrideEqualsAndHashCode.Data2()";
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java b/test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java
index 64b6f4d3..d99fc71c 100644
--- a/test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java
+++ b/test/transform/resource/after-delombok/EqualsAndHashCodeAnnotated.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.*;
class EqualsAndHashCodeAnnotated {
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java b/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java
new file mode 100644
index 00000000..4f3574b6
--- /dev/null
+++ b/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java
@@ -0,0 +1,167 @@
+class EqualsAndHashCode {
+ @java.lang.SuppressWarnings("all")
+ private transient int $hashCodeCache;
+ int x;
+ boolean[] y;
+ Object[] z;
+ String a;
+ String b;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof EqualsAndHashCode)) return false;
+ final EqualsAndHashCode other = (EqualsAndHashCode) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (this.x != other.x) return false;
+ if (!java.util.Arrays.equals(this.y, other.y)) return false;
+ if (!java.util.Arrays.deepEquals(this.z, other.z)) return false;
+ final java.lang.Object this$a = this.a;
+ final java.lang.Object other$a = other.a;
+ if (this$a == null ? other$a != null : !this$a.equals(other$a)) return false;
+ final java.lang.Object this$b = this.b;
+ final java.lang.Object other$b = other.b;
+ if (this$b == null ? other$b != null : !this$b.equals(other$b)) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof EqualsAndHashCode;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ if (this.$hashCodeCache != 0) return this.$hashCodeCache;
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.x;
+ result = result * PRIME + java.util.Arrays.hashCode(this.y);
+ result = result * PRIME + java.util.Arrays.deepHashCode(this.z);
+ final java.lang.Object $a = this.a;
+ result = result * PRIME + ($a == null ? 43 : $a.hashCode());
+ final java.lang.Object $b = this.b;
+ result = result * PRIME + ($b == null ? 43 : $b.hashCode());
+ if (result == 0) result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final class EqualsAndHashCode2 {
+ @java.lang.SuppressWarnings("all")
+ private transient int $hashCodeCache;
+ int x;
+ long y;
+ float f;
+ double d;
+ boolean b;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof EqualsAndHashCode2)) return false;
+ final EqualsAndHashCode2 other = (EqualsAndHashCode2) o;
+ if (this.x != other.x) return false;
+ if (this.y != other.y) return false;
+ if (java.lang.Float.compare(this.f, other.f) != 0) return false;
+ if (java.lang.Double.compare(this.d, other.d) != 0) return false;
+ if (this.b != other.b) return false;
+ return true;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ if (this.$hashCodeCache != 0) return this.$hashCodeCache;
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.x;
+ final long $y = this.y;
+ result = result * PRIME + (int) ($y >>> 32 ^ $y);
+ result = result * PRIME + java.lang.Float.floatToIntBits(this.f);
+ final long $d = java.lang.Double.doubleToLongBits(this.d);
+ result = result * PRIME + (int) ($d >>> 32 ^ $d);
+ result = result * PRIME + (this.b ? 79 : 97);
+ if (result == 0) result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final class EqualsAndHashCode3 extends EqualsAndHashCode {
+ @java.lang.SuppressWarnings("all")
+ private transient int $hashCodeCache;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof EqualsAndHashCode3)) return false;
+ final EqualsAndHashCode3 other = (EqualsAndHashCode3) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof EqualsAndHashCode3;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ if (this.$hashCodeCache != 0) return this.$hashCodeCache;
+ int result = 1;
+ if (result == 0) result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+class EqualsAndHashCode4 extends EqualsAndHashCode {
+ @java.lang.SuppressWarnings("all")
+ private transient int $hashCodeCache;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof EqualsAndHashCode4)) return false;
+ final EqualsAndHashCode4 other = (EqualsAndHashCode4) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (!super.equals(o)) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof EqualsAndHashCode4;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ if (this.$hashCodeCache != 0) return this.$hashCodeCache;
+ int result = super.hashCode();
+ if (result == 0) result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final class EqualsAndHashCode5 extends EqualsAndHashCode {
+ @java.lang.SuppressWarnings("all")
+ private transient int $hashCodeCache;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof EqualsAndHashCode5)) return false;
+ final EqualsAndHashCode5 other = (EqualsAndHashCode5) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (!super.equals(o)) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof EqualsAndHashCode5;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ if (this.$hashCodeCache != 0) return this.$hashCodeCache;
+ int result = super.hashCode();
+ if (result == 0) result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
diff --git a/test/transform/resource/after-delombok/ExtensionMethodAutoboxing.java b/test/transform/resource/after-delombok/ExtensionMethodAutoboxing.java
new file mode 100644
index 00000000..f274cabb
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodAutoboxing.java
@@ -0,0 +1,20 @@
+class ExtensionMethodAutoboxing {
+ public void test() {
+ Long l1 = 1L;
+ long l2 = 1L;
+ Integer i1 = 1;
+ int i2 = 1;
+ String string = "test";
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l1, i1);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l1, i2);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l2, i1);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l2, i2);
+ }
+
+
+ static class Extensions {
+ public static String boxing(String string, Long a, int b) {
+ return string + " " + a + " " + b;
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ExtensionMethodChain.java b/test/transform/resource/after-delombok/ExtensionMethodChain.java
new file mode 100644
index 00000000..77f79dea
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodChain.java
@@ -0,0 +1,15 @@
+import java.util.Arrays;
+import java.util.List;
+
+class ExtensionMethodChain {
+ public void test() {
+ ExtensionMethodChain.Extensions.intValue("1").intValue();
+ }
+
+
+ static class Extensions {
+ public static Integer intValue(String s) {
+ return Integer.valueOf(s);
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ExtensionMethodFunctional.java b/test/transform/resource/after-delombok/ExtensionMethodFunctional.java
new file mode 100644
index 00000000..2b82a957
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodFunctional.java
@@ -0,0 +1,42 @@
+// version 8:
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+class ExtensionMethodFunctional {
+ public void test() {
+ String test = "test";
+ test = ExtensionMethodFunctional.Extensions.map(test, s -> ExtensionMethodFunctional.Extensions.reverse(s));
+ ExtensionMethodFunctional.Extensions.consume(test, s -> System.out.println("1: " + s), s -> System.out.println("2: " + s));
+ ExtensionMethodFunctional.Extensions.consume(test, System.out::println, System.out::println);
+ ExtensionMethodFunctional.Extensions.toList1(Stream.of("a", "b", "c").map(String::toUpperCase));
+ List<Integer> i2 = ExtensionMethodFunctional.Extensions.toList2(Stream.of("a", "b", "c").map(String::toUpperCase));
+ }
+
+ static class Extensions {
+ public static <T, R> R map(T value, Function<T, R> mapper) {
+ return mapper.apply(value);
+ }
+
+ public static String reverse(String string) {
+ return new StringBuilder(string).reverse().toString();
+ }
+
+ @SafeVarargs
+ public static <T> void consume(T o, Consumer<T>... consumer) {
+ for (int i = 0; i < consumer.length; i++) {
+ consumer[i].accept(o);
+ }
+ }
+
+ public static <T> List<T> toList1(Stream<T> stream) {
+ return (List<T>) stream.collect(Collectors.toList());
+ }
+
+ public static <T, U> List<U> toList2(Stream<T> stream) {
+ return null;
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/ExtensionMethodGeneric.java b/test/transform/resource/after-delombok/ExtensionMethodGeneric.java
new file mode 100644
index 00000000..8559b7ff
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodGeneric.java
@@ -0,0 +1,33 @@
+import java.util.List;
+import java.util.Map;
+
+class ExtensionMethodGeneric {
+ public void test() {
+ List<String> stringList = null;
+ List<Number> numberList = null;
+ ExtensionMethodGeneric.Extensions.test(stringList);
+ ExtensionMethodGeneric.Extensions.test(stringList, numberList);
+ ExtensionMethodGeneric.Extensions.test(ExtensionMethodGeneric.Extensions.test(stringList, stringList), numberList);
+ Integer i = ExtensionMethodGeneric.Extensions.test2(stringList);
+ Map<String, Integer> map = null;
+ List<String> l = ExtensionMethodGeneric.Extensions.test(map, stringList, numberList);
+ }
+
+ static class Extensions {
+ public static <T> List<T> test(List<String> obj, List<T> list) {
+ return null;
+ }
+
+ public static <K, V> K test(Map<String, Integer> obj, K k, V v) {
+ return k;
+ }
+
+ public static <T> T test(List<T> list) {
+ return null;
+ }
+
+ public static <T, U> U test2(List<T> list) {
+ return null;
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/ExtensionMethodNames.java b/test/transform/resource/after-delombok/ExtensionMethodNames.java
new file mode 100644
index 00000000..45f76ee4
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodNames.java
@@ -0,0 +1,27 @@
+package a;
+
+class ExtensionMethodNames {
+
+ public void instanceCalls() {
+ a.Extensions.ext((new Test()));
+ Test t = new Test();
+ a.Extensions.ext(t);
+ Test Test = new Test();
+ a.Extensions.ext(Test);
+ }
+
+ public void staticCalls() {
+ Test.ext();
+ a.Test.ext();
+ }
+}
+
+class Extensions {
+ public static void ext(Test t) {
+ }
+}
+
+class Test {
+ public static void ext() {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ExtensionMethodSuppress.java b/test/transform/resource/after-delombok/ExtensionMethodSuppress.java
new file mode 100644
index 00000000..d9e7cb28
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodSuppress.java
@@ -0,0 +1,33 @@
+class ExtensionMethodSuppress {
+ public void test() {
+ Test.staticMethod();
+ Test test = new Test();
+ Extensions.instanceMethod(test);
+ Extensions.staticMethod(test);
+ }
+}
+
+class ExtensionMethodKeep {
+ public void test() {
+ Test.staticMethod();
+ Test test = new Test();
+ test.instanceMethod();
+ test.staticMethod();
+ }
+}
+
+class Test {
+ public static void staticMethod() {
+ }
+
+ public void instanceMethod() {
+ }
+}
+
+class Extensions {
+ public static void staticMethod(Test test) {
+ }
+
+ public static void instanceMethod(Test test) {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ExtensionMethodVarargs.java b/test/transform/resource/after-delombok/ExtensionMethodVarargs.java
new file mode 100644
index 00000000..237b73ef
--- /dev/null
+++ b/test/transform/resource/after-delombok/ExtensionMethodVarargs.java
@@ -0,0 +1,19 @@
+class ExtensionMethodVarargs {
+ public void test() {
+ Long l1 = 1L;
+ long l2 = 1L;
+ Integer i1 = 1;
+ int i2 = 1;
+ ExtensionMethodVarargs.Extensions.format("%d %d %d %d", l1, l2, i1, i2);
+ ExtensionMethodVarargs.Extensions.format("%d", l1);
+ ExtensionMethodVarargs.Extensions.format("", new Integer[] {1, 2});
+ ExtensionMethodVarargs.Extensions.format("", new Integer[] {1, 2}, new Integer[] {1, 2});
+ }
+
+
+ static class Extensions {
+ public static String format(String string, Object... params) {
+ return String.format(string, params);
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/GetterLazyArguments.java b/test/transform/resource/after-delombok/GetterLazyArguments.java
index a8a422c0..604513cd 100644
--- a/test/transform/resource/after-delombok/GetterLazyArguments.java
+++ b/test/transform/resource/after-delombok/GetterLazyArguments.java
@@ -1,3 +1,4 @@
+// version 8:
class GetterLazyArguments {
static String fun() {
return null;
diff --git a/test/transform/resource/after-delombok/GetterOnClass.java b/test/transform/resource/after-delombok/GetterOnClass.java
index f0025370..ae845e54 100644
--- a/test/transform/resource/after-delombok/GetterOnClass.java
+++ b/test/transform/resource/after-delombok/GetterOnClass.java
@@ -1,3 +1,4 @@
+//version 8:
class GetterOnClass1 {
boolean isNone;
boolean isPublic;
diff --git a/test/transform/resource/after-delombok/I2335_BuilderMultipleObtainVia.java b/test/transform/resource/after-delombok/I2335_BuilderMultipleObtainVia.java
index f9cd424d..6cf390ed 100644
--- a/test/transform/resource/after-delombok/I2335_BuilderMultipleObtainVia.java
+++ b/test/transform/resource/after-delombok/I2335_BuilderMultipleObtainVia.java
@@ -26,11 +26,17 @@ public class I2335_BuilderMultipleObtainVia {
@java.lang.SuppressWarnings("all")
I2335_BuilderMultipleObtainViaBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public I2335_BuilderMultipleObtainVia.I2335_BuilderMultipleObtainViaBuilder theString(final String theString) {
this.theString = theString;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public I2335_BuilderMultipleObtainVia.I2335_BuilderMultipleObtainViaBuilder theLong(final Long theLong) {
this.theLong = theLong;
diff --git a/test/transform/resource/after-delombok/JacksonBuilderSingular.java b/test/transform/resource/after-delombok/JacksonBuilderSingular.java
index feaa6832..b2bbfa5a 100644
--- a/test/transform/resource/after-delombok/JacksonBuilderSingular.java
+++ b/test/transform/resource/after-delombok/JacksonBuilderSingular.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnySetter;
diff --git a/test/transform/resource/after-delombok/JacksonJsonProperty.java b/test/transform/resource/after-delombok/JacksonJsonProperty.java
index 9ca8d7de..7bb17dfd 100644
--- a/test/transform/resource/after-delombok/JacksonJsonProperty.java
+++ b/test/transform/resource/after-delombok/JacksonJsonProperty.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
@@ -16,6 +17,9 @@ public class JacksonJsonProperty {
@java.lang.SuppressWarnings("all")
JacksonJsonPropertyBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@JsonProperty("kebab-case-prop")
@JsonSetter(nulls = Nulls.SKIP)
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/JacksonizedBuilderComplex.java b/test/transform/resource/after-delombok/JacksonizedBuilderComplex.java
index 30f6b9af..ed0ca9e7 100644
--- a/test/transform/resource/after-delombok/JacksonizedBuilderComplex.java
+++ b/test/transform/resource/after-delombok/JacksonizedBuilderComplex.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
//CONF: lombok.builder.className = Test*Name
import java.util.List;
@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedBuilderComplex.TestVoidName.class)
@@ -18,21 +19,33 @@ class JacksonizedBuilderComplex {
@java.lang.SuppressWarnings("all")
TestVoidName() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderComplex.TestVoidName<T> withNumber(final T number) {
this.number = number;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderComplex.TestVoidName<T> withArg2(final int arg2) {
this.arg2 = arg2;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderComplex.TestVoidName<T> withArg3(final String arg3) {
this.arg3 = arg3;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderComplex.TestVoidName<T> withSelfRef(final JacksonizedBuilderComplex selfRef) {
this.selfRef = selfRef;
diff --git a/test/transform/resource/after-delombok/JacksonizedBuilderSimple.java b/test/transform/resource/after-delombok/JacksonizedBuilderSimple.java
index bd79df90..cb8390d2 100644
--- a/test/transform/resource/after-delombok/JacksonizedBuilderSimple.java
+++ b/test/transform/resource/after-delombok/JacksonizedBuilderSimple.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -23,11 +24,17 @@ class JacksonizedBuilderSimple<T> {
@java.lang.SuppressWarnings("all")
JacksonizedBuilderSimpleBuilder() {
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderSimple.JacksonizedBuilderSimpleBuilder<T> yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public JacksonizedBuilderSimple.JacksonizedBuilderSimpleBuilder<T> also(final List<T> also) {
this.also = also;
diff --git a/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java b/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java
index 7fd3f8dc..88a51f41 100644
--- a/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java
+++ b/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java
@@ -1,55 +1,59 @@
-public class JacksonizedSuperBuilderSimple {
- @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)
- @com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl.class)
- public static class Parent {
- int field1;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends JacksonizedSuperBuilderSimple.Parent, B extends JacksonizedSuperBuilderSimple.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "JacksonizedSuperBuilderSimple.Parent.ParentBuilder(field1=" + this.field1 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)
- @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- static final class ParentBuilderImpl extends JacksonizedSuperBuilderSimple.Parent.ParentBuilder<JacksonizedSuperBuilderSimple.Parent, JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public JacksonizedSuperBuilderSimple.Parent build() {
- return new JacksonizedSuperBuilderSimple.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final JacksonizedSuperBuilderSimple.Parent.ParentBuilder<?, ?> b) {
- this.field1 = b.field1;
- }
- @java.lang.SuppressWarnings("all")
- public static JacksonizedSuperBuilderSimple.Parent.ParentBuilder<?, ?> builder() {
- return new JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl();
- }
- }
- public static void test() {
- Parent x = Parent.builder().field1(5).build();
- }
-}
+//version 8: Jackson deps are at least Java7+.
+public class JacksonizedSuperBuilderSimple {
+ @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)
+ @com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl.class)
+ public static class Parent {
+ int field1;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends JacksonizedSuperBuilderSimple.Parent, B extends JacksonizedSuperBuilderSimple.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "JacksonizedSuperBuilderSimple.Parent.ParentBuilder(field1=" + this.field1 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ @com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)
+ @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ static final class ParentBuilderImpl extends JacksonizedSuperBuilderSimple.Parent.ParentBuilder<JacksonizedSuperBuilderSimple.Parent, JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public JacksonizedSuperBuilderSimple.Parent build() {
+ return new JacksonizedSuperBuilderSimple.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final JacksonizedSuperBuilderSimple.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static JacksonizedSuperBuilderSimple.Parent.ParentBuilder<?, ?> builder() {
+ return new JacksonizedSuperBuilderSimple.Parent.ParentBuilderImpl();
+ }
+ }
+ public static void test() {
+ Parent x = Parent.builder().field1(5).build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java b/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java
index a94d5f5b..1ed38f05 100644
--- a/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java
+++ b/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java
@@ -1,5 +1,4 @@
//skip-idempotent
-@lombok.experimental.SuperBuilder
@com.fasterxml.jackson.databind.annotation.JsonDeserialize
public class JacksonizedSuperBuilderWithJsonDeserialize {
int field1;
@@ -11,6 +10,9 @@ public class JacksonizedSuperBuilderWithJsonDeserialize {
protected abstract B self();
@java.lang.SuppressWarnings("all")
public abstract C build();
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B field1(final int field1) {
this.field1 = field1;
diff --git a/test/transform/resource/after-delombok/JavadocMultiline.java b/test/transform/resource/after-delombok/JavadocMultiline.java
new file mode 100644
index 00000000..cc8b1148
--- /dev/null
+++ b/test/transform/resource/after-delombok/JavadocMultiline.java
@@ -0,0 +1,51 @@
+class JavadocMultiline {
+ /**
+ * This is a list of booleans.
+ */
+ private java.util.List<Boolean> booleans;
+ /**
+ * This is a list of booleans.
+ */
+ private java.util.List<Boolean> booleans2;
+
+ /**
+ * This is a list of booleans.
+ *
+ * @return A list of booleans to set for this object. This is a Javadoc return that is long
+ * enough to wrap to multiple lines.
+ */
+ @java.lang.SuppressWarnings("all")
+ public java.util.List<Boolean> getBooleans() {
+ return this.booleans;
+ }
+
+ /**
+ * This is a list of booleans.
+ */
+ @java.lang.SuppressWarnings("all")
+ public java.util.List<Boolean> getBooleans2() {
+ return this.booleans2;
+ }
+
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ */
+ @java.lang.SuppressWarnings("all")
+ public void setBooleans(final java.util.List<Boolean> booleans) {
+ this.booleans = booleans;
+ }
+
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ */
+ @java.lang.SuppressWarnings("all")
+ public void setBooleans2(final java.util.List<Boolean> booleans2) {
+ this.booleans2 = booleans2;
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java
index b32c7722..cba516f2 100644
--- a/test/transform/resource/after-delombok/LoggerLog4j2.java
+++ b/test/transform/resource/after-delombok/LoggerLog4j2.java
@@ -1,3 +1,4 @@
+//version 8:
class LoggerLog4j2 {
@java.lang.SuppressWarnings("all")
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2.class);
diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java
index 70f11ae4..152c8708 100644
--- a/test/transform/resource/after-delombok/LoggerSlf4j.java
+++ b/test/transform/resource/after-delombok/LoggerSlf4j.java
@@ -29,8 +29,3 @@ class LoggerSlf4jWithTwoStaticFields {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithTwoStaticFields.TOPIC + LoggerSlf4jWithTwoStaticFields.TOPIC);
static final String TOPIC = "StaticField";
}
-
-class LoggerSlf4jWithTwoLiterals {
- @java.lang.SuppressWarnings("all")
- private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("A" + "B");
-} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerSlf4jInvalidTopic.java b/test/transform/resource/after-delombok/LoggerSlf4jInvalidTopic.java
deleted file mode 100644
index 86e6ae2c..00000000
--- a/test/transform/resource/after-delombok/LoggerSlf4jInvalidTopic.java
+++ /dev/null
@@ -1,5 +0,0 @@
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j(topic = 42)
-class LoggerSlf4jWithIntegerTopic {
-} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/NonNullOnParameter.java b/test/transform/resource/after-delombok/NonNullOnParameter.java
index 4f6df920..95fd13ec 100644
--- a/test/transform/resource/after-delombok/NonNullOnParameter.java
+++ b/test/transform/resource/after-delombok/NonNullOnParameter.java
@@ -1,3 +1,4 @@
+//version 8:
class NonNullOnParameter extends Thread {
NonNullOnParameter(@lombok.NonNull String arg) {
this(arg, "");
diff --git a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java
index 88577f25..df496931 100644
--- a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java
+++ b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java
@@ -1,3 +1,4 @@
+//version 8:
abstract class NonNullOnParameterAbstract {
public void test(@lombok.NonNull String arg) {
if (arg == null) {
diff --git a/test/transform/resource/after-delombok/NonNullPlain.java b/test/transform/resource/after-delombok/NonNullPlain.java
index 24377237..9fc29042 100644
--- a/test/transform/resource/after-delombok/NonNullPlain.java
+++ b/test/transform/resource/after-delombok/NonNullPlain.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.*;
class NonNullPlain {
@lombok.NonNull
diff --git a/test/transform/resource/after-delombok/NonNullTypeUse.java b/test/transform/resource/after-delombok/NonNullTypeUse.java
index 7c438501..b80a6da8 100644
--- a/test/transform/resource/after-delombok/NonNullTypeUse.java
+++ b/test/transform/resource/after-delombok/NonNullTypeUse.java
@@ -1,3 +1,4 @@
+//version 8:
import lombok.NonNull;
class NonNullTypeUse {
void test1(@NonNull String[][][] args) {
diff --git a/test/transform/resource/after-delombok/NonNullWithAlternateException.java b/test/transform/resource/after-delombok/NonNullWithAlternateException.java
index 7f30fd1f..e76feca2 100644
--- a/test/transform/resource/after-delombok/NonNullWithAlternateException.java
+++ b/test/transform/resource/after-delombok/NonNullWithAlternateException.java
@@ -1,3 +1,4 @@
+//version 8:
public class NonNullWithAlternateException {
@lombok.NonNull
private String test;
diff --git a/test/transform/resource/after-delombok/NonNullWithAssertion.java b/test/transform/resource/after-delombok/NonNullWithAssertion.java
index 15dc0254..318d85b9 100644
--- a/test/transform/resource/after-delombok/NonNullWithAssertion.java
+++ b/test/transform/resource/after-delombok/NonNullWithAssertion.java
@@ -1,3 +1,4 @@
+//version 8:
public class NonNullWithAssertion {
@lombok.NonNull
private String test;
diff --git a/test/transform/resource/after-delombok/NonNullWithGuava.java b/test/transform/resource/after-delombok/NonNullWithGuava.java
index b3c13d30..efa5878e 100644
--- a/test/transform/resource/after-delombok/NonNullWithGuava.java
+++ b/test/transform/resource/after-delombok/NonNullWithGuava.java
@@ -1,3 +1,4 @@
+//version 8:
import static com.google.common.base.Preconditions.*;
public class NonNullWithGuava {
@lombok.NonNull
diff --git a/test/transform/resource/after-delombok/NonNullWithJdk.java b/test/transform/resource/after-delombok/NonNullWithJdk.java
index d7e2958c..725d90c7 100644
--- a/test/transform/resource/after-delombok/NonNullWithJdk.java
+++ b/test/transform/resource/after-delombok/NonNullWithJdk.java
@@ -1,4 +1,4 @@
-//version 7:
+//version 8:
import static java.util.Objects.*;
public class NonNullWithJdk {
@lombok.NonNull
diff --git a/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java
index 44640164..cd7f8092 100644
--- a/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java
+++ b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java
@@ -1,3 +1,4 @@
+//version 8:
class NonNullWithSneakyThrows {
void test(@lombok.NonNull String in) {
try {
diff --git a/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java
new file mode 100644
index 00000000..25a76c6d
--- /dev/null
+++ b/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java
@@ -0,0 +1,237 @@
+//version 8:
+//CONF: lombok.addNullAnnotations = checkerframework
+import java.util.List;
+
+class NullAnnotatedCheckerFrameworkSuperBuilder {
+
+ 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 NullAnnotatedCheckerFrameworkSuperBuilder.Parent, B extends NullAnnotatedCheckerFrameworkSuperBuilder.Parent.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;
+
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B x(final int x) {
+ this.x$value = x;
+ x$set = true;
+ return self();
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B y(final int y) {
+ this.y = y;
+ return self();
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B z(final int z) {
+ this.z = z;
+ return self();
+ }
+
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @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.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B names(final java.util.@org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
+ if (names == null) {
+ throw new java.lang.NullPointerException("names cannot be null");
+ }
+ if (this.names == null) this.names = new java.util.ArrayList<String>();
+ this.names.addAll(names);
+ return self();
+ }
+
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B clearNames() {
+ if (this.names != null) this.names.clear();
+ return self();
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.@org.checkerframework.checker.nullness.qual.NonNull String toString() {
+ return "NullAnnotatedCheckerFrameworkSuperBuilder.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 NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilder<NullAnnotatedCheckerFrameworkSuperBuilder.Parent, NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public NullAnnotatedCheckerFrameworkSuperBuilder.@org.checkerframework.checker.nullness.qual.NonNull Parent build() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.Parent(this);
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> b) {
+ if (b.x$set) this.x = b.x$value;
+ else this.x = NullAnnotatedCheckerFrameworkSuperBuilder.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;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static NullAnnotatedCheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.nullness.qual.NonNull ParentBuilder<?, ?> builder() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl();
+ }
+ }
+
+
+ public static class ZChild 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 ZChildBuilder<C extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild, B extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<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
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B a(final int a) {
+ this.a$value = a;
+ a$set = true;
+ return self();
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @org.checkerframework.checker.nullness.qual.NonNull
+ @java.lang.SuppressWarnings("all")
+ public B b(final int b) {
+ this.b = b;
+ return self();
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.@org.checkerframework.checker.nullness.qual.NonNull String toString() {
+ return "NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString() + ", a$value=" + this.a$value + ", b=" + this.b + ")";
+ }
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ private static final class ZChildBuilderImpl extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<NullAnnotatedCheckerFrameworkSuperBuilder.ZChild, NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ZChildBuilderImpl() {
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() {
+ return this;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public NullAnnotatedCheckerFrameworkSuperBuilder.@org.checkerframework.checker.nullness.qual.NonNull ZChild build() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.ZChild(this);
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected ZChild(final NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> b) {
+ super(b);
+ if (b.a$set) this.a = b.a$value;
+ else this.a = NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.$default$a();
+ this.b = b.b;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.nullness.qual.NonNull ZChildBuilder<?, ?> builder() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl();
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/NullLibrary1.java b/test/transform/resource/after-delombok/NullLibrary1.java
index e426e3d3..e299be3d 100644
--- a/test/transform/resource/after-delombok/NullLibrary1.java
+++ b/test/transform/resource/after-delombok/NullLibrary1.java
@@ -1,3 +1,4 @@
+//version 8:
public class NullLibrary1 {
String foo;
@java.lang.Override
@@ -34,6 +35,9 @@ public class NullLibrary1 {
public NullLibrary1(final String foo) {
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@org.eclipse.jdt.annotation.NonNull
@java.lang.SuppressWarnings("all")
public NullLibrary1 withFoo(final String foo) {
diff --git a/test/transform/resource/after-delombok/NullLibrary2.java b/test/transform/resource/after-delombok/NullLibrary2.java
index 8f48c8a5..fec143c2 100644
--- a/test/transform/resource/after-delombok/NullLibrary2.java
+++ b/test/transform/resource/after-delombok/NullLibrary2.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
public class NullLibrary2 {
String foo;
@java.lang.Override
@@ -35,6 +36,9 @@ public class NullLibrary2 {
public NullLibrary2(final String foo) {
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@org.springframework.lang.NonNull
@java.lang.SuppressWarnings("all")
public NullLibrary2 withFoo(final String foo) {
diff --git a/test/transform/resource/after-delombok/SetterOnClass.java b/test/transform/resource/after-delombok/SetterOnClass.java
index 24f376cb..d95a280f 100644
--- a/test/transform/resource/after-delombok/SetterOnClass.java
+++ b/test/transform/resource/after-delombok/SetterOnClass.java
@@ -1,3 +1,4 @@
+//version 8:
class SetterOnClass1 {
boolean isNone;
boolean isPublic;
diff --git a/test/transform/resource/after-delombok/StaticConstructor.java b/test/transform/resource/after-delombok/StaticConstructor.java
index f9c862d7..4de6dbe5 100644
--- a/test/transform/resource/after-delombok/StaticConstructor.java
+++ b/test/transform/resource/after-delombok/StaticConstructor.java
@@ -1,3 +1,4 @@
+//version 8:
public class StaticConstructor {
String name;
@java.lang.SuppressWarnings("all")
diff --git a/test/transform/resource/after-delombok/SuperBuilderAbstract.java b/test/transform/resource/after-delombok/SuperBuilderAbstract.java
index a5825bf4..727c5beb 100644
--- a/test/transform/resource/after-delombok/SuperBuilderAbstract.java
+++ b/test/transform/resource/after-delombok/SuperBuilderAbstract.java
@@ -1,129 +1,138 @@
-public class SuperBuilderAbstract {
- public static class Parent {
- int parentField;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderAbstract.Parent, B extends SuperBuilderAbstract.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int parentField;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B parentField(final int parentField) {
- this.parentField = parentField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstract.Parent.ParentBuilder(parentField=" + this.parentField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderAbstract.Parent.ParentBuilder<SuperBuilderAbstract.Parent, SuperBuilderAbstract.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderAbstract.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstract.Parent build() {
- return new SuperBuilderAbstract.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderAbstract.Parent.ParentBuilder<?, ?> b) {
- this.parentField = b.parentField;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderAbstract.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderAbstract.Parent.ParentBuilderImpl();
- }
- }
- public static abstract class Child extends Parent {
- double childField;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderAbstract.Child, B extends SuperBuilderAbstract.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double childField;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B childField(final double childField) {
- this.childField = childField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderAbstract.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.childField = b.childField;
- }
- }
- public static class GrandChild extends Child {
- String grandChildField;
- @java.lang.SuppressWarnings("all")
- public static abstract class GrandChildBuilder<C extends SuperBuilderAbstract.GrandChild, B extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private String grandChildField;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B grandChildField(final String grandChildField) {
- this.grandChildField = grandChildField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class GrandChildBuilderImpl extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<SuperBuilderAbstract.GrandChild, SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private GrandChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstract.GrandChild build() {
- return new SuperBuilderAbstract.GrandChild(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected GrandChild(final SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> b) {
- super(b);
- this.grandChildField = b.grandChildField;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> builder() {
- return new SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl();
- }
- }
- public static void test() {
- GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build();
- }
-}
+public class SuperBuilderAbstract {
+ public static class Parent {
+ int parentField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderAbstract.Parent, B extends SuperBuilderAbstract.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int parentField;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B parentField(final int parentField) {
+ this.parentField = parentField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstract.Parent.ParentBuilder(parentField=" + this.parentField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderAbstract.Parent.ParentBuilder<SuperBuilderAbstract.Parent, SuperBuilderAbstract.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderAbstract.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstract.Parent build() {
+ return new SuperBuilderAbstract.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderAbstract.Parent.ParentBuilder<?, ?> b) {
+ this.parentField = b.parentField;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderAbstract.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderAbstract.Parent.ParentBuilderImpl();
+ }
+ }
+ public static abstract class Child extends Parent {
+ double childField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderAbstract.Child, B extends SuperBuilderAbstract.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double childField;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B childField(final double childField) {
+ this.childField = childField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderAbstract.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.childField = b.childField;
+ }
+ }
+ public static class GrandChild extends Child {
+ String grandChildField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class GrandChildBuilder<C extends SuperBuilderAbstract.GrandChild, B extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private String grandChildField;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B grandChildField(final String grandChildField) {
+ this.grandChildField = grandChildField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class GrandChildBuilderImpl extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<SuperBuilderAbstract.GrandChild, SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private GrandChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstract.GrandChild build() {
+ return new SuperBuilderAbstract.GrandChild(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected GrandChild(final SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> b) {
+ super(b);
+ this.grandChildField = b.grandChildField;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> builder() {
+ return new SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl();
+ }
+ }
+ public static void test() {
+ GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java
index aef3976f..53962c60 100644
--- a/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java
+++ b/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java
@@ -1,168 +1,177 @@
-public class SuperBuilderAbstractToBuilder {
- public static class Parent {
- int parentField;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderAbstractToBuilder.Parent, B extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int parentField;
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- SuperBuilderAbstractToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Parent instance, final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
- b.parentField(instance.parentField);
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B parentField(final int parentField) {
- this.parentField = parentField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstractToBuilder.Parent.ParentBuilder(parentField=" + this.parentField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<SuperBuilderAbstractToBuilder.Parent, SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstractToBuilder.Parent build() {
- return new SuperBuilderAbstractToBuilder.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
- this.parentField = b.parentField;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static abstract class Child extends Parent {
- double childField;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderAbstractToBuilder.Child, B extends SuperBuilderAbstractToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double childField;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderAbstractToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Child instance, final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
- b.childField(instance.childField);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B childField(final double childField) {
- this.childField = childField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.childField = b.childField;
- }
- }
- public static class GrandChild extends Child {
- String grandChildField;
- @java.lang.SuppressWarnings("all")
- public static abstract class GrandChildBuilder<C extends SuperBuilderAbstractToBuilder.GrandChild, B extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private String grandChildField;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.GrandChild instance, final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
- b.grandChildField(instance.grandChildField);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B grandChildField(final String grandChildField) {
- this.grandChildField = grandChildField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class GrandChildBuilderImpl extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<SuperBuilderAbstractToBuilder.GrandChild, SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private GrandChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstractToBuilder.GrandChild build() {
- return new SuperBuilderAbstractToBuilder.GrandChild(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected GrandChild(final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
- super(b);
- this.grandChildField = b.grandChildField;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> builder() {
- return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static void test() {
- GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build().toBuilder().build();
- }
-}
+public class SuperBuilderAbstractToBuilder {
+ public static class Parent {
+ int parentField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderAbstractToBuilder.Parent, B extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int parentField;
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ SuperBuilderAbstractToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Parent instance, final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
+ b.parentField(instance.parentField);
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B parentField(final int parentField) {
+ this.parentField = parentField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstractToBuilder.Parent.ParentBuilder(parentField=" + this.parentField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<SuperBuilderAbstractToBuilder.Parent, SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstractToBuilder.Parent build() {
+ return new SuperBuilderAbstractToBuilder.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
+ this.parentField = b.parentField;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static abstract class Child extends Parent {
+ double childField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderAbstractToBuilder.Child, B extends SuperBuilderAbstractToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double childField;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderAbstractToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Child instance, final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
+ b.childField(instance.childField);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B childField(final double childField) {
+ this.childField = childField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.childField = b.childField;
+ }
+ }
+ public static class GrandChild extends Child {
+ String grandChildField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class GrandChildBuilder<C extends SuperBuilderAbstractToBuilder.GrandChild, B extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private String grandChildField;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.GrandChild instance, final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
+ b.grandChildField(instance.grandChildField);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B grandChildField(final String grandChildField) {
+ this.grandChildField = grandChildField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class GrandChildBuilderImpl extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<SuperBuilderAbstractToBuilder.GrandChild, SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private GrandChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstractToBuilder.GrandChild build() {
+ return new SuperBuilderAbstractToBuilder.GrandChild(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected GrandChild(final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
+ super(b);
+ this.grandChildField = b.grandChildField;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> builder() {
+ return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static void test() {
+ GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderBasic.java b/test/transform/resource/after-delombok/SuperBuilderBasic.java
index c3fa86f2..7fff2ef8 100644
--- a/test/transform/resource/after-delombok/SuperBuilderBasic.java
+++ b/test/transform/resource/after-delombok/SuperBuilderBasic.java
@@ -1,136 +1,142 @@
-import java.util.List;
-public class SuperBuilderBasic {
- public static class Parent {
- int field1;
- List<String> items;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderBasic.Parent, B extends SuperBuilderBasic.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderBasic.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderBasic.Parent.ParentBuilder<SuperBuilderBasic.Parent, SuperBuilderBasic.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderBasic.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasic.Parent build() {
- return new SuperBuilderBasic.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderBasic.Parent.ParentBuilder<?, ?> b) {
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderBasic.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderBasic.Parent.ParentBuilderImpl();
- }
- }
- public static class Child extends SuperBuilderBasic.Parent {
- double field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderBasic.Child, B extends SuperBuilderBasic.Child.ChildBuilder<C, B>> extends SuperBuilderBasic.Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl extends SuperBuilderBasic.Child.ChildBuilder<SuperBuilderBasic.Child, SuperBuilderBasic.Child.ChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderBasic.Child.ChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasic.Child build() {
- return new SuperBuilderBasic.Child(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderBasic.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderBasic.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderBasic.Child.ChildBuilderImpl();
- }
- }
- public static void test() {
- Child x = Child.builder().field3(0.0).field1(5).item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderBasic {
+ public static class Parent {
+ int field1;
+ List<String> items;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderBasic.Parent, B extends SuperBuilderBasic.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderBasic.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderBasic.Parent.ParentBuilder<SuperBuilderBasic.Parent, SuperBuilderBasic.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderBasic.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasic.Parent build() {
+ return new SuperBuilderBasic.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderBasic.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderBasic.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderBasic.Parent.ParentBuilderImpl();
+ }
+ }
+ public static class Child extends SuperBuilderBasic.Parent {
+ double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderBasic.Child, B extends SuperBuilderBasic.Child.ChildBuilder<C, B>> extends SuperBuilderBasic.Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderBasic.Child.ChildBuilder<SuperBuilderBasic.Child, SuperBuilderBasic.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderBasic.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasic.Child build() {
+ return new SuperBuilderBasic.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderBasic.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderBasic.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderBasic.Child.ChildBuilderImpl();
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java
index c0a80f93..add6f841 100644
--- a/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java
+++ b/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java
@@ -1,201 +1,216 @@
-import java.util.List;
-public class SuperBuilderBasicToBuilder {
- public static class Parent {
- private int field1;
- int obtainViaField;
- int obtainViaMethod;
- String obtainViaStaticMethod;
- List<String> items;
- private int method() {
- return 2;
- }
- private static String staticMethod(Parent instance) {
- return "staticMethod";
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderBasicToBuilder.Parent, B extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- @java.lang.SuppressWarnings("all")
- private int obtainViaField;
- @java.lang.SuppressWarnings("all")
- private int obtainViaMethod;
- @java.lang.SuppressWarnings("all")
- private String obtainViaStaticMethod;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- SuperBuilderBasicToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Parent instance, final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
- b.field1(instance.field1);
- b.obtainViaField(instance.field1);
- b.obtainViaMethod(instance.method());
- b.obtainViaStaticMethod(SuperBuilderBasicToBuilder.Parent.staticMethod(instance));
- b.items(instance.items == null ? java.util.Collections.emptyList() : instance.items);
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B obtainViaField(final int obtainViaField) {
- this.obtainViaField = obtainViaField;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B obtainViaMethod(final int obtainViaMethod) {
- this.obtainViaMethod = obtainViaMethod;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B obtainViaStaticMethod(final String obtainViaStaticMethod) {
- this.obtainViaStaticMethod = obtainViaStaticMethod;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderBasicToBuilder.Parent.ParentBuilder(field1=" + this.field1 + ", obtainViaField=" + this.obtainViaField + ", obtainViaMethod=" + this.obtainViaMethod + ", obtainViaStaticMethod=" + this.obtainViaStaticMethod + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<SuperBuilderBasicToBuilder.Parent, SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasicToBuilder.Parent build() {
- return new SuperBuilderBasicToBuilder.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
- this.field1 = b.field1;
- this.obtainViaField = b.obtainViaField;
- this.obtainViaMethod = b.obtainViaMethod;
- this.obtainViaStaticMethod = b.obtainViaStaticMethod;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static class Child extends Parent {
- private double field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderBasicToBuilder.Child, B extends SuperBuilderBasicToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderBasicToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Child instance, final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
- b.field3(instance.field3);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl extends SuperBuilderBasicToBuilder.Child.ChildBuilder<SuperBuilderBasicToBuilder.Child, SuperBuilderBasicToBuilder.Child.ChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderBasicToBuilder.Child.ChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasicToBuilder.Child build() {
- return new SuperBuilderBasicToBuilder.Child(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static void test() {
- Child x = Child.builder().field3(0.0).field1(5).item("").build().toBuilder().build();
- }
-}
+import java.util.List;
+public class SuperBuilderBasicToBuilder {
+ public static class Parent {
+ private int field1;
+ int obtainViaField;
+ int obtainViaMethod;
+ String obtainViaStaticMethod;
+ List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderBasicToBuilder.Parent, B extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaField;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaMethod;
+ @java.lang.SuppressWarnings("all")
+ private String obtainViaStaticMethod;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ SuperBuilderBasicToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Parent instance, final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
+ b.field1(instance.field1);
+ b.obtainViaField(instance.field1);
+ b.obtainViaMethod(instance.method());
+ b.obtainViaStaticMethod(SuperBuilderBasicToBuilder.Parent.staticMethod(instance));
+ b.items(instance.items == null ? java.util.Collections.<String>emptyList() : instance.items);
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B obtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B obtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B obtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderBasicToBuilder.Parent.ParentBuilder(field1=" + this.field1 + ", obtainViaField=" + this.obtainViaField + ", obtainViaMethod=" + this.obtainViaMethod + ", obtainViaStaticMethod=" + this.obtainViaStaticMethod + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<SuperBuilderBasicToBuilder.Parent, SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasicToBuilder.Parent build() {
+ return new SuperBuilderBasicToBuilder.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static class Child extends Parent {
+ private double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderBasicToBuilder.Child, B extends SuperBuilderBasicToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderBasicToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Child instance, final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
+ b.field3(instance.field3);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderBasicToBuilder.Child.ChildBuilder<SuperBuilderBasicToBuilder.Child, SuperBuilderBasicToBuilder.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderBasicToBuilder.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasicToBuilder.Child build() {
+ return new SuperBuilderBasicToBuilder.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().field3(0.0).field1(5).item("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderCustomized.java b/test/transform/resource/after-delombok/SuperBuilderCustomized.java
index f66133c9..3a0bbd9b 100644
--- a/test/transform/resource/after-delombok/SuperBuilderCustomized.java
+++ b/test/transform/resource/after-delombok/SuperBuilderCustomized.java
@@ -1,100 +1,103 @@
-import java.util.List;
-public class SuperBuilderCustomized {
- public static class Parent {
- public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- public B resetToDefault() {
- field1 = 0;
- return self();
- }
- public B field1(int field1) {
- this.field1 = field1 + 1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderCustomized.Parent.ParentBuilder(field1=" + this.field1 + ")";
- }
- }
- int field1;
- protected Parent(ParentBuilder<?, ?> b) {
- if (b.field1 == 0) throw new IllegalArgumentException("field1 must be != 0");
- this.field1 = b.field1;
- }
- public static SuperBuilderCustomized.Parent.ParentBuilder<?, ?> builder(int field1) {
- return new SuperBuilderCustomized.Parent.ParentBuilderImpl().field1(field1);
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderCustomized.Parent.ParentBuilder<SuperBuilderCustomized.Parent, SuperBuilderCustomized.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderCustomized.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderCustomized.Parent build() {
- return new SuperBuilderCustomized.Parent(this);
- }
- }
- }
- public static class Child extends Parent {
- private static final class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
- @Override
- public Child build() {
- this.resetToDefault();
- return new Child(this);
- }
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderCustomized.Child.ChildBuilderImpl self() {
- return this;
- }
- }
- double field2;
- public static ChildBuilder<?, ?> builder() {
- return new ChildBuilderImpl().field2(10.0);
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderCustomized.Child, B extends SuperBuilderCustomized.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double field2;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field2(final double field2) {
- this.field2 = field2;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString() + ", field2=" + this.field2 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderCustomized.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field2 = b.field2;
- }
- }
- public static void test() {
- Child x = Child.builder().field2(1.0).field1(5).resetToDefault().build();
- }
-}
+import java.util.List;
+public class SuperBuilderCustomized {
+ public static class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ public B resetToDefault() {
+ field1 = 0;
+ return self();
+ }
+ public B field1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderCustomized.Parent.ParentBuilder(field1=" + this.field1 + ")";
+ }
+ }
+ int field1;
+ protected Parent(ParentBuilder<?, ?> b) {
+ if (b.field1 == 0) throw new IllegalArgumentException("field1 must be != 0");
+ this.field1 = b.field1;
+ }
+ public static SuperBuilderCustomized.Parent.ParentBuilder<?, ?> builder(int field1) {
+ return new SuperBuilderCustomized.Parent.ParentBuilderImpl().field1(field1);
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderCustomized.Parent.ParentBuilder<SuperBuilderCustomized.Parent, SuperBuilderCustomized.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderCustomized.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderCustomized.Parent build() {
+ return new SuperBuilderCustomized.Parent(this);
+ }
+ }
+ }
+ public static class Child extends Parent {
+ private static final class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
+ @Override
+ public Child build() {
+ this.resetToDefault();
+ return new Child(this);
+ }
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderCustomized.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ }
+ double field2;
+ public static ChildBuilder<?, ?> builder() {
+ return new ChildBuilderImpl().field2(10.0);
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderCustomized.Child, B extends SuperBuilderCustomized.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field2;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field2(final double field2) {
+ this.field2 = field2;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString() + ", field2=" + this.field2 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderCustomized.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field2 = b.field2;
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().field2(1.0).field1(5).resetToDefault().build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java b/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java
index 8cc5dfe0..cee5ac89 100644
--- a/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/SuperBuilderCustomizedWithSetterPrefix.java
@@ -1,50 +1,50 @@
-import java.util.List;
-public class SuperBuilderCustomizedWithSetterPrefix {
- public static class Parent {
- public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- public B setField1(int field1) {
- this.field1 = field1 + 1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ")";
- }
- }
- int field1;
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderCustomizedWithSetterPrefix.Parent build() {
- return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- this.field1 = b.field1;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
- }
- }
- public static void test() {
- Parent x = Parent.builder().setField1(5).build();
- }
-}
+import java.util.List;
+public class SuperBuilderCustomizedWithSetterPrefix {
+ public static class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ public B setField1(int field1) {
+ this.field1 = field1 + 1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ")";
+ }
+ }
+ int field1;
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderCustomizedWithSetterPrefix.Parent build() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public static void test() {
+ Parent x = Parent.builder().setField1(5).build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderInitializer.java b/test/transform/resource/after-delombok/SuperBuilderInitializer.java
new file mode 100644
index 00000000..95943aa9
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderInitializer.java
@@ -0,0 +1,74 @@
+class SuperBuilderInitializer {
+
+ public static class One {
+ private String world;
+
+ {
+ world = "Hello";
+ }
+
+ private static final String world2;
+
+ static {
+ world2 = "Hello";
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ public static abstract class OneBuilder<C extends SuperBuilderInitializer.One, B extends SuperBuilderInitializer.One.OneBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private String world;
+
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B world(final String world) {
+ this.world = world;
+ return self();
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderInitializer.One.OneBuilder(world=" + this.world + ")";
+ }
+ }
+
+
+ @java.lang.SuppressWarnings("all")
+ private static final class OneBuilderImpl extends SuperBuilderInitializer.One.OneBuilder<SuperBuilderInitializer.One, SuperBuilderInitializer.One.OneBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private OneBuilderImpl() {
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderInitializer.One.OneBuilderImpl self() {
+ return this;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderInitializer.One build() {
+ return new SuperBuilderInitializer.One(this);
+ }
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected One(final SuperBuilderInitializer.One.OneBuilder<?, ?> b) {
+ this.world = b.world;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderInitializer.One.OneBuilder<?, ?> builder() {
+ return new SuperBuilderInitializer.One.OneBuilderImpl();
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderNameClashes.java b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java
index baf47dc4..8cef4e11 100644
--- a/test/transform/resource/after-delombok/SuperBuilderNameClashes.java
+++ b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java
@@ -1,124 +1,127 @@
-public class SuperBuilderNameClashes {
- public static class GenericsClash<B, C, C2> {
- @java.lang.SuppressWarnings("all")
- public static abstract class GenericsClashBuilder<B, C, C2, C3 extends SuperBuilderNameClashes.GenericsClash<B, C, C2>, B2 extends SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, C3, B2>> {
- @java.lang.SuppressWarnings("all")
- protected abstract B2 self();
- @java.lang.SuppressWarnings("all")
- public abstract C3 build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder()";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class GenericsClashBuilderImpl<B, C, C2> extends SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, SuperBuilderNameClashes.GenericsClash<B, C, C2>, SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2>> {
- @java.lang.SuppressWarnings("all")
- private GenericsClashBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderNameClashes.GenericsClash<B, C, C2> build() {
- return new SuperBuilderNameClashes.GenericsClash<B, C, C2>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected GenericsClash(final SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, ?, ?> b) {
- }
- @java.lang.SuppressWarnings("all")
- public static <B, C, C2> SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, ?, ?> builder() {
- return new SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2>();
- }
- }
- public static class B {
- @java.lang.SuppressWarnings("all")
- public static abstract class BBuilder<C extends SuperBuilderNameClashes.B, B2 extends SuperBuilderNameClashes.B.BBuilder<C, B2>> {
- @java.lang.SuppressWarnings("all")
- protected abstract B2 self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderNameClashes.B.BBuilder()";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class BBuilderImpl extends SuperBuilderNameClashes.B.BBuilder<SuperBuilderNameClashes.B, SuperBuilderNameClashes.B.BBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private BBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderNameClashes.B.BBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderNameClashes.B build() {
- return new SuperBuilderNameClashes.B(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected B(final SuperBuilderNameClashes.B.BBuilder<?, ?> b) {
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderNameClashes.B.BBuilder<?, ?> builder() {
- return new SuperBuilderNameClashes.B.BBuilderImpl();
- }
- }
- public static class C2 {
- }
- public static class C {
- C2 c2;
- @java.lang.SuppressWarnings("all")
- public static abstract class CBuilder<C3 extends SuperBuilderNameClashes.C, B extends SuperBuilderNameClashes.C.CBuilder<C3, B>> {
- @java.lang.SuppressWarnings("all")
- private C2 c2;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C3 build();
- @java.lang.SuppressWarnings("all")
- public B c2(final C2 c2) {
- this.c2 = c2;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderNameClashes.C.CBuilder(c2=" + this.c2 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class CBuilderImpl extends SuperBuilderNameClashes.C.CBuilder<SuperBuilderNameClashes.C, SuperBuilderNameClashes.C.CBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private CBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderNameClashes.C.CBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderNameClashes.C build() {
- return new SuperBuilderNameClashes.C(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected C(final SuperBuilderNameClashes.C.CBuilder<?, ?> b) {
- this.c2 = b.c2;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderNameClashes.C.CBuilder<?, ?> builder() {
- return new SuperBuilderNameClashes.C.CBuilderImpl();
- }
- }
-}
+public class SuperBuilderNameClashes {
+ public static class GenericsClash<B, C, C2> {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class GenericsClashBuilder<B, C, C2, C3 extends SuperBuilderNameClashes.GenericsClash<B, C, C2>, B2 extends SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, C3, B2>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B2 self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C3 build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class GenericsClashBuilderImpl<B, C, C2> extends SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, SuperBuilderNameClashes.GenericsClash<B, C, C2>, SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2>> {
+ @java.lang.SuppressWarnings("all")
+ private GenericsClashBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderNameClashes.GenericsClash<B, C, C2> build() {
+ return new SuperBuilderNameClashes.GenericsClash<B, C, C2>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected GenericsClash(final SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, ?, ?> b) {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <B, C, C2> SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder<B, C, C2, ?, ?> builder() {
+ return new SuperBuilderNameClashes.GenericsClash.GenericsClashBuilderImpl<B, C, C2>();
+ }
+ }
+ public static class B {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class BBuilder<C extends SuperBuilderNameClashes.B, B2 extends SuperBuilderNameClashes.B.BBuilder<C, B2>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B2 self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNameClashes.B.BBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class BBuilderImpl extends SuperBuilderNameClashes.B.BBuilder<SuperBuilderNameClashes.B, SuperBuilderNameClashes.B.BBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private BBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderNameClashes.B.BBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderNameClashes.B build() {
+ return new SuperBuilderNameClashes.B(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected B(final SuperBuilderNameClashes.B.BBuilder<?, ?> b) {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderNameClashes.B.BBuilder<?, ?> builder() {
+ return new SuperBuilderNameClashes.B.BBuilderImpl();
+ }
+ }
+ public static class C2 {
+ }
+ public static class C {
+ C2 c2;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class CBuilder<C3 extends SuperBuilderNameClashes.C, B extends SuperBuilderNameClashes.C.CBuilder<C3, B>> {
+ @java.lang.SuppressWarnings("all")
+ private C2 c2;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C3 build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B c2(final C2 c2) {
+ this.c2 = c2;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNameClashes.C.CBuilder(c2=" + this.c2 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class CBuilderImpl extends SuperBuilderNameClashes.C.CBuilder<SuperBuilderNameClashes.C, SuperBuilderNameClashes.C.CBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private CBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderNameClashes.C.CBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderNameClashes.C build() {
+ return new SuperBuilderNameClashes.C(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected C(final SuperBuilderNameClashes.C.CBuilder<?, ?> b) {
+ this.c2 = b.c2;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderNameClashes.C.CBuilder<?, ?> builder() {
+ return new SuperBuilderNameClashes.C.CBuilderImpl();
+ }
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java b/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java
index ad738c01..fadc0580 100644
--- a/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java
+++ b/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java
@@ -1,41 +1,41 @@
-public class SuperBuilderNestedGenericTypes {
- public static abstract class Generic<T extends Generic<?>> {
- @java.lang.SuppressWarnings("all")
- public static abstract class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
- }
- }
- public static abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
- @java.lang.SuppressWarnings("all")
- public static abstract class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString() + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- protected NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
- super(b);
- }
- }
- public interface OtherGeneric<T> {
- }
-}
+public class SuperBuilderNestedGenericTypes {
+ public static abstract class Generic<T extends Generic<?>> {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
+ }
+ }
+ public static abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString() + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
+ super(b);
+ }
+ }
+ public interface OtherGeneric<T> {
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java
index f6e0f024..ad51816a 100644
--- a/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java
+++ b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Set;
diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..04cfd9f2
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java
@@ -0,0 +1,77 @@
+import java.util.Set;
+class SuperBuilderSingularCustomized {
+ private Set<String> foos;
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> foos;
+ public B custom(final String value) {
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.SuppressWarnings("all")
+ public B foo(final String foo) {
+ if (this.foos == null) this.foos = new java.util.ArrayList<String>();
+ this.foos.add(foo);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B foos(final java.util.Collection<? extends String> foos) {
+ if (foos == null) {
+ throw new java.lang.NullPointerException("foos cannot be null");
+ }
+ if (this.foos == null) this.foos = new java.util.ArrayList<String>();
+ this.foos.addAll(foos);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearFoos() {
+ if (this.foos != null) this.foos.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder(foos=" + this.foos + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class SuperBuilderSingularCustomizedBuilderImpl extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<SuperBuilderSingularCustomized, SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private SuperBuilderSingularCustomizedBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderSingularCustomized build() {
+ return new SuperBuilderSingularCustomized(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderSingularCustomized(final SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> b) {
+ java.util.Set<String> foos;
+ switch (b.foos == null ? 0 : b.foos.size()) {
+ case 0:
+ foos = java.util.Collections.emptySet();
+ break;
+ case 1:
+ foos = java.util.Collections.singleton(b.foos.get(0));
+ break;
+ default:
+ foos = new java.util.LinkedHashSet<String>(b.foos.size() < 1073741824 ? 1 + b.foos.size() + (b.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE);
+ foos.addAll(b.foos);
+ foos = java.util.Collections.unmodifiableSet(foos);
+ }
+ this.foos = foos;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> builder() {
+ return new SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java
index cfa39295..9237a148 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java
@@ -1,135 +1,142 @@
-import java.util.List;
-public class SuperBuilderWithCustomBuilderMethod {
- public static class Parent<A> {
- A field1;
- List<String> items;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Parent<A>, B extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, C, B>> {
- @java.lang.SuppressWarnings("all")
- private A field1;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, SuperBuilderWithCustomBuilderMethod.Parent<A>, SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithCustomBuilderMethod.Parent<A> build() {
- return new SuperBuilderWithCustomBuilderMethod.Parent<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> b) {
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>();
- }
- }
- public static class Child<A> extends Parent<A> {
- double field3;
- public static <A> ChildBuilder<A, ?, ?> builder() {
- return new ChildBuilderImpl<A>().item("default item");
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Child<A>, B extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, SuperBuilderWithCustomBuilderMethod.Child<A>, SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithCustomBuilderMethod.Child<A> build() {
- return new SuperBuilderWithCustomBuilderMethod.Child<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
- }
-}
+//version 8: Javac 6 will error out due to `ChildBuilder` not existing before properly running lombok. Giving j6 support status, not worth fixing.
+import java.util.List;
+public class SuperBuilderWithCustomBuilderMethod {
+ public static class Parent<A> {
+ A field1;
+ List<String> items;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Parent<A>, B extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private A field1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, SuperBuilderWithCustomBuilderMethod.Parent<A>, SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithCustomBuilderMethod.Parent<A> build() {
+ return new SuperBuilderWithCustomBuilderMethod.Parent<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> b) {
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static class Child<A> extends Parent<A> {
+ double field3;
+ public static <A> ChildBuilder<A, ?, ?> builder() {
+ return new ChildBuilderImpl<A>().item("default item");
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Child<A>, B extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, SuperBuilderWithCustomBuilderMethod.Child<A>, SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithCustomBuilderMethod.Child<A> build() {
+ return new SuperBuilderWithCustomBuilderMethod.Child<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java
index ad56cea2..a9d92ff9 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java
@@ -1,134 +1,143 @@
-import java.util.List;
-public class SuperBuilderWithDefaults {
- public static class Parent<N extends Number> {
- private long millis;
- private N numberField;
- @java.lang.SuppressWarnings("all")
- private static <N extends Number> long $default$millis() {
- return System.currentTimeMillis();
- }
- @java.lang.SuppressWarnings("all")
- private static <N extends Number> N $default$numberField() {
- return null;
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<N extends Number, C extends SuperBuilderWithDefaults.Parent<N>, B extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, C, B>> {
- @java.lang.SuppressWarnings("all")
- private boolean millis$set;
- @java.lang.SuppressWarnings("all")
- private long millis$value;
- @java.lang.SuppressWarnings("all")
- private boolean numberField$set;
- @java.lang.SuppressWarnings("all")
- private N numberField$value;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B millis(final long millis) {
- this.millis$value = millis;
- millis$set = true;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B numberField(final N numberField) {
- this.numberField$value = numberField;
- numberField$set = true;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithDefaults.Parent.ParentBuilder(millis$value=" + this.millis$value + ", numberField$value=" + this.numberField$value + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl<N extends Number> extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, SuperBuilderWithDefaults.Parent<N>, SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithDefaults.Parent<N> build() {
- return new SuperBuilderWithDefaults.Parent<N>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> b) {
- if (b.millis$set) this.millis = b.millis$value;
- else this.millis = SuperBuilderWithDefaults.Parent.<N>$default$millis();
- if (b.numberField$set) this.numberField = b.numberField$value;
- else this.numberField = SuperBuilderWithDefaults.Parent.<N>$default$numberField();
- }
- @java.lang.SuppressWarnings("all")
- public static <N extends Number> SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> builder() {
- return new SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>();
- }
- }
- public static class Child extends Parent<Integer> {
- private double doubleField;
- @java.lang.SuppressWarnings("all")
- private static double $default$doubleField() {
- return Math.PI;
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderWithDefaults.Child, B extends SuperBuilderWithDefaults.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<Integer, C, B> {
- @java.lang.SuppressWarnings("all")
- private boolean doubleField$set;
- @java.lang.SuppressWarnings("all")
- private double doubleField$value;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B doubleField(final double doubleField) {
- this.doubleField$value = doubleField;
- doubleField$set = true;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString() + ", doubleField$value=" + this.doubleField$value + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl extends SuperBuilderWithDefaults.Child.ChildBuilder<SuperBuilderWithDefaults.Child, SuperBuilderWithDefaults.Child.ChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithDefaults.Child.ChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithDefaults.Child build() {
- return new SuperBuilderWithDefaults.Child(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> b) {
- super(b);
- if (b.doubleField$set) this.doubleField = b.doubleField$value;
- else this.doubleField = SuperBuilderWithDefaults.Child.$default$doubleField();
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithDefaults.Child.ChildBuilderImpl();
- }
- }
- public static void test() {
- Child x = Child.builder().doubleField(0.1).numberField(5).millis(1234567890L).build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithDefaults {
+ public static class Parent<N extends Number> {
+ private long millis;
+ private N numberField;
+ @java.lang.SuppressWarnings("all")
+ private static <N extends Number> long $default$millis() {
+ return System.currentTimeMillis();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static <N extends Number> N $default$numberField() {
+ return null;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<N extends Number, C extends SuperBuilderWithDefaults.Parent<N>, B extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private boolean millis$set;
+ @java.lang.SuppressWarnings("all")
+ private long millis$value;
+ @java.lang.SuppressWarnings("all")
+ private boolean numberField$set;
+ @java.lang.SuppressWarnings("all")
+ private N numberField$value;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B millis(final long millis) {
+ this.millis$value = millis;
+ millis$set = true;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B numberField(final N numberField) {
+ this.numberField$value = numberField;
+ numberField$set = true;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithDefaults.Parent.ParentBuilder(millis$value=" + this.millis$value + ", numberField$value=" + this.numberField$value + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl<N extends Number> extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, SuperBuilderWithDefaults.Parent<N>, SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithDefaults.Parent<N> build() {
+ return new SuperBuilderWithDefaults.Parent<N>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> b) {
+ if (b.millis$set) this.millis = b.millis$value;
+ else this.millis = SuperBuilderWithDefaults.Parent.<N>$default$millis();
+ if (b.numberField$set) this.numberField = b.numberField$value;
+ else this.numberField = SuperBuilderWithDefaults.Parent.<N>$default$numberField();
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <N extends Number> SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> builder() {
+ return new SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>();
+ }
+ }
+ public static class Child extends Parent<Integer> {
+ private double doubleField;
+ @java.lang.SuppressWarnings("all")
+ private static double $default$doubleField() {
+ return Math.PI;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderWithDefaults.Child, B extends SuperBuilderWithDefaults.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<Integer, C, B> {
+ @java.lang.SuppressWarnings("all")
+ private boolean doubleField$set;
+ @java.lang.SuppressWarnings("all")
+ private double doubleField$value;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B doubleField(final double doubleField) {
+ this.doubleField$value = doubleField;
+ doubleField$set = true;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString() + ", doubleField$value=" + this.doubleField$value + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderWithDefaults.Child.ChildBuilder<SuperBuilderWithDefaults.Child, SuperBuilderWithDefaults.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithDefaults.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithDefaults.Child build() {
+ return new SuperBuilderWithDefaults.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ if (b.doubleField$set) this.doubleField = b.doubleField$value;
+ else this.doubleField = SuperBuilderWithDefaults.Child.$default$doubleField();
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithDefaults.Child.ChildBuilderImpl();
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().doubleField(0.1).numberField(5).millis(1234567890L).build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java b/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..c6ab1072
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,39 @@
+public class SuperBuilderWithExistingConstructor {
+ public SuperBuilderWithExistingConstructor() {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class SuperBuilderWithExistingConstructorBuilder<C extends SuperBuilderWithExistingConstructor, B extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class SuperBuilderWithExistingConstructorBuilderImpl extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<SuperBuilderWithExistingConstructor, SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private SuperBuilderWithExistingConstructorBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithExistingConstructor build() {
+ return new SuperBuilderWithExistingConstructor(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithExistingConstructor(final SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> b) {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> builder() {
+ return new SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java
index f5627211..017ebf31 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java
@@ -1,136 +1,142 @@
-import java.util.List;
-public class SuperBuilderWithGenerics {
- public static class Parent<A> {
- A field1;
- List<String> items;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenerics.Parent<A>, B extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, C, B>> {
- @java.lang.SuppressWarnings("all")
- private A field1;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenerics.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, SuperBuilderWithGenerics.Parent<A>, SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenerics.Parent<A> build() {
- return new SuperBuilderWithGenerics.Parent<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> b) {
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>();
- }
- }
- public static class Child<A> extends Parent<A> {
- double field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenerics.Child<A>, B extends SuperBuilderWithGenerics.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenerics.Child.ChildBuilder<A, SuperBuilderWithGenerics.Child<A>, SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenerics.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenerics.Child<A> build() {
- return new SuperBuilderWithGenerics.Child<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>();
- }
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithGenerics {
+ public static class Parent<A> {
+ A field1;
+ List<String> items;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenerics.Parent<A>, B extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private A field1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenerics.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, SuperBuilderWithGenerics.Parent<A>, SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenerics.Parent<A> build() {
+ return new SuperBuilderWithGenerics.Parent<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> b) {
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static class Child<A> extends Parent<A> {
+ double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenerics.Child<A>, B extends SuperBuilderWithGenerics.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenerics.Child.ChildBuilder<A, SuperBuilderWithGenerics.Child<A>, SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenerics.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenerics.Child<A> build() {
+ return new SuperBuilderWithGenerics.Child<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>();
+ }
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java
index 2b4697d5..8c465b0e 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java
@@ -1,136 +1,142 @@
-import java.util.List;
-public class SuperBuilderWithGenerics2 {
- public static class Parent<A> {
- A field1;
- List<String> items;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenerics2.Parent<A>, B extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, C, B>> {
- @java.lang.SuppressWarnings("all")
- private A field1;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenerics2.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, SuperBuilderWithGenerics2.Parent<A>, SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenerics2.Parent<A> build() {
- return new SuperBuilderWithGenerics2.Parent<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> b) {
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>();
- }
- }
- public static class Child<A> extends Parent<String> {
- A field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenerics2.Child<A>, B extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<String, C, B> {
- @java.lang.SuppressWarnings("all")
- private A field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final A field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, SuperBuilderWithGenerics2.Child<A>, SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenerics2.Child<A> build() {
- return new SuperBuilderWithGenerics2.Child<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> builder2() {
- return new SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>();
- }
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder2().field3(1).field1("value").item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithGenerics2 {
+ public static class Parent<A> {
+ A field1;
+ List<String> items;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenerics2.Parent<A>, B extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private A field1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenerics2.Parent.ParentBuilder(field1=" + this.field1 + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, SuperBuilderWithGenerics2.Parent<A>, SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenerics2.Parent<A> build() {
+ return new SuperBuilderWithGenerics2.Parent<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> b) {
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static class Child<A> extends Parent<String> {
+ A field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenerics2.Child<A>, B extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<String, C, B> {
+ @java.lang.SuppressWarnings("all")
+ private A field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final A field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, SuperBuilderWithGenerics2.Child<A>, SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenerics2.Child<A> build() {
+ return new SuperBuilderWithGenerics2.Child<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> builder2() {
+ return new SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>();
+ }
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder2().field3(1).field1("value").item("").build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java
index b21f8fee..991d7cbe 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java
@@ -10,6 +10,9 @@ public class SuperBuilderWithGenerics3 {
protected abstract B self();
@java.lang.SuppressWarnings("all")
public abstract C build();
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B str(final String str) {
this.str = str;
@@ -60,6 +63,9 @@ public class SuperBuilderWithGenerics3 {
@java.lang.Override
@java.lang.SuppressWarnings("all")
public abstract C build();
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B field3(final double field3) {
this.field3 = field3;
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java
index 48d51fba..28c48db3 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java
@@ -1,182 +1,188 @@
-import java.util.Map;
-public class SuperBuilderWithGenericsAndToBuilder {
- public static class Parent<A> {
- A field1;
- Map<Integer, String> items;
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Parent<A>, B extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, C, B>> {
- @java.lang.SuppressWarnings("all")
- private A field1;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<Integer> items$key;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items$value;
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static <A> void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Parent<A> instance, final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
- b.field1(instance.field1);
- b.items(instance.items == null ? java.util.Collections.emptyMap() : instance.items);
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B item(final Integer itemKey, final String itemValue) {
- if (this.items$key == null) {
- this.items$key = new java.util.ArrayList<Integer>();
- this.items$value = new java.util.ArrayList<String>();
- }
- this.items$key.add(itemKey);
- this.items$value.add(itemValue);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B items(final java.util.Map<? extends Integer, ? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items$key == null) {
- this.items$key = new java.util.ArrayList<Integer>();
- this.items$value = new java.util.ArrayList<String>();
- }
- for (final java.util.Map.Entry<? extends Integer, ? extends String> $lombokEntry : items.entrySet()) {
- this.items$key.add($lombokEntry.getKey());
- this.items$value.add($lombokEntry.getValue());
- }
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items$key != null) {
- this.items$key.clear();
- this.items$value.clear();
- }
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder(field1=" + this.field1 + ", items$key=" + this.items$key + ", items$value=" + this.items$value + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, SuperBuilderWithGenericsAndToBuilder.Parent<A>, SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenericsAndToBuilder.Parent<A> build() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
- this.field1 = b.field1;
- java.util.Map<Integer, String> items;
- switch (b.items$key == null ? 0 : b.items$key.size()) {
- case 0:
- items = java.util.Collections.emptyMap();
- break;
- case 1:
- items = java.util.Collections.singletonMap(b.items$key.get(0), b.items$value.get(0));
- break;
- default:
- items = new java.util.LinkedHashMap<Integer, String>(b.items$key.size() < 1073741824 ? 1 + b.items$key.size() + (b.items$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE);
- for (int $i = 0; $i < b.items$key.size(); $i++) items.put(b.items$key.get($i), (String) b.items$value.get($i));
- items = java.util.Collections.unmodifiableMap(items);
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> toBuilder() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>().$fillValuesFrom(this);
- }
- }
- public static class Child<A> extends Parent<A> {
- double field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Child<A>, B extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static <A> void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Child<A> instance, final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
- b.field3(instance.field3);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, SuperBuilderWithGenericsAndToBuilder.Child<A>, SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenericsAndToBuilder.Child<A> build() {
- return new SuperBuilderWithGenericsAndToBuilder.Child<A>(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static <A> SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> toBuilder() {
- return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>().$fillValuesFrom(this);
- }
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item(5, "").build().toBuilder().build();
- }
-}
+import java.util.Map;
+public class SuperBuilderWithGenericsAndToBuilder {
+ public static class Parent<A> {
+ A field1;
+ Map<Integer, String> items;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Parent<A>, B extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private A field1;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<Integer> items$key;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items$value;
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static <A> void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Parent<A> instance, final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
+ b.field1(instance.field1);
+ b.items(instance.items == null ? java.util.Collections.<Integer, String>emptyMap() : instance.items);
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B item(final Integer itemKey, final String itemValue) {
+ if (this.items$key == null) {
+ this.items$key = new java.util.ArrayList<Integer>();
+ this.items$value = new java.util.ArrayList<String>();
+ }
+ this.items$key.add(itemKey);
+ this.items$value.add(itemValue);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B items(final java.util.Map<? extends Integer, ? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items$key == null) {
+ this.items$key = new java.util.ArrayList<Integer>();
+ this.items$value = new java.util.ArrayList<String>();
+ }
+ for (final java.util.Map.Entry<? extends Integer, ? extends String> $lombokEntry : items.entrySet()) {
+ this.items$key.add($lombokEntry.getKey());
+ this.items$value.add($lombokEntry.getValue());
+ }
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items$key != null) {
+ this.items$key.clear();
+ this.items$value.clear();
+ }
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder(field1=" + this.field1 + ", items$key=" + this.items$key + ", items$value=" + this.items$value + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, SuperBuilderWithGenericsAndToBuilder.Parent<A>, SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenericsAndToBuilder.Parent<A> build() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
+ this.field1 = b.field1;
+ java.util.Map<Integer, String> items;
+ switch (b.items$key == null ? 0 : b.items$key.size()) {
+ case 0:
+ items = java.util.Collections.emptyMap();
+ break;
+ case 1:
+ items = java.util.Collections.singletonMap(b.items$key.get(0), b.items$value.get(0));
+ break;
+ default:
+ items = new java.util.LinkedHashMap<Integer, String>(b.items$key.size() < 1073741824 ? 1 + b.items$key.size() + (b.items$key.size() - 3) / 3 : java.lang.Integer.MAX_VALUE);
+ for (int $i = 0; $i < b.items$key.size(); $i++) items.put(b.items$key.get($i), (String) b.items$value.get($i));
+ items = java.util.Collections.unmodifiableMap(items);
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> toBuilder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>().$fillValuesFrom(this);
+ }
+ }
+ public static class Child<A> extends Parent<A> {
+ double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Child<A>, B extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static <A> void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Child<A> instance, final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
+ b.field3(instance.field3);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, SuperBuilderWithGenericsAndToBuilder.Child<A>, SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenericsAndToBuilder.Child<A> build() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child<A>(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static <A> SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> toBuilder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>().$fillValuesFrom(this);
+ }
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item(5, "").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java
index 7c9a5a13..a3e15e8d 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java
@@ -1,123 +1,130 @@
-import java.util.List;
-public class SuperBuilderWithNonNull {
- public static class Parent {
- @lombok.NonNull
- final String nonNullParentField;
- @java.lang.SuppressWarnings("all")
- private static String $default$nonNullParentField() {
- return "default";
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderWithNonNull.Parent, B extends SuperBuilderWithNonNull.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private boolean nonNullParentField$set;
- @java.lang.SuppressWarnings("all")
- private String nonNullParentField$value;
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B nonNullParentField(@lombok.NonNull final String nonNullParentField) {
- if (nonNullParentField == null) {
- throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
- }
- this.nonNullParentField$value = nonNullParentField;
- nonNullParentField$set = true;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithNonNull.Parent.ParentBuilder(nonNullParentField$value=" + this.nonNullParentField$value + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderWithNonNull.Parent.ParentBuilder<SuperBuilderWithNonNull.Parent, SuperBuilderWithNonNull.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithNonNull.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithNonNull.Parent build() {
- return new SuperBuilderWithNonNull.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> b) {
- if (b.nonNullParentField$set) this.nonNullParentField = b.nonNullParentField$value;
- else this.nonNullParentField = SuperBuilderWithNonNull.Parent.$default$nonNullParentField();
- if (nonNullParentField == null) {
- throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
- }
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderWithNonNull.Parent.ParentBuilderImpl();
- }
- }
- public static class Child extends Parent {
- @lombok.NonNull
- String nonNullChildField;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderWithNonNull.Child, B extends SuperBuilderWithNonNull.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private String nonNullChildField;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B nonNullChildField(@lombok.NonNull final String nonNullChildField) {
- if (nonNullChildField == null) {
- throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
- }
- this.nonNullChildField = nonNullChildField;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString() + ", nonNullChildField=" + this.nonNullChildField + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl extends SuperBuilderWithNonNull.Child.ChildBuilder<SuperBuilderWithNonNull.Child, SuperBuilderWithNonNull.Child.ChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithNonNull.Child.ChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithNonNull.Child build() {
- return new SuperBuilderWithNonNull.Child(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.nonNullChildField = b.nonNullChildField;
- if (nonNullChildField == null) {
- throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
- }
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithNonNull.Child.ChildBuilderImpl();
- }
- }
- public static void test() {
- Child x = Child.builder().nonNullChildField("child").nonNullParentField("parent").build();
- }
-}
+//version 8:
+import java.util.List;
+public class SuperBuilderWithNonNull {
+ public static class Parent {
+ @lombok.NonNull
+ final String nonNullParentField;
+ @java.lang.SuppressWarnings("all")
+ private static String $default$nonNullParentField() {
+ return "default";
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderWithNonNull.Parent, B extends SuperBuilderWithNonNull.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private boolean nonNullParentField$set;
+ @java.lang.SuppressWarnings("all")
+ private String nonNullParentField$value;
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B nonNullParentField(@lombok.NonNull final String nonNullParentField) {
+ if (nonNullParentField == null) {
+ throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
+ }
+ this.nonNullParentField$value = nonNullParentField;
+ nonNullParentField$set = true;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithNonNull.Parent.ParentBuilder(nonNullParentField$value=" + this.nonNullParentField$value + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderWithNonNull.Parent.ParentBuilder<SuperBuilderWithNonNull.Parent, SuperBuilderWithNonNull.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithNonNull.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithNonNull.Parent build() {
+ return new SuperBuilderWithNonNull.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> b) {
+ if (b.nonNullParentField$set) this.nonNullParentField = b.nonNullParentField$value;
+ else this.nonNullParentField = SuperBuilderWithNonNull.Parent.$default$nonNullParentField();
+ if (nonNullParentField == null) {
+ throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithNonNull.Parent.ParentBuilderImpl();
+ }
+ }
+ public static class Child extends Parent {
+ @lombok.NonNull
+ String nonNullChildField;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderWithNonNull.Child, B extends SuperBuilderWithNonNull.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private String nonNullChildField;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B nonNullChildField(@lombok.NonNull final String nonNullChildField) {
+ if (nonNullChildField == null) {
+ throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
+ }
+ this.nonNullChildField = nonNullChildField;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString() + ", nonNullChildField=" + this.nonNullChildField + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderWithNonNull.Child.ChildBuilder<SuperBuilderWithNonNull.Child, SuperBuilderWithNonNull.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithNonNull.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithNonNull.Child build() {
+ return new SuperBuilderWithNonNull.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.nonNullChildField = b.nonNullChildField;
+ if (nonNullChildField == null) {
+ throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithNonNull.Child.ChildBuilderImpl();
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().nonNullChildField("child").nonNullParentField("parent").build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java b/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java
index 9662c4d9..16325113 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java
@@ -14,11 +14,17 @@ class SuperBuilderWithPrefixes {
protected abstract B self();
@java.lang.SuppressWarnings("all")
public abstract C build();
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B field(final int field) {
this.field = field;
return self();
}
+ /**
+ * @return {@code this}.
+ */
@java.lang.SuppressWarnings("all")
public B otherField(final int otherField) {
this.otherField = otherField;
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java
index 28395fcd..88db8511 100644
--- a/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java
+++ b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java
@@ -1,201 +1,216 @@
-import java.util.List;
-public class SuperBuilderWithSetterPrefix {
- public static class Parent {
- private int field1;
- int obtainViaField;
- int obtainViaMethod;
- String obtainViaStaticMethod;
- List<String> items;
- private int method() {
- return 2;
- }
- private static String staticMethod(Parent instance) {
- return "staticMethod";
- }
- @java.lang.SuppressWarnings("all")
- public static abstract class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
- @java.lang.SuppressWarnings("all")
- private int field1;
- @java.lang.SuppressWarnings("all")
- private int obtainViaField;
- @java.lang.SuppressWarnings("all")
- private int obtainViaMethod;
- @java.lang.SuppressWarnings("all")
- private String obtainViaStaticMethod;
- @java.lang.SuppressWarnings("all")
- private java.util.ArrayList<String> items;
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- b.withField1(instance.field1);
- b.withObtainViaField(instance.field1);
- b.withObtainViaMethod(instance.method());
- b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
- b.withItems(instance.items == null ? java.util.Collections.emptyList() : instance.items);
- }
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B withField1(final int field1) {
- this.field1 = field1;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B withObtainViaField(final int obtainViaField) {
- this.obtainViaField = obtainViaField;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B withObtainViaMethod(final int obtainViaMethod) {
- this.obtainViaMethod = obtainViaMethod;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
- this.obtainViaStaticMethod = obtainViaStaticMethod;
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B withItem(final String item) {
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B withItems(final java.util.Collection<? extends String> items) {
- if (items == null) {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if (this.items == null) this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- public B clearItems() {
- if (this.items != null) this.items.clear();
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ", obtainViaField=" + this.obtainViaField + ", obtainViaMethod=" + this.obtainViaMethod + ", obtainViaStaticMethod=" + this.obtainViaStaticMethod + ", items=" + this.items + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ParentBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithSetterPrefix.Parent build() {
- return new SuperBuilderWithSetterPrefix.Parent(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- this.field1 = b.field1;
- this.obtainViaField = b.obtainViaField;
- this.obtainViaMethod = b.obtainViaMethod;
- this.obtainViaStaticMethod = b.obtainViaStaticMethod;
- java.util.List<String> items;
- switch (b.items == null ? 0 : b.items.size()) {
- case 0:
- items = java.util.Collections.emptyList();
- break;
- case 1:
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default:
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static class Child extends Parent {
- private double field3;
- @java.lang.SuppressWarnings("all")
- public static abstract class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- @java.lang.SuppressWarnings("all")
- private double field3;
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- @java.lang.SuppressWarnings("all")
- private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
- b.setField3(instance.field3);
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected abstract B self();
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public abstract C build();
- @java.lang.SuppressWarnings("all")
- public B setField3(final double field3) {
- this.field3 = field3;
- return self();
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public java.lang.String toString() {
- return "SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
- }
- }
- @java.lang.SuppressWarnings("all")
- private static final class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
- @java.lang.SuppressWarnings("all")
- private ChildBuilderImpl() {
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- protected SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
- return this;
- }
- @java.lang.Override
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithSetterPrefix.Child build() {
- return new SuperBuilderWithSetterPrefix.Child(this);
- }
- }
- @java.lang.SuppressWarnings("all")
- protected Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- @java.lang.SuppressWarnings("all")
- public static SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
- }
- @java.lang.SuppressWarnings("all")
- public SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
- }
- }
- public static void test() {
- Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithSetterPrefix {
+ public static class Parent {
+ private int field1;
+ int obtainViaField;
+ int obtainViaMethod;
+ String obtainViaStaticMethod;
+ List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private int field1;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaField;
+ @java.lang.SuppressWarnings("all")
+ private int obtainViaMethod;
+ @java.lang.SuppressWarnings("all")
+ private String obtainViaStaticMethod;
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> items;
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ b.withField1(instance.field1);
+ b.withObtainViaField(instance.field1);
+ b.withObtainViaMethod(instance.method());
+ b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
+ b.withItems(instance.items == null ? java.util.Collections.<String>emptyList() : instance.items);
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B withField1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withItem(final String item) {
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B withItems(final java.util.Collection<? extends String> items) {
+ if (items == null) {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if (this.items == null) this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearItems() {
+ if (this.items != null) this.items.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1 + ", obtainViaField=" + this.obtainViaField + ", obtainViaMethod=" + this.obtainViaMethod + ", obtainViaStaticMethod=" + this.obtainViaStaticMethod + ", items=" + this.items + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ParentBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Parent build() {
+ return new SuperBuilderWithSetterPrefix.Parent(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (b.items == null ? 0 : b.items.size()) {
+ case 0:
+ items = java.util.Collections.emptyList();
+ break;
+ case 1:
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default:
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static class Child extends Parent {
+ private double field3;
+ @java.lang.SuppressWarnings("all")
+ public static abstract class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ @java.lang.SuppressWarnings("all")
+ private double field3;
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ private static void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ b.setField3(instance.field3);
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public B setField3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private ChildBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Child build() {
+ return new SuperBuilderWithSetterPrefix.Child(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
+ }
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ }
+ public static void test() {
+ Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-delombok/Tolerate.java b/test/transform/resource/after-delombok/Tolerate.java
index c3e3d7fd..2539f091 100644
--- a/test/transform/resource/after-delombok/Tolerate.java
+++ b/test/transform/resource/after-delombok/Tolerate.java
@@ -1,54 +1,39 @@
import java.util.regex.Pattern;
-
class Tolerate {
-
private Pattern pattern;
-
@lombok.experimental.Tolerate
public void setPattern(String pattern) {
setPattern(Pattern.compile(pattern));
}
-
@java.lang.SuppressWarnings("all")
-
-
public void setPattern(final Pattern pattern) {
this.pattern = pattern;
}
-
@java.lang.SuppressWarnings("all")
-
-
public Pattern getPattern() {
return this.pattern;
}
}
class Tolerate2 {
private final Pattern pattern;
-
@lombok.experimental.Tolerate
public Tolerate2 withPattern(String pattern) {
return withPattern(Pattern.compile(pattern));
}
-
public Tolerate2 withPattern(String nameGlob, String extensionGlob) {
return withPattern(nameGlob.replace("*", ".*") + "\\." + extensionGlob.replace("*", ".*"));
}
-
@java.lang.SuppressWarnings("all")
-
-
public Pattern getPattern() {
return this.pattern;
}
-
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
-
-
public Tolerate2 withPattern(final Pattern pattern) {
return this.pattern == pattern ? this : new Tolerate2(pattern);
}
-
@java.lang.SuppressWarnings("all")
public Tolerate2(final Pattern pattern) {
this.pattern = pattern;
diff --git a/test/transform/resource/after-delombok/TypeUseAnnotations.java b/test/transform/resource/after-delombok/TypeUseAnnotations.java
index fbf32577..37c24c53 100644
--- a/test/transform/resource/after-delombok/TypeUseAnnotations.java
+++ b/test/transform/resource/after-delombok/TypeUseAnnotations.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.List;
diff --git a/test/transform/resource/after-delombok/ValDelegateMethodReference.java b/test/transform/resource/after-delombok/ValDelegateMethodReference.java
index 186e2aaa..c62edd66 100644
--- a/test/transform/resource/after-delombok/ValDelegateMethodReference.java
+++ b/test/transform/resource/after-delombok/ValDelegateMethodReference.java
@@ -1,3 +1,4 @@
+//version 8:
import java.util.function.Function;
public class ValDelegateMethodReference {
diff --git a/test/transform/resource/after-delombok/ValWeirdTypes.java b/test/transform/resource/after-delombok/ValWeirdTypes.java
index bc18fdac..b3ecfc49 100644
--- a/test/transform/resource/after-delombok/ValWeirdTypes.java
+++ b/test/transform/resource/after-delombok/ValWeirdTypes.java
@@ -1,3 +1,4 @@
+// version 8: In java6/7, lub types worked differently, so, the `arraysAsList` method has a slightly different inferred type there.
import java.math.BigDecimal;
import java.util.*;
public class ValWeirdTypes<Z> {
diff --git a/test/transform/resource/after-delombok/WithAlreadyExists.java b/test/transform/resource/after-delombok/WithAlreadyExists.java
index a9cb975d..6997deb9 100644
--- a/test/transform/resource/after-delombok/WithAlreadyExists.java
+++ b/test/transform/resource/after-delombok/WithAlreadyExists.java
@@ -32,6 +32,9 @@ class With5 {
}
With5(String foo) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public With5 withFoo(final String foo) {
return this.foo == foo ? this : new With5(foo);
@@ -43,6 +46,9 @@ class With6 {
}
With6(String foo) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public With6 withFoo(final String foo) {
return this.foo == foo ? this : new With6(foo);
diff --git a/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java b/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java
index 131e792c..4a88bb0e 100644
--- a/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java
+++ b/test/transform/resource/after-delombok/WithAndAllArgsConstructor.java
@@ -11,10 +11,16 @@ class WithAndAllArgsConstructor<T, J extends T, L extends java.lang.Number> {
this.y = y;
this.z = z;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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/WithByNullAnnos.java b/test/transform/resource/after-delombok/WithByNullAnnos.java
index cdaed973..04d64f16 100644
--- a/test/transform/resource/after-delombok/WithByNullAnnos.java
+++ b/test/transform/resource/after-delombok/WithByNullAnnos.java
@@ -1,3 +1,4 @@
+//version 8:
import java.util.List;
public class WithByNullAnnos {
final List<String> test;
diff --git a/test/transform/resource/after-delombok/WithByTypes.java b/test/transform/resource/after-delombok/WithByTypes.java
index e5e2fb07..f1f1ef5f 100644
--- a/test/transform/resource/after-delombok/WithByTypes.java
+++ b/test/transform/resource/after-delombok/WithByTypes.java
@@ -1,3 +1,4 @@
+//version 8:
public class WithByTypes<T> {
private final int a;
private final long b;
diff --git a/test/transform/resource/after-delombok/WithMethodAbstract.java b/test/transform/resource/after-delombok/WithMethodAbstract.java
index 16f6f060..250330f7 100644
--- a/test/transform/resource/after-delombok/WithMethodAbstract.java
+++ b/test/transform/resource/after-delombok/WithMethodAbstract.java
@@ -1,5 +1,8 @@
abstract class WithMethodAbstract {
String foo;
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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
index d81e76ed..dad6ff9b 100644
--- a/test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java
+++ b/test/transform/resource/after-delombok/WithMethodMarkedDeprecated.java
@@ -7,6 +7,9 @@ class WithMethodMarkedDeprecated {
int javadoc;
WithMethodMarkedDeprecated(int annotation, int javadoc) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.Deprecated
@java.lang.SuppressWarnings("all")
public WithMethodMarkedDeprecated withAnnotation(final int annotation) {
diff --git a/test/transform/resource/after-delombok/WithMethodMarkedDeprecatedAnnOnly.java b/test/transform/resource/after-delombok/WithMethodMarkedDeprecatedAnnOnly.java
new file mode 100644
index 00000000..41139a0f
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithMethodMarkedDeprecatedAnnOnly.java
@@ -0,0 +1,14 @@
+class WithMethodMarkedDeprecatedAnnOnly {
+ @Deprecated
+ int annotation;
+ WithMethodMarkedDeprecatedAnnOnly(int annotation) {
+ }
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public WithMethodMarkedDeprecatedAnnOnly withAnnotation(final int annotation) {
+ return this.annotation == annotation ? this : new WithMethodMarkedDeprecatedAnnOnly(annotation);
+ }
+}
diff --git a/test/transform/resource/after-delombok/WithNested.java b/test/transform/resource/after-delombok/WithNested.java
index 27b65577..b186dabf 100644
--- a/test/transform/resource/after-delombok/WithNested.java
+++ b/test/transform/resource/after-delombok/WithNested.java
@@ -5,6 +5,9 @@ public interface WithNested<Z> {
public IAmStaticReally(final String x) {
this.x = x;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WithNested.IAmStaticReally withX(final String x) {
return this.x == x ? this : new WithNested.IAmStaticReally(x);
diff --git a/test/transform/resource/after-delombok/WithOnClass.java b/test/transform/resource/after-delombok/WithOnClass.java
index d6fb6fdf..0fa973eb 100644
--- a/test/transform/resource/after-delombok/WithOnClass.java
+++ b/test/transform/resource/after-delombok/WithOnClass.java
@@ -1,8 +1,12 @@
+//version 8:
class WithOnClass1 {
boolean isNone;
boolean isPublic;
WithOnClass1(boolean isNone, boolean isPublic) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WithOnClass1 withPublic(final boolean isPublic) {
return this.isPublic == isPublic ? this : new WithOnClass1(this.isNone, isPublic);
@@ -14,10 +18,16 @@ class WithOnClass2 {
boolean isPackage;
WithOnClass2(boolean isNone, boolean isProtected, boolean isPackage) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
protected WithOnClass2 withProtected(final boolean isProtected) {
return this.isProtected == isProtected ? this : new WithOnClass2(this.isNone, isProtected, this.isPackage);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
WithOnClass2 withPackage(final boolean isPackage) {
return this.isPackage == isPackage ? this : new WithOnClass2(this.isNone, this.isProtected, isPackage);
@@ -29,10 +39,16 @@ class WithOnClass3 {
String nonNull;
WithOnClass3(String couldBeNull, String nonNull) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WithOnClass3 withCouldBeNull(final String couldBeNull) {
return this.couldBeNull == couldBeNull ? this : new WithOnClass3(couldBeNull, this.nonNull);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WithOnClass3 withNonNull(@lombok.NonNull final String nonNull) {
if (nonNull == null) {
@@ -47,6 +63,9 @@ class WithOnClass4 {
WithOnClass4(int y) {
this.fY = y;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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/WithPlain.java b/test/transform/resource/after-delombok/WithPlain.java
index 01fca04e..6a1c46e6 100644
--- a/test/transform/resource/after-delombok/WithPlain.java
+++ b/test/transform/resource/after-delombok/WithPlain.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
class WithPlain {
int i;
final int foo;
@@ -5,11 +6,17 @@ class WithPlain {
this.i = i;
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@org.springframework.lang.NonNull
@java.lang.SuppressWarnings("all")
public WithPlain withI(final int i) {
return this.i == i ? this : new WithPlain(i, this.foo);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@org.springframework.lang.NonNull
@java.lang.SuppressWarnings("all")
public WithPlain withFoo(final int foo) {
diff --git a/test/transform/resource/after-delombok/WithWithGenerics.java b/test/transform/resource/after-delombok/WithWithGenerics.java
index ac34f01a..d1cd3380 100644
--- a/test/transform/resource/after-delombok/WithWithGenerics.java
+++ b/test/transform/resource/after-delombok/WithWithGenerics.java
@@ -5,14 +5,23 @@ class WithWithGenerics<T, J extends T, L extends java.lang.Number> {
int $i;
public WithWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@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/WithWithTypeAnnos.java b/test/transform/resource/after-delombok/WithWithTypeAnnos.java
index bf7559ba..8bc1dc88 100644
--- a/test/transform/resource/after-delombok/WithWithTypeAnnos.java
+++ b/test/transform/resource/after-delombok/WithWithTypeAnnos.java
@@ -14,6 +14,9 @@ class WithWithTypeAnnos {
WithWithTypeAnnos(@TA @TB List<String> foo) {
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WithWithTypeAnnos withFoo(@TA final List<String> foo) {
return this.foo == foo ? this : new WithWithTypeAnnos(foo);
diff --git a/test/transform/resource/after-delombok/WitherAccessLevel.java b/test/transform/resource/after-delombok/WitherAccessLevel.java
index c687d645..eec79cb6 100644
--- a/test/transform/resource/after-delombok/WitherAccessLevel.java
+++ b/test/transform/resource/after-delombok/WitherAccessLevel.java
@@ -7,22 +7,37 @@ class WitherAccessLevel {
boolean value;
WitherAccessLevel(boolean isNone, boolean isPrivate, boolean isPackage, boolean isProtected, boolean isPublic, boolean value) {
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
private WitherAccessLevel withPrivate(final boolean isPrivate) {
return this.isPrivate == isPrivate ? this : new WitherAccessLevel(this.isNone, isPrivate, this.isPackage, this.isProtected, this.isPublic, this.value);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
WitherAccessLevel withPackage(final boolean isPackage) {
return this.isPackage == isPackage ? this : new WitherAccessLevel(this.isNone, this.isPrivate, isPackage, this.isProtected, this.isPublic, this.value);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
protected WitherAccessLevel withProtected(final boolean isProtected) {
return this.isProtected == isProtected ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, isProtected, this.isPublic, this.value);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WitherAccessLevel withPublic(final boolean isPublic) {
return this.isPublic == isPublic ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, isPublic, this.value);
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WitherAccessLevel withValue(final boolean value) {
return this.value == value ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, this.isPublic, value);
diff --git a/test/transform/resource/after-delombok/WitherLegacyStar.java b/test/transform/resource/after-delombok/WitherLegacyStar.java
index 69da9278..90d55cee 100644
--- a/test/transform/resource/after-delombok/WitherLegacyStar.java
+++ b/test/transform/resource/after-delombok/WitherLegacyStar.java
@@ -3,6 +3,9 @@ class WitherLegacyStar {
WitherLegacyStar(int i) {
this.i = i;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all")
public WitherLegacyStar withI(final int i) {
return this.i == i ? this : new WitherLegacyStar(i);
diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java
index 8ac92e6e..cdc7b146 100644
--- a/test/transform/resource/after-ecj/Accessors.java
+++ b/test/transform/resource/after-ecj/Accessors.java
@@ -6,6 +6,9 @@ class AccessorsFluent {
public @java.lang.SuppressWarnings("all") String fieldName() {
return this.fieldName;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") AccessorsFluent fieldName(final String fieldName) {
this.fieldName = fieldName;
return this;
@@ -17,6 +20,9 @@ class AccessorsFluent {
AccessorsFluentOnClass() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") AccessorsFluentOnClass fieldName(final String fieldName) {
this.fieldName = fieldName;
return this;
@@ -33,6 +39,9 @@ class AccessorsChain {
AccessorsChain() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") AccessorsChain setRunning(final boolean isRunning) {
this.isRunning = isRunning;
return this;
@@ -102,6 +111,9 @@ class AccessorsFluentGenerics<T extends Number> {
AccessorsFluentGenerics() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") AccessorsFluentGenerics<T> name(final String name) {
this.name = name;
return this;
diff --git a/test/transform/resource/after-ecj/AccessorsConfiguration.java b/test/transform/resource/after-ecj/AccessorsConfiguration.java
index 6678e020..a844763c 100644
--- a/test/transform/resource/after-ecj/AccessorsConfiguration.java
+++ b/test/transform/resource/after-ecj/AccessorsConfiguration.java
@@ -24,6 +24,9 @@ class AccessorsConfiguration {
AccessorsConfiguration3() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") AccessorsConfiguration3 setFieldName(final String fFieldName) {
this.fFieldName = fFieldName;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderAccessWithGetter.java b/test/transform/resource/after-ecj/BuilderAccessWithGetter.java
new file mode 100644
index 00000000..7ad5fa6a
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderAccessWithGetter.java
@@ -0,0 +1,35 @@
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+public final @Builder(access = AccessLevel.PRIVATE) class BuilderAccessWithGetter {
+ private static @java.lang.SuppressWarnings("all") class BuilderAccessWithGetterBuilder {
+ private @java.lang.SuppressWarnings("all") String string;
+ @java.lang.SuppressWarnings("all") BuilderAccessWithGetterBuilder() {
+ super();
+ }
+ /**
+ * @return {@code this}.
+ */
+ private @java.lang.SuppressWarnings("all") BuilderAccessWithGetter.BuilderAccessWithGetterBuilder string(final String string) {
+ this.string = string;
+ return this;
+ }
+ private @java.lang.SuppressWarnings("all") BuilderAccessWithGetter build() {
+ return new BuilderAccessWithGetter(this.string);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("BuilderAccessWithGetter.BuilderAccessWithGetterBuilder(string=" + this.string) + ")");
+ }
+ }
+ private final @Getter String string;
+ @java.lang.SuppressWarnings("all") BuilderAccessWithGetter(final String string) {
+ super();
+ this.string = string;
+ }
+ private static @java.lang.SuppressWarnings("all") BuilderAccessWithGetter.BuilderAccessWithGetterBuilder builder() {
+ return new BuilderAccessWithGetter.BuilderAccessWithGetterBuilder();
+ }
+ public @java.lang.SuppressWarnings("all") String getString() {
+ return this.string;
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderComplex.java b/test/transform/resource/after-ecj/BuilderComplex.java
index 6a28e114..ce6b0fd4 100644
--- a/test/transform/resource/after-ecj/BuilderComplex.java
+++ b/test/transform/resource/after-ecj/BuilderComplex.java
@@ -9,18 +9,30 @@ class BuilderComplex {
@java.lang.SuppressWarnings("all") TestVoidName() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderComplex.TestVoidName<T> number(final T number) {
this.number = number;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderComplex.TestVoidName<T> arg2(final int arg2) {
this.arg2 = arg2;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderComplex.TestVoidName<T> arg3(final String arg3) {
this.arg3 = arg3;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderComplex.TestVoidName<T> selfRef(final BuilderComplex selfRef) {
this.selfRef = selfRef;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderConstructorJavadoc.java b/test/transform/resource/after-ecj/BuilderConstructorJavadoc.java
index bb3916e8..29b6373b 100644
--- a/test/transform/resource/after-ecj/BuilderConstructorJavadoc.java
+++ b/test/transform/resource/after-ecj/BuilderConstructorJavadoc.java
@@ -16,10 +16,16 @@ class BuilderConstructorJavadoc<T> {
@java.lang.SuppressWarnings("all") BuilderConstructorJavadocBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> basic(final int basic) {
this.basic = basic;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> multiline(final int multiline) {
this.multiline = multiline;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderCustomName.java b/test/transform/resource/after-ecj/BuilderCustomName.java
index ee44cc75..652bdf16 100644
--- a/test/transform/resource/after-ecj/BuilderCustomName.java
+++ b/test/transform/resource/after-ecj/BuilderCustomName.java
@@ -7,6 +7,9 @@ import java.util.List;
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B field(final int field) {
this.field = field;
return self();
diff --git a/test/transform/resource/after-ecj/BuilderDefaults.java b/test/transform/resource/after-ecj/BuilderDefaults.java
index c9be219d..37a00cbf 100644
--- a/test/transform/resource/after-ecj/BuilderDefaults.java
+++ b/test/transform/resource/after-ecj/BuilderDefaults.java
@@ -10,15 +10,24 @@ public final @Value @Builder class BuilderDefaults {
@java.lang.SuppressWarnings("all") BuilderDefaultsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaults.BuilderDefaultsBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaults.BuilderDefaultsBuilder name(final String name) {
this.name = name;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaults.BuilderDefaultsBuilder z(final long z) {
this.z$value = z;
z$set = true;
diff --git a/test/transform/resource/after-ecj/BuilderDefaultsGenerics.java b/test/transform/resource/after-ecj/BuilderDefaultsGenerics.java
index 0dc06144..4f9a3cfd 100644
--- a/test/transform/resource/after-ecj/BuilderDefaultsGenerics.java
+++ b/test/transform/resource/after-ecj/BuilderDefaultsGenerics.java
@@ -11,16 +11,25 @@ public @Builder class BuilderDefaultsGenerics<N extends Number, T, R extends Lis
@java.lang.SuppressWarnings("all") BuilderDefaultsGenericsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> callable(final java.util.concurrent.Callable<N> callable) {
this.callable$value = callable;
callable$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> tee(final T tee) {
this.tee$value = tee;
tee$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaultsGenerics.BuilderDefaultsGenericsBuilder<N, T, R> arrr(final R arrr) {
this.arrr$value = arrr;
arrr$set = true;
diff --git a/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
index bc773df3..16caf39e 100644
--- a/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
+++ b/test/transform/resource/after-ecj/BuilderDefaultsWarnings.java
@@ -8,10 +8,16 @@ public @Builder class BuilderDefaultsWarnings {
@java.lang.SuppressWarnings("all") BuilderDefaultsWarningsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder x(final long x) {
this.x = x;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderDefaultsWarnings.BuilderDefaultsWarningsBuilder z(final int z) {
this.z = z;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderGenericMethod.java b/test/transform/resource/after-ecj/BuilderGenericMethod.java
index 442d74dd..be35cf9e 100644
--- a/test/transform/resource/after-ecj/BuilderGenericMethod.java
+++ b/test/transform/resource/after-ecj/BuilderGenericMethod.java
@@ -8,10 +8,16 @@ class BuilderGenericMethod<T> {
@java.lang.SuppressWarnings("all") MapBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderGenericMethod<T>.MapBuilder<N> a(final int a) {
this.a = a;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderGenericMethod<T>.MapBuilder<N> b(final long b) {
this.b = b;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderInstanceMethod.java b/test/transform/resource/after-ecj/BuilderInstanceMethod.java
index e0bf16fd..33502ca9 100644
--- a/test/transform/resource/after-ecj/BuilderInstanceMethod.java
+++ b/test/transform/resource/after-ecj/BuilderInstanceMethod.java
@@ -8,18 +8,30 @@ class BuilderInstanceMethod<T> {
@java.lang.SuppressWarnings("all") StringBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderInstanceMethod<T>.StringBuilder show(final int show) {
this.show = show;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderInstanceMethod<T>.StringBuilder yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderInstanceMethod<T>.StringBuilder also(final List<T> also) {
this.also = also;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderInstanceMethod<T>.StringBuilder $andMe(final int $andMe) {
this.$andMe = $andMe;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderJavadoc.java b/test/transform/resource/after-ecj/BuilderJavadoc.java
index 445b5417..f5790ee7 100644
--- a/test/transform/resource/after-ecj/BuilderJavadoc.java
+++ b/test/transform/resource/after-ecj/BuilderJavadoc.java
@@ -16,10 +16,21 @@ import java.util.List;
@java.lang.SuppressWarnings("all") BuilderJavadocBuilder() {
super();
}
+ /**
+ * basic gets only a builder setter.
+ * @see #getsetwith
+ * @param tag is moved to the setter.
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderJavadoc.BuilderJavadocBuilder<T> basic(final int basic) {
this.basic = basic;
return this;
}
+ /**
+ * getsetwith gets a builder setter, an instance getter and setter, and a wither.
+ * @param tag is moved to the setters and wither.
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderJavadoc.BuilderJavadocBuilder<T> getsetwith(final int getsetwith) {
this.getsetwith = getsetwith;
return this;
@@ -45,12 +56,25 @@ import java.util.List;
public static @java.lang.SuppressWarnings("all") <T>BuilderJavadoc.BuilderJavadocBuilder<T> builder() {
return new BuilderJavadoc.BuilderJavadocBuilder<T>();
}
+ /**
+ * getsetwith gets a builder setter, an instance getter and setter, and a wither.
+ * @return tag is moved to the getter.
+ */
public @java.lang.SuppressWarnings("all") int getGetsetwith() {
return this.getsetwith;
}
+ /**
+ * getsetwith gets a builder setter, an instance getter and setter, and a wither.
+ * @param tag is moved to the setters and wither.
+ */
public @java.lang.SuppressWarnings("all") void setGetsetwith(final int getsetwith) {
this.getsetwith = getsetwith;
}
+ /**
+ * getsetwith gets a builder setter, an instance getter and setter, and a wither.
+ * @param tag is moved to the setters and wither.
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") BuilderJavadoc<T> withGetsetwith(final int getsetwith) {
return ((this.getsetwith == getsetwith) ? this : new BuilderJavadoc<T>(this.basic, getsetwith, this.predef, this.predefWithJavadoc));
}
diff --git a/test/transform/resource/after-ecj/BuilderSimple.java b/test/transform/resource/after-ecj/BuilderSimple.java
index 36804792..a991545e 100644
--- a/test/transform/resource/after-ecj/BuilderSimple.java
+++ b/test/transform/resource/after-ecj/BuilderSimple.java
@@ -6,10 +6,16 @@ import java.util.List;
@java.lang.SuppressWarnings("all") BuilderSimpleBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderSimple.BuilderSimpleBuilder<T> yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderSimple.BuilderSimpleBuilder<T> also(final List<T> also) {
this.also = also;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java
index bcb3a4f5..51077a91 100644
--- a/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/BuilderSimpleWithSetterPrefix.java
@@ -5,6 +5,9 @@ import java.util.List;
@java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefixBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderSimpleWithSetterPrefix.BuilderSimpleWithSetterPrefixBuilder<T> withUnprefixed(final int unprefixed) {
this.unprefixed = unprefixed;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderSingularNullBehavior2.java b/test/transform/resource/after-ecj/BuilderSingularNullBehavior2.java
index cf4bd91b..e1adccb5 100644
--- a/test/transform/resource/after-ecj/BuilderSingularNullBehavior2.java
+++ b/test/transform/resource/after-ecj/BuilderSingularNullBehavior2.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
import java.util.List;
import lombok.Singular;
@lombok.Builder class BuilderSingularNullBehavior2 {
diff --git a/test/transform/resource/after-ecj/BuilderTypeAnnos.java b/test/transform/resource/after-ecj/BuilderTypeAnnos.java
index 0037b435..cae7f2b4 100644
--- a/test/transform/resource/after-ecj/BuilderTypeAnnos.java
+++ b/test/transform/resource/after-ecj/BuilderTypeAnnos.java
@@ -11,6 +11,9 @@ import java.util.List;
@java.lang.SuppressWarnings("all") BuilderTypeAnnosBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderTypeAnnos.BuilderTypeAnnosBuilder foo(final @TA List<String> foo) {
this.foo = foo;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java
index 2ca07414..a3e27985 100644
--- a/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/BuilderTypeAnnosWithSetterPrefix.java
@@ -11,6 +11,9 @@ import java.util.List;
@java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefixBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderTypeAnnosWithSetterPrefix.BuilderTypeAnnosWithSetterPrefixBuilder withFoo(final @TA List<String> foo) {
this.foo = foo;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithAccessors.java b/test/transform/resource/after-ecj/BuilderWithAccessors.java
index 7b666077..2d9f80d5 100644
--- a/test/transform/resource/after-ecj/BuilderWithAccessors.java
+++ b/test/transform/resource/after-ecj/BuilderWithAccessors.java
@@ -7,18 +7,30 @@
@java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithAccessors.BuilderWithAccessorsBuilder plower(final int plower) {
this.plower = plower;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithAccessors.BuilderWithAccessorsBuilder upper(final int upper) {
this.upper = upper;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithAccessors.BuilderWithAccessorsBuilder foo(final int foo) {
this.foo = foo;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithAccessors.BuilderWithAccessorsBuilder _bar(final int _bar) {
this._bar = _bar;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithBadNames.java b/test/transform/resource/after-ecj/BuilderWithBadNames.java
index 9285021d..c0366e14 100644
--- a/test/transform/resource/after-ecj/BuilderWithBadNames.java
+++ b/test/transform/resource/after-ecj/BuilderWithBadNames.java
@@ -5,10 +5,16 @@ public @lombok.Builder class BuilderWithBadNames {
@java.lang.SuppressWarnings("all") BuilderWithBadNamesBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithBadNames.BuilderWithBadNamesBuilder build(final String build) {
this.build = build;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithBadNames.BuilderWithBadNamesBuilder toString(final String toString) {
this.toString = toString;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithDeprecated.java b/test/transform/resource/after-ecj/BuilderWithDeprecated.java
index 724a25e6..7e484b5d 100644
--- a/test/transform/resource/after-ecj/BuilderWithDeprecated.java
+++ b/test/transform/resource/after-ecj/BuilderWithDeprecated.java
@@ -10,10 +10,17 @@ public @Builder class BuilderWithDeprecated {
@java.lang.SuppressWarnings("all") BuilderWithDeprecatedBuilder() {
super();
}
+ /**
+ * @deprecated since always
+ * @return {@code this}.
+ */
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecated.BuilderWithDeprecatedBuilder dep1(final String dep1) {
this.dep1 = dep1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecated.BuilderWithDeprecatedBuilder dep2(final int dep2) {
this.dep2 = dep2;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithDeprecatedAnnOnly.java b/test/transform/resource/after-ecj/BuilderWithDeprecatedAnnOnly.java
new file mode 100644
index 00000000..2c563387
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderWithDeprecatedAnnOnly.java
@@ -0,0 +1,91 @@
+import com.google.common.collect.ImmutableList;
+import lombok.Builder;
+import lombok.Singular;
+public @Builder class BuilderWithDeprecatedAnnOnly {
+ public static @java.lang.SuppressWarnings("all") class BuilderWithDeprecatedAnnOnlyBuilder {
+ private @java.lang.SuppressWarnings("all") int dep1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> strings;
+ private @java.lang.SuppressWarnings("all") com.google.common.collect.ImmutableList.Builder<Integer> numbers;
+ @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnlyBuilder() {
+ super();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder dep1(final int dep1) {
+ this.dep1 = dep1;
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder string(final String string) {
+ if ((this.strings == null))
+ this.strings = new java.util.ArrayList<String>();
+ this.strings.add(string);
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder strings(final java.util.Collection<? extends String> strings) {
+ if ((strings == null))
+ {
+ throw new java.lang.NullPointerException("strings cannot be null");
+ }
+ if ((this.strings == null))
+ this.strings = new java.util.ArrayList<String>();
+ this.strings.addAll(strings);
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder clearStrings() {
+ if ((this.strings != null))
+ this.strings.clear();
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder number(final Integer number) {
+ if ((this.numbers == null))
+ this.numbers = com.google.common.collect.ImmutableList.builder();
+ this.numbers.add(number);
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder numbers(final java.lang.Iterable<? extends Integer> numbers) {
+ if ((numbers == null))
+ {
+ throw new java.lang.NullPointerException("numbers cannot be null");
+ }
+ if ((this.numbers == null))
+ this.numbers = com.google.common.collect.ImmutableList.builder();
+ this.numbers.addAll(numbers);
+ return this;
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder clearNumbers() {
+ this.numbers = null;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly build() {
+ java.util.List<String> strings;
+ switch (((this.strings == null) ? 0 : this.strings.size())) {
+ case 0 :
+ strings = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ strings = java.util.Collections.singletonList(this.strings.get(0));
+ break;
+ default :
+ strings = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(this.strings));
+ }
+ com.google.common.collect.ImmutableList<Integer> numbers = ((this.numbers == null) ? com.google.common.collect.ImmutableList.<Integer>of() : this.numbers.build());
+ return new BuilderWithDeprecatedAnnOnly(this.dep1, strings, numbers);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((((("BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder(dep1=" + this.dep1) + ", strings=") + this.strings) + ", numbers=") + this.numbers) + ")");
+ }
+ }
+ @Deprecated int dep1;
+ @Singular @Deprecated java.util.List<String> strings;
+ @Singular @Deprecated ImmutableList<Integer> numbers;
+ @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly(final int dep1, final java.util.List<String> strings, final ImmutableList<Integer> numbers) {
+ super();
+ this.dep1 = dep1;
+ this.strings = strings;
+ this.numbers = numbers;
+ }
+ public static @java.lang.SuppressWarnings("all") BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder builder() {
+ return new BuilderWithDeprecatedAnnOnly.BuilderWithDeprecatedAnnOnlyBuilder();
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderWithExistingBuilderClass.java b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClass.java
index ea7171f0..b8c716a7 100644
--- a/test/transform/resource/after-ecj/BuilderWithExistingBuilderClass.java
+++ b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClass.java
@@ -9,10 +9,16 @@ class BuilderWithExistingBuilderClass<T, K extends Number> {
@java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClass.BuilderWithExistingBuilderClassBuilder<Z> arg1(final Z arg1) {
this.arg1 = arg1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClass.BuilderWithExistingBuilderClassBuilder<Z> arg3(final String arg3) {
this.arg3 = arg3;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java
index 4b8a5ff4..f3619019 100644
--- a/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/BuilderWithExistingBuilderClassWithSetterPrefix.java
@@ -9,10 +9,16 @@ class BuilderWithExistingBuilderClassWithSetterPrefix<T, K extends Number> {
@java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefixBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z> withArg1(final Z arg1) {
this.arg1 = arg1;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithExistingBuilderClassWithSetterPrefix.BuilderWithExistingBuilderClassWithSetterPrefixBuilder<Z> withArg3(final String arg3) {
this.arg3 = arg3;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithNoBuilderMethod.java b/test/transform/resource/after-ecj/BuilderWithNoBuilderMethod.java
index 8ad9b56e..d5cdf765 100644
--- a/test/transform/resource/after-ecj/BuilderWithNoBuilderMethod.java
+++ b/test/transform/resource/after-ecj/BuilderWithNoBuilderMethod.java
@@ -5,6 +5,9 @@ import lombok.Builder;
@java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethodBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithNoBuilderMethod.BuilderWithNoBuilderMethodBuilder a(final String a) {
this.a = a;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithNonNull.java b/test/transform/resource/after-ecj/BuilderWithNonNull.java
index 49fd863b..eb041fae 100644
--- a/test/transform/resource/after-ecj/BuilderWithNonNull.java
+++ b/test/transform/resource/after-ecj/BuilderWithNonNull.java
@@ -4,6 +4,9 @@
@java.lang.SuppressWarnings("all") BuilderWithNonNullBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithNonNull.BuilderWithNonNullBuilder id(final @lombok.NonNull String id) {
if ((id == null))
{
diff --git a/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java
index 0ae45a67..dc43f9a9 100644
--- a/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/BuilderWithNonNullWithSetterPrefix.java
@@ -4,6 +4,9 @@
@java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefixBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithNonNullWithSetterPrefix.BuilderWithNonNullWithSetterPrefixBuilder withId(final @lombok.NonNull String id) {
if ((id == null))
{
diff --git a/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java b/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java
index a004ff98..e42b9e5f 100644
--- a/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java
+++ b/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java
@@ -11,10 +11,16 @@ public class BuilderWithRecursiveGenerics {
@java.lang.SuppressWarnings("all") TestBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithRecursiveGenerics.Test.TestBuilder<Foo, Bar, Quz> foo(final Foo foo) {
this.foo = foo;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithRecursiveGenerics.Test.TestBuilder<Foo, Bar, Quz> bar(final Bar bar) {
this.bar = bar;
return this;
diff --git a/test/transform/resource/after-ecj/BuilderWithToBuilder.java b/test/transform/resource/after-ecj/BuilderWithToBuilder.java
index 72fa3721..0ba3e11a 100644
--- a/test/transform/resource/after-ecj/BuilderWithToBuilder.java
+++ b/test/transform/resource/after-ecj/BuilderWithToBuilder.java
@@ -9,14 +9,23 @@ import lombok.Builder;
@java.lang.SuppressWarnings("all") BuilderWithToBuilderBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> one(final String one) {
this.one = one;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> two(final String two) {
this.two = two;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithToBuilder.BuilderWithToBuilderBuilder<T> foo(final T foo) {
this.foo = foo;
return this;
@@ -93,14 +102,23 @@ import lombok.Builder;
@java.lang.SuppressWarnings("all") ConstructorWithToBuilderBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> mOne(final String mOne) {
this.mOne = mOne;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> baz(final T baz) {
this.baz = baz;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T> bars(final com.google.common.collect.ImmutableList<T> bars) {
this.bars = bars;
return this;
@@ -126,3 +144,38 @@ import lombok.Builder;
return new ConstructorWithToBuilder.ConstructorWithToBuilderBuilder<T>().mOne(this.mOne).baz(this.foo).bars(this.bars);
}
}
+class StaticMethodWithToBuilder<T> {
+ public static @java.lang.SuppressWarnings("all") class StaticMethodWithToBuilderBuilder<T> {
+ private @java.lang.SuppressWarnings("all") T foo;
+ @java.lang.SuppressWarnings("all") StaticMethodWithToBuilderBuilder() {
+ super();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> foo(final T foo) {
+ this.foo = foo;
+ return this;
+ }
+ public @java.lang.SuppressWarnings("all") StaticMethodWithToBuilder<T> build() {
+ return StaticMethodWithToBuilder.<T>of(this.foo);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder(foo=" + this.foo) + ")");
+ }
+ }
+ private T foo;
+ public StaticMethodWithToBuilder(T foo) {
+ super();
+ this.foo = foo;
+ }
+ public static @Builder(toBuilder = true) <T>StaticMethodWithToBuilder<T> of(T foo) {
+ return new StaticMethodWithToBuilder<T>(foo);
+ }
+ public static @java.lang.SuppressWarnings("all") <T>StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> builder() {
+ return new StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T>();
+ }
+ public @java.lang.SuppressWarnings("all") StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T> toBuilder() {
+ return new StaticMethodWithToBuilder.StaticMethodWithToBuilderBuilder<T>().foo(this.foo);
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/BuilderWithTolerate.java b/test/transform/resource/after-ecj/BuilderWithTolerate.java
index 79de7869..8b6fbb53 100644
--- a/test/transform/resource/after-ecj/BuilderWithTolerate.java
+++ b/test/transform/resource/after-ecj/BuilderWithTolerate.java
@@ -9,6 +9,9 @@ public @Builder class BuilderWithTolerate {
@java.lang.SuppressWarnings("all") BuilderWithTolerateBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") BuilderWithTolerate.BuilderWithTolerateBuilder value(final int value) {
this.value = value;
return this;
diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java
index ce4d11f8..87466c7d 100644
--- a/test/transform/resource/after-ecj/CheckerFrameworkBasic.java
+++ b/test/transform/resource/after-ecj/CheckerFrameworkBasic.java
@@ -1,10 +1,14 @@
+import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.With;
-@Data @Accessors(chain = true) class CheckerFrameworkBasic {
+@Data @AllArgsConstructor @Accessors(chain = true) class CheckerFrameworkBasic {
private final @With int x;
private final int y;
private int z;
+ /**
+ * @return {@code this}.
+ */
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));
}
@@ -17,7 +21,10 @@ import lombok.With;
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) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBasic setZ(final int z) {
this.z = z;
return this;
}
@@ -51,9 +58,10 @@ import lombok.With;
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) {
+ public @java.lang.SuppressWarnings("all") CheckerFrameworkBasic(final int x, final int y, final int z) {
super();
this.x = x;
this.y = y;
+ this.z = z;
}
-}
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
index 3f998df4..d5ad0991 100644
--- a/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
+++ b/test/transform/resource/after-ecj/CheckerFrameworkBuilder.java
@@ -8,29 +8,38 @@ import lombok.Singular;
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() {
+ @java.lang.SuppressWarnings("all") CheckerFrameworkBuilderBuilder() {
super();
}
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(final @org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int x) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder x(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.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") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(final @org.checkerframework.checker.builder.qual.NotCalledMethods("y") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int y) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder y(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") CheckerFrameworkBuilderBuilder this, final int y) {
this.y = y;
return this;
}
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(final @org.checkerframework.checker.builder.qual.NotCalledMethods("z") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this, final int z) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder z(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") CheckerFrameworkBuilderBuilder this, final int z) {
this.z = z;
return this;
}
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder name(final String name) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.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") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder names(final java.util.Collection<? extends String> names) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder names(final java.util.Collection<? extends String> names) {
if ((names == null))
{
throw new java.lang.NullPointerException("names cannot be null");
@@ -40,12 +49,12 @@ import lombok.Singular;
this.names.addAll(names);
return this;
}
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder clearNames() {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.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"}) CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder this) {
+ public @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder build(CheckerFrameworkBuilder.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) CheckerFrameworkBuilderBuilder this) {
java.util.List<String> names;
switch (((this.names == null) ? 0 : this.names.size())) {
case 0 :
@@ -73,14 +82,14 @@ import lombok.Singular;
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) {
+ @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") CheckerFrameworkBuilder.CheckerFrameworkBuilderBuilder builder() {
+ public static @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkBuilder.@org.checkerframework.common.aliasing.qual.Unique CheckerFrameworkBuilderBuilder builder() {
return new CheckerFrameworkBuilder.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
index 7c8ff0ed..6236fc72 100644
--- a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java
+++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java
@@ -11,28 +11,37 @@ class CheckerFrameworkSuperBuilder {
public ParentBuilder() {
super();
}
- protected abstract @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @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"}) CheckerFrameworkSuperBuilder.Parent.ParentBuilder this);
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B x(final @org.checkerframework.checker.builder.qual.NotCalledMethods("x") CheckerFrameworkSuperBuilder.Parent.ParentBuilder this, final int x) {
+ protected abstract @org.checkerframework.common.returnsreceiver.qual.This @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") B self();
+ public abstract @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilder<C, B> this);
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B x(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("x") ParentBuilder<C, B> 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") CheckerFrameworkSuperBuilder.Parent.ParentBuilder this, final int y) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B y(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("y") ParentBuilder<C, B> 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") CheckerFrameworkSuperBuilder.Parent.ParentBuilder this, final int z) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B z(CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("z") ParentBuilder<C, B> 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) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @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) {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B names(final java.util.Collection<? extends String> names) {
if ((names == null))
{
throw new java.lang.NullPointerException("names cannot be null");
@@ -42,7 +51,7 @@ class CheckerFrameworkSuperBuilder {
this.names.addAll(names);
return self();
}
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B clearNames() {
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B clearNames() {
if ((this.names != null))
this.names.clear();
return self();
@@ -55,10 +64,10 @@ class CheckerFrameworkSuperBuilder {
private ParentBuilderImpl() {
super();
}
- protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl self() {
+ protected @java.lang.Override @org.checkerframework.common.returnsreceiver.qual.This @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl self() {
return this;
}
- public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent build(final @org.checkerframework.checker.builder.qual.CalledMethods({"y", "z"}) CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl this) {
+ public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent build(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilderImpl this) {
return new CheckerFrameworkSuperBuilder.Parent(this);
}
}
@@ -69,7 +78,7 @@ class CheckerFrameworkSuperBuilder {
private static @java.lang.SuppressWarnings("all") int $default$x() {
return 5;
}
- protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") Parent(final CheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> b) {
+ protected @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") Parent(final CheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> b) {
super();
if (b.x$set)
this.x = b.x$value;
@@ -90,7 +99,7 @@ class CheckerFrameworkSuperBuilder {
}
this.names = names;
}
- public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> builder() {
+ public static @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Parent. @org.checkerframework.common.aliasing.qual.Unique ParentBuilder<?, ?> builder() {
return new CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl();
}
}
@@ -102,14 +111,20 @@ class CheckerFrameworkSuperBuilder {
public ZChildBuilder() {
super();
}
- protected abstract @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @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") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this);
- public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B a(final @org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int a) {
+ protected abstract @java.lang.Override @org.checkerframework.common.returnsreceiver.qual.This @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilder<C, B> this);
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B a(CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("a") ZChildBuilder<C, B> 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") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int b) {
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.common.returnsreceiver.qual.This @java.lang.SuppressWarnings("all") B b(CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.calledmethods.qual.NotCalledMethods("b") ZChildBuilder<C, B> this, final int b) {
this.b = b;
return self();
}
@@ -121,10 +136,10 @@ class CheckerFrameworkSuperBuilder {
private ZChildBuilderImpl() {
super();
}
- protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() {
+ protected @java.lang.Override @org.checkerframework.common.returnsreceiver.qual.This @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() {
return this;
}
- public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl this) {
+ public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild build(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilderImpl this) {
return new CheckerFrameworkSuperBuilder.ZChild(this);
}
}
@@ -133,7 +148,7 @@ class CheckerFrameworkSuperBuilder {
private static @java.lang.SuppressWarnings("all") int $default$a() {
return 1;
}
- protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") ZChild(final CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> b) {
+ protected @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") ZChild(final CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> b) {
super(b);
if (b.a$set)
this.a = b.a$value;
@@ -141,7 +156,7 @@ class CheckerFrameworkSuperBuilder {
this.a = CheckerFrameworkSuperBuilder.ZChild.$default$a();
this.b = b.b;
}
- public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> builder() {
+ public static @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.common.aliasing.qual.Unique ZChildBuilder<?, ?> builder() {
return new CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl();
}
}
diff --git a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java
index ba4ee605..1fcd97e3 100644
--- a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java
+++ b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults.java
@@ -10,11 +10,17 @@ final @NoArgsConstructor(force = true) @AllArgsConstructor @Builder @Value class
@java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder x(final int x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder y(final int y) {
this.y = y;
return this;
diff --git a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java
index 4355ee5c..4d6e7079 100644
--- a/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java
+++ b/test/transform/resource/after-ecj/ConstructorsWithBuilderDefaults2.java
@@ -11,16 +11,25 @@ final @Builder @Value class ConstructorsWithBuilderDefaults<T> {
@java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaultsBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> z(final java.util.List<T> z) {
this.z$value = z;
z$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> x(final T x) {
this.x$value = x;
x$set = true;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") ConstructorsWithBuilderDefaults.ConstructorsWithBuilderDefaultsBuilder<T> q(final T q) {
this.q = q;
return this;
diff --git a/test/transform/resource/after-ecj/DataWithOverrideEqualsAndHashCode.java b/test/transform/resource/after-ecj/DataWithOverrideEqualsAndHashCode.java
new file mode 100644
index 00000000..2149321f
--- /dev/null
+++ b/test/transform/resource/after-ecj/DataWithOverrideEqualsAndHashCode.java
@@ -0,0 +1,25 @@
+import lombok.Data;
+class DataWithOverrideEqualsAndHashCode {
+ class Data1 {
+ Data1() {
+ super();
+ }
+ }
+ @Data class Data2 extends Data1 {
+ public int hashCode() {
+ return 42;
+ }
+ public boolean equals(Object other) {
+ return false;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "DataWithOverrideEqualsAndHashCode.Data2()";
+ }
+ public @java.lang.SuppressWarnings("all") Data2() {
+ super();
+ }
+ }
+ DataWithOverrideEqualsAndHashCode() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeCache.java b/test/transform/resource/after-ecj/EqualsAndHashCodeCache.java
new file mode 100644
index 00000000..7094b636
--- /dev/null
+++ b/test/transform/resource/after-ecj/EqualsAndHashCodeCache.java
@@ -0,0 +1,189 @@
+@lombok.EqualsAndHashCode(cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY) class EqualsAndHashCode {
+ private transient @java.lang.SuppressWarnings("all") int $hashCodeCache;
+ int x;
+ boolean[] y;
+ Object[] z;
+ String a;
+ String b;
+ EqualsAndHashCode() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof EqualsAndHashCode)))
+ return false;
+ final EqualsAndHashCode other = (EqualsAndHashCode) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.x != other.x))
+ return false;
+ if ((! java.util.Arrays.equals(this.y, other.y)))
+ return false;
+ if ((! java.util.Arrays.deepEquals(this.z, other.z)))
+ return false;
+ final java.lang.Object this$a = this.a;
+ final java.lang.Object other$a = other.a;
+ if (((this$a == null) ? (other$a != null) : (! this$a.equals(other$a))))
+ return false;
+ final java.lang.Object this$b = this.b;
+ final java.lang.Object other$b = other.b;
+ if (((this$b == null) ? (other$b != null) : (! this$b.equals(other$b))))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof EqualsAndHashCode);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ if ((this.$hashCodeCache != 0))
+ return this.$hashCodeCache;
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.x);
+ result = ((result * PRIME) + java.util.Arrays.hashCode(this.y));
+ result = ((result * PRIME) + java.util.Arrays.deepHashCode(this.z));
+ final java.lang.Object $a = this.a;
+ result = ((result * PRIME) + (($a == null) ? 43 : $a.hashCode()));
+ final java.lang.Object $b = this.b;
+ result = ((result * PRIME) + (($b == null) ? 43 : $b.hashCode()));
+ if ((result == 0))
+ result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final @lombok.EqualsAndHashCode(cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY) class EqualsAndHashCode2 {
+ private transient @java.lang.SuppressWarnings("all") int $hashCodeCache;
+ int x;
+ long y;
+ float f;
+ double d;
+ boolean b;
+ EqualsAndHashCode2() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof EqualsAndHashCode2)))
+ return false;
+ final EqualsAndHashCode2 other = (EqualsAndHashCode2) o;
+ if ((this.x != other.x))
+ return false;
+ if ((this.y != other.y))
+ return false;
+ if ((java.lang.Float.compare(this.f, other.f) != 0))
+ return false;
+ if ((java.lang.Double.compare(this.d, other.d) != 0))
+ return false;
+ if ((this.b != other.b))
+ return false;
+ return true;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ if ((this.$hashCodeCache != 0))
+ return this.$hashCodeCache;
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.x);
+ final long $y = this.y;
+ result = ((result * PRIME) + (int) ($y ^ ($y >>> 32)));
+ result = ((result * PRIME) + java.lang.Float.floatToIntBits(this.f));
+ final long $d = java.lang.Double.doubleToLongBits(this.d);
+ result = ((result * PRIME) + (int) ($d ^ ($d >>> 32)));
+ result = ((result * PRIME) + (this.b ? 79 : 97));
+ if ((result == 0))
+ result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final @lombok.EqualsAndHashCode(callSuper = false,cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY) class EqualsAndHashCode3 extends EqualsAndHashCode {
+ private transient @java.lang.SuppressWarnings("all") int $hashCodeCache;
+ EqualsAndHashCode3() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof EqualsAndHashCode3)))
+ return false;
+ final EqualsAndHashCode3 other = (EqualsAndHashCode3) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof EqualsAndHashCode3);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ if ((this.$hashCodeCache != 0))
+ return this.$hashCodeCache;
+ int result = 1;
+ if ((result == 0))
+ result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+@lombok.EqualsAndHashCode(callSuper = true,cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY) class EqualsAndHashCode4 extends EqualsAndHashCode {
+ private transient @java.lang.SuppressWarnings("all") int $hashCodeCache;
+ EqualsAndHashCode4() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof EqualsAndHashCode4)))
+ return false;
+ final EqualsAndHashCode4 other = (EqualsAndHashCode4) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((! super.equals(o)))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof EqualsAndHashCode4);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ if ((this.$hashCodeCache != 0))
+ return this.$hashCodeCache;
+ int result = super.hashCode();
+ if ((result == 0))
+ result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
+final @lombok.EqualsAndHashCode(callSuper = true,cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY) class EqualsAndHashCode5 extends EqualsAndHashCode {
+ private transient @java.lang.SuppressWarnings("all") int $hashCodeCache;
+ EqualsAndHashCode5() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof EqualsAndHashCode5)))
+ return false;
+ final EqualsAndHashCode5 other = (EqualsAndHashCode5) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((! super.equals(o)))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof EqualsAndHashCode5);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ if ((this.$hashCodeCache != 0))
+ return this.$hashCodeCache;
+ int result = super.hashCode();
+ if ((result == 0))
+ result = java.lang.Integer.MIN_VALUE;
+ this.$hashCodeCache = result;
+ return result;
+ }
+}
diff --git a/test/transform/resource/after-ecj/ExtensionMethodAutoboxing.java b/test/transform/resource/after-ecj/ExtensionMethodAutoboxing.java
new file mode 100644
index 00000000..8bc2b30f
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodAutoboxing.java
@@ -0,0 +1,25 @@
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod({ExtensionMethodAutoboxing.Extensions.class}) class ExtensionMethodAutoboxing {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static String boxing(String string, Long a, int b) {
+ return ((((string + " ") + a) + " ") + b);
+ }
+ }
+ ExtensionMethodAutoboxing() {
+ super();
+ }
+ public void test() {
+ Long l1 = 1l;
+ long l2 = 1l;
+ Integer i1 = 1;
+ int i2 = 1;
+ String string = "test";
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l1, i1);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l1, i2);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l2, i1);
+ ExtensionMethodAutoboxing.Extensions.boxing(string, l2, i2);
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ExtensionMethodChain.java b/test/transform/resource/after-ecj/ExtensionMethodChain.java
new file mode 100644
index 00000000..8eda4bf8
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodChain.java
@@ -0,0 +1,19 @@
+import java.util.Arrays;
+import java.util.List;
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(ExtensionMethodChain.Extensions.class) class ExtensionMethodChain {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static Integer intValue(String s) {
+ return Integer.valueOf(s);
+ }
+ }
+ ExtensionMethodChain() {
+ super();
+ }
+ public void test() {
+ ExtensionMethodChain.Extensions.intValue("1").intValue();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ExtensionMethodFunctional.java b/test/transform/resource/after-ecj/ExtensionMethodFunctional.java
new file mode 100644
index 00000000..0971a9be
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodFunctional.java
@@ -0,0 +1,42 @@
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(value = ExtensionMethodFunctional.Extensions.class,suppressBaseMethods = false) class ExtensionMethodFunctional {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static <T, R>R map(T value, Function<T, R> mapper) {
+ return mapper.apply(value);
+ }
+ public static String reverse(String string) {
+ return new StringBuilder(string).reverse().toString();
+ }
+ public static @SafeVarargs <T>void consume(T o, Consumer<T>... consumer) {
+ for (int i = 0;; (i < consumer.length); i ++)
+ {
+ consumer[i].accept(o);
+ }
+ }
+ public static <T>List<T> toList1(Stream<T> stream) {
+ return (List<T>) stream.collect(Collectors.toList());
+ }
+ public static <T, U>List<U> toList2(Stream<T> stream) {
+ return null;
+ }
+ }
+ ExtensionMethodFunctional() {
+ super();
+ }
+ public void test() {
+ String test = "test";
+ test = ExtensionMethodFunctional.Extensions.map(test, (<no type> s) -> ExtensionMethodFunctional.Extensions.reverse(s));
+ ExtensionMethodFunctional.Extensions.consume(test, (<no type> s) -> System.out.println(("1: " + s)), (<no type> s) -> System.out.println(("2: " + s)));
+ ExtensionMethodFunctional.Extensions.consume(test, System.out::println, System.out::println);
+ ExtensionMethodFunctional.Extensions.toList1(Stream.of("a", "b", "c").map(String::toUpperCase));
+ List<Integer> i2 = ExtensionMethodFunctional.Extensions.toList2(Stream.of("a", "b", "c").map(String::toUpperCase));
+ }
+}
diff --git a/test/transform/resource/after-ecj/ExtensionMethodGeneric.java b/test/transform/resource/after-ecj/ExtensionMethodGeneric.java
new file mode 100644
index 00000000..2bfab9cc
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodGeneric.java
@@ -0,0 +1,35 @@
+import java.util.List;
+import java.util.Map;
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(ExtensionMethodGeneric.Extensions.class) class ExtensionMethodGeneric {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static <T>List<T> test(List<String> obj, List<T> list) {
+ return null;
+ }
+ public static <K, V>K test(Map<String, Integer> obj, K k, V v) {
+ return k;
+ }
+ public static <T>T test(List<T> list) {
+ return null;
+ }
+ public static <T, U>U test2(List<T> list) {
+ return null;
+ }
+ }
+ ExtensionMethodGeneric() {
+ super();
+ }
+ public void test() {
+ List<String> stringList = null;
+ List<Number> numberList = null;
+ ExtensionMethodGeneric.Extensions.test(stringList);
+ ExtensionMethodGeneric.Extensions.test(stringList, numberList);
+ ExtensionMethodGeneric.Extensions.test(ExtensionMethodGeneric.Extensions.test(stringList, stringList), numberList);
+ Integer i = ExtensionMethodGeneric.Extensions.test2(stringList);
+ Map<String, Integer> map = null;
+ List<String> l = ExtensionMethodGeneric.Extensions.test(map, stringList, numberList);
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ExtensionMethodNames.java b/test/transform/resource/after-ecj/ExtensionMethodNames.java
new file mode 100644
index 00000000..015e8ac2
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodNames.java
@@ -0,0 +1,32 @@
+package a;
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(Extensions.class) class ExtensionMethodNames {
+ ExtensionMethodNames() {
+ super();
+ }
+ public void instanceCalls() {
+ a.Extensions.ext(new Test());
+ Test t = new Test();
+ a.Extensions.ext(t);
+ Test Test = new Test();
+ a.Extensions.ext(Test);
+ }
+ public void staticCalls() {
+ Test.ext();
+ a.Test.ext();
+ }
+}
+class Extensions {
+ Extensions() {
+ super();
+ }
+ public static void ext(Test t) {
+ }
+}
+class Test {
+ Test() {
+ super();
+ }
+ public static void ext() {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ExtensionMethodNonStaticAccess.java b/test/transform/resource/after-ecj/ExtensionMethodNonStaticAccess.java
new file mode 100644
index 00000000..c930a329
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodNonStaticAccess.java
@@ -0,0 +1,22 @@
+class ExtensionMethodNonStaticAccess {
+ ExtensionMethodNonStaticAccess() {
+ super();
+ }
+ public void method() {
+ Derived derived = new Derived();
+ derived.staticMethod();
+ }
+}
+class Base {
+ Base() {
+ super();
+ }
+ static String staticMethod() {
+ return "";
+ }
+}
+class Derived extends Base {
+ Derived() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/ExtensionMethodSuppress.java b/test/transform/resource/after-ecj/ExtensionMethodSuppress.java
new file mode 100644
index 00000000..83e4b57f
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodSuppress.java
@@ -0,0 +1,41 @@
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(Extensions.class) class ExtensionMethodSuppress {
+ ExtensionMethodSuppress() {
+ super();
+ }
+ public void test() {
+ Test.staticMethod();
+ Test test = new Test();
+ Extensions.instanceMethod(test);
+ Extensions.staticMethod(test);
+ }
+}
+@ExtensionMethod(value = Extensions.class,suppressBaseMethods = false) class ExtensionMethodKeep {
+ ExtensionMethodKeep() {
+ super();
+ }
+ public void test() {
+ Test.staticMethod();
+ Test test = new Test();
+ test.instanceMethod();
+ test.staticMethod();
+ }
+}
+class Test {
+ Test() {
+ super();
+ }
+ public static void staticMethod() {
+ }
+ public void instanceMethod() {
+ }
+}
+class Extensions {
+ Extensions() {
+ super();
+ }
+ public static void staticMethod(Test test) {
+ }
+ public static void instanceMethod(Test test) {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ExtensionMethodVarargs.java b/test/transform/resource/after-ecj/ExtensionMethodVarargs.java
new file mode 100644
index 00000000..727b6494
--- /dev/null
+++ b/test/transform/resource/after-ecj/ExtensionMethodVarargs.java
@@ -0,0 +1,24 @@
+import lombok.experimental.ExtensionMethod;
+@ExtensionMethod(ExtensionMethodVarargs.Extensions.class) class ExtensionMethodVarargs {
+ static class Extensions {
+ Extensions() {
+ super();
+ }
+ public static String format(String string, Object... params) {
+ return String.format(string, params);
+ }
+ }
+ ExtensionMethodVarargs() {
+ super();
+ }
+ public void test() {
+ Long l1 = 1l;
+ long l2 = 1l;
+ Integer i1 = 1;
+ int i2 = 1;
+ ExtensionMethodVarargs.Extensions.format("%d %d %d %d", l1, l2, i1, i2);
+ ExtensionMethodVarargs.Extensions.format("%d", l1);
+ ExtensionMethodVarargs.Extensions.format("", new Integer[]{1, 2});
+ ExtensionMethodVarargs.Extensions.format("", new Integer[]{1, 2}, new Integer[]{1, 2});
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/GetterDeprecated.java b/test/transform/resource/after-ecj/GetterDeprecated.java
index 546f7fb7..087a60b8 100644
--- a/test/transform/resource/after-ecj/GetterDeprecated.java
+++ b/test/transform/resource/after-ecj/GetterDeprecated.java
@@ -8,6 +8,9 @@ class GetterDeprecated {
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") int getAnnotation() {
return this.annotation;
}
+ /**
+ * @deprecated
+ */
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") int getJavadoc() {
return this.javadoc;
}
diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java
index 4923fd02..c3308c51 100644
--- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java
+++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java
@@ -1,8 +1,18 @@
@lombok.Data class GetterSetterJavadoc1 {
private int fieldName;
+ /**
+ * Getter section
+ *
+ * @return Sky is blue1
+ */
public @java.lang.SuppressWarnings("all") int getFieldName() {
return this.fieldName;
}
+ /**
+ * Some text
+ *
+ * @param fieldName Hello, World1
+ */
public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) {
this.fieldName = fieldName;
}
@@ -39,9 +49,19 @@ class GetterSetterJavadoc2 {
GetterSetterJavadoc2() {
super();
}
+ /**
+ * Some text
+ *
+ * @return Sky is blue2
+ */
public @java.lang.SuppressWarnings("all") int getFieldName() {
return this.fieldName;
}
+ /**
+ * Some text
+ *
+ * @param fieldName Hello, World2
+ */
public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) {
this.fieldName = fieldName;
}
@@ -51,9 +71,17 @@ class GetterSetterJavadoc3 {
GetterSetterJavadoc3() {
super();
}
+ /**
+ * Getter section
+ * @return Sky is blue3
+ */
public @java.lang.SuppressWarnings("all") int getFieldName() {
return this.fieldName;
}
+ /**
+ * Setter section
+ * @param fieldName Hello, World3
+ */
public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) {
this.fieldName = fieldName;
}
@@ -63,9 +91,20 @@ class GetterSetterJavadoc3 {
GetterSetterJavadoc4() {
super();
}
+ /**
+ * Some text
+ *
+ * @return Sky is blue4
+ */
public @java.lang.SuppressWarnings("all") int fieldName() {
return this.fieldName;
}
+ /**
+ * Some text
+ *
+ * @param fieldName Hello, World4
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") GetterSetterJavadoc4 fieldName(final int fieldName) {
this.fieldName = fieldName;
return this;
@@ -76,9 +115,18 @@ class GetterSetterJavadoc3 {
GetterSetterJavadoc5() {
super();
}
+ /**
+ * Getter section
+ * @return Sky is blue5
+ */
public @java.lang.SuppressWarnings("all") int fieldName() {
return this.fieldName;
}
+ /**
+ * Setter section
+ * @param fieldName Hello, World5
+ * @return Sky is blue5
+ */
public @java.lang.SuppressWarnings("all") GetterSetterJavadoc5 fieldName(final int fieldName) {
this.fieldName = fieldName;
return this;
diff --git a/test/transform/resource/after-ecj/I2335_BuilderMultipleObtainVia.java b/test/transform/resource/after-ecj/I2335_BuilderMultipleObtainVia.java
index 9c5eb6ae..393fe42a 100644
--- a/test/transform/resource/after-ecj/I2335_BuilderMultipleObtainVia.java
+++ b/test/transform/resource/after-ecj/I2335_BuilderMultipleObtainVia.java
@@ -6,10 +6,16 @@ public @Builder class I2335_BuilderMultipleObtainVia {
@java.lang.SuppressWarnings("all") I2335_BuilderMultipleObtainViaBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") I2335_BuilderMultipleObtainVia.I2335_BuilderMultipleObtainViaBuilder theString(final String theString) {
this.theString = theString;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") I2335_BuilderMultipleObtainVia.I2335_BuilderMultipleObtainViaBuilder theLong(final Long theLong) {
this.theLong = theLong;
return this;
diff --git a/test/transform/resource/after-ecj/JacksonJsonProperty.java b/test/transform/resource/after-ecj/JacksonJsonProperty.java
index 008f0256..c6d3d290 100644
--- a/test/transform/resource/after-ecj/JacksonJsonProperty.java
+++ b/test/transform/resource/after-ecj/JacksonJsonProperty.java
@@ -9,6 +9,9 @@ public @Builder class JacksonJsonProperty {
@java.lang.SuppressWarnings("all") JacksonJsonPropertyBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @JsonProperty("kebab-case-prop") @JsonSetter(nulls = Nulls.SKIP) @java.lang.SuppressWarnings("all") JacksonJsonProperty.JacksonJsonPropertyBuilder kebabCaseProp(final String kebabCaseProp) {
this.kebabCaseProp = kebabCaseProp;
return this;
diff --git a/test/transform/resource/after-ecj/JacksonizedBuilderComplex.java b/test/transform/resource/after-ecj/JacksonizedBuilderComplex.java
index 8a06b34b..6b95a6a2 100644
--- a/test/transform/resource/after-ecj/JacksonizedBuilderComplex.java
+++ b/test/transform/resource/after-ecj/JacksonizedBuilderComplex.java
@@ -10,18 +10,30 @@ import lombok.extern.jackson.Jacksonized;
@java.lang.SuppressWarnings("all") TestVoidName() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderComplex.TestVoidName<T> withNumber(final T number) {
this.number = number;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderComplex.TestVoidName<T> withArg2(final int arg2) {
this.arg2 = arg2;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderComplex.TestVoidName<T> withArg3(final String arg3) {
this.arg3 = arg3;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderComplex.TestVoidName<T> withSelfRef(final JacksonizedBuilderComplex selfRef) {
this.selfRef = selfRef;
return this;
diff --git a/test/transform/resource/after-ecj/JacksonizedBuilderSimple.java b/test/transform/resource/after-ecj/JacksonizedBuilderSimple.java
index 2e0a4e0c..87910d47 100644
--- a/test/transform/resource/after-ecj/JacksonizedBuilderSimple.java
+++ b/test/transform/resource/after-ecj/JacksonizedBuilderSimple.java
@@ -8,10 +8,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@java.lang.SuppressWarnings("all") JacksonizedBuilderSimpleBuilder() {
super();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderSimple.JacksonizedBuilderSimpleBuilder<T> yes(final int yes) {
this.yes = yes;
return this;
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") JacksonizedBuilderSimple.JacksonizedBuilderSimpleBuilder<T> also(final List<T> also) {
this.also = also;
return this;
diff --git a/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java b/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java
index 8227162a..46709a66 100644
--- a/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java
+++ b/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java
@@ -7,6 +7,9 @@ public class JacksonizedSuperBuilderSimple {
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B field1(final int field1) {
this.field1 = field1;
return self();
diff --git a/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java b/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java
index a5677275..62938eea 100644
--- a/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java
+++ b/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java
@@ -6,6 +6,9 @@ public @lombok.extern.jackson.Jacksonized @lombok.experimental.SuperBuilder @com
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B field1(final int field1) {
this.field1 = field1;
return self();
diff --git a/test/transform/resource/after-ecj/JavadocMultiline.java b/test/transform/resource/after-ecj/JavadocMultiline.java
new file mode 100644
index 00000000..bf058975
--- /dev/null
+++ b/test/transform/resource/after-ecj/JavadocMultiline.java
@@ -0,0 +1,40 @@
+@lombok.Getter @lombok.Setter class JavadocMultiline {
+ private java.util.List<Boolean> booleans;
+ private java.util.List<Boolean> booleans2;
+ JavadocMultiline() {
+ super();
+ }
+ /**
+ * This is a list of booleans.
+ *
+ * @return A list of booleans to set for this object. This is a Javadoc return that is long
+ * enough to wrap to multiple lines.
+ */
+ public @java.lang.SuppressWarnings("all") java.util.List<Boolean> getBooleans() {
+ return this.booleans;
+ }
+ /**
+ * This is a list of booleans.
+ */
+ public @java.lang.SuppressWarnings("all") java.util.List<Boolean> getBooleans2() {
+ return this.booleans2;
+ }
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ */
+ public @java.lang.SuppressWarnings("all") void setBooleans(final java.util.List<Boolean> booleans) {
+ this.booleans = booleans;
+ }
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ */
+ public @java.lang.SuppressWarnings("all") void setBooleans2(final java.util.List<Boolean> booleans2) {
+ this.booleans2 = booleans2;
+ }
+}
diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java
index c303a895..286d023b 100644
--- a/test/transform/resource/after-ecj/LoggerSlf4j.java
+++ b/test/transform/resource/after-ecj/LoggerSlf4j.java
@@ -56,11 +56,3 @@ class LoggerSlf4jOuter {
super();
}
}
-@Slf4j(topic = ExtendedStringLiteral{AB}) class LoggerSlf4jWithTwoLiterals {
- private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("AB");
- <clinit>() {
- }
- LoggerSlf4jWithTwoLiterals() {
- super();
- }
-} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerSlf4jInvalidTopic.java b/test/transform/resource/after-ecj/LoggerSlf4jInvalidTopic.java
deleted file mode 100644
index 33e212e3..00000000
--- a/test/transform/resource/after-ecj/LoggerSlf4jInvalidTopic.java
+++ /dev/null
@@ -1,9 +0,0 @@
-import lombok.extern.slf4j.Slf4j;
-@Slf4j(topic = 42) class LoggerSlf4jWithIntegerTopic {
- private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(42);
- <clinit>() {
- }
- LoggerSlf4jWithIntegerTopic() {
- super();
- }
-} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java
new file mode 100644
index 00000000..94b708d2
--- /dev/null
+++ b/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java
@@ -0,0 +1,166 @@
+import java.util.List;
+import lombok.Singular;
+class NullAnnotatedCheckerFrameworkSuperBuilder {
+ public static @lombok.experimental.SuperBuilder class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends NullAnnotatedCheckerFrameworkSuperBuilder.Parent, B extends NullAnnotatedCheckerFrameworkSuperBuilder.Parent.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() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B x(final int x) {
+ this.x$value = x;
+ x$set = true;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B y(final int y) {
+ this.y = y;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B z(final int z) {
+ this.z = z;
+ return self();
+ }
+ public @org.checkerframework.checker.nullness.qual.NonNull @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.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B names(final java.util. @org.checkerframework.checker.nullness.qual.NonNull Collection<? extends String> names) {
+ if ((names == null))
+ {
+ throw new java.lang.NullPointerException("names cannot be null");
+ }
+ if ((this.names == null))
+ this.names = new java.util.ArrayList<String>();
+ this.names.addAll(names);
+ return self();
+ }
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B clearNames() {
+ if ((this.names != null))
+ this.names.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.@org.checkerframework.checker.nullness.qual.NonNull String toString() {
+ return (((((((("NullAnnotatedCheckerFrameworkSuperBuilder.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 NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilder<NullAnnotatedCheckerFrameworkSuperBuilder.Parent, NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.@org.checkerframework.checker.nullness.qual.NonNull Parent build() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.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 @java.lang.SuppressWarnings("all") Parent(final NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilder<?, ?> b) {
+ super();
+ if (b.x$set)
+ this.x = b.x$value;
+ else
+ this.x = NullAnnotatedCheckerFrameworkSuperBuilder.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 @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.Parent. @org.checkerframework.checker.nullness.qual.NonNull ParentBuilder<?, ?> builder() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class ZChild extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ZChildBuilder<C extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild, B extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<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 ZChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B a(final int a) {
+ this.a$value = a;
+ a$set = true;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @org.checkerframework.checker.nullness.qual.NonNull @java.lang.SuppressWarnings("all") B b(final int b) {
+ this.b = b;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.@org.checkerframework.checker.nullness.qual.NonNull String toString() {
+ return (((((("NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ZChildBuilderImpl extends NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<NullAnnotatedCheckerFrameworkSuperBuilder.ZChild, NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl> {
+ private ZChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.@org.checkerframework.checker.nullness.qual.NonNull ZChild build() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.ZChild(this);
+ }
+ }
+ @lombok.Builder.Default int a;
+ int b;
+ private static @java.lang.SuppressWarnings("all") int $default$a() {
+ return 1;
+ }
+ protected @java.lang.SuppressWarnings("all") ZChild(final NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder<?, ?> b) {
+ super(b);
+ if (b.a$set)
+ this.a = b.a$value;
+ else
+ this.a = NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.$default$a();
+ this.b = b.b;
+ }
+ public static @java.lang.SuppressWarnings("all") NullAnnotatedCheckerFrameworkSuperBuilder.ZChild. @org.checkerframework.checker.nullness.qual.NonNull ZChildBuilder<?, ?> builder() {
+ return new NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl();
+ }
+ }
+ NullAnnotatedCheckerFrameworkSuperBuilder() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/NullLibrary1.java b/test/transform/resource/after-ecj/NullLibrary1.java
index baea9e7a..5856f3b4 100644
--- a/test/transform/resource/after-ecj/NullLibrary1.java
+++ b/test/transform/resource/after-ecj/NullLibrary1.java
@@ -1,5 +1,8 @@
public @lombok.EqualsAndHashCode @lombok.ToString @lombok.AllArgsConstructor class NullLibrary1 {
@lombok.With String foo;
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @org.eclipse.jdt.annotation.NonNull @java.lang.SuppressWarnings("all") NullLibrary1 withFoo(final String foo) {
return ((this.foo == foo) ? this : new NullLibrary1(foo));
}
diff --git a/test/transform/resource/after-ecj/NullLibrary2.java b/test/transform/resource/after-ecj/NullLibrary2.java
index 60ad103f..e6a0723c 100644
--- a/test/transform/resource/after-ecj/NullLibrary2.java
+++ b/test/transform/resource/after-ecj/NullLibrary2.java
@@ -1,5 +1,8 @@
public @lombok.EqualsAndHashCode @lombok.ToString @lombok.AllArgsConstructor class NullLibrary2 {
@lombok.With String foo;
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") NullLibrary2 withFoo(final String foo) {
return ((this.foo == foo) ? this : new NullLibrary2(foo));
}
diff --git a/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java
index dd64e358..c95b7bab 100644
--- a/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java
+++ b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java
@@ -7,15 +7,33 @@ class SetterAndWithMethodJavadoc {
this.i = i;
this.j = j;
}
+ /**
+ * Some value.
+ * @param the new value
+ */
public @java.lang.SuppressWarnings("all") void setI(final int i) {
this.i = i;
}
+ /**
+ * Some value.
+ * @param the new value
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") SetterAndWithMethodJavadoc withI(final int i) {
return ((this.i == i) ? this : new SetterAndWithMethodJavadoc(i, this.j));
}
+ /**
+ * Set some other value.
+ * @param the new other value
+ */
public @java.lang.SuppressWarnings("all") void setJ(final int j) {
this.j = j;
}
+ /**
+ * Reinstantiate with some other value.
+ * @param the other new other value
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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/SetterDeprecated.java b/test/transform/resource/after-ecj/SetterDeprecated.java
index d76612b7..cc089566 100644
--- a/test/transform/resource/after-ecj/SetterDeprecated.java
+++ b/test/transform/resource/after-ecj/SetterDeprecated.java
@@ -8,6 +8,9 @@ class SetterDeprecated {
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setAnnotation(final int annotation) {
this.annotation = annotation;
}
+ /**
+ * @deprecated
+ */
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setJavadoc(final int javadoc) {
this.javadoc = javadoc;
}
diff --git a/test/transform/resource/after-ecj/SuperBuilderAbstract.java b/test/transform/resource/after-ecj/SuperBuilderAbstract.java
index 51701668..2fef9451 100644
--- a/test/transform/resource/after-ecj/SuperBuilderAbstract.java
+++ b/test/transform/resource/after-ecj/SuperBuilderAbstract.java
@@ -1,102 +1,111 @@
-public class SuperBuilderAbstract {
- public static @lombok.experimental.SuperBuilder class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderAbstract.Parent, B extends SuperBuilderAbstract.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int parentField;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B parentField(final int parentField) {
- this.parentField = parentField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderAbstract.Parent.ParentBuilder(parentField=" + this.parentField) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderAbstract.Parent.ParentBuilder<SuperBuilderAbstract.Parent, SuperBuilderAbstract.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent build() {
- return new SuperBuilderAbstract.Parent(this);
- }
- }
- int parentField;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderAbstract.Parent.ParentBuilder<?, ?> b) {
- super();
- this.parentField = b.parentField;
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderAbstract.Parent.ParentBuilderImpl();
- }
- }
- public static abstract @lombok.experimental.SuperBuilder class Child extends Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderAbstract.Child, B extends SuperBuilderAbstract.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double childField;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B childField(final double childField) {
- this.childField = childField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")");
- }
- }
- double childField;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderAbstract.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.childField = b.childField;
- }
- }
- public static @lombok.experimental.SuperBuilder class GrandChild extends Child {
- public static abstract @java.lang.SuppressWarnings("all") class GrandChildBuilder<C extends SuperBuilderAbstract.GrandChild, B extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") String grandChildField;
- public GrandChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B grandChildField(final String grandChildField) {
- this.grandChildField = grandChildField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class GrandChildBuilderImpl extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<SuperBuilderAbstract.GrandChild, SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl> {
- private GrandChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild build() {
- return new SuperBuilderAbstract.GrandChild(this);
- }
- }
- String grandChildField;
- protected @java.lang.SuppressWarnings("all") GrandChild(final SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> b) {
- super(b);
- this.grandChildField = b.grandChildField;
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> builder() {
- return new SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl();
- }
- }
- public SuperBuilderAbstract() {
- super();
- }
- public static void test() {
- GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build();
- }
-}
+public class SuperBuilderAbstract {
+ public static @lombok.experimental.SuperBuilder class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderAbstract.Parent, B extends SuperBuilderAbstract.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int parentField;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B parentField(final int parentField) {
+ this.parentField = parentField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderAbstract.Parent.ParentBuilder(parentField=" + this.parentField) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderAbstract.Parent.ParentBuilder<SuperBuilderAbstract.Parent, SuperBuilderAbstract.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent build() {
+ return new SuperBuilderAbstract.Parent(this);
+ }
+ }
+ int parentField;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderAbstract.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.parentField = b.parentField;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderAbstract.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderAbstract.Parent.ParentBuilderImpl();
+ }
+ }
+ public static abstract @lombok.experimental.SuperBuilder class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderAbstract.Child, B extends SuperBuilderAbstract.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double childField;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B childField(final double childField) {
+ this.childField = childField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")");
+ }
+ }
+ double childField;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderAbstract.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.childField = b.childField;
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class GrandChild extends Child {
+ public static abstract @java.lang.SuppressWarnings("all") class GrandChildBuilder<C extends SuperBuilderAbstract.GrandChild, B extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") String grandChildField;
+ public GrandChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B grandChildField(final String grandChildField) {
+ this.grandChildField = grandChildField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class GrandChildBuilderImpl extends SuperBuilderAbstract.GrandChild.GrandChildBuilder<SuperBuilderAbstract.GrandChild, SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl> {
+ private GrandChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild build() {
+ return new SuperBuilderAbstract.GrandChild(this);
+ }
+ }
+ String grandChildField;
+ protected @java.lang.SuppressWarnings("all") GrandChild(final SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> b) {
+ super(b);
+ this.grandChildField = b.grandChildField;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderAbstract.GrandChild.GrandChildBuilder<?, ?> builder() {
+ return new SuperBuilderAbstract.GrandChild.GrandChildBuilderImpl();
+ }
+ }
+ public SuperBuilderAbstract() {
+ super();
+ }
+ public static void test() {
+ GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java
index 4fa722e5..2d2cd422 100644
--- a/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java
+++ b/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java
@@ -1,131 +1,140 @@
-public class SuperBuilderAbstractToBuilder {
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderAbstractToBuilder.Parent, B extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int parentField;
- public ParentBuilder() {
- super();
- }
- protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- SuperBuilderAbstractToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Parent instance, final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
- b.parentField(instance.parentField);
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B parentField(final int parentField) {
- this.parentField = parentField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderAbstractToBuilder.Parent.ParentBuilder(parentField=" + this.parentField) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<SuperBuilderAbstractToBuilder.Parent, SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent build() {
- return new SuperBuilderAbstractToBuilder.Parent(this);
- }
- }
- int parentField;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
- super();
- this.parentField = b.parentField;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl();
- }
- }
- public static abstract @lombok.experimental.SuperBuilder(toBuilder = true) class Child extends Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderAbstractToBuilder.Child, B extends SuperBuilderAbstractToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double childField;
- public ChildBuilder() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderAbstractToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Child instance, final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
- b.childField(instance.childField);
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B childField(final double childField) {
- this.childField = childField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")");
- }
- }
- double childField;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.childField = b.childField;
- }
- }
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class GrandChild extends Child {
- public static abstract @java.lang.SuppressWarnings("all") class GrandChildBuilder<C extends SuperBuilderAbstractToBuilder.GrandChild, B extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") String grandChildField;
- public GrandChildBuilder() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.GrandChild instance, final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
- b.grandChildField(instance.grandChildField);
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B grandChildField(final String grandChildField) {
- this.grandChildField = grandChildField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class GrandChildBuilderImpl extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<SuperBuilderAbstractToBuilder.GrandChild, SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl> {
- private GrandChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild build() {
- return new SuperBuilderAbstractToBuilder.GrandChild(this);
- }
- }
- String grandChildField;
- protected @java.lang.SuppressWarnings("all") GrandChild(final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
- super(b);
- this.grandChildField = b.grandChildField;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> builder() {
- return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl();
- }
- }
- public SuperBuilderAbstractToBuilder() {
- super();
- }
- public static void test() {
- GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build().toBuilder().build();
- }
-}
+public class SuperBuilderAbstractToBuilder {
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderAbstractToBuilder.Parent, B extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int parentField;
+ public ParentBuilder() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ SuperBuilderAbstractToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Parent instance, final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
+ b.parentField(instance.parentField);
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B parentField(final int parentField) {
+ this.parentField = parentField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderAbstractToBuilder.Parent.ParentBuilder(parentField=" + this.parentField) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderAbstractToBuilder.Parent.ParentBuilder<SuperBuilderAbstractToBuilder.Parent, SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent build() {
+ return new SuperBuilderAbstractToBuilder.Parent(this);
+ }
+ }
+ int parentField;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.parentField = b.parentField;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderAbstractToBuilder.Parent.ParentBuilderImpl();
+ }
+ }
+ public static abstract @lombok.experimental.SuperBuilder(toBuilder = true) class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderAbstractToBuilder.Child, B extends SuperBuilderAbstractToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double childField;
+ public ChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderAbstractToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.Child instance, final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
+ b.childField(instance.childField);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B childField(final double childField) {
+ this.childField = childField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")");
+ }
+ }
+ double childField;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderAbstractToBuilder.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.childField = b.childField;
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class GrandChild extends Child {
+ public static abstract @java.lang.SuppressWarnings("all") class GrandChildBuilder<C extends SuperBuilderAbstractToBuilder.GrandChild, B extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<C, B>> extends Child.ChildBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") String grandChildField;
+ public GrandChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderAbstractToBuilder.GrandChild instance, final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
+ b.grandChildField(instance.grandChildField);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B grandChildField(final String grandChildField) {
+ this.grandChildField = grandChildField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class GrandChildBuilderImpl extends SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<SuperBuilderAbstractToBuilder.GrandChild, SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl> {
+ private GrandChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild build() {
+ return new SuperBuilderAbstractToBuilder.GrandChild(this);
+ }
+ }
+ String grandChildField;
+ protected @java.lang.SuppressWarnings("all") GrandChild(final SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> b) {
+ super(b);
+ this.grandChildField = b.grandChildField;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder<?, ?> builder() {
+ return new SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilderImpl();
+ }
+ }
+ public SuperBuilderAbstractToBuilder() {
+ super();
+ }
+ public static void test() {
+ GrandChild x = GrandChild.builder().grandChildField("").parentField(5).childField(2.5).build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderBasic.java b/test/transform/resource/after-ecj/SuperBuilderBasic.java
index 7902c95f..844206d0 100644
--- a/test/transform/resource/after-ecj/SuperBuilderBasic.java
+++ b/test/transform/resource/after-ecj/SuperBuilderBasic.java
@@ -1,116 +1,122 @@
-import java.util.List;
-public class SuperBuilderBasic {
- public static @lombok.experimental.SuperBuilder class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderBasic.Parent, B extends SuperBuilderBasic.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int field1;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderBasic.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderBasic.Parent.ParentBuilder<SuperBuilderBasic.Parent, SuperBuilderBasic.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent build() {
- return new SuperBuilderBasic.Parent(this);
- }
- }
- int field1;
- @lombok.Singular List<String> items;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderBasic.Parent.ParentBuilder<?, ?> b) {
- super();
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderBasic.Parent.ParentBuilderImpl();
- }
- }
- public static @lombok.experimental.SuperBuilder class Child extends SuperBuilderBasic.Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderBasic.Child, B extends SuperBuilderBasic.Child.ChildBuilder<C, B>> extends SuperBuilderBasic.Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderBasic.Child.ChildBuilder<SuperBuilderBasic.Child, SuperBuilderBasic.Child.ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child.ChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child build() {
- return new SuperBuilderBasic.Child(this);
- }
- }
- double field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderBasic.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderBasic.Child.ChildBuilderImpl();
- }
- }
- public SuperBuilderBasic() {
- super();
- }
- public static void test() {
- Child x = Child.builder().field3(0.0).field1(5).item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderBasic {
+ public static @lombok.experimental.SuperBuilder class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderBasic.Parent, B extends SuperBuilderBasic.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderBasic.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderBasic.Parent.ParentBuilder<SuperBuilderBasic.Parent, SuperBuilderBasic.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent build() {
+ return new SuperBuilderBasic.Parent(this);
+ }
+ }
+ int field1;
+ @lombok.Singular List<String> items;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderBasic.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderBasic.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderBasic.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child extends SuperBuilderBasic.Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderBasic.Child, B extends SuperBuilderBasic.Child.ChildBuilder<C, B>> extends SuperBuilderBasic.Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderBasic.Child.ChildBuilder<SuperBuilderBasic.Child, SuperBuilderBasic.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child build() {
+ return new SuperBuilderBasic.Child(this);
+ }
+ }
+ double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderBasic.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderBasic.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderBasic.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderBasic() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java
index 56703396..67ee62f6 100644
--- a/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java
+++ b/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java
@@ -1,168 +1,183 @@
-import java.util.List;
-public class SuperBuilderBasicToBuilder {
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderBasicToBuilder.Parent, B extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int field1;
- private @java.lang.SuppressWarnings("all") int obtainViaField;
- private @java.lang.SuppressWarnings("all") int obtainViaMethod;
- private @java.lang.SuppressWarnings("all") String obtainViaStaticMethod;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- SuperBuilderBasicToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Parent instance, final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
- b.field1(instance.field1);
- b.obtainViaField(instance.field1);
- b.obtainViaMethod(instance.method());
- b.obtainViaStaticMethod(SuperBuilderBasicToBuilder.Parent.staticMethod(instance));
- b.items(((instance.items == null) ? java.util.Collections.emptyList() : instance.items));
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final int field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B obtainViaField(final int obtainViaField) {
- this.obtainViaField = obtainViaField;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B obtainViaMethod(final int obtainViaMethod) {
- this.obtainViaMethod = obtainViaMethod;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B obtainViaStaticMethod(final String obtainViaStaticMethod) {
- this.obtainViaStaticMethod = obtainViaStaticMethod;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((((((((("SuperBuilderBasicToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<SuperBuilderBasicToBuilder.Parent, SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent build() {
- return new SuperBuilderBasicToBuilder.Parent(this);
- }
- }
- private int field1;
- @lombok.Builder.ObtainVia(field = "field1") int obtainViaField;
- @lombok.Builder.ObtainVia(method = "method") int obtainViaMethod;
- @lombok.Builder.ObtainVia(method = "staticMethod",isStatic = true) String obtainViaStaticMethod;
- @lombok.Singular List<String> items;
- private int method() {
- return 2;
- }
- private static String staticMethod(Parent instance) {
- return "staticMethod";
- }
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
- super();
- this.field1 = b.field1;
- this.obtainViaField = b.obtainViaField;
- this.obtainViaMethod = b.obtainViaMethod;
- this.obtainViaStaticMethod = b.obtainViaStaticMethod;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl();
- }
- }
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class Child extends Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderBasicToBuilder.Child, B extends SuperBuilderBasicToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderBasicToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Child instance, final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
- b.field3(instance.field3);
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderBasicToBuilder.Child.ChildBuilder<SuperBuilderBasicToBuilder.Child, SuperBuilderBasicToBuilder.Child.ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child build() {
- return new SuperBuilderBasicToBuilder.Child(this);
- }
- }
- private double field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl();
- }
- }
- public SuperBuilderBasicToBuilder() {
- super();
- }
- public static void test() {
- Child x = Child.builder().field3(0.0).field1(5).item("").build().toBuilder().build();
- }
-}
+import java.util.List;
+public class SuperBuilderBasicToBuilder {
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderBasicToBuilder.Parent, B extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ private @java.lang.SuppressWarnings("all") int obtainViaField;
+ private @java.lang.SuppressWarnings("all") int obtainViaMethod;
+ private @java.lang.SuppressWarnings("all") String obtainViaStaticMethod;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ SuperBuilderBasicToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Parent instance, final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
+ b.field1(instance.field1);
+ b.obtainViaField(instance.field1);
+ b.obtainViaMethod(instance.method());
+ b.obtainViaStaticMethod(SuperBuilderBasicToBuilder.Parent.staticMethod(instance));
+ b.items(((instance.items == null) ? java.util.Collections.<String>emptyList() : instance.items));
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B obtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B obtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B obtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((((((((("SuperBuilderBasicToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderBasicToBuilder.Parent.ParentBuilder<SuperBuilderBasicToBuilder.Parent, SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent build() {
+ return new SuperBuilderBasicToBuilder.Parent(this);
+ }
+ }
+ private int field1;
+ @lombok.Builder.ObtainVia(field = "field1") int obtainViaField;
+ @lombok.Builder.ObtainVia(method = "method") int obtainViaMethod;
+ @lombok.Builder.ObtainVia(method = "staticMethod",isStatic = true) String obtainViaStaticMethod;
+ @lombok.Singular List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderBasicToBuilder.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderBasicToBuilder.Child, B extends SuperBuilderBasicToBuilder.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderBasicToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderBasicToBuilder.Child instance, final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
+ b.field3(instance.field3);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderBasicToBuilder.Child.ChildBuilder<SuperBuilderBasicToBuilder.Child, SuperBuilderBasicToBuilder.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child build() {
+ return new SuperBuilderBasicToBuilder.Child(this);
+ }
+ }
+ private double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderBasicToBuilder.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderBasicToBuilder.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderBasicToBuilder() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().field3(0.0).field1(5).item("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderCustomized.java b/test/transform/resource/after-ecj/SuperBuilderCustomized.java
index fe0e1238..1fb41367 100644
--- a/test/transform/resource/after-ecj/SuperBuilderCustomized.java
+++ b/test/transform/resource/after-ecj/SuperBuilderCustomized.java
@@ -1,88 +1,91 @@
-import java.util.List;
-public class SuperBuilderCustomized {
- public static @lombok.experimental.SuperBuilder class Parent {
- public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int field1;
- public ParentBuilder() {
- super();
- }
- public B resetToDefault() {
- field1 = 0;
- return self();
- }
- public B field1(int field1) {
- this.field1 = (field1 + 1);
- return self();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderCustomized.Parent.ParentBuilder(field1=" + this.field1) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderCustomized.Parent.ParentBuilder<SuperBuilderCustomized.Parent, SuperBuilderCustomized.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Parent build() {
- return new SuperBuilderCustomized.Parent(this);
- }
- }
- int field1;
- protected Parent(ParentBuilder<?, ?> b) {
- super();
- if ((b.field1 == 0))
- throw new IllegalArgumentException("field1 must be != 0");
- this.field1 = b.field1;
- }
- public static SuperBuilderCustomized.Parent.ParentBuilder<?, ?> builder(int field1) {
- return new SuperBuilderCustomized.Parent.ParentBuilderImpl().field1(field1);
- }
- }
- public static @lombok.experimental.SuperBuilder class Child extends Parent {
- private static final class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- public @Override Child build() {
- this.resetToDefault();
- return new Child(this);
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Child.ChildBuilderImpl self() {
- return this;
- }
- }
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderCustomized.Child, B extends SuperBuilderCustomized.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double field2;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field2(final double field2) {
- this.field2 = field2;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString()) + ", field2=") + this.field2) + ")");
- }
- }
- double field2;
- public static ChildBuilder<?, ?> builder() {
- return new ChildBuilderImpl().field2(10.0);
- }
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderCustomized.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field2 = b.field2;
- }
- }
- public SuperBuilderCustomized() {
- super();
- }
- public static void test() {
- Child x = Child.builder().field2(1.0).field1(5).resetToDefault().build();
- }
-}
+import java.util.List;
+public class SuperBuilderCustomized {
+ public static @lombok.experimental.SuperBuilder class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ public ParentBuilder() {
+ super();
+ }
+ public B resetToDefault() {
+ field1 = 0;
+ return self();
+ }
+ public B field1(int field1) {
+ this.field1 = (field1 + 1);
+ return self();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderCustomized.Parent.ParentBuilder(field1=" + this.field1) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderCustomized.Parent.ParentBuilder<SuperBuilderCustomized.Parent, SuperBuilderCustomized.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Parent build() {
+ return new SuperBuilderCustomized.Parent(this);
+ }
+ }
+ int field1;
+ protected Parent(ParentBuilder<?, ?> b) {
+ super();
+ if ((b.field1 == 0))
+ throw new IllegalArgumentException("field1 must be != 0");
+ this.field1 = b.field1;
+ }
+ public static SuperBuilderCustomized.Parent.ParentBuilder<?, ?> builder(int field1) {
+ return new SuperBuilderCustomized.Parent.ParentBuilderImpl().field1(field1);
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child extends Parent {
+ private static final class ChildBuilderImpl extends ChildBuilder<Child, ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ public @Override Child build() {
+ this.resetToDefault();
+ return new Child(this);
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomized.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ }
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderCustomized.Child, B extends SuperBuilderCustomized.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double field2;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field2(final double field2) {
+ this.field2 = field2;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString()) + ", field2=") + this.field2) + ")");
+ }
+ }
+ double field2;
+ public static ChildBuilder<?, ?> builder() {
+ return new ChildBuilderImpl().field2(10.0);
+ }
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderCustomized.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field2 = b.field2;
+ }
+ }
+ public SuperBuilderCustomized() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().field2(1.0).field1(5).resetToDefault().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java b/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java
index 283bacd4..142181ec 100644
--- a/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/SuperBuilderCustomizedWithSetterPrefix.java
@@ -1,45 +1,45 @@
-import java.util.List;
-public class SuperBuilderCustomizedWithSetterPrefix {
- public static @lombok.experimental.SuperBuilder(setterPrefix = "set") class Parent {
- public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int field1;
- public ParentBuilder() {
- super();
- }
- public B setField1(int field1) {
- this.field1 = (field1 + 1);
- return self();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent build() {
- return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
- }
- }
- int field1;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- super();
- this.field1 = b.field1;
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
- }
- }
- public SuperBuilderCustomizedWithSetterPrefix() {
- super();
- }
- public static void test() {
- Parent x = Parent.builder().setField1(5).build();
- }
-}
+import java.util.List;
+public class SuperBuilderCustomizedWithSetterPrefix {
+ public static @lombok.experimental.SuperBuilder(setterPrefix = "set") class Parent {
+ public static abstract class ParentBuilder<C extends Parent, B extends ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ public ParentBuilder() {
+ super();
+ }
+ public B setField1(int field1) {
+ this.field1 = (field1 + 1);
+ return self();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<SuperBuilderCustomizedWithSetterPrefix.Parent, SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent build() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent(this);
+ }
+ }
+ int field1;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderCustomizedWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public SuperBuilderCustomizedWithSetterPrefix() {
+ super();
+ }
+ public static void test() {
+ Parent x = Parent.builder().setField1(5).build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderInitializer.java b/test/transform/resource/after-ecj/SuperBuilderInitializer.java
new file mode 100644
index 00000000..0425fb89
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderInitializer.java
@@ -0,0 +1,54 @@
+import lombok.experimental.SuperBuilder;
+class SuperBuilderInitializer {
+ public static @SuperBuilder class One {
+ public static abstract @java.lang.SuppressWarnings("all") class OneBuilder<C extends SuperBuilderInitializer.One, B extends SuperBuilderInitializer.One.OneBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") String world;
+ public OneBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B world(final String world) {
+ this.world = world;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderInitializer.One.OneBuilder(world=" + this.world) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class OneBuilderImpl extends SuperBuilderInitializer.One.OneBuilder<SuperBuilderInitializer.One, SuperBuilderInitializer.One.OneBuilderImpl> {
+ private OneBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One.OneBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One build() {
+ return new SuperBuilderInitializer.One(this);
+ }
+ }
+ private String world;
+ {
+ world = "Hello";
+ }
+ private static final String world2;
+ static {
+ world2 = "Hello";
+ }
+ <clinit>() {
+ }
+ protected @java.lang.SuppressWarnings("all") One(final SuperBuilderInitializer.One.OneBuilder<?, ?> b) {
+ super();
+ this.world = b.world;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderInitializer.One.OneBuilder<?, ?> builder() {
+ return new SuperBuilderInitializer.One.OneBuilderImpl();
+ }
+ }
+ SuperBuilderInitializer() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderNameClashes.java b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java
index 89ce3824..44d3db92 100644
--- a/test/transform/resource/after-ecj/SuperBuilderNameClashes.java
+++ b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java
@@ -70,6 +70,9 @@ public class SuperBuilderNameClashes {
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C3 build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B c2(final C2 c2) {
this.c2 = c2;
return self();
diff --git a/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java b/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java
index e511b276..0c51d4ee 100644
--- a/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java
+++ b/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java
@@ -1,37 +1,37 @@
-public class SuperBuilderNestedGenericTypes {
- public static abstract @lombok.experimental.SuperBuilder class Generic<T extends Generic<?>> {
- public static abstract @java.lang.SuppressWarnings("all") class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
- public GenericBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
- }
- }
- protected @java.lang.SuppressWarnings("all") Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
- super();
- }
- }
- public static abstract @lombok.experimental.SuperBuilder class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
- public static abstract @java.lang.SuppressWarnings("all") class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
- public NestedGenericBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString()) + ")");
- }
- }
- protected @java.lang.SuppressWarnings("all") NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
- super(b);
- }
- }
- public interface OtherGeneric<T> {
- }
- public SuperBuilderNestedGenericTypes() {
- super();
- }
+public class SuperBuilderNestedGenericTypes {
+ public static abstract @lombok.experimental.SuperBuilder class Generic<T extends Generic<?>> {
+ public static abstract @java.lang.SuppressWarnings("all") class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
+ public GenericBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
+ }
+ }
+ protected @java.lang.SuppressWarnings("all") Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
+ super();
+ }
+ }
+ public static abstract @lombok.experimental.SuperBuilder class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
+ public static abstract @java.lang.SuppressWarnings("all") class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
+ public NestedGenericBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString()) + ")");
+ }
+ }
+ protected @java.lang.SuppressWarnings("all") NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
+ super(b);
+ }
+ }
+ public interface OtherGeneric<T> {
+ }
+ public SuperBuilderNestedGenericTypes() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..613edb03
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java
@@ -0,0 +1,70 @@
+import java.util.Set;
+@lombok.experimental.SuperBuilder class SuperBuilderSingularCustomized {
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> foos;
+ public SuperBuilderSingularCustomizedBuilder() {
+ super();
+ }
+ public B custom(final String value) {
+ return self();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.SuppressWarnings("all") B foo(final String foo) {
+ if ((this.foos == null))
+ this.foos = new java.util.ArrayList<String>();
+ this.foos.add(foo);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B foos(final java.util.Collection<? extends String> foos) {
+ if ((foos == null))
+ {
+ throw new java.lang.NullPointerException("foos cannot be null");
+ }
+ if ((this.foos == null))
+ this.foos = new java.util.ArrayList<String>();
+ this.foos.addAll(foos);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearFoos() {
+ if ((this.foos != null))
+ this.foos.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder(foos=" + this.foos) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class SuperBuilderSingularCustomizedBuilderImpl extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<SuperBuilderSingularCustomized, SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl> {
+ private SuperBuilderSingularCustomizedBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized build() {
+ return new SuperBuilderSingularCustomized(this);
+ }
+ }
+ private @lombok.Singular Set<String> foos;
+ protected @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized(final SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> b) {
+ super();
+ java.util.Set<String> foos;
+ switch (((b.foos == null) ? 0 : b.foos.size())) {
+ case 0 :
+ foos = java.util.Collections.emptySet();
+ break;
+ case 1 :
+ foos = java.util.Collections.singleton(b.foos.get(0));
+ break;
+ default :
+ foos = new java.util.LinkedHashSet<String>(((b.foos.size() < 0x40000000) ? ((1 + b.foos.size()) + ((b.foos.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE));
+ foos.addAll(b.foos);
+ foos = java.util.Collections.unmodifiableSet(foos);
+ }
+ this.foos = foos;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> builder() {
+ return new SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java
index 25f6f876..93b78c3d 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java
@@ -1,116 +1,122 @@
-import java.util.List;
-public class SuperBuilderWithCustomBuilderMethod {
- public static @lombok.experimental.SuperBuilder class Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Parent<A>, B extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, C, B>> {
- private @java.lang.SuppressWarnings("all") A field1;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, SuperBuilderWithCustomBuilderMethod.Parent<A>, SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Parent<A> build() {
- return new SuperBuilderWithCustomBuilderMethod.Parent<A>(this);
- }
- }
- A field1;
- @lombok.Singular List<String> items;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> b) {
- super();
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>();
- }
- }
- public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Child<A>, B extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, SuperBuilderWithCustomBuilderMethod.Child<A>, SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A>> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Child<A> build() {
- return new SuperBuilderWithCustomBuilderMethod.Child<A>(this);
- }
- }
- double field3;
- public static <A>ChildBuilder<A, ?, ?> builder() {
- return new ChildBuilderImpl<A>().item("default item");
- }
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- }
- public SuperBuilderWithCustomBuilderMethod() {
- super();
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithCustomBuilderMethod {
+ public static @lombok.experimental.SuperBuilder class Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Parent<A>, B extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, C, B>> {
+ private @java.lang.SuppressWarnings("all") A field1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, SuperBuilderWithCustomBuilderMethod.Parent<A>, SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Parent<A> build() {
+ return new SuperBuilderWithCustomBuilderMethod.Parent<A>(this);
+ }
+ }
+ A field1;
+ @lombok.Singular List<String> items;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithCustomBuilderMethod.Child<A>, B extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, SuperBuilderWithCustomBuilderMethod.Child<A>, SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A>> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithCustomBuilderMethod.Child<A> build() {
+ return new SuperBuilderWithCustomBuilderMethod.Child<A>(this);
+ }
+ }
+ double field3;
+ public static <A>ChildBuilder<A, ?, ?> builder() {
+ return new ChildBuilderImpl<A>().item("default item");
+ }
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ }
+ public SuperBuilderWithCustomBuilderMethod() {
+ super();
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java b/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java
index 03bfd319..7c5a344a 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java
@@ -1,112 +1,121 @@
-import java.util.List;
-public class SuperBuilderWithDefaults {
- public static @lombok.experimental.SuperBuilder class Parent<N extends Number> {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<N extends Number, C extends SuperBuilderWithDefaults.Parent<N>, B extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, C, B>> {
- private @java.lang.SuppressWarnings("all") long millis$value;
- private @java.lang.SuppressWarnings("all") boolean millis$set;
- private @java.lang.SuppressWarnings("all") N numberField$value;
- private @java.lang.SuppressWarnings("all") boolean numberField$set;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B millis(final long millis) {
- this.millis$value = millis;
- millis$set = true;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B numberField(final N numberField) {
- this.numberField$value = numberField;
- numberField$set = true;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithDefaults.Parent.ParentBuilder(millis$value=" + this.millis$value) + ", numberField$value=") + this.numberField$value) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<N extends Number> extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, SuperBuilderWithDefaults.Parent<N>, SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Parent<N> build() {
- return new SuperBuilderWithDefaults.Parent<N>(this);
- }
- }
- private @lombok.Builder.Default long millis;
- private @lombok.Builder.Default N numberField;
- private static @java.lang.SuppressWarnings("all") <N extends Number>long $default$millis() {
- return System.currentTimeMillis();
- }
- private static @java.lang.SuppressWarnings("all") <N extends Number>N $default$numberField() {
- return null;
- }
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> b) {
- super();
- if (b.millis$set)
- this.millis = b.millis$value;
- else
- this.millis = SuperBuilderWithDefaults.Parent.<N>$default$millis();
- if (b.numberField$set)
- this.numberField = b.numberField$value;
- else
- this.numberField = SuperBuilderWithDefaults.Parent.<N>$default$numberField();
- }
- public static @java.lang.SuppressWarnings("all") <N extends Number>SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> builder() {
- return new SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>();
- }
- }
- public static @lombok.experimental.SuperBuilder class Child extends Parent<Integer> {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithDefaults.Child, B extends SuperBuilderWithDefaults.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<Integer, C, B> {
- private @java.lang.SuppressWarnings("all") double doubleField$value;
- private @java.lang.SuppressWarnings("all") boolean doubleField$set;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B doubleField(final double doubleField) {
- this.doubleField$value = doubleField;
- doubleField$set = true;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString()) + ", doubleField$value=") + this.doubleField$value) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithDefaults.Child.ChildBuilder<SuperBuilderWithDefaults.Child, SuperBuilderWithDefaults.Child.ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child.ChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child build() {
- return new SuperBuilderWithDefaults.Child(this);
- }
- }
- private @lombok.Builder.Default double doubleField;
- private static @java.lang.SuppressWarnings("all") double $default$doubleField() {
- return Math.PI;
- }
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> b) {
- super(b);
- if (b.doubleField$set)
- this.doubleField = b.doubleField$value;
- else
- this.doubleField = SuperBuilderWithDefaults.Child.$default$doubleField();
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithDefaults.Child.ChildBuilderImpl();
- }
- }
- public SuperBuilderWithDefaults() {
- super();
- }
- public static void test() {
- Child x = Child.builder().doubleField(0.1).numberField(5).millis(1234567890L).build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithDefaults {
+ public static @lombok.experimental.SuperBuilder class Parent<N extends Number> {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<N extends Number, C extends SuperBuilderWithDefaults.Parent<N>, B extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, C, B>> {
+ private @java.lang.SuppressWarnings("all") long millis$value;
+ private @java.lang.SuppressWarnings("all") boolean millis$set;
+ private @java.lang.SuppressWarnings("all") N numberField$value;
+ private @java.lang.SuppressWarnings("all") boolean numberField$set;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B millis(final long millis) {
+ this.millis$value = millis;
+ millis$set = true;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B numberField(final N numberField) {
+ this.numberField$value = numberField;
+ numberField$set = true;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithDefaults.Parent.ParentBuilder(millis$value=" + this.millis$value) + ", numberField$value=") + this.numberField$value) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<N extends Number> extends SuperBuilderWithDefaults.Parent.ParentBuilder<N, SuperBuilderWithDefaults.Parent<N>, SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Parent<N> build() {
+ return new SuperBuilderWithDefaults.Parent<N>(this);
+ }
+ }
+ private @lombok.Builder.Default long millis;
+ private @lombok.Builder.Default N numberField;
+ private static @java.lang.SuppressWarnings("all") <N extends Number>long $default$millis() {
+ return System.currentTimeMillis();
+ }
+ private static @java.lang.SuppressWarnings("all") <N extends Number>N $default$numberField() {
+ return null;
+ }
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> b) {
+ super();
+ if (b.millis$set)
+ this.millis = b.millis$value;
+ else
+ this.millis = SuperBuilderWithDefaults.Parent.<N>$default$millis();
+ if (b.numberField$set)
+ this.numberField = b.numberField$value;
+ else
+ this.numberField = SuperBuilderWithDefaults.Parent.<N>$default$numberField();
+ }
+ public static @java.lang.SuppressWarnings("all") <N extends Number>SuperBuilderWithDefaults.Parent.ParentBuilder<N, ?, ?> builder() {
+ return new SuperBuilderWithDefaults.Parent.ParentBuilderImpl<N>();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child extends Parent<Integer> {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithDefaults.Child, B extends SuperBuilderWithDefaults.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<Integer, C, B> {
+ private @java.lang.SuppressWarnings("all") double doubleField$value;
+ private @java.lang.SuppressWarnings("all") boolean doubleField$set;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B doubleField(final double doubleField) {
+ this.doubleField$value = doubleField;
+ doubleField$set = true;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString()) + ", doubleField$value=") + this.doubleField$value) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithDefaults.Child.ChildBuilder<SuperBuilderWithDefaults.Child, SuperBuilderWithDefaults.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child build() {
+ return new SuperBuilderWithDefaults.Child(this);
+ }
+ }
+ private @lombok.Builder.Default double doubleField;
+ private static @java.lang.SuppressWarnings("all") double $default$doubleField() {
+ return Math.PI;
+ }
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ if (b.doubleField$set)
+ this.doubleField = b.doubleField$value;
+ else
+ this.doubleField = SuperBuilderWithDefaults.Child.$default$doubleField();
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithDefaults.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithDefaults.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderWithDefaults() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().doubleField(0.1).numberField(5).millis(1234567890L).build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java b/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..d42c3ca7
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,32 @@
+public @lombok.experimental.SuperBuilder class SuperBuilderWithExistingConstructor {
+ public static abstract @java.lang.SuppressWarnings("all") class SuperBuilderWithExistingConstructorBuilder<C extends SuperBuilderWithExistingConstructor, B extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<C, B>> {
+ public SuperBuilderWithExistingConstructorBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder()";
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class SuperBuilderWithExistingConstructorBuilderImpl extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<SuperBuilderWithExistingConstructor, SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl> {
+ private SuperBuilderWithExistingConstructorBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor build() {
+ return new SuperBuilderWithExistingConstructor(this);
+ }
+ }
+ public SuperBuilderWithExistingConstructor() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor(final SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> b) {
+ super();
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> builder() {
+ return new SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java
index 6bda526e..db989687 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java
@@ -1,116 +1,122 @@
-import java.util.List;
-public class SuperBuilderWithGenerics {
- public static @lombok.experimental.SuperBuilder class Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenerics.Parent<A>, B extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, C, B>> {
- private @java.lang.SuppressWarnings("all") A field1;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithGenerics.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, SuperBuilderWithGenerics.Parent<A>, SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Parent<A> build() {
- return new SuperBuilderWithGenerics.Parent<A>(this);
- }
- }
- A field1;
- @lombok.Singular List<String> items;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> b) {
- super();
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>();
- }
- }
- public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenerics.Child<A>, B extends SuperBuilderWithGenerics.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenerics.Child.ChildBuilder<A, SuperBuilderWithGenerics.Child<A>, SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Child<A> build() {
- return new SuperBuilderWithGenerics.Child<A>(this);
- }
- }
- double field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>();
- }
- }
- public SuperBuilderWithGenerics() {
- super();
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithGenerics {
+ public static @lombok.experimental.SuperBuilder class Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenerics.Parent<A>, B extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, C, B>> {
+ private @java.lang.SuppressWarnings("all") A field1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithGenerics.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenerics.Parent.ParentBuilder<A, SuperBuilderWithGenerics.Parent<A>, SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Parent<A> build() {
+ return new SuperBuilderWithGenerics.Parent<A>(this);
+ }
+ }
+ A field1;
+ @lombok.Singular List<String> items;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child<A> extends Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenerics.Child<A>, B extends SuperBuilderWithGenerics.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenerics.Child.ChildBuilder<A, SuperBuilderWithGenerics.Child<A>, SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics.Child<A> build() {
+ return new SuperBuilderWithGenerics.Child<A>(this);
+ }
+ }
+ double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics.Child.ChildBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics.Child.ChildBuilderImpl<A>();
+ }
+ }
+ public SuperBuilderWithGenerics() {
+ super();
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item("").build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java
index 4fac5de9..96e681f4 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java
@@ -1,116 +1,122 @@
-import java.util.List;
-public class SuperBuilderWithGenerics2 {
- public static @lombok.experimental.SuperBuilder class Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenerics2.Parent<A>, B extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, C, B>> {
- private @java.lang.SuppressWarnings("all") A field1;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithGenerics2.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, SuperBuilderWithGenerics2.Parent<A>, SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Parent<A> build() {
- return new SuperBuilderWithGenerics2.Parent<A>(this);
- }
- }
- A field1;
- @lombok.Singular List<String> items;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> b) {
- super();
- this.field1 = b.field1;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>();
- }
- }
- public static @lombok.experimental.SuperBuilder(builderMethodName = "builder2") class Child<A> extends Parent<String> {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenerics2.Child<A>, B extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<String, C, B> {
- private @java.lang.SuppressWarnings("all") A field3;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final A field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, SuperBuilderWithGenerics2.Child<A>, SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Child<A> build() {
- return new SuperBuilderWithGenerics2.Child<A>(this);
- }
- }
- A field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> builder2() {
- return new SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>();
- }
- }
- public SuperBuilderWithGenerics2() {
- super();
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder2().field3(1).field1("value").item("").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithGenerics2 {
+ public static @lombok.experimental.SuperBuilder class Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenerics2.Parent<A>, B extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, C, B>> {
+ private @java.lang.SuppressWarnings("all") A field1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithGenerics2.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenerics2.Parent.ParentBuilder<A, SuperBuilderWithGenerics2.Parent<A>, SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Parent<A> build() {
+ return new SuperBuilderWithGenerics2.Parent<A>(this);
+ }
+ }
+ A field1;
+ @lombok.Singular List<String> items;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics2.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenerics2.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(builderMethodName = "builder2") class Child<A> extends Parent<String> {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenerics2.Child<A>, B extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<String, C, B> {
+ private @java.lang.SuppressWarnings("all") A field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final A field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenerics2.Child.ChildBuilder<A, SuperBuilderWithGenerics2.Child<A>, SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenerics2.Child<A> build() {
+ return new SuperBuilderWithGenerics2.Child<A>(this);
+ }
+ }
+ A field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenerics2.Child.ChildBuilder<A, ?, ?> builder2() {
+ return new SuperBuilderWithGenerics2.Child.ChildBuilderImpl<A>();
+ }
+ }
+ public SuperBuilderWithGenerics2() {
+ super();
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder2().field3(1).field1("value").item("").build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java
index 760c4439..8184bb05 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java
@@ -8,6 +8,9 @@ public class SuperBuilderWithGenerics3 {
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B str(final String str) {
this.str = str;
return self();
@@ -49,6 +52,9 @@ public class SuperBuilderWithGenerics3 {
}
protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B field3(final double field3) {
this.field3 = field3;
return self();
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java
index 4e55ae38..829b50b9 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java
@@ -1,156 +1,162 @@
-import java.util.Map;
-public class SuperBuilderWithGenericsAndToBuilder {
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Parent<A>, B extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, C, B>> {
- private @java.lang.SuppressWarnings("all") A field1;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<Integer> items$key;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items$value;
- public ParentBuilder() {
- super();
- }
- protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Parent<A> instance, final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
- b.field1(instance.field1);
- b.items(((instance.items == null) ? java.util.Collections.emptyMap() : instance.items));
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field1(final A field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B item(final Integer itemKey, final String itemValue) {
- if ((this.items$key == null))
- {
- this.items$key = new java.util.ArrayList<Integer>();
- this.items$value = new java.util.ArrayList<String>();
- }
- this.items$key.add(itemKey);
- this.items$value.add(itemValue);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B items(final java.util.Map<? extends Integer, ? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items$key == null))
- {
- this.items$key = new java.util.ArrayList<Integer>();
- this.items$value = new java.util.ArrayList<String>();
- }
- for (java.util.Map.Entry<? extends Integer, ? extends String> $lombokEntry : items.entrySet())
- {
- this.items$key.add($lombokEntry.getKey());
- this.items$value.add($lombokEntry.getValue());
- }
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items$key != null))
- {
- this.items$key.clear();
- this.items$value.clear();
- }
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((((("SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", items$key=") + this.items$key) + ", items$value=") + this.items$value) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, SuperBuilderWithGenericsAndToBuilder.Parent<A>, SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent<A> build() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent<A>(this);
- }
- }
- A field1;
- @lombok.Singular Map<Integer, String> items;
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
- super();
- this.field1 = b.field1;
- java.util.Map<Integer, String> items;
- switch (((b.items$key == null) ? 0 : b.items$key.size())) {
- case 0 :
- items = java.util.Collections.emptyMap();
- break;
- case 1 :
- items = java.util.Collections.singletonMap(b.items$key.get(0), b.items$value.get(0));
- break;
- default :
- items = new java.util.LinkedHashMap<Integer, String>(((b.items$key.size() < 0x40000000) ? ((1 + b.items$key.size()) + ((b.items$key.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE));
- for (int $i = 0;; ($i < b.items$key.size()); $i ++)
- items.put(b.items$key.get($i), b.items$value.get($i));
- items = java.util.Collections.unmodifiableMap(items);
- }
- this.items = items;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> toBuilder() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>();
- }
- }
- public static @lombok.experimental.SuperBuilder(toBuilder = true) class Child<A> extends Parent<A> {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Child<A>, B extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Child<A> instance, final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
- b.field3(instance.field3);
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B field3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, SuperBuilderWithGenericsAndToBuilder.Child<A>, SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A> self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child<A> build() {
- return new SuperBuilderWithGenericsAndToBuilder.Child<A>(this);
- }
- }
- double field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> toBuilder() {
- return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> builder() {
- return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>();
- }
- }
- public SuperBuilderWithGenericsAndToBuilder() {
- super();
- }
- public static void test() {
- Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item(5, "").build().toBuilder().build();
- }
-}
+import java.util.Map;
+public class SuperBuilderWithGenericsAndToBuilder {
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Parent<A>, B extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, C, B>> {
+ private @java.lang.SuppressWarnings("all") A field1;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<Integer> items$key;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items$value;
+ public ParentBuilder() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Parent<A> instance, final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
+ b.field1(instance.field1);
+ b.items(((instance.items == null) ? java.util.Collections.<Integer, String>emptyMap() : instance.items));
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field1(final A field1) {
+ this.field1 = field1;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B item(final Integer itemKey, final String itemValue) {
+ if ((this.items$key == null))
+ {
+ this.items$key = new java.util.ArrayList<Integer>();
+ this.items$value = new java.util.ArrayList<String>();
+ }
+ this.items$key.add(itemKey);
+ this.items$value.add(itemValue);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B items(final java.util.Map<? extends Integer, ? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items$key == null))
+ {
+ this.items$key = new java.util.ArrayList<Integer>();
+ this.items$value = new java.util.ArrayList<String>();
+ }
+ for (java.util.Map.Entry<? extends Integer, ? extends String> $lombokEntry : items.entrySet())
+ {
+ this.items$key.add($lombokEntry.getKey());
+ this.items$value.add($lombokEntry.getValue());
+ }
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items$key != null))
+ {
+ this.items$key.clear();
+ this.items$value.clear();
+ }
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((((("SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", items$key=") + this.items$key) + ", items$value=") + this.items$value) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, SuperBuilderWithGenericsAndToBuilder.Parent<A>, SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent<A> build() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent<A>(this);
+ }
+ }
+ A field1;
+ @lombok.Singular Map<Integer, String> items;
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ java.util.Map<Integer, String> items;
+ switch (((b.items$key == null) ? 0 : b.items$key.size())) {
+ case 0 :
+ items = java.util.Collections.emptyMap();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonMap(b.items$key.get(0), b.items$value.get(0));
+ break;
+ default :
+ items = new java.util.LinkedHashMap<Integer, String>(((b.items$key.size() < 0x40000000) ? ((1 + b.items$key.size()) + ((b.items$key.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE));
+ for (int $i = 0;; ($i < b.items$key.size()); $i ++)
+ items.put(b.items$key.get($i), b.items$value.get($i));
+ items = java.util.Collections.unmodifiableMap(items);
+ }
+ this.items = items;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> toBuilder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilderImpl<A>();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(toBuilder = true) class Child<A> extends Parent<A> {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<A, C extends SuperBuilderWithGenericsAndToBuilder.Child<A>, B extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, C, B>> extends Parent.ParentBuilder<A, C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") <A>void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithGenericsAndToBuilder.Child<A> instance, final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
+ b.field3(instance.field3);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B field3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl<A> extends SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, SuperBuilderWithGenericsAndToBuilder.Child<A>, SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A> self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child<A> build() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child<A>(this);
+ }
+ }
+ double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> toBuilder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") <A>SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder<A, ?, ?> builder() {
+ return new SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilderImpl<A>();
+ }
+ }
+ public SuperBuilderWithGenericsAndToBuilder() {
+ super();
+ }
+ public static void test() {
+ Child<Integer> x = Child.<Integer>builder().field3(0.0).field1(5).item(5, "").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java b/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java
index f0a2bc00..28504f29 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java
@@ -1,105 +1,111 @@
-import java.util.List;
-public class SuperBuilderWithNonNull {
- public static @lombok.experimental.SuperBuilder class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithNonNull.Parent, B extends SuperBuilderWithNonNull.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") String nonNullParentField$value;
- private @java.lang.SuppressWarnings("all") boolean nonNullParentField$set;
- public ParentBuilder() {
- super();
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B nonNullParentField(final @lombok.NonNull String nonNullParentField) {
- if ((nonNullParentField == null))
- {
- throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
- }
- this.nonNullParentField$value = nonNullParentField;
- nonNullParentField$set = true;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (("SuperBuilderWithNonNull.Parent.ParentBuilder(nonNullParentField$value=" + this.nonNullParentField$value) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithNonNull.Parent.ParentBuilder<SuperBuilderWithNonNull.Parent, SuperBuilderWithNonNull.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent build() {
- return new SuperBuilderWithNonNull.Parent(this);
- }
- }
- final @lombok.NonNull @lombok.Builder.Default String nonNullParentField;
- private static @java.lang.SuppressWarnings("all") String $default$nonNullParentField() {
- return "default";
- }
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> b) {
- super();
- if (b.nonNullParentField$set)
- this.nonNullParentField = b.nonNullParentField$value;
- else
- this.nonNullParentField = SuperBuilderWithNonNull.Parent.$default$nonNullParentField();
- if ((nonNullParentField == null))
- {
- throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
- }
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderWithNonNull.Parent.ParentBuilderImpl();
- }
- }
- public static @lombok.experimental.SuperBuilder class Child extends Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithNonNull.Child, B extends SuperBuilderWithNonNull.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") String nonNullChildField;
- public ChildBuilder() {
- super();
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B nonNullChildField(final @lombok.NonNull String nonNullChildField) {
- if ((nonNullChildField == null))
- {
- throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
- }
- this.nonNullChildField = nonNullChildField;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString()) + ", nonNullChildField=") + this.nonNullChildField) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithNonNull.Child.ChildBuilder<SuperBuilderWithNonNull.Child, SuperBuilderWithNonNull.Child.ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child.ChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child build() {
- return new SuperBuilderWithNonNull.Child(this);
- }
- }
- @lombok.NonNull String nonNullChildField;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.nonNullChildField = b.nonNullChildField;
- if ((nonNullChildField == null))
- {
- throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
- }
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithNonNull.Child.ChildBuilderImpl();
- }
- }
- public SuperBuilderWithNonNull() {
- super();
- }
- public static void test() {
- Child x = Child.builder().nonNullChildField("child").nonNullParentField("parent").build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithNonNull {
+ public static @lombok.experimental.SuperBuilder class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithNonNull.Parent, B extends SuperBuilderWithNonNull.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") String nonNullParentField$value;
+ private @java.lang.SuppressWarnings("all") boolean nonNullParentField$set;
+ public ParentBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B nonNullParentField(final @lombok.NonNull String nonNullParentField) {
+ if ((nonNullParentField == null))
+ {
+ throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
+ }
+ this.nonNullParentField$value = nonNullParentField;
+ nonNullParentField$set = true;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderWithNonNull.Parent.ParentBuilder(nonNullParentField$value=" + this.nonNullParentField$value) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithNonNull.Parent.ParentBuilder<SuperBuilderWithNonNull.Parent, SuperBuilderWithNonNull.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent build() {
+ return new SuperBuilderWithNonNull.Parent(this);
+ }
+ }
+ final @lombok.NonNull @lombok.Builder.Default String nonNullParentField;
+ private static @java.lang.SuppressWarnings("all") String $default$nonNullParentField() {
+ return "default";
+ }
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> b) {
+ super();
+ if (b.nonNullParentField$set)
+ this.nonNullParentField = b.nonNullParentField$value;
+ else
+ this.nonNullParentField = SuperBuilderWithNonNull.Parent.$default$nonNullParentField();
+ if ((nonNullParentField == null))
+ {
+ throw new java.lang.NullPointerException("nonNullParentField is marked non-null but is null");
+ }
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithNonNull.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithNonNull.Child, B extends SuperBuilderWithNonNull.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") String nonNullChildField;
+ public ChildBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B nonNullChildField(final @lombok.NonNull String nonNullChildField) {
+ if ((nonNullChildField == null))
+ {
+ throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
+ }
+ this.nonNullChildField = nonNullChildField;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString()) + ", nonNullChildField=") + this.nonNullChildField) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithNonNull.Child.ChildBuilder<SuperBuilderWithNonNull.Child, SuperBuilderWithNonNull.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child build() {
+ return new SuperBuilderWithNonNull.Child(this);
+ }
+ }
+ @lombok.NonNull String nonNullChildField;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.nonNullChildField = b.nonNullChildField;
+ if ((nonNullChildField == null))
+ {
+ throw new java.lang.NullPointerException("nonNullChildField is marked non-null but is null");
+ }
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithNonNull.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithNonNull.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderWithNonNull() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().nonNullChildField("child").nonNullParentField("parent").build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java b/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java
index 1f972899..303d53f6 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java
@@ -8,10 +8,16 @@
}
protected abstract @java.lang.SuppressWarnings("all") B self();
public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B field(final int field) {
this.field = field;
return self();
}
+ /**
+ * @return {@code this}.
+ */
public @java.lang.SuppressWarnings("all") B otherField(final int otherField) {
this.otherField = otherField;
return self();
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java
index 6d24f613..3a1278c1 100644
--- a/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java
+++ b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java
@@ -1,168 +1,183 @@
-import java.util.List;
-public class SuperBuilderWithSetterPrefix {
- public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "with") class Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
- private @java.lang.SuppressWarnings("all") int field1;
- private @java.lang.SuppressWarnings("all") int obtainViaField;
- private @java.lang.SuppressWarnings("all") int obtainViaMethod;
- private @java.lang.SuppressWarnings("all") String obtainViaStaticMethod;
- private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
- public ParentBuilder() {
- super();
- }
- protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- b.withField1(instance.field1);
- b.withObtainViaField(instance.field1);
- b.withObtainViaMethod(instance.method());
- b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
- b.withItems(((instance.items == null) ? java.util.Collections.emptyList() : instance.items));
- }
- protected abstract @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B withField1(final int field1) {
- this.field1 = field1;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B withObtainViaField(final int obtainViaField) {
- this.obtainViaField = obtainViaField;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B withObtainViaMethod(final int obtainViaMethod) {
- this.obtainViaMethod = obtainViaMethod;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
- this.obtainViaStaticMethod = obtainViaStaticMethod;
- return self();
- }
- public @java.lang.SuppressWarnings("all") B withItem(final String item) {
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.add(item);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B withItems(final java.util.Collection<? extends String> items) {
- if ((items == null))
- {
- throw new java.lang.NullPointerException("items cannot be null");
- }
- if ((this.items == null))
- this.items = new java.util.ArrayList<String>();
- this.items.addAll(items);
- return self();
- }
- public @java.lang.SuppressWarnings("all") B clearItems() {
- if ((this.items != null))
- this.items.clear();
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((((((((("SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
- private ParentBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent build() {
- return new SuperBuilderWithSetterPrefix.Parent(this);
- }
- }
- private int field1;
- @lombok.Builder.ObtainVia(field = "field1") int obtainViaField;
- @lombok.Builder.ObtainVia(method = "method") int obtainViaMethod;
- @lombok.Builder.ObtainVia(method = "staticMethod",isStatic = true) String obtainViaStaticMethod;
- @lombok.Singular List<String> items;
- private int method() {
- return 2;
- }
- private static String staticMethod(Parent instance) {
- return "staticMethod";
- }
- protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
- super();
- this.field1 = b.field1;
- this.obtainViaField = b.obtainViaField;
- this.obtainViaMethod = b.obtainViaMethod;
- this.obtainViaStaticMethod = b.obtainViaStaticMethod;
- java.util.List<String> items;
- switch (((b.items == null) ? 0 : b.items.size())) {
- case 0 :
- items = java.util.Collections.emptyList();
- break;
- case 1 :
- items = java.util.Collections.singletonList(b.items.get(0));
- break;
- default :
- items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
- }
- this.items = items;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
- return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
- return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
- }
- }
- public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "set") class Child extends Parent {
- public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
- private @java.lang.SuppressWarnings("all") double field3;
- public ChildBuilder() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
- super.$fillValuesFrom(instance);
- SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
- return self();
- }
- private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
- b.setField3(instance.field3);
- }
- protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
- public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
- public @java.lang.SuppressWarnings("all") B setField3(final double field3) {
- this.field3 = field3;
- return self();
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return (((("SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
- }
- }
- private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
- private ChildBuilderImpl() {
- super();
- }
- protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
- return this;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child build() {
- return new SuperBuilderWithSetterPrefix.Child(this);
- }
- }
- private double field3;
- protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
- super(b);
- this.field3 = b.field3;
- }
- public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
- return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
- }
- public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
- return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
- }
- }
- public SuperBuilderWithSetterPrefix() {
- super();
- }
- public static void test() {
- Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
- }
-}
+import java.util.List;
+public class SuperBuilderWithSetterPrefix {
+ public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "with") class Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithSetterPrefix.Parent, B extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") int field1;
+ private @java.lang.SuppressWarnings("all") int obtainViaField;
+ private @java.lang.SuppressWarnings("all") int obtainViaMethod;
+ private @java.lang.SuppressWarnings("all") String obtainViaStaticMethod;
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> items;
+ public ParentBuilder() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ SuperBuilderWithSetterPrefix.Parent.ParentBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Parent instance, final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ b.withField1(instance.field1);
+ b.withObtainViaField(instance.field1);
+ b.withObtainViaMethod(instance.method());
+ b.withObtainViaStaticMethod(SuperBuilderWithSetterPrefix.Parent.staticMethod(instance));
+ b.withItems(((instance.items == null) ? java.util.Collections.<String>emptyList() : instance.items));
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B withField1(final int field1) {
+ this.field1 = field1;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B withObtainViaField(final int obtainViaField) {
+ this.obtainViaField = obtainViaField;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B withObtainViaMethod(final int obtainViaMethod) {
+ this.obtainViaMethod = obtainViaMethod;
+ return self();
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B withObtainViaStaticMethod(final String obtainViaStaticMethod) {
+ this.obtainViaStaticMethod = obtainViaStaticMethod;
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withItem(final String item) {
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.add(item);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B withItems(final java.util.Collection<? extends String> items) {
+ if ((items == null))
+ {
+ throw new java.lang.NullPointerException("items cannot be null");
+ }
+ if ((this.items == null))
+ this.items = new java.util.ArrayList<String>();
+ this.items.addAll(items);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearItems() {
+ if ((this.items != null))
+ this.items.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((((((((("SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithSetterPrefix.Parent.ParentBuilder<SuperBuilderWithSetterPrefix.Parent, SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl> {
+ private ParentBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent build() {
+ return new SuperBuilderWithSetterPrefix.Parent(this);
+ }
+ }
+ private int field1;
+ @lombok.Builder.ObtainVia(field = "field1") int obtainViaField;
+ @lombok.Builder.ObtainVia(method = "method") int obtainViaMethod;
+ @lombok.Builder.ObtainVia(method = "staticMethod",isStatic = true) String obtainViaStaticMethod;
+ @lombok.Singular List<String> items;
+ private int method() {
+ return 2;
+ }
+ private static String staticMethod(Parent instance) {
+ return "staticMethod";
+ }
+ protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> b) {
+ super();
+ this.field1 = b.field1;
+ this.obtainViaField = b.obtainViaField;
+ this.obtainViaMethod = b.obtainViaMethod;
+ this.obtainViaStaticMethod = b.obtainViaStaticMethod;
+ java.util.List<String> items;
+ switch (((b.items == null) ? 0 : b.items.size())) {
+ case 0 :
+ items = java.util.Collections.emptyList();
+ break;
+ case 1 :
+ items = java.util.Collections.singletonList(b.items.get(0));
+ break;
+ default :
+ items = java.util.Collections.unmodifiableList(new java.util.ArrayList<String>(b.items));
+ }
+ this.items = items;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Parent.ParentBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Parent.ParentBuilderImpl();
+ }
+ }
+ public static @lombok.experimental.SuperBuilder(toBuilder = true,setterPrefix = "set") class Child extends Parent {
+ public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithSetterPrefix.Child, B extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> {
+ private @java.lang.SuppressWarnings("all") double field3;
+ public ChildBuilder() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") B $fillValuesFrom(final C instance) {
+ super.$fillValuesFrom(instance);
+ SuperBuilderWithSetterPrefix.Child.ChildBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
+ return self();
+ }
+ private static @java.lang.SuppressWarnings("all") void $fillValuesFromInstanceIntoBuilder(final SuperBuilderWithSetterPrefix.Child instance, final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ b.setField3(instance.field3);
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") B setField3(final double field3) {
+ this.field3 = field3;
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithSetterPrefix.Child.ChildBuilder<SuperBuilderWithSetterPrefix.Child, SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl> {
+ private ChildBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child build() {
+ return new SuperBuilderWithSetterPrefix.Child(this);
+ }
+ }
+ private double field3;
+ protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> b) {
+ super(b);
+ this.field3 = b.field3;
+ }
+ public @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> toBuilder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl().$fillValuesFrom(this);
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithSetterPrefix.Child.ChildBuilder<?, ?> builder() {
+ return new SuperBuilderWithSetterPrefix.Child.ChildBuilderImpl();
+ }
+ }
+ public SuperBuilderWithSetterPrefix() {
+ super();
+ }
+ public static void test() {
+ Child x = Child.builder().setField3(0.0).withField1(5).withItem("").build().toBuilder().build();
+ }
+}
diff --git a/test/transform/resource/after-ecj/Tolerate.java b/test/transform/resource/after-ecj/Tolerate.java
index 1fe5fe4c..fa3f8624 100644
--- a/test/transform/resource/after-ecj/Tolerate.java
+++ b/test/transform/resource/after-ecj/Tolerate.java
@@ -25,6 +25,9 @@ import java.util.regex.Pattern;
public @java.lang.SuppressWarnings("all") Pattern getPattern() {
return this.pattern;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") Tolerate2 withPattern(final Pattern pattern) {
return ((this.pattern == pattern) ? this : new Tolerate2(pattern));
}
diff --git a/test/transform/resource/after-ecj/ValueCallSuper.java b/test/transform/resource/after-ecj/ValueCallSuper.java
index 2fef08ab..72422a4a 100644
--- a/test/transform/resource/after-ecj/ValueCallSuper.java
+++ b/test/transform/resource/after-ecj/ValueCallSuper.java
@@ -1,32 +1,32 @@
-class ValueParent {
- ValueParent() {
- super();
- }
-}
-final @lombok.Value class ValueCallSuper extends ValueParent {
- public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
- if ((o == this))
- return true;
- if ((! (o instanceof ValueCallSuper)))
- return false;
- final ValueCallSuper other = (ValueCallSuper) o;
- if ((! other.canEqual((java.lang.Object) this)))
- return false;
- if ((! super.equals(o)))
- return false;
- return true;
- }
- protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
- return (other instanceof ValueCallSuper);
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
- final int result = super.hashCode();
- return result;
- }
- public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
- return "ValueCallSuper()";
- }
- public @java.lang.SuppressWarnings("all") ValueCallSuper() {
- super();
- }
-}
+class ValueParent {
+ ValueParent() {
+ super();
+ }
+}
+final @lombok.Value class ValueCallSuper extends ValueParent {
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof ValueCallSuper)))
+ return false;
+ final ValueCallSuper other = (ValueCallSuper) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((! super.equals(o)))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof ValueCallSuper);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int result = super.hashCode();
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "ValueCallSuper()";
+ }
+ public @java.lang.SuppressWarnings("all") ValueCallSuper() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/WithAlreadyExists.java b/test/transform/resource/after-ecj/WithAlreadyExists.java
index a868cde5..9dbd6d8a 100644
--- a/test/transform/resource/after-ecj/WithAlreadyExists.java
+++ b/test/transform/resource/after-ecj/WithAlreadyExists.java
@@ -37,6 +37,9 @@ class With5 {
With5(String foo) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") With5 withFoo(final String foo) {
return ((this.foo == foo) ? this : new With5(foo));
}
@@ -48,6 +51,9 @@ class With6 {
With6(String foo) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") With6 withFoo(final String foo) {
return ((this.foo == foo) ? this : new With6(foo));
}
diff --git a/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java b/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java
index d3fcded2..52a7f3a3 100644
--- a/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java
+++ b/test/transform/resource/after-ecj/WithAndAllArgsConstructor.java
@@ -4,9 +4,15 @@
final int x = 10;
int y = 20;
final int z;
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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));
}
diff --git a/test/transform/resource/after-ecj/WithMethodAbstract.java b/test/transform/resource/after-ecj/WithMethodAbstract.java
index cb71357a..e0b14fc2 100644
--- a/test/transform/resource/after-ecj/WithMethodAbstract.java
+++ b/test/transform/resource/after-ecj/WithMethodAbstract.java
@@ -3,5 +3,8 @@ abstract class WithMethodAbstract {
WithMethodAbstract() {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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
index cd123fe8..d5f2bbcc 100644
--- a/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java
+++ b/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java
@@ -5,9 +5,16 @@ class WithMethodMarkedDeprecated {
WithMethodMarkedDeprecated(int annotation, int javadoc) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecated withAnnotation(final int annotation) {
return ((this.annotation == annotation) ? this : new WithMethodMarkedDeprecated(annotation, this.javadoc));
}
+ /**
+ * @deprecated
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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/WithMethodMarkedDeprecatedAnnOnly.java b/test/transform/resource/after-ecj/WithMethodMarkedDeprecatedAnnOnly.java
new file mode 100644
index 00000000..d4604af5
--- /dev/null
+++ b/test/transform/resource/after-ecj/WithMethodMarkedDeprecatedAnnOnly.java
@@ -0,0 +1,14 @@
+import lombok.With;
+class WithMethodMarkedDeprecatedAnnOnly {
+ @Deprecated @With int annotation;
+ WithMethodMarkedDeprecatedAnnOnly(int annotation) {
+ super();
+ }
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecatedAnnOnly withAnnotation(final int annotation) {
+ return ((this.annotation == annotation) ? this : new WithMethodMarkedDeprecatedAnnOnly(annotation));
+ }
+}
+
diff --git a/test/transform/resource/after-ecj/WithNested.java b/test/transform/resource/after-ecj/WithNested.java
index 55f6edb2..25a8bced 100644
--- a/test/transform/resource/after-ecj/WithNested.java
+++ b/test/transform/resource/after-ecj/WithNested.java
@@ -1,6 +1,9 @@
public interface WithNested<Z> {
@lombok.RequiredArgsConstructor class IAmStaticReally {
final @lombok.With String x;
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WithNested.IAmStaticReally withX(final String x) {
return ((this.x == x) ? this : new WithNested.IAmStaticReally(x));
}
diff --git a/test/transform/resource/after-ecj/WithOnClass.java b/test/transform/resource/after-ecj/WithOnClass.java
index ca3e8c6b..1c635fce 100644
--- a/test/transform/resource/after-ecj/WithOnClass.java
+++ b/test/transform/resource/after-ecj/WithOnClass.java
@@ -4,6 +4,9 @@
WithOnClass1(boolean isNone, boolean isPublic) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WithOnClass1 withPublic(final boolean isPublic) {
return ((this.isPublic == isPublic) ? this : new WithOnClass1(this.isNone, isPublic));
}
@@ -15,9 +18,15 @@
WithOnClass2(boolean isNone, boolean isProtected, boolean isPackage) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all") WithOnClass2 withPackage(final boolean isPackage) {
return ((this.isPackage == isPackage) ? this : new WithOnClass2(this.isNone, this.isProtected, isPackage));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
protected @java.lang.SuppressWarnings("all") WithOnClass2 withProtected(final boolean isProtected) {
return ((this.isProtected == isProtected) ? this : new WithOnClass2(this.isNone, isProtected, this.isPackage));
}
@@ -28,9 +37,15 @@
WithOnClass3(String couldBeNull, String nonNull) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WithOnClass3 withCouldBeNull(final String couldBeNull) {
return ((this.couldBeNull == couldBeNull) ? this : new WithOnClass3(couldBeNull, this.nonNull));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WithOnClass3 withNonNull(final @lombok.NonNull String nonNull) {
if ((nonNull == null))
{
@@ -46,6 +61,9 @@
super();
this.fY = y;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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/WithPlain.java b/test/transform/resource/after-ecj/WithPlain.java
index 66a1455b..9f888abe 100644
--- a/test/transform/resource/after-ecj/WithPlain.java
+++ b/test/transform/resource/after-ecj/WithPlain.java
@@ -7,9 +7,15 @@ class WithPlain {
this.i = i;
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @org.springframework.lang.NonNull @java.lang.SuppressWarnings("all") WithPlain withI(final int i) {
return ((this.i == i) ? this : new WithPlain(i, this.foo));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @org.springframework.lang.NonNull @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/WithWithGenerics.java b/test/transform/resource/after-ecj/WithWithGenerics.java
index b6985b99..98b18092 100644
--- a/test/transform/resource/after-ecj/WithWithGenerics.java
+++ b/test/transform/resource/after-ecj/WithWithGenerics.java
@@ -6,12 +6,21 @@ class WithWithGenerics<T, J extends T, L extends java.lang.Number> {
public WithWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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/WithWithTypeAnnos.java b/test/transform/resource/after-ecj/WithWithTypeAnnos.java
index ff73869b..8f1b3f69 100644
--- a/test/transform/resource/after-ecj/WithWithTypeAnnos.java
+++ b/test/transform/resource/after-ecj/WithWithTypeAnnos.java
@@ -12,6 +12,9 @@ class WithWithTypeAnnos {
super();
this.foo = foo;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
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/WitherAccessLevel.java b/test/transform/resource/after-ecj/WitherAccessLevel.java
index 09a2e514..b6457534 100644
--- a/test/transform/resource/after-ecj/WitherAccessLevel.java
+++ b/test/transform/resource/after-ecj/WitherAccessLevel.java
@@ -9,18 +9,33 @@ class WitherAccessLevel {
WitherAccessLevel(boolean isNone, boolean isPrivate, boolean isPackage, boolean isProtected, boolean isPublic, boolean value) {
super();
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
private @java.lang.SuppressWarnings("all") WitherAccessLevel withPrivate(final boolean isPrivate) {
return ((this.isPrivate == isPrivate) ? this : new WitherAccessLevel(this.isNone, isPrivate, this.isPackage, this.isProtected, this.isPublic, this.value));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
@java.lang.SuppressWarnings("all") WitherAccessLevel withPackage(final boolean isPackage) {
return ((this.isPackage == isPackage) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, isPackage, this.isProtected, this.isPublic, this.value));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
protected @java.lang.SuppressWarnings("all") WitherAccessLevel withProtected(final boolean isProtected) {
return ((this.isProtected == isProtected) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, isProtected, this.isPublic, this.value));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WitherAccessLevel withPublic(final boolean isPublic) {
return ((this.isPublic == isPublic) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, isPublic, this.value));
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WitherAccessLevel withValue(final boolean value) {
return ((this.value == value) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, this.isPublic, value));
}
diff --git a/test/transform/resource/after-ecj/WitherLegacyStar.java b/test/transform/resource/after-ecj/WitherLegacyStar.java
index 7aeaa969..2b9ebe79 100644
--- a/test/transform/resource/after-ecj/WitherLegacyStar.java
+++ b/test/transform/resource/after-ecj/WitherLegacyStar.java
@@ -5,6 +5,9 @@ class WitherLegacyStar {
super();
this.i = i;
}
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
public @java.lang.SuppressWarnings("all") WitherLegacyStar withI(final int i) {
return ((this.i == i) ? this : new WitherLegacyStar(i));
}
diff --git a/test/transform/resource/before/BuilderAccessWithGetter.java b/test/transform/resource/before/BuilderAccessWithGetter.java
new file mode 100644
index 00000000..38212ecf
--- /dev/null
+++ b/test/transform/resource/before/BuilderAccessWithGetter.java
@@ -0,0 +1,10 @@
+import lombok.AccessLevel;
+import lombok.Builder;
+import lombok.Getter;
+
+@Builder(access = AccessLevel.PRIVATE)
+public final class BuilderAccessWithGetter {
+
+ @Getter
+ private final String string;
+}
diff --git a/test/transform/resource/before/BuilderSingularNullBehavior1.java b/test/transform/resource/before/BuilderSingularNullBehavior1.java
index bcf473a4..add00ea7 100644
--- a/test/transform/resource/before/BuilderSingularNullBehavior1.java
+++ b/test/transform/resource/before/BuilderSingularNullBehavior1.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.addNullAnnotations = checkerframework
//CONF: lombok.nonNull.exceptionType = assertion
import java.util.List;
diff --git a/test/transform/resource/before/BuilderSingularNullBehavior2.java b/test/transform/resource/before/BuilderSingularNullBehavior2.java
index 7d1d0e57..dde4eea9 100644
--- a/test/transform/resource/before/BuilderSingularNullBehavior2.java
+++ b/test/transform/resource/before/BuilderSingularNullBehavior2.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
//CONF: lombok.addNullAnnotations = spring
//CONF: lombok.nonNull.exceptionType = JDK
import java.util.List;
diff --git a/test/transform/resource/before/BuilderWithDeprecatedAnnOnly.java b/test/transform/resource/before/BuilderWithDeprecatedAnnOnly.java
new file mode 100644
index 00000000..1d2d199c
--- /dev/null
+++ b/test/transform/resource/before/BuilderWithDeprecatedAnnOnly.java
@@ -0,0 +1,10 @@
+import com.google.common.collect.ImmutableList;
+import lombok.Builder;
+import lombok.Singular;
+
+@Builder
+public class BuilderWithDeprecatedAnnOnly {
+ @Deprecated int dep1;
+ @Singular @Deprecated java.util.List<String> strings;
+ @Singular @Deprecated ImmutableList<Integer> numbers;
+}
diff --git a/test/transform/resource/before/BuilderWithNonNull.java b/test/transform/resource/before/BuilderWithNonNull.java
index 03a54326..b0c1d36a 100644
--- a/test/transform/resource/before/BuilderWithNonNull.java
+++ b/test/transform/resource/before/BuilderWithNonNull.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.Builder
class BuilderWithNonNull {
@lombok.NonNull
diff --git a/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java b/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java
index 8ef1f70e..7c1aa983 100644
--- a/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java
+++ b/test/transform/resource/before/BuilderWithNonNullWithSetterPrefix.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.Builder(setterPrefix = "with")
class BuilderWithNonNullWithSetterPrefix {
@lombok.NonNull
diff --git a/test/transform/resource/before/BuilderWithToBuilder.java b/test/transform/resource/before/BuilderWithToBuilder.java
index 50938ab2..5b87a18f 100644
--- a/test/transform/resource/before/BuilderWithToBuilder.java
+++ b/test/transform/resource/before/BuilderWithToBuilder.java
@@ -18,3 +18,16 @@ class ConstructorWithToBuilder<T> {
public ConstructorWithToBuilder(String mOne, @Builder.ObtainVia(field = "foo") T baz, com.google.common.collect.ImmutableList<T> bars) {
}
}
+
+class StaticMethodWithToBuilder<T> {
+ private T foo;
+
+ public StaticMethodWithToBuilder(T foo) {
+ this.foo = foo;
+ }
+
+ @Builder(toBuilder = true)
+ public static <T> StaticMethodWithToBuilder<T> of(T foo) {
+ return new StaticMethodWithToBuilder<T>(foo);
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/CheckerFrameworkBasic.java b/test/transform/resource/before/CheckerFrameworkBasic.java
index 8a0bd118..4bf1ac73 100644
--- a/test/transform/resource/before/CheckerFrameworkBasic.java
+++ b/test/transform/resource/before/CheckerFrameworkBasic.java
@@ -1,9 +1,11 @@
+//version 8:
//CONF: checkerframework = 4.0
+import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.With;
-@Data @Accessors(chain = true)
+@Data @AllArgsConstructor @Accessors(chain = true)
class CheckerFrameworkBasic {
@With private final int x;
private final int y;
diff --git a/test/transform/resource/before/CheckerFrameworkBuilder.java b/test/transform/resource/before/CheckerFrameworkBuilder.java
index 440b80e9..0f24e1b7 100644
--- a/test/transform/resource/before/CheckerFrameworkBuilder.java
+++ b/test/transform/resource/before/CheckerFrameworkBuilder.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: checkerframework = 4.0
import java.util.List;
import lombok.Builder;
diff --git a/test/transform/resource/before/CheckerFrameworkSuperBuilder.java b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java
index ed9e14cb..fefff676 100644
--- a/test/transform/resource/before/CheckerFrameworkSuperBuilder.java
+++ b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: checkerframework = 4.0
import java.util.List;
import lombok.Singular;
diff --git a/test/transform/resource/before/ConstructorsWithAccessors.java b/test/transform/resource/before/ConstructorsWithAccessors.java
index e67a47ce..fc72be55 100644
--- a/test/transform/resource/before/ConstructorsWithAccessors.java
+++ b/test/transform/resource/before/ConstructorsWithAccessors.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.AllArgsConstructor @lombok.experimental.Accessors(prefix={"p", "_"}) class ConstructorsWithAccessors {
int plower;
int pUpper;
@@ -11,4 +12,3 @@
@lombok.NonNull Integer _huh;
@lombok.NonNull final Integer __huh2;
}
-
diff --git a/test/transform/resource/before/DataOnLocalClass.java b/test/transform/resource/before/DataOnLocalClass.java
index b1272b7e..e4fa4cd5 100644
--- a/test/transform/resource/before/DataOnLocalClass.java
+++ b/test/transform/resource/before/DataOnLocalClass.java
@@ -1,3 +1,4 @@
+//version 8:
import lombok.Data;
class DataOnLocalClass1 {
public static void main(String[] args) {
diff --git a/test/transform/resource/before/DataWithOverrideEqualsAndHashCode.java b/test/transform/resource/before/DataWithOverrideEqualsAndHashCode.java
new file mode 100644
index 00000000..78138bbf
--- /dev/null
+++ b/test/transform/resource/before/DataWithOverrideEqualsAndHashCode.java
@@ -0,0 +1,18 @@
+import lombok.Data;
+
+class DataWithOverrideEqualsAndHashCode {
+ class Data1 {
+
+ }
+
+ @Data
+ class Data2 extends Data1 {
+ public int hashCode() {
+ return 42;
+ }
+
+ public boolean equals(Object other) {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/DelegateAlreadyImplemented.java b/test/transform/resource/before/DelegateAlreadyImplemented.java
index c43c1949..feaf3c4b 100644
--- a/test/transform/resource/before/DelegateAlreadyImplemented.java
+++ b/test/transform/resource/before/DelegateAlreadyImplemented.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
public class DelegateAlreadyImplemented<T> {
@lombok.experimental.Delegate
diff --git a/test/transform/resource/before/DelegateFlagUsage.java b/test/transform/resource/before/DelegateFlagUsage.java
index 1f274e24..0b52c764 100644
--- a/test/transform/resource/before/DelegateFlagUsage.java
+++ b/test/transform/resource/before/DelegateFlagUsage.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
//conf: lombok.delegate.flagUsage = warning
//skip compare content: We're just checking if the flagUsage key works.
public class DelegateFlagUsage {
diff --git a/test/transform/resource/before/DelegateGenerics.java b/test/transform/resource/before/DelegateGenerics.java
index e89158a9..f00c90aa 100644
--- a/test/transform/resource/before/DelegateGenerics.java
+++ b/test/transform/resource/before/DelegateGenerics.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
public class DelegateGenerics<T> {
@lombok.experimental.Delegate
I1<T> target;
diff --git a/test/transform/resource/before/DelegateOnGetter.java b/test/transform/resource/before/DelegateOnGetter.java
index afe09ff4..ad9d1cfb 100644
--- a/test/transform/resource/before/DelegateOnGetter.java
+++ b/test/transform/resource/before/DelegateOnGetter.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.Delegate;
import lombok.Getter;
diff --git a/test/transform/resource/before/DelegateOnGetterNone.java b/test/transform/resource/before/DelegateOnGetterNone.java
index f9a97e6a..cd471369 100644
--- a/test/transform/resource/before/DelegateOnGetterNone.java
+++ b/test/transform/resource/before/DelegateOnGetterNone.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.AccessLevel;
import lombok.experimental.Delegate;
import lombok.Getter;
diff --git a/test/transform/resource/before/DelegateOnLocalClass.java b/test/transform/resource/before/DelegateOnLocalClass.java
new file mode 100644
index 00000000..7376c087
--- /dev/null
+++ b/test/transform/resource/before/DelegateOnLocalClass.java
@@ -0,0 +1,19 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
+//skip compare content
+//ignore: crashed javac with NPE, should be enabled when that bug is fixed
+import lombok.experimental.Delegate;
+import lombok.Getter;
+
+interface DelegateOnLocalClass {
+ void test1() {
+ class DelegateOnStatic {
+ @Delegate private final java.lang.Runnable field = null;
+ }
+ }
+
+ void test2() {
+ Runnable r = new Runnable() {
+ @Delegate private final java.lang.Runnable field = null;
+ }
+ }
+}
diff --git a/test/transform/resource/before/DelegateOnMethods.java b/test/transform/resource/before/DelegateOnMethods.java
index 79189cc1..4ea70d74 100644
--- a/test/transform/resource/before/DelegateOnMethods.java
+++ b/test/transform/resource/before/DelegateOnMethods.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.experimental.Delegate;
abstract class DelegateOnMethods {
diff --git a/test/transform/resource/before/DelegateOnStatic.java b/test/transform/resource/before/DelegateOnStatic.java
index 7a420b20..b9b728bc 100644
--- a/test/transform/resource/before/DelegateOnStatic.java
+++ b/test/transform/resource/before/DelegateOnStatic.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
//skip compare content
import lombok.experimental.Delegate;
import lombok.Getter;
diff --git a/test/transform/resource/before/DelegateRecursion.java b/test/transform/resource/before/DelegateRecursion.java
index d74107e2..c6428d06 100644
--- a/test/transform/resource/before/DelegateRecursion.java
+++ b/test/transform/resource/before/DelegateRecursion.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
//skip compare content: This test is to see if the 'delegate recursion is not supported' error pops up.
import lombok.experimental.Delegate;
class DelegateRecursionOuterMost {
diff --git a/test/transform/resource/before/DelegateTypesAndExcludes.java b/test/transform/resource/before/DelegateTypesAndExcludes.java
index 164261d8..2c0f8770 100644
--- a/test/transform/resource/before/DelegateTypesAndExcludes.java
+++ b/test/transform/resource/before/DelegateTypesAndExcludes.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.experimental.Delegate;
class DelegatePlain {
@Delegate(types = Bar.class)
diff --git a/test/transform/resource/before/DelegateWithDeprecated.java b/test/transform/resource/before/DelegateWithDeprecated.java
index a0deb788..bf3519b3 100644
--- a/test/transform/resource/before/DelegateWithDeprecated.java
+++ b/test/transform/resource/before/DelegateWithDeprecated.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.experimental.Delegate;
class DelegateWithDeprecated {
diff --git a/test/transform/resource/before/DelegateWithVarargs.java b/test/transform/resource/before/DelegateWithVarargs.java
index 0c266620..91519884 100644
--- a/test/transform/resource/before/DelegateWithVarargs.java
+++ b/test/transform/resource/before/DelegateWithVarargs.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.experimental.Delegate;
class DelegateWithVarargs {
diff --git a/test/transform/resource/before/DelegateWithVarargs2.java b/test/transform/resource/before/DelegateWithVarargs2.java
index 8a3dbf14..bc3fdf09 100644
--- a/test/transform/resource/before/DelegateWithVarargs2.java
+++ b/test/transform/resource/before/DelegateWithVarargs2.java
@@ -1,3 +1,4 @@
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.experimental.Delegate;
class DelegateWithVarargs2 {
diff --git a/test/transform/resource/before/EqualsAndHashCodeAnnotated.java b/test/transform/resource/before/EqualsAndHashCodeAnnotated.java
index d672b982..f65d7b5b 100644
--- a/test/transform/resource/before/EqualsAndHashCodeAnnotated.java
+++ b/test/transform/resource/before/EqualsAndHashCodeAnnotated.java
@@ -1,4 +1,4 @@
-//version 8
+//version 8:
import java.lang.annotation.*;
@lombok.EqualsAndHashCode
diff --git a/test/transform/resource/before/EqualsAndHashCodeCache.java b/test/transform/resource/before/EqualsAndHashCodeCache.java
new file mode 100644
index 00000000..3c84ee59
--- /dev/null
+++ b/test/transform/resource/before/EqualsAndHashCodeCache.java
@@ -0,0 +1,29 @@
+@lombok.EqualsAndHashCode(cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY)
+class EqualsAndHashCode {
+ int x;
+ boolean[] y;
+ Object[] z;
+ String a;
+ String b;
+}
+
+@lombok.EqualsAndHashCode(cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY)
+final class EqualsAndHashCode2 {
+ int x;
+ long y;
+ float f;
+ double d;
+ boolean b;
+}
+
+@lombok.EqualsAndHashCode(callSuper=false, cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY)
+final class EqualsAndHashCode3 extends EqualsAndHashCode {
+}
+
+@lombok.EqualsAndHashCode(callSuper=true, cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY)
+class EqualsAndHashCode4 extends EqualsAndHashCode {
+}
+
+@lombok.EqualsAndHashCode(callSuper=true, cacheStrategy = lombok.EqualsAndHashCode.CacheStrategy.LAZY)
+final class EqualsAndHashCode5 extends EqualsAndHashCode {
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ExtensionMethodAutoboxing.java b/test/transform/resource/before/ExtensionMethodAutoboxing.java
new file mode 100644
index 00000000..5e07a6b3
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodAutoboxing.java
@@ -0,0 +1,23 @@
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod({ExtensionMethodAutoboxing.Extensions.class})
+class ExtensionMethodAutoboxing {
+ public void test() {
+ Long l1 = 1l;
+ long l2 = 1l;
+ Integer i1 = 1;
+ int i2 = 1;
+
+ String string = "test";
+ string.boxing(l1, i1);
+ string.boxing(l1, i2);
+ string.boxing(l2, i1);
+ string.boxing(l2, i2);
+ }
+
+ static class Extensions {
+ public static String boxing(String string, Long a, int b) {
+ return string + " " + a + " " + b;
+ }
+ }
+}
diff --git a/test/transform/resource/before/ExtensionMethodChain.java b/test/transform/resource/before/ExtensionMethodChain.java
new file mode 100644
index 00000000..f7960ed4
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodChain.java
@@ -0,0 +1,17 @@
+import java.util.Arrays;
+import java.util.List;
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(ExtensionMethodChain.Extensions.class)
+class ExtensionMethodChain {
+
+ public void test() {
+ "1".intValue().intValue();
+ }
+
+ static class Extensions {
+ public static Integer intValue(String s) {
+ return Integer.valueOf(s);
+ }
+ }
+}
diff --git a/test/transform/resource/before/ExtensionMethodFunctional.java b/test/transform/resource/before/ExtensionMethodFunctional.java
new file mode 100644
index 00000000..8586dd7a
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodFunctional.java
@@ -0,0 +1,47 @@
+// version 8:
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(value = ExtensionMethodFunctional.Extensions.class, suppressBaseMethods = false)
+class ExtensionMethodFunctional {
+ public void test() {
+ String test = "test";
+ test = test.map(s -> s.reverse());
+
+ test.consume(s -> System.out.println("1: " + s), s -> System.out.println("2: " + s));
+ test.consume(System.out::println, System.out::println);
+
+ Stream.of("a", "b", "c").map(String::toUpperCase).toList1();
+ List<Integer> i2 = Stream.of("a", "b", "c").map(String::toUpperCase).toList2();
+ }
+
+ static class Extensions {
+ public static <T, R> R map(T value, Function<T, R> mapper) {
+ return mapper.apply(value);
+ }
+
+ public static String reverse(String string) {
+ return new StringBuilder(string).reverse().toString();
+ }
+
+ @SafeVarargs
+ public static <T> void consume(T o, Consumer<T>... consumer) {
+ for (int i = 0; i < consumer.length; i++) {
+ consumer[i].accept(o);
+ }
+ }
+
+ public static <T> List<T> toList1(Stream<T> stream) {
+ return (List<T>) stream.collect(Collectors.toList());
+ }
+
+ public static <T, U> List<U> toList2(Stream<T> stream) {
+ return null;
+ }
+ }
+}
diff --git a/test/transform/resource/before/ExtensionMethodGeneric.java b/test/transform/resource/before/ExtensionMethodGeneric.java
new file mode 100644
index 00000000..d44c663b
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodGeneric.java
@@ -0,0 +1,34 @@
+import java.util.List;
+import java.util.Map;
+
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(ExtensionMethodGeneric.Extensions.class)
+class ExtensionMethodGeneric {
+ public void test() {
+ List<String> stringList = null;
+ List<Number> numberList = null;
+ stringList.test();
+ stringList.test(numberList);
+ stringList.test(stringList).test(numberList);
+ Integer i = stringList.test2();
+
+ Map<String, Integer> map = null;
+ List<String> l = map.test(stringList, numberList);
+ }
+
+ static class Extensions {
+ public static <T> List<T> test(List<String> obj, List<T> list) {
+ return null;
+ }
+ public static <K,V> K test(Map<String, Integer> obj, K k, V v) {
+ return k;
+ }
+ public static <T> T test(List<T> list) {
+ return null;
+ }
+ public static <T,U> U test2(List<T> list) {
+ return null;
+ }
+ }
+}
diff --git a/test/transform/resource/before/ExtensionMethodNames.java b/test/transform/resource/before/ExtensionMethodNames.java
new file mode 100644
index 00000000..4ca63a63
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodNames.java
@@ -0,0 +1,33 @@
+package a;
+
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(Extensions.class)
+class ExtensionMethodNames {
+
+ public void instanceCalls() {
+ (new Test()).ext();
+
+ Test t = new Test();
+ t.ext();
+
+ Test Test = new Test();
+ Test.ext();
+ }
+
+ public void staticCalls() {
+ Test.ext();
+ a.Test.ext();
+ }
+}
+
+class Extensions {
+ public static void ext(Test t) {
+ }
+}
+
+class Test {
+ public static void ext() {
+
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ExtensionMethodNonStaticAccess.java b/test/transform/resource/before/ExtensionMethodNonStaticAccess.java
new file mode 100644
index 00000000..0d317c35
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodNonStaticAccess.java
@@ -0,0 +1,18 @@
+//issue #2752: this test triggers an indirect static access and a non static access warning for the same method call
+//platform ecj,eclipse
+class ExtensionMethodNonStaticAccess {
+ public void method(){
+ Derived derived = new Derived();
+ derived.staticMethod();
+ }
+}
+
+class Base {
+ static String staticMethod() {
+ return "";
+ }
+}
+
+class Derived extends Base {
+
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ExtensionMethodSuppress.java b/test/transform/resource/before/ExtensionMethodSuppress.java
new file mode 100644
index 00000000..d30652d3
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodSuppress.java
@@ -0,0 +1,43 @@
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(Extensions.class)
+class ExtensionMethodSuppress {
+ public void test() {
+ Test.staticMethod();
+
+ Test test = new Test();
+ test.instanceMethod();
+ test.staticMethod();
+ }
+}
+
+@ExtensionMethod(value = Extensions.class, suppressBaseMethods = false)
+class ExtensionMethodKeep {
+ public void test() {
+ Test.staticMethod();
+
+ Test test = new Test();
+ test.instanceMethod();
+ test.staticMethod();
+ }
+}
+
+class Test {
+ public static void staticMethod() {
+
+ }
+
+ public void instanceMethod() {
+
+ }
+}
+
+class Extensions {
+ public static void staticMethod(Test test) {
+
+ }
+
+ public static void instanceMethod(Test test) {
+
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ExtensionMethodVarargs.java b/test/transform/resource/before/ExtensionMethodVarargs.java
new file mode 100644
index 00000000..a976f9e6
--- /dev/null
+++ b/test/transform/resource/before/ExtensionMethodVarargs.java
@@ -0,0 +1,23 @@
+// version 8:
+import lombok.experimental.ExtensionMethod;
+
+@ExtensionMethod(ExtensionMethodVarargs.Extensions.class)
+class ExtensionMethodVarargs {
+ public void test() {
+ Long l1 = 1l;
+ long l2 = 1l;
+ Integer i1 = 1;
+ int i2 = 1;
+
+ "%d %d %d %d".format(l1, l2, i1, i2);
+ "%d".format(l1);
+ "".format(new Integer[]{1,2});
+ "".format(new Integer[]{1,2}, new Integer[]{1,2});
+ }
+
+ static class Extensions {
+ public static String format(String string, Object... params) {
+ return String.format(string, params);
+ }
+ }
+}
diff --git a/test/transform/resource/before/GetterDeprecated.java b/test/transform/resource/before/GetterDeprecated.java
index 01b66bca..16d66a85 100644
--- a/test/transform/resource/before/GetterDeprecated.java
+++ b/test/transform/resource/before/GetterDeprecated.java
@@ -8,4 +8,4 @@ class GetterDeprecated {
* @deprecated
*/
@Getter int javadoc;
-} \ No newline at end of file
+}
diff --git a/test/transform/resource/before/GetterOnClass.java b/test/transform/resource/before/GetterOnClass.java
index 0a38b386..f44d2556 100644
--- a/test/transform/resource/before/GetterOnClass.java
+++ b/test/transform/resource/before/GetterOnClass.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.Getter
class GetterOnClass1 {
@lombok.Getter(lombok.AccessLevel.NONE)
diff --git a/test/transform/resource/before/JacksonBuilderSingular.java b/test/transform/resource/before/JacksonBuilderSingular.java
index c179c760..20d6979a 100644
--- a/test/transform/resource/before/JacksonBuilderSingular.java
+++ b/test/transform/resource/before/JacksonBuilderSingular.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import java.util.List;
import java.util.Map;
diff --git a/test/transform/resource/before/JacksonJsonProperty.java b/test/transform/resource/before/JacksonJsonProperty.java
index f0b7b2f2..c0bccfae 100644
--- a/test/transform/resource/before/JacksonJsonProperty.java
+++ b/test/transform/resource/before/JacksonJsonProperty.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
diff --git a/test/transform/resource/before/JacksonizedBuilderComplex.java b/test/transform/resource/before/JacksonizedBuilderComplex.java
index dec1cd3b..5942926d 100644
--- a/test/transform/resource/before/JacksonizedBuilderComplex.java
+++ b/test/transform/resource/before/JacksonizedBuilderComplex.java
@@ -1,10 +1,11 @@
-//CONF: lombok.builder.className = Test*Name
-import java.util.List;
-import lombok.Builder;
-import lombok.extern.jackson.Jacksonized;
-
-class JacksonizedBuilderComplex {
- @Jacksonized
- @Builder(buildMethodName = "execute", setterPrefix = "with")
- private static <T extends Number> void testVoidWithGenerics(T number, int arg2, String arg3, JacksonizedBuilderComplex selfRef) {}
-}
+//version 8: Jackson deps are at least Java7+.
+//CONF: lombok.builder.className = Test*Name
+import java.util.List;
+import lombok.Builder;
+import lombok.extern.jackson.Jacksonized;
+
+class JacksonizedBuilderComplex {
+ @Jacksonized
+ @Builder(buildMethodName = "execute", setterPrefix = "with")
+ private static <T extends Number> void testVoidWithGenerics(T number, int arg2, String arg3, JacksonizedBuilderComplex selfRef) {}
+}
diff --git a/test/transform/resource/before/JacksonizedBuilderSimple.java b/test/transform/resource/before/JacksonizedBuilderSimple.java
index 6da015ec..b81a0f5d 100644
--- a/test/transform/resource/before/JacksonizedBuilderSimple.java
+++ b/test/transform/resource/before/JacksonizedBuilderSimple.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
diff --git a/test/transform/resource/before/JacksonizedSuperBuilderSimple.java b/test/transform/resource/before/JacksonizedSuperBuilderSimple.java
index 1e3bd0fc..23e52c97 100644
--- a/test/transform/resource/before/JacksonizedSuperBuilderSimple.java
+++ b/test/transform/resource/before/JacksonizedSuperBuilderSimple.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
public class JacksonizedSuperBuilderSimple {
@lombok.extern.jackson.Jacksonized
@lombok.experimental.SuperBuilder
diff --git a/test/transform/resource/before/JacksonizedSuperBuilderWithJsonDeserialize.java b/test/transform/resource/before/JacksonizedSuperBuilderWithJsonDeserialize.java
index 0c80d1a6..ac0dba07 100644
--- a/test/transform/resource/before/JacksonizedSuperBuilderWithJsonDeserialize.java
+++ b/test/transform/resource/before/JacksonizedSuperBuilderWithJsonDeserialize.java
@@ -1,3 +1,4 @@
+//version 8: Jackson deps are at least Java7+.
@lombok.extern.jackson.Jacksonized
@lombok.experimental.SuperBuilder
@com.fasterxml.jackson.databind.annotation.JsonDeserialize
diff --git a/test/transform/resource/before/JavadocMultiline.java b/test/transform/resource/before/JavadocMultiline.java
new file mode 100644
index 00000000..8557dba8
--- /dev/null
+++ b/test/transform/resource/before/JavadocMultiline.java
@@ -0,0 +1,22 @@
+@lombok.Getter
+@lombok.Setter
+class JavadocMultiline {
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ * @return A list of booleans to set for this object. This is a Javadoc return that is long
+ * enough to wrap to multiple lines.
+ */
+ private java.util.List<Boolean> booleans;
+
+
+ /**
+ * This is a list of booleans.
+ *
+ * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
+ * long enough to wrap to multiple lines.
+ */
+ private java.util.List<Boolean> booleans2;
+}
diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java
index 10b3aae5..1dd48d7a 100644
--- a/test/transform/resource/before/LoggerLog4j2.java
+++ b/test/transform/resource/before/LoggerLog4j2.java
@@ -1,3 +1,4 @@
+//version 8:
import lombok.extern.log4j.Log4j2;
@lombok.extern.log4j.Log4j2
diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java
index 3f8284e8..c59db4ee 100644
--- a/test/transform/resource/before/LoggerSlf4j.java
+++ b/test/transform/resource/before/LoggerSlf4j.java
@@ -28,7 +28,3 @@ class LoggerSlf4jWithStaticField {
class LoggerSlf4jWithTwoStaticFields {
static final String TOPIC = "StaticField";
}
-
-@Slf4j(topic="A"+"B")
-class LoggerSlf4jWithTwoLiterals {
-} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerSlf4jInvalidTopic.java b/test/transform/resource/before/LoggerSlf4jInvalidTopic.java
deleted file mode 100644
index eed02f01..00000000
--- a/test/transform/resource/before/LoggerSlf4jInvalidTopic.java
+++ /dev/null
@@ -1,5 +0,0 @@
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j(topic=42)
-class LoggerSlf4jWithIntegerTopic {
-} \ No newline at end of file
diff --git a/test/transform/resource/before/NonNullOnParameter.java b/test/transform/resource/before/NonNullOnParameter.java
index 22aceac7..43175832 100644
--- a/test/transform/resource/before/NonNullOnParameter.java
+++ b/test/transform/resource/before/NonNullOnParameter.java
@@ -1,3 +1,4 @@
+//version 8:
class NonNullOnParameter extends Thread {
NonNullOnParameter(@lombok.NonNull String arg) {
this(arg, "");
diff --git a/test/transform/resource/before/NonNullOnParameterAbstract.java b/test/transform/resource/before/NonNullOnParameterAbstract.java
index 16691184..0508be42 100644
--- a/test/transform/resource/before/NonNullOnParameterAbstract.java
+++ b/test/transform/resource/before/NonNullOnParameterAbstract.java
@@ -1,3 +1,4 @@
+//version 8:
abstract class NonNullOnParameterAbstract {
public void test(@lombok.NonNull String arg) {
System.out.println("Hey");
diff --git a/test/transform/resource/before/NonNullPlain.java b/test/transform/resource/before/NonNullPlain.java
index a438d1d4..1a016fb4 100644
--- a/test/transform/resource/before/NonNullPlain.java
+++ b/test/transform/resource/before/NonNullPlain.java
@@ -1,3 +1,4 @@
+//version 8:
import java.lang.annotation.*;
@lombok.RequiredArgsConstructor
diff --git a/test/transform/resource/before/NonNullWithAlternateException.java b/test/transform/resource/before/NonNullWithAlternateException.java
index c47f5727..28b7be6d 100644
--- a/test/transform/resource/before/NonNullWithAlternateException.java
+++ b/test/transform/resource/before/NonNullWithAlternateException.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.nonNull.exceptionType = IllegalArgumentException
public class NonNullWithAlternateException {
diff --git a/test/transform/resource/before/NonNullWithAssertion.java b/test/transform/resource/before/NonNullWithAssertion.java
index c3d271a6..1e282ffa 100644
--- a/test/transform/resource/before/NonNullWithAssertion.java
+++ b/test/transform/resource/before/NonNullWithAssertion.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.nonNull.exceptionType = Assertion
public class NonNullWithAssertion {
diff --git a/test/transform/resource/before/NonNullWithGuava.java b/test/transform/resource/before/NonNullWithGuava.java
index dc877daa..e592ee14 100644
--- a/test/transform/resource/before/NonNullWithGuava.java
+++ b/test/transform/resource/before/NonNullWithGuava.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.nonNull.exceptionType = Guava
import static com.google.common.base.Preconditions.*;
public class NonNullWithGuava {
diff --git a/test/transform/resource/before/NonNullWithJdk.java b/test/transform/resource/before/NonNullWithJdk.java
index c8cbf2ee..5c3d03a5 100644
--- a/test/transform/resource/before/NonNullWithJdk.java
+++ b/test/transform/resource/before/NonNullWithJdk.java
@@ -1,4 +1,4 @@
-//version 7:
+//version 8:
//CONF: lombok.nonNull.exceptionType = Jdk
import static java.util.Objects.*;
public class NonNullWithJdk {
diff --git a/test/transform/resource/before/NonNullWithSneakyThrows.java b/test/transform/resource/before/NonNullWithSneakyThrows.java
index 35f78a7f..00c03f04 100644
--- a/test/transform/resource/before/NonNullWithSneakyThrows.java
+++ b/test/transform/resource/before/NonNullWithSneakyThrows.java
@@ -1,3 +1,4 @@
+//version 8:
class NonNullWithSneakyThrows {
@lombok.SneakyThrows void test(@lombok.NonNull String in) {
System.out.println(in);
diff --git a/test/transform/resource/before/NullAnnotatedCheckerFrameworkSuperBuilder.java b/test/transform/resource/before/NullAnnotatedCheckerFrameworkSuperBuilder.java
new file mode 100644
index 00000000..eea118cb
--- /dev/null
+++ b/test/transform/resource/before/NullAnnotatedCheckerFrameworkSuperBuilder.java
@@ -0,0 +1,20 @@
+//version 8:
+//CONF: lombok.addNullAnnotations = checkerframework
+import java.util.List;
+import lombok.Singular;
+
+class NullAnnotatedCheckerFrameworkSuperBuilder {
+ @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 ZChild extends Parent {
+ @lombok.Builder.Default int a = 1;
+ int b;
+ }
+}
diff --git a/test/transform/resource/before/NullLibrary1.java b/test/transform/resource/before/NullLibrary1.java
index 95433270..d57d3d09 100644
--- a/test/transform/resource/before/NullLibrary1.java
+++ b/test/transform/resource/before/NullLibrary1.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.addNullAnnotations = eclipse
@lombok.EqualsAndHashCode
@lombok.ToString
diff --git a/test/transform/resource/before/NullLibrary2.java b/test/transform/resource/before/NullLibrary2.java
index 17b1e6e0..6b0ce4b0 100644
--- a/test/transform/resource/before/NullLibrary2.java
+++ b/test/transform/resource/before/NullLibrary2.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
//CONF: lombok.addNullAnnotations = spring
@lombok.EqualsAndHashCode
@lombok.ToString
diff --git a/test/transform/resource/before/OnXJava7StyleOn8.java b/test/transform/resource/before/OnXJava7StyleOn8.java
index 582fe6ce..94865c97 100644
--- a/test/transform/resource/before/OnXJava7StyleOn8.java
+++ b/test/transform/resource/before/OnXJava7StyleOn8.java
@@ -1,4 +1,4 @@
-//platform ecj
+//platform ecj,eclipse
//version 8:
public class OnXJava7StyleOn8 {
diff --git a/test/transform/resource/before/OnXJava8StyleOn7.java b/test/transform/resource/before/OnXJava8StyleOn7.java
index c006e468..98f76451 100644
--- a/test/transform/resource/before/OnXJava8StyleOn7.java
+++ b/test/transform/resource/before/OnXJava8StyleOn7.java
@@ -1,4 +1,4 @@
-//platform ecj
+//platform ecj,eclipse
//version :7
public class OnXJava8StyleOn7 {
diff --git a/test/transform/resource/before/SetterDeprecated.java b/test/transform/resource/before/SetterDeprecated.java
index e655622f..585cade1 100644
--- a/test/transform/resource/before/SetterDeprecated.java
+++ b/test/transform/resource/before/SetterDeprecated.java
@@ -8,4 +8,4 @@ class SetterDeprecated {
* @deprecated
*/
@Setter int javadoc;
-} \ No newline at end of file
+}
diff --git a/test/transform/resource/before/SetterOnClass.java b/test/transform/resource/before/SetterOnClass.java
index a7629ff0..b7ab4177 100644
--- a/test/transform/resource/before/SetterOnClass.java
+++ b/test/transform/resource/before/SetterOnClass.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.Setter
class SetterOnClass1 {
@lombok.Setter(lombok.AccessLevel.NONE)
diff --git a/test/transform/resource/before/StaticConstructor.java b/test/transform/resource/before/StaticConstructor.java
index eff1fa9b..7b720c6f 100644
--- a/test/transform/resource/before/StaticConstructor.java
+++ b/test/transform/resource/before/StaticConstructor.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.addNullAnnotations = checkerframework
import lombok.AllArgsConstructor;
@AllArgsConstructor(staticName = "of")
diff --git a/test/transform/resource/before/SuperBuilderBasicToBuilder.java b/test/transform/resource/before/SuperBuilderBasicToBuilder.java
index 93161443..bd97876e 100644
--- a/test/transform/resource/before/SuperBuilderBasicToBuilder.java
+++ b/test/transform/resource/before/SuperBuilderBasicToBuilder.java
@@ -15,7 +15,7 @@ public class SuperBuilderBasicToBuilder {
private int method() {
return 2;
}
-
+
private static String staticMethod(Parent instance) {
return "staticMethod";
}
diff --git a/test/transform/resource/before/SuperBuilderCustomized.java b/test/transform/resource/before/SuperBuilderCustomized.java
index 8e641d90..652d0865 100644
--- a/test/transform/resource/before/SuperBuilderCustomized.java
+++ b/test/transform/resource/before/SuperBuilderCustomized.java
@@ -1,3 +1,4 @@
+//version 8: Javac 6 will error out due to `ChildBuilder` not existing before properly running lombok. Giving j6 support status, not worth fixing.
import java.util.List;
public class SuperBuilderCustomized {
diff --git a/test/transform/resource/before/SuperBuilderInitializer.java b/test/transform/resource/before/SuperBuilderInitializer.java
new file mode 100644
index 00000000..966a4daf
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderInitializer.java
@@ -0,0 +1,16 @@
+import lombok.experimental.SuperBuilder;
+
+class SuperBuilderInitializer {
+ @SuperBuilder
+ public static class One {
+ private String world;
+ {
+ world = "Hello";
+ }
+
+ private static final String world2;
+ static {
+ world2 = "Hello";
+ }
+ }
+}
diff --git a/test/transform/resource/before/SuperBuilderSingularAnnotatedTypes.java b/test/transform/resource/before/SuperBuilderSingularAnnotatedTypes.java
index d26352d2..097f4e60 100644
--- a/test/transform/resource/before/SuperBuilderSingularAnnotatedTypes.java
+++ b/test/transform/resource/before/SuperBuilderSingularAnnotatedTypes.java
@@ -1,4 +1,4 @@
-//VERSION 8:
+//version 8:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Set;
diff --git a/test/transform/resource/before/SuperBuilderSingularCustomized.java b/test/transform/resource/before/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..86b6022a
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderSingularCustomized.java
@@ -0,0 +1,9 @@
+import java.util.Set;
+@lombok.experimental.SuperBuilder
+class SuperBuilderSingularCustomized {
+ @lombok.Singular private Set<String> foos;
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ public B custom(final String value) {
+ return self();
+ }
+ }}
diff --git a/test/transform/resource/before/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/before/SuperBuilderWithCustomBuilderMethod.java
index d52cbded..b828eafe 100644
--- a/test/transform/resource/before/SuperBuilderWithCustomBuilderMethod.java
+++ b/test/transform/resource/before/SuperBuilderWithCustomBuilderMethod.java
@@ -1,3 +1,4 @@
+//version 8: Javac 6 will error out due to `ChildBuilder` not existing before properly running lombok. Giving j6 support status, not worth fixing.
import java.util.List;
public class SuperBuilderWithCustomBuilderMethod {
diff --git a/test/transform/resource/before/SuperBuilderWithExistingConstructor.java b/test/transform/resource/before/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..d6bfe2ec
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,5 @@
+@lombok.experimental.SuperBuilder
+public class SuperBuilderWithExistingConstructor {
+ public SuperBuilderWithExistingConstructor() {
+ }
+}
diff --git a/test/transform/resource/before/SuperBuilderWithNonNull.java b/test/transform/resource/before/SuperBuilderWithNonNull.java
index 34668bbc..7287c688 100644
--- a/test/transform/resource/before/SuperBuilderWithNonNull.java
+++ b/test/transform/resource/before/SuperBuilderWithNonNull.java
@@ -1,3 +1,4 @@
+//version 8:
import java.util.List;
public class SuperBuilderWithNonNull {
diff --git a/test/transform/resource/before/ValDelegateMethodReference.java b/test/transform/resource/before/ValDelegateMethodReference.java
index 7adc402a..3d1f082c 100644
--- a/test/transform/resource/before/ValDelegateMethodReference.java
+++ b/test/transform/resource/before/ValDelegateMethodReference.java
@@ -1,4 +1,5 @@
-
+//version 8:
+//platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run.
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Delegate;
diff --git a/test/transform/resource/before/ValWeirdTypes.java b/test/transform/resource/before/ValWeirdTypes.java
index 8dd63e86..f62feca6 100644
--- a/test/transform/resource/before/ValWeirdTypes.java
+++ b/test/transform/resource/before/ValWeirdTypes.java
@@ -1,3 +1,4 @@
+// version 8: In java6/7, lub types worked differently, so, the `arraysAsList` method has a slightly different inferred type there.
import java.math.BigDecimal;
import java.util.*;
import lombok.val;
diff --git a/test/transform/resource/before/ValueCallSuper.java b/test/transform/resource/before/ValueCallSuper.java
index e236b404..bf561998 100644
--- a/test/transform/resource/before/ValueCallSuper.java
+++ b/test/transform/resource/before/ValueCallSuper.java
@@ -1,7 +1,7 @@
-//CONF: lombok.equalsAndHashCode.callSuper = call
-
-class ValueParent {
-}
-@lombok.Value
-class ValueCallSuper extends ValueParent {
-}
+//CONF: lombok.equalsAndHashCode.callSuper = call
+
+class ValueParent {
+}
+@lombok.Value
+class ValueCallSuper extends ValueParent {
+}
diff --git a/test/transform/resource/before/WithByNullAnnos.java b/test/transform/resource/before/WithByNullAnnos.java
index 3fd8087f..a3ef6ac3 100644
--- a/test/transform/resource/before/WithByNullAnnos.java
+++ b/test/transform/resource/before/WithByNullAnnos.java
@@ -1,3 +1,4 @@
+//version 8:
//CONF: lombok.addNullAnnotations=checkerframework
import java.util.List;
@lombok.RequiredArgsConstructor
diff --git a/test/transform/resource/before/WithByTypes.java b/test/transform/resource/before/WithByTypes.java
index 9d2fe358..e33b0dd6 100644
--- a/test/transform/resource/before/WithByTypes.java
+++ b/test/transform/resource/before/WithByTypes.java
@@ -1,3 +1,4 @@
+//version 8:
@lombok.RequiredArgsConstructor
@lombok.experimental.FieldDefaults(level = lombok.AccessLevel.PRIVATE, makeFinal = true)
@lombok.experimental.WithBy
diff --git a/test/transform/resource/before/WithMethodMarkedDeprecatedAnnOnly.java b/test/transform/resource/before/WithMethodMarkedDeprecatedAnnOnly.java
new file mode 100644
index 00000000..50509545
--- /dev/null
+++ b/test/transform/resource/before/WithMethodMarkedDeprecatedAnnOnly.java
@@ -0,0 +1,10 @@
+import lombok.With;
+
+class WithMethodMarkedDeprecatedAnnOnly {
+
+ @Deprecated
+ @With int annotation;
+
+ WithMethodMarkedDeprecatedAnnOnly(int annotation) {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/WithOnClass.java b/test/transform/resource/before/WithOnClass.java
index a6215b54..fb6350e7 100644
--- a/test/transform/resource/before/WithOnClass.java
+++ b/test/transform/resource/before/WithOnClass.java
@@ -1,3 +1,5 @@
+//version 8:
+
@lombok.With
class WithOnClass1 {
@lombok.With(lombok.AccessLevel.NONE)
diff --git a/test/transform/resource/before/WithPlain.java b/test/transform/resource/before/WithPlain.java
index 4f048242..9be8d4d5 100644
--- a/test/transform/resource/before/WithPlain.java
+++ b/test/transform/resource/before/WithPlain.java
@@ -1,3 +1,4 @@
+//version 8: springframework dep is too new to run on j6
//CONF: lombok.addNullAnnotations = spring
import lombok.With;
class WithPlain {
diff --git a/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages b/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages
deleted file mode 100644
index 9ee959a4..00000000
--- a/test/transform/resource/messages-delombok/CheckerFrameworkBasic.java.messages
+++ /dev/null
@@ -1,4 +0,0 @@
-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
deleted file mode 100644
index 8c736705..00000000
--- a/test/transform/resource/messages-delombok/CheckerFrameworkBuilder.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index 5dd6251a..00000000
--- a/test/transform/resource/messages-delombok/CheckerFrameworkSuperBuilder.java.messages
+++ /dev/null
@@ -1,3 +0,0 @@
-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/ExtensionMethodVarargs.java.messages b/test/transform/resource/messages-delombok/ExtensionMethodVarargs.java.messages
new file mode 100644
index 00000000..587d0767
--- /dev/null
+++ b/test/transform/resource/messages-delombok/ExtensionMethodVarargs.java.messages
@@ -0,0 +1 @@
+14 non-varargs call of varargs method with inexact argument type for last parameter \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jInvalidTopic.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jInvalidTopic.java.messages
deleted file mode 100644
index 8de0a120..00000000
--- a/test/transform/resource/messages-delombok/LoggerSlf4jInvalidTopic.java.messages
+++ /dev/null
@@ -1,2 +0,0 @@
-3 incompatible types: int cannot be converted to java.lang.String
--1 not flagged modified \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/UtilityClassErrors.java.messages b/test/transform/resource/messages-delombok/UtilityClassErrors.java.messages
index 0ff5b231..21e23ed5 100644
--- a/test/transform/resource/messages-delombok/UtilityClassErrors.java.messages
+++ b/test/transform/resource/messages-delombok/UtilityClassErrors.java.messages
@@ -1,4 +1,4 @@
4 @UtilityClasses cannot have declared constructors.
7 @UtilityClass cannot be placed on a method local or anonymous inner class, or any class nested in such a class.
-12 @UtilityClass is only supported on a class (can't be an interface, enum, annotation, or record).
+12 @UtilityClass is only supported on a class.
17 @UtilityClass automatically makes the class static, however, this class cannot be made static. \ 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
deleted file mode 100644
index 8cc7fb58..00000000
--- a/test/transform/resource/messages-ecj/CheckerFrameworkBasic.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-6 org.checkerframework.common 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
deleted file mode 100644
index d385a95c..00000000
--- a/test/transform/resource/messages-ecj/CheckerFrameworkBuilder.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index 8cc7fb58..00000000
--- a/test/transform/resource/messages-ecj/CheckerFrameworkSuperBuilder.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-6 org.checkerframework.common cannot be resolved to a type
diff --git a/test/transform/resource/messages-ecj/ExtensionMethodNonStaticAccess.java.messages b/test/transform/resource/messages-ecj/ExtensionMethodNonStaticAccess.java.messages
new file mode 100644
index 00000000..3f5f3988
--- /dev/null
+++ b/test/transform/resource/messages-ecj/ExtensionMethodNonStaticAccess.java.messages
@@ -0,0 +1,2 @@
+6 The static method staticMethod() from the type Base should be accessed directly
+6 The static method staticMethod() from the type Base should be accessed in a static way \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/ExtensionMethodSuppress.java.messages b/test/transform/resource/messages-ecj/ExtensionMethodSuppress.java.messages
new file mode 100644
index 00000000..dfa778a4
--- /dev/null
+++ b/test/transform/resource/messages-ecj/ExtensionMethodSuppress.java.messages
@@ -0,0 +1 @@
+21 The static method staticMethod() from the type Test should be accessed in a static way \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jInvalidTopic.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jInvalidTopic.java.messages
deleted file mode 100644
index 9bc2a82b..00000000
--- a/test/transform/resource/messages-ecj/LoggerSlf4jInvalidTopic.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-3 Type mismatch: cannot convert from int to String \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/UtilityClassErrors.java.messages b/test/transform/resource/messages-ecj/UtilityClassErrors.java.messages
index 6995eb65..21e23ed5 100644
--- a/test/transform/resource/messages-ecj/UtilityClassErrors.java.messages
+++ b/test/transform/resource/messages-ecj/UtilityClassErrors.java.messages
@@ -1,4 +1,4 @@
4 @UtilityClasses cannot have declared constructors.
7 @UtilityClass cannot be placed on a method local or anonymous inner class, or any class nested in such a class.
-12 @UtilityClass is only supported on a class (can't be an interface, enum, annotation, or record)
+12 @UtilityClass is only supported on a class.
17 @UtilityClass automatically makes the class static, however, this class cannot be made static. \ No newline at end of file
diff --git a/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages b/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages
deleted file mode 100644
index 80694a06..00000000
--- a/test/transform/resource/messages-idempotent/CheckerFrameworkBasic.java.messages
+++ /dev/null
@@ -1,10 +0,0 @@
-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/test/transform/resource/messages-idempotent/ExtensionMethodVarargs.java.messages b/test/transform/resource/messages-idempotent/ExtensionMethodVarargs.java.messages
new file mode 100644
index 00000000..5a1016ca
--- /dev/null
+++ b/test/transform/resource/messages-idempotent/ExtensionMethodVarargs.java.messages
@@ -0,0 +1 @@
+9 non-varargs call of varargs method with inexact argument type for last parameter \ No newline at end of file
diff --git a/test/transform/resource/messages-idempotent/LoggerSlf4jInvalidTopic.java.messages b/test/transform/resource/messages-idempotent/LoggerSlf4jInvalidTopic.java.messages
deleted file mode 100644
index d894fad1..00000000
--- a/test/transform/resource/messages-idempotent/LoggerSlf4jInvalidTopic.java.messages
+++ /dev/null
@@ -1 +0,0 @@
-3 incompatible types: int cannot be converted to java.lang.String \ No newline at end of file
diff --git a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
index 754a4237..42d2b636 100644
--- a/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
+++ b/test/transform/src/lombok/transform/TestLombokFilesIdempotent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -58,4 +58,8 @@ public class TestLombokFilesIdempotent extends DirectoryRunner.TestParams {
public boolean expectChanges() {
return false;
}
+
+ @Override public String testNamePrefix() {
+ return "idempotent-";
+ }
}
diff --git a/test/transform/src/lombok/transform/TestSourceFiles.java b/test/transform/src/lombok/transform/TestSourceFiles.java
index 17be133e..ac8b59c1 100644
--- a/test/transform/src/lombok/transform/TestSourceFiles.java
+++ b/test/transform/src/lombok/transform/TestSourceFiles.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -58,4 +58,8 @@ public class TestSourceFiles extends DirectoryRunner.TestParams {
public boolean expectChanges() {
return false;
}
+
+ @Override public String testNamePrefix() {
+ return "prettyprint-";
+ }
}
diff --git a/test/transform/src/lombok/transform/TestWithDelombok.java b/test/transform/src/lombok/transform/TestWithDelombok.java
index 9f4cf94a..f075ba04 100644
--- a/test/transform/src/lombok/transform/TestWithDelombok.java
+++ b/test/transform/src/lombok/transform/TestWithDelombok.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -58,4 +58,8 @@ public class TestWithDelombok extends DirectoryRunner.TestParams {
public boolean expectChanges() {
return true;
}
+
+ @Override public String testNamePrefix() {
+ return "javac-";
+ }
}
diff --git a/test/transform/src/lombok/transform/TestWithEcj.java b/test/transform/src/lombok/transform/TestWithEcj.java
index 3df8dc8b..7b2a6c03 100644
--- a/test/transform/src/lombok/transform/TestWithEcj.java
+++ b/test/transform/src/lombok/transform/TestWithEcj.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2015 The Project Lombok Authors.
+ * Copyright (C) 2009-2021 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
@@ -62,4 +62,8 @@ public class TestWithEcj extends DirectoryRunner.TestParams {
public boolean expectChanges() {
return true;
}
+
+ @Override public String testNamePrefix() {
+ return "ecj-";
+ }
}
diff --git a/website/resources/css/custom.css b/website/resources/css/custom.css
index 2588ae66..ded02a06 100644
--- a/website/resources/css/custom.css
+++ b/website/resources/css/custom.css
@@ -230,9 +230,7 @@ ul.dropdown-menu .header {
}
div.snippet code {
- padding: 0 0 0 2rem;
display: inline-block;
- text-indent: -2rem;
word-break: break-word;
}
diff --git a/website/resources/js/order-license.js b/website/resources/js/order-license.js
index 21550f34..6745567d 100644
--- a/website/resources/js/order-license.js
+++ b/website/resources/js/order-license.js
@@ -110,7 +110,7 @@
formFail = true;
}
- if (!data.seats || isNaN(data.seats) || data.seats < 1) {
+ if (!data.seats || isNaN(data.seats) || data.seats < 10) {
$("#seats").focus();
showError("seats");
formFail = true;
diff --git a/website/templates/features/EqualsAndHashCode.html b/website/templates/features/EqualsAndHashCode.html
index 2ea2954a..474b4ee2 100644
--- a/website/templates/features/EqualsAndHashCode.html
+++ b/website/templates/features/EqualsAndHashCode.html
@@ -12,6 +12,8 @@
<em>NEW in Lombok 0.10: </em>Unless your class is <code>final</code> and extends <code>java.lang.Object</code>, lombok generates a <code>canEqual</code> method which means JPA proxies can still be equal to their base class, but subclasses that add new state don't break the equals contract. The complicated reasons for why such a method is necessary are explained in this paper: <a href="https://www.artima.com/lejava/articles/equality.html">How to Write an Equality Method in Java</a>. If all classes in a hierarchy are a mix of scala case classes and classes with lombok-generated equals methods, all equality will 'just work'. If you need to write your own equals methods, you should always override <code>canEqual</code> if you change <code>equals</code> and <code>hashCode</code>.
</p><p>
<em>NEW in Lombok 1.14.0: </em>To put annotations on the <code>other</code> parameter of the <code>equals</code> (and, if relevant, <code>canEqual</code>) 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 ng-click="toFeature('on-x')">onX</a> feature.
+ </p><p>
+ <em>NEW in Lombok 1.18.16: </em>The result of the generated <code>hashCode()</code> can be cached by setting <code>cacheStrategy</code> to a value other than <code>CacheStrategy.NEVER</code>. <em>Do not</em> use this if objects of the annotated class can be modified in any way that would lead to the result of <code>hashCode()</code> changing.
</p>
</@f.overview>
diff --git a/website/templates/features/configuration.html b/website/templates/features/configuration.html
index 16214d4e..11aa3455 100644
--- a/website/templates/features/configuration.html
+++ b/website/templates/features/configuration.html
@@ -84,7 +84,7 @@
can be included. We suggest you put this in the root of your workspace directory.
</p><p id="addNullAnnotations">
Lombok can add nullity annotations (usually called <code>@NonNull</code> and <code>@Nullable</code>) whenever it makes sense to do so; think of generated <a href="ToString"><code>toString</code></a> and <a href="with"><code>withX</code> methods (these never return null), or the parameter of a generated <a href="EqualsAndHashCode"><code>equals</code></a> method, which is allowed to be null, and requires such an annotation if you've set up your IDE for strict null checks as well as 'parameters are non-null by default'. There are many such libraries; you must tell lombok which one to use. By default, no such annotations are added. Enable this feature with:
- <ol class="snippet example oneLiner">
+ <ol class="snippet example oneliner">
<li><code>lombok.addNullAnnotations = <em>&lt;flavor&gt;</em></code></li>
</ol>
Many <em>flavors</em> are available: <code>javax</code> (=JSR305; not recommended), <code>eclipse</code>, <code>jetbrains</code>, <code>netbeans</code>, <code>androidx</code>, <code>android.support</code> (deprecated within android), <code>checkerframework</code> (recommended), <code>findbugs</code>, <code>spring</code>, <code>jml</code>, or define your own via <code>CUSTOM:fully.qualified.NonNullAnnotation:fully.qualified.NullableAnnotation</code>; if your nullity annotation is solely of the type use style (it annotates types, such as eclipse's and checkerframework's offerings, versus annotating methods and parameters), the format is <code>CUSTOM:TYPE_USE:nonnullanno:nullableanno</code>.<br />
diff --git a/website/templates/features/experimental/Accessors.html b/website/templates/features/experimental/Accessors.html
index 97017dc6..54d507f8 100644
--- a/website/templates/features/experimental/Accessors.html
+++ b/website/templates/features/experimental/Accessors.html
@@ -15,7 +15,12 @@
New feature – community feedback requested.
</li>
</ul>
- Current status: <em>positive</em> - Currently we feel this feature may move out of experimental status with no or minor changes soon.
+ Current status: <em>neutral</em> - Some changes are expected. These changes are intended to be backwards compatible, but should start in an experimental feature:
+ <ul>
+ <li>Open feature request: naming behaviour for properties that start with a lowercase letter followed by an uppercase letter. Half of specs, tools and lombok users prefer that a field named <code>uLimit</code> into <code>getULimit</code> (including lombok) and the other half turn prefer <code>getuLimit</code>. <code>@Accessors</code> may be involved in any update that addresses this <a href="https://github.com/rzwitserloot/lombok/issues/2693">request</a>.</li>
+ <li>Open feature request: More control over naming accessors; for example to address creatively named boolean properties: Turn <code>boolean wasRunning</code> into <code>boolean wasRunning()</code> instead of <code>boolean isWasRunning()</code>, as well as more expansive prefix support. <code>@Accessors</code> will be involved if this feature <a href="https://github.com/rzwitserloot/lombok/issues/2464">request</a> is addressed.</li>
+ <li><code>@Accessors</code> currently does not 'cascade' from field <code>@Accessors</code> annotation to the class-level <code>@Accessors</code> annotation, but it does 'cascade' to <code>lombok.config</code>. Changing this is not difficult but backwards incompatible. It's not likely to break much existing code, but this needs to be decided on before the feature can move out of <em>experimental</em> status.</li>
+ </ul>
</@f.experimental>
<@f.overview>
@@ -39,7 +44,7 @@
</li>
</ul>
<p><p>
- The <code>@Accessors</code> annotation is legal on types and fields; the annotation that applies is the one on the field if present, otherwise the one on the class. When a <code>@Accessors</code> annotation on a field is present, any <code>@Accessors</code> annotation also present on that field's type is ignored.
+ The <code>@Accessors</code> annotation is legal on types and fields; the annotation that applies is the one on the field if present, otherwise the one on the class. When a <code>@Accessors</code> annotation on a field is present, any <code>@Accessors</code> annotation also present on the class the field is in, is entirely ignored, <em>even for properties not configured on the field <code>@Accessors</code></em>. This in contrast to any <code>lombok.config</code> configuration keys which serve as fall-back default if any explicit <code>@Accessors</code> annotation doesn't specify.
</p>
</@f.overview>
diff --git a/website/templates/order-license.html b/website/templates/order-license.html
index c3f52cef..1feacbbc 100644
--- a/website/templates/order-license.html
+++ b/website/templates/order-license.html
@@ -28,21 +28,21 @@
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input licenseType" name="licenseType" value="professional" checked="checked" />
- Professional (€2,- per developer per month; ~ $2.50).
+ Professional (€2,- per developer per month; ~ $2.40).
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input licenseType" name="licenseType" value="enterprise" />
- Enterprise (€5,- per developer per month; ~ $6.10).
+ Enterprise (€5,- per developer per month; ~ $6.00).
</label>
</div>
</div>
<div id="licenseTypeErr" class="formErr" hidden="hidden">License type is a required field.</div>
<div class="form-group">
- <label for="seats"># of developers using lombok</label>
+ <label for="seats"># of developers using lombok (minimum: 10)</label>
<input type="number" placeholder="# of developers" class="form-control" id="seats" />
- <div id="seatsErr" class="formErr" hidden="hidden">We need to know the # of developers to determine the license price.</div>
+ <div id="seatsErr" class="formErr" hidden="hidden">We need to know the # of developers to determine the license price, and that # needs to be at least 10.</div>
</div>
</fieldset>
<fieldset class="form-group">
diff --git a/website/templates/setup/intellij.html b/website/templates/setup/intellij.html
index 9e99adbf..76a3c7b9 100644
--- a/website/templates/setup/intellij.html
+++ b/website/templates/setup/intellij.html
@@ -3,9 +3,9 @@
<@s.scaffold title="IntelliJ IDEA">
<@s.introduction>
<p>
- The <a href="https://www.jetbrains.com/idea/">Jetbrains IntelliJ IDEA</a> editor is compatible with lombok.
+ The <a href="https://www.jetbrains.com/idea/">Jetbrains IntelliJ IDEA</a> editor is compatible with lombok without a plugin as of version 2020.3.
</p><p>
- Add the <a href="https://plugins.jetbrains.com/plugin/6317">Lombok IntelliJ plugin</a> to add lombok support for IntelliJ:
+ For versions prior to 2020.3, you can add the <a href="https://plugins.jetbrains.com/plugin/6317">Lombok IntelliJ plugin</a> to add lombok support for IntelliJ:
<ul><li>
Go to <code>File &gt; Settings &gt; Plugins</code>
</li><li>