diff options
131 files changed, 2231 insertions, 375 deletions
@@ -24,3 +24,4 @@ /website/lombokSupporters /pom.xml /jvm.locations +/testenv
\ No newline at end of file @@ -45,7 +45,7 @@ Roel Spilker <r.spilker@gmail.com> Roland Praml <pram@gmx.de> Rostislav Krasny <45571812+rosti-il@users.noreply.github.com> Samuel Pereira <samuel.p.araujo@gmail.com> -Sander Koning <askoning@gmail.com> +Sasha Koning <askoning@gmail.com> Szymon Pacanowski <spacanowski@gmail.com> Taiki Sugawara <buzz.taiki@gmail.com> Takuya Murakami <tmurakam@tmurakam.org> diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.46.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.46.xml new file mode 100644 index 00000000..37de93e6 --- /dev/null +++ b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.46.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.projectlombok" module="lombok.patcher" revision="0.46" publication="20230111220000"> + <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" /> + <description homepage="https://projectlombok.org/" /> + </info> + <configurations> + <conf name="default" /> + </configurations> + <publications> + <artifact conf="default" url="https://projectlombok.org/downloads/lombok.patcher-0.46.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index afd799d0..adab33b4 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -29,7 +29,9 @@ <conf name="ecj11" /> <conf name="ecj14" /> <conf name="ecj16" /> + <conf name="ecj19" /> + <conf name="eclipse-202212" /> <conf name="eclipse-oxygen" /> <conf name="eclipse-202006" /> @@ -37,13 +39,13 @@ </configurations> <dependencies> - <dependency org="org.projectlombok" name="lombok.patcher" rev="0.44" conf="build,stripe->default" /> + <dependency org="org.projectlombok" name="lombok.patcher" rev="0.46" conf="build,stripe->default" /> <dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="build,stripe->runtime" /> <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" /> + <dependency org="junit" name="junit" rev="4.13.2" conf="test->default; sources" /> <dependency org="log4j" name="log4j" rev="1.2.17" conf="test->default; sources" /> <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.17.1" conf="test->default; sources" /> <dependency org="commons-logging" name="commons-logging" rev="1.2" conf="test->default; sources" /> @@ -77,6 +79,7 @@ <!-- ecjs --> + <dependency org="org.eclipse.jdt" name="ecj" rev="3.32.0" conf="ecj19->master" /> <dependency org="org.eclipse.jdt" name="ecj" rev="3.25.0" conf="ecj16->master" /> <dependency org="org.eclipse.jdt" name="ecj" rev="3.22.0.v20200530-2032" conf="ecj14->master" /> <dependency org="org.eclipse.jdt" name="ecj" rev="3.16.0" conf="ecj11->master" /> @@ -86,6 +89,18 @@ <!-- eclipses --> + <dependency org="org.eclipse.platform" name="org.eclipse.core.runtime" rev="3.26.100" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.32.0" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.jdt" name="org.eclipse.jdt.ui" rev="3.27.100" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.equinox.common" rev="3.17.0" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.equinox.registry" rev="3.11.200" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.equinox.app" rev="1.6.200" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.core.resources" rev="3.18.100" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.core.contenttype" rev="3.8.200" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.core.jobs" rev="3.13.200" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.osgi" rev="3.18.200" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.text" rev="3.12.300" conf="eclipse-202212->default" transitive="false" /> + <dependency org="org.eclipse.platform" name="org.eclipse.core.runtime" rev="3.13.0" conf="eclipse-oxygen->default" transitive="false" /> <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" /> diff --git a/buildScripts/setup.ant.xml b/buildScripts/setup.ant.xml index 2a9104eb..0531a392 100644 --- a/buildScripts/setup.ant.xml +++ b/buildScripts/setup.ant.xml @@ -34,10 +34,32 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <property name="jdk6-rt.loc" location="lib/openjdk6_rt.jar" /> <property name="jdk8-rt.loc" location="lib/openjdk8_rt.jar" /> + <property name="rtstubs18.loc" location="lib/rtstubs18.jar" /> <available file="${jdk6-rt.loc}" property="jdk6-rt.available" /> <available file="${jdk8-rt.loc}" property="jdk8-rt.available" /> + <available file="${rtstubs18.loc}" property="rtstubs18.available" /> <property name="ssh.configuration.file" location="ssh.configuration" /> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.gtk.linux.aarch64"> + <os name="Linux" arch="aarch64" /> + </condition> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.gtk.linux.x86_64"> + <os name="Linux" /> + </condition> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.cocoa.macosx.aarch64"> + <os name="Mac OS X" arch="aarch64" /> + </condition> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.cocoa.macosx.x86_64"> + <os name="Mac OS X" /> + </condition> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.win32.win32.aarch64"> + <os family="windows" arch="aarch64" /> + </condition> + <condition property="os.specific.native-swt-lib" value="org.eclipse.swt.win32.win32.x86_64"> + <os family="windows" /> + </condition> + <fail unless="os.specific.native-swt-lib">Full eclipse testing requires downloading a native SWT binding. This script knows how to download for OS = [mac, linux, or windows] and architecture = [aarch64 or x86-64]. You have something different, you unique snowflake you. Your OS: "${os.name}", Your arch: "${os.arch}".</fail> + <target name="-setup.ssh.ask"> <property file="${ssh.configuration.file}" /> <fail> @@ -167,6 +189,12 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <get src="https://projectlombok.org/ivyrepo/langtools/rt-openjdk8.jar" dest="${jdk8-rt.loc}" verbose="true" usetimestamp="true" /> </target> + <target name="deps.rtstubs18" unless="rtstubs18.available"> + <echo>To test in eclipse, we need a java runtime, which will now be downloaded...</echo> + <mkdir dir="lib" /> + <get src="https://github.com/eclipse-jdt/eclipse.jdt.ui/raw/master/org.eclipse.jdt.ui.tests/testresources/rtstubs18.jar" dest="${rtstubs18.loc}" verbose="true" usetimestamp="true" /> + </target> + <target name="deps.jdk-runtime" depends="deps.jdk6-runtime, deps.jdk8-runtime" /> <target name="deps.custom" depends="ivy.config" description="Download the dependencies that comprise a configuration (from ivy.xml)"> @@ -175,6 +203,14 @@ This buildfile is part of projectlombok.org. It sets up the build itself. <ivy:retrieve symlink="true" /> </target> + <target name="deps.eclipse.oxygen" depends="deps.rtstubs18, compile.support"> + <fetchdep.eclipse.osgi name="oxygen" version="4.7/R-4.7-201706120950" /> + </target> + + <target name="deps.eclipse.2022-03" depends="deps.rtstubs18, compile.support"> + <fetchdep.eclipse.osgi name="2022-03" version="4.23/R-4.23-202203080310" /> + </target> + <macrodef name="fetchdep.ecj"> <attribute name="version" /> <sequential> @@ -195,6 +231,132 @@ This buildfile is part of projectlombok.org. It sets up the build itself. </sequential> </macrodef> + <macrodef name="fetchdep.eclipse.osgi"> + <attribute name="target" default="testenv" /> + <attribute name="name" /> + <attribute name="version" /> + <sequential> + <java classname="lombok.eclipse.dependencies.DownloadEclipseDependencies" failonerror="true"> + <classpath> + <path refid="cp.buildtools" /> + <pathelement location="build/support" /> + </classpath> + <arg value="@{target}" /> + <arg value="eclipse-@{name}" /> + <arg value="https://download.eclipse.org/eclipse/updates/@{version}/plugins/" /> + <arg value="com.ibm.icu" /> + <arg value="com.sun.jna" /> + <arg value="com.sun.jna.platform" /> + <arg value="javax.inject" /> + <arg value="javax.annotation" /> + <arg value="org.apache.batik.constants" /> + <arg value="org.apache.batik.css" /> + <arg value="org.apache.batik.i18n" /> + <arg value="org.apache.batik.util" /> + <arg value="org.apache.commons.io" /> + <arg value="org.apache.commons.logging" /> + <arg value="org.apache.commons.jxpath" /> + <arg value="org.apache.felix.scr" /> + <arg value="org.apache.xmlgraphics" /> + <arg value="org.bouncycastle.bcpg" /> + <arg value="org.bouncycastle.bcprov" /> + <arg value="org.eclipse.compare" /> + <arg value="org.eclipse.compare.core" /> + <arg value="org.eclipse.core.commands" /> + <arg value="org.eclipse.core.contenttype" /> + <arg value="org.eclipse.core.databinding" /> + <arg value="org.eclipse.core.databinding.observable" /> + <arg value="org.eclipse.core.databinding.property" /> + <arg value="org.eclipse.core.expressions" /> + <arg value="org.eclipse.core.filebuffers" /> + <arg value="org.eclipse.core.filesystem" /> + <arg value="org.eclipse.core.jobs" /> + <arg value="org.eclipse.core.resources" /> + <arg value="org.eclipse.core.runtime" /> + <arg value="org.eclipse.core.variables" /> + <arg value="org.eclipse.debug.core" /> + <arg value="org.eclipse.debug.ui" /> + <arg value="org.eclipse.e4.core.commands" /> + <arg value="org.eclipse.e4.core.contexts" /> + <arg value="org.eclipse.e4.core.di" /> + <arg value="org.eclipse.e4.core.di.annotations" /> + <arg value="org.eclipse.e4.core.di.extensions" /> + <arg value="org.eclipse.e4.core.di.extensions.supplier" /> + <arg value="org.eclipse.e4.core.services" /> + <arg value="org.eclipse.e4.emf.xpath" /> + <arg value="org.eclipse.e4.ui.bindings" /> + <arg value="org.eclipse.e4.ui.css.core" /> + <arg value="org.eclipse.e4.ui.css.swt" /> + <arg value="org.eclipse.e4.ui.css.swt.theme" /> + <arg value="org.eclipse.e4.ui.di" /> + <arg value="org.eclipse.e4.ui.dialogs" /> + <arg value="org.eclipse.e4.ui.ide" /> + <arg value="org.eclipse.e4.ui.model.workbench" /> + <arg value="org.eclipse.e4.ui.services" /> + <arg value="org.eclipse.e4.ui.widgets" /> + <arg value="org.eclipse.e4.ui.workbench" /> + <arg value="org.eclipse.e4.ui.workbench.addons.swt" /> + <arg value="org.eclipse.e4.ui.workbench.renderers.swt" /> + <arg value="org.eclipse.e4.ui.workbench.swt" /> + <arg value="org.eclipse.e4.ui.workbench3" /> + <arg value="org.eclipse.emf.common" /> + <arg value="org.eclipse.emf.ecore" /> + <arg value="org.eclipse.emf.ecore.change" /> + <arg value="org.eclipse.emf.ecore.xmi" /> + <arg value="org.eclipse.equinox.app" /> + <arg value="org.eclipse.equinox.bidi" /> + <arg value="org.eclipse.equinox.common" /> + <arg value="org.eclipse.equinox.p2.artifact.repository" /> + <arg value="org.eclipse.equinox.p2.core" /> + <arg value="org.eclipse.equinox.p2.engine" /> + <arg value="org.eclipse.equinox.p2.jarprocessor" /> + <arg value="org.eclipse.equinox.p2.metadata" /> + <arg value="org.eclipse.equinox.p2.metadata.repository" /> + <arg value="org.eclipse.equinox.p2.repository" /> + <arg value="org.eclipse.equinox.preferences" /> + <arg value="org.eclipse.equinox.registry" /> + <arg value="org.eclipse.equinox.security" /> + <arg value="org.eclipse.help" /> + <arg value="org.eclipse.jdt.core" /> + <arg value="org.eclipse.jdt.core.manipulation" /> + <arg value="org.eclipse.jdt.debug" /> + <arg value="org.eclipse.jdt.launching" /> + <arg value="org.eclipse.jdt.ui" /> + <arg value="org.eclipse.jface" /> + <arg value="org.eclipse.jface.databinding" /> + <arg value="org.eclipse.jface.text" /> + <arg value="org.eclipse.ltk.core.refactoring" /> + <arg value="org.eclipse.ltk.ui.refactoring" /> + <arg value="org.eclipse.osgi" /> + <arg value="org.eclipse.osgi.services" /> + <arg value="org.eclipse.osgi.util" /> + <arg value="org.eclipse.search" /> + <arg value="org.eclipse.swt" /> + <arg value="${os.specific.native-swt-lib}" /> + <arg value="org.eclipse.team.core" /> + <arg value="org.eclipse.team.ui" /> + <arg value="org.eclipse.text" /> + <arg value="org.eclipse.ui" /> + <arg value="org.eclipse.ui.console" /> + <arg value="org.eclipse.ui.editors" /> + <arg value="org.eclipse.ui.forms" /> + <arg value="org.eclipse.ui.ide" /> + <arg value="org.eclipse.ui.navigator" /> + <arg value="org.eclipse.ui.navigator.resources" /> + <arg value="org.eclipse.ui.views" /> + <arg value="org.eclipse.ui.views.properties.tabbed" /> + <arg value="org.eclipse.ui.workbench" /> + <arg value="org.eclipse.ui.workbench.texteditor" /> + <arg value="org.eclipse.urischeme" /> + <arg value="org.tukaani.xz" /> + <arg value="org.w3c.css.sac" /> + <arg value="org.w3c.dom.events" /> + <arg value="org.w3c.dom.smil" /> + <arg value="org.w3c.dom.svg" /> + </java> + </sequential> + </macrodef> + <target name="deps" depends="ivy.config, deps.jdk-runtime" description="Downloads all dependencies needed for common tasks"> <ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="javac6,javac8,ecj8,build,eclipse-oxygen,mapstruct,sources,stripe,buildtools,test" /> <ivy:retrieve symlink="true" /> diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml index 0191d642..d34e1f82 100644 --- a/buildScripts/tests.ant.xml +++ b/buildScripts/tests.ant.xml @@ -1,5 +1,5 @@ <!-- - Copyright (C) 2020-2021 The Project Lombok Authors. + Copyright (C) 2020-2023 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 @@ -55,6 +55,24 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn </ivy:compile> </target> + <target name="test.eclipse.compile" depends="deps.eclipse.oxygen, compile" description="compiles the eclipse tests" unless="skip.tests"> + <mkdir dir="build/tests" /> + <path id="cp.eclipse"> + <fileset dir="testenv/eclipse-oxygen/plugins"> + <include name="*.jar" /> + </fileset> + </path> + <ivy:compile destdir="build/tests" source="1.8" target="1.8" ecj="true" nowarn="true"> + <bootclasspath path="${jdk8-rt.loc}" /> + <classpath refid="cp.eclipse" /> + <classpath refid="cp.test" /> + <classpath refid="cp.javac8" /> + <classpath refid="packing.basedirs.path" /> + <classpath path="build/tests" /> + <src path="test/eclipse/src" /> + </ivy:compile> + </target> + <target name="test.ecj11.call" depends="deps, dist" description="Runs a few ecj-specific tests" unless="skip.tests"> <java jar="lib/ecj11/org.eclipse.jdt-ecj.jar" fork="true" failonerror="true"> <jvmarg value="-javaagent:dist/lombok.jar=ecj" /> @@ -126,14 +144,14 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <test.javacX version="11" /> </target> - <!-- 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 6 month window. --> - <target name="test.javac17" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac17 as underlying compiler"> <test.javacX version="17" /> </target> - <target name="test.javac18" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac18 as underlying compiler"> - <test.javacX version="18" /> + <!-- 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 6 month window. --> + + <target name="test.javac19" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac19 as underlying compiler"> + <test.javacX version="19" /> </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"> @@ -157,7 +175,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <condition property="compiler.compliance.level" value="-Dcompiler.compliance.level=@{compiler.compliance.level}" else="-Dnot=set"> <not><equals arg1="@{compiler.compliance.level}" arg2="latest" /></not> </condition> - <echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version} using. Compiler compliance level: @{compiler.compliance.level}</echo> + <echo>Running TestEclipse on eclipse-@{version} on JVM${ant.java.version}. Compiler compliance level: @{compiler.compliance.level}</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}" /> @@ -176,6 +194,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn </sequential> </macrodef> + <target name="test.eclipse-202212" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2022-12 release of eclipse"> + <fetchdep.eclipse version="202212" /> + <test.eclipse-X version="202212" /> + </target> + <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> @@ -190,6 +213,44 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <test.eclipse-X version="202006" compiler.compliance.level="8" /> </target> + <macrodef name="test.eclipse-X-full"> + <attribute name="version" /> + <sequential> + <path id="cp.eclipse-@{version}"> + <fileset dir="testenv/eclipse-@{version}/plugins"> + <include name="*.jar" /> + </fileset> + </path> + <echo>Running EclipseTests on eclipse-@{version} on JVM${ant.java.version}</echo> + <condition property="os.specific.firstThread" value="-XstartOnFirstThread"> + <os name="Mac OS X" /> + </condition> + <!-- On Mac OS X, -XstartOnFirstThread is required, on other OSes, the JVM doesn't recognize the option. -showversion serves as a no-op --> + <property name="os.specific.firstThread" value="-showversion" /> + <junit haltonfailure="yes" fork="true" forkmode="once"> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> + <jvmarg value="-javaagent:dist/lombok.jar" /> + <jvmarg value="${os.specific.firstThread}" /> + <jvmarg value="-Dlombok.testenv=testenv/eclipse-@{version}" /> + <classpath refid="cp.eclipse-@{version}" /> + <classpath location="build/ant" /> + <classpath refid="cp.test" /> + <classpath refid="cp.eclipse-@{version}" /> + <classpath refid="packing.basedirs.path" /> + <classpath location="build/tests" /> + <test name="lombok.eclipse.EclipseTests" /> + </junit> + </sequential> + </macrodef> + + <target name="test.eclipse-oxygen-full" depends="test.formatter.compile, test.eclipse.compile, deps.eclipse.oxygen" description="runs the full eclipse tests on your default VM, testing the oxygen release of eclipse"> + <test.eclipse-X-full version="oxygen" /> + </target> + + <target name="test.eclipse-2022-03-full" depends="test.formatter.compile, test.eclipse.compile, deps.eclipse.2022-03" description="runs the full eclipse tests on your default VM, testing the 2022-03 release of eclipse"> + <test.eclipse-X-full version="2022-03" /> + </target> + <macrodef name="test.ecj-X"> <attribute name="version" /> <sequential> @@ -216,16 +277,21 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <test.ecj-X version="11" /> </target> - <target name="test.ecj14" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj11 release"> + <target name="test.ecj14" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj14 release"> <fetchdep.ecj version="14" /> <test.ecj-X version="14" /> </target> - <target name="test.ecj16" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj11 release"> + <target name="test.ecj16" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj16 release"> <fetchdep.ecj version="16" /> <test.ecj-X version="16" /> </target> - <target name="test" depends="test.javacCurrent, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" /> - <target name="test.broad" depends="test.javac8, test.javac17, test.javac18, test.eclipse-oxygen, test.eclipse-202006, test.eclipse-202006-jdk8" description="runs the tests against the default JVM, javac, and eclipse" /> + <target name="test.ecj19" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj19 release"> + <fetchdep.ecj version="19" /> + <test.ecj-X version="19" /> + </target> + + <target name="test" depends="test.javacCurrent, test.eclipse-202212" description="runs the tests against the default JVM, javac, and eclipse" /> + <target name="test.broad" depends="test.javac8, test.javac17, test.javac19, test.eclipse-oxygen, test.eclipse-202212, test.eclipse-202006-jdk8" description="runs the tests against the default JVM, javac, and eclipse" /> </project> diff --git a/doc/changelog.markdown b/doc/changelog.markdown index dee3ba6f..a3703316 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -232,7 +232,7 @@ Lombok Changelog * FEATURE: A `lombok.config` key can now be used to make your fields `final` and/or `private`... __everywhere__. We'll be monitoring the performance impact of this for a while. We'll touch every source file if you turn these on, and even if you don't, we have to call into the lombok config system for every file. * FEATURE: A `lombok.config` key can now be used to set the default behaviour of `@EqualsAndHashCode` when generating methods for a class that extends something in regards to calling the superclass implementations of `equals` and `hashCode` or not. [Issue #965](https://github.com/projectlombok/lombok/issues/965). * FEATURE: Putting `@Wither` on abstract classes now generates something slightly more useful: An abstract wither method. [Issue #945](https://github.com/projectlombok/lombok/issues/945). -* BUGFIX: `@Helper` used to only be be legal in pretty specific places; now it works just about everywhere. +* BUGFIX: `@Helper` used to only be legal in pretty specific places; now it works just about everywhere. * BUGFIX: lambdas with 1 argument that has an explicit type did not pretty print correctly. [Issue #972](https://github.com/projectlombok/lombok/issues/972). * BUGFIX: When using delombok, a source file with only `@NonNull` annotations on parameters as lombok feature would not get properly delomboked. [Issue #950](https://github.com/projectlombok/lombok/issues/950). * BUGFIX: `@Delegate` in javac would generate arrays instead of varargs parameters. [Issue #932](https://github.com/projectlombok/lombok/issues/932). diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index 64294e4b..06ca3853 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -160,7 +160,7 @@ public @interface Builder { * For example, a method normally generated as {@code someField(String someField)} would instead be * generated as {@code withSomeField(String someField)} if using {@code @Builder(setterPrefix = "with")}. * - * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally + * Note that using "with" to prefix builder setter methods is strongly discouraged as "with" normally * suggests immutable data structures, and builders by definition are mutable objects. * * For {@code @Singular} fields, the generated methods are called {@code withName}, {@code withNames}, and {@code clearNames}, instead of diff --git a/src/core/lombok/NoArgsConstructor.java b/src/core/lombok/NoArgsConstructor.java index 672cd1c2..ce4df9a2 100644 --- a/src/core/lombok/NoArgsConstructor.java +++ b/src/core/lombok/NoArgsConstructor.java @@ -75,7 +75,7 @@ public @interface NoArgsConstructor { * If {@code true}, initializes all final fields to 0 / null / false. * Otherwise, a compile time error occurs. * - * @return Return {@code} true to force generation of a no-args constructor, picking defaults if necessary to assign required fields. + * @return {@code} true to force generation of a no-args constructor, picking defaults if necessary to assign required fields. */ boolean force() default false; diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 312d34d3..5e68f619 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -140,7 +140,7 @@ public class HandlerUtil { "androidx.annotation.RecentlyNullable", "com.android.annotations.NonNull", "com.android.annotations.Nullable", - // "com.google.api.server.spi.config.Nullable", - let's think about this one a litte, as it is targeted solely at parameters, so you can't even put it on fields. If we choose to support it, we should REMOVE it from the field, then - that's not something we currently support. + // "com.google.api.server.spi.config.Nullable", - let's think about this one a little, as it is targeted solely at parameters, so you can't even put it on fields. If we choose to support it, we should REMOVE it from the field, then - that's not something we currently support. "com.google.firebase.database.annotations.NotNull", "com.google.firebase.database.annotations.Nullable", "com.mongodb.lang.NonNull", @@ -197,7 +197,7 @@ public class HandlerUtil { // Checker Framework annotations. // To update Checker Framework annotations, run: // grep --recursive --files-with-matches -e '^@Target\b.*TYPE_USE' $CHECKERFRAMEWORK/checker/src/main/java $CHECKERFRAMEWORK/checker-qual/src/main/java $CHECKERFRAMEWORK/checker-util/src/main/java $CHECKERFRAMEWORK/framework/src/main/java | grep '\.java$' | sed 's/.*\/java\//\t\t\t"/' | sed 's/\.java$/",/' | sed 's/\//./g' | sort - // Only add new annotations, do not remove annotations that have been removed from the lastest version of the Checker Framework. + // Only add new annotations, do not remove annotations that have been removed from the latest version of the Checker Framework. "org.checkerframework.checker.builder.qual.CalledMethods", "org.checkerframework.checker.builder.qual.NotCalledMethods", "org.checkerframework.checker.calledmethods.qual.CalledMethods", diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index a2dd5057..bb9b6dda 100755 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -983,7 +983,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { } if (field == null) { - FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0); + FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = copyType(bfd.type); diff --git a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java index 5857780c..b84018c6 100644 --- a/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java +++ b/src/core/lombok/eclipse/handlers/HandleExtensionMethod.java @@ -50,10 +50,10 @@ public class HandleExtensionMethod extends EclipseAnnotationHandler<ExtensionMet int modifiers = typeDecl == null ? 0 : typeDecl.modifiers; boolean notAClass = (modifiers & - (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0; + (ClassFileConstants.AccAnnotation)) != 0; if (typeDecl == null || notAClass) { - annotationNode.addError("@ExtensionMethod is legal only on classes and enums."); + annotationNode.addError("@ExtensionMethod is legal only on classes and enums and interfaces."); return; } diff --git a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java index 3297ba06..fd36454d 100644 --- a/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java +++ b/src/core/lombok/eclipse/handlers/HandleFieldDefaults.java @@ -160,7 +160,7 @@ public class HandleFieldDefaults extends EclipseASTAdapter { boolean defaultToFinal = makeFinalIsExplicit ? false : Boolean.TRUE.equals(typeNode.getAst().readConfiguration(ConfigurationKeys.FIELD_DEFAULTS_FINAL_EVERYWHERE)); if (!defaultToPrivate && !defaultToFinal && fieldDefaults == null) return; - // Do not apply field defaults to records if set using the the config system + // Do not apply field defaults to records if set using the config system if (fieldDefaults == null && !isClassOrEnum(typeNode)) return; AccessLevel fdAccessLevel = (fieldDefaults != null && levelIsExplicit) ? fd.level() : defaultToPrivate ? AccessLevel.PRIVATE : null; boolean fdToFinal = (fieldDefaults != null && makeFinalIsExplicit) ? fd.makeFinal() : defaultToFinal; diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java index 558c6ec2..e91478e0 100644 --- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java @@ -51,7 +51,6 @@ 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.MarkerAnnotation; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.NullLiteral; @@ -387,16 +386,16 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { injectMethod(job.builderType, generateStaticFillValuesMethod(job, annInstance.setterPrefix())); } - // Generate abstract self() and build() methods in the abstract builder. - 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 : job.builderFields) { generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); } + // Generate abstract self() and build() methods in the abstract builder. + injectMethod(job.builderType, generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName)); + job.setBuilderToAbstract(); + injectMethod(job.builderType, generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName)); + // Create the toString() method for the abstract builder. if (methodExists("toString", job.builderType, 0) == MemberExistsResult.NOT_EXISTS) { List<Included<EclipseNode, ToString.Include>> fieldNodes = new ArrayList<Included<EclipseNode, ToString.Include>>(); @@ -948,7 +947,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { } if (field == null) { - FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName, 0, 0); + FieldDeclaration fd = new FieldDeclaration(bfd.builderFieldName.clone(), 0, 0); fd.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; fd.modifiers = ClassFileConstants.AccPrivate; fd.type = copyType(bfd.type); @@ -1100,14 +1099,29 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> { 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])); + addFirstToken(usedNames, field.type); + } + } + + // 4. Add extends and implements clauses. + addFirstToken(usedNames, td.superclass); + if (td.superInterfaces != null) { + for (TypeReference typeReference : td.superInterfaces) { + addFirstToken(usedNames, typeReference); } } return usedNames; } + + private void addFirstToken(java.util.Set<String> usedNames, TypeReference type) { + if (type == null) + return; + // Add the first token, because only that can collide. + char[][] typeName = type.getTypeName(); + if (typeName != null && typeName.length >= 1) + usedNames.add(String.valueOf(typeName[0])); + } private String generateNonclashingNameFor(String classGenericName, java.util.Set<String> typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; diff --git a/src/core/lombok/experimental/SuperBuilder.java b/src/core/lombok/experimental/SuperBuilder.java index 0733a616..193bda0f 100644 --- a/src/core/lombok/experimental/SuperBuilder.java +++ b/src/core/lombok/experimental/SuperBuilder.java @@ -69,7 +69,7 @@ public @interface SuperBuilder { * For example, a method normally generated as {@code someField(String someField)} would instead be * generated as {@code withSomeField(String someField)} if using {@code @SuperBuilder(setterPrefix = "with")}. * - * Note that using "with" to prefix builder setter methods is strongly discouraged as as "with" normally + * Note that using "with" to prefix builder setter methods is strongly discouraged as "with" normally * suggests immutable data structures, and builders by definition are mutable objects. * * For {@code @Singular} fields, the generated methods are called {@code withName}, {@code withNames}, and {@code clearNames}, instead of diff --git a/src/core/lombok/extern/jackson/Jacksonized.java b/src/core/lombok/extern/jackson/Jacksonized.java index cf6678da..801ddbcb 100644 --- a/src/core/lombok/extern/jackson/Jacksonized.java +++ b/src/core/lombok/extern/jackson/Jacksonized.java @@ -49,7 +49,7 @@ import lombok.experimental.SuperBuilder; * <li>Insert {@code @JsonPOJOBuilder(withPrefix="")} on the generated builder * class to override Jackson's default prefix "with". If you configured a * different prefix in lombok using {@code setterPrefix}, this value is used. If - * you changed the name of the {@code build()} method using using + * you changed the name of the {@code build()} method using * {@code buildMethodName}, this is also made known to Jackson.</li> * <li>For {@code @SuperBuilder}, make the builder implementation class * package-private.</li> diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java index f1109f4e..6ff6efe7 100644 --- a/src/core/lombok/javac/JavacResolution.java +++ b/src/core/lombok/javac/JavacResolution.java @@ -244,8 +244,15 @@ public class JavacResolution { } private void attrib(JCTree tree, Env<AttrContext> env) { - if (env.enclClass.type == null) try { - env.enclClass.type = Type.noType; + try { + if (env.enclClass.type == null) { + if (env.enclClass.sym != null) { + env.enclClass.type = env.enclClass.sym.type; + } + } + if (env.enclClass.type == null) { + env.enclClass.type = Type.noType; + } } catch (Throwable ignore) { // This addresses issue #1553 which involves JDK9; if it doesn't exist, we probably don't need to set it. } diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java index dd565f72..98b000c2 100644 --- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java +++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java @@ -73,10 +73,10 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho deleteAnnotationIfNeccessary(annotationNode, ExtensionMethod.class); JavacNode typeNode = annotationNode.up(); - boolean isClassOrEnum = isClassOrEnum(typeNode); + boolean isClassOrEnumOrInterface = isClassOrEnumOrInterface(typeNode); - if (!isClassOrEnum) { - annotationNode.addError("@ExtensionMethod can only be used on a class or an enum"); + if (!isClassOrEnumOrInterface) { + annotationNode.addError("@ExtensionMethod can only be used on a class or an enum or an interface"); return; } diff --git a/src/core/lombok/javac/handlers/HandleFieldDefaults.java b/src/core/lombok/javac/handlers/HandleFieldDefaults.java index 9a6632dd..b373d1df 100644 --- a/src/core/lombok/javac/handlers/HandleFieldDefaults.java +++ b/src/core/lombok/javac/handlers/HandleFieldDefaults.java @@ -140,7 +140,7 @@ public class HandleFieldDefaults extends JavacASTAdapter { boolean defaultToFinal = makeFinalIsExplicit ? false : Boolean.TRUE.equals(typeNode.getAst().readConfiguration(ConfigurationKeys.FIELD_DEFAULTS_FINAL_EVERYWHERE)); if (!defaultToPrivate && !defaultToFinal && fieldDefaults == null) return; - // Do not apply field defaults to records if set using the the config system + // Do not apply field defaults to records if set using the config system if (fieldDefaults == null && !isClassOrEnum(typeNode)) return; AccessLevel fdAccessLevel = (fieldDefaults != null && levelIsExplicit) ? fd.level() : defaultToPrivate ? AccessLevel.PRIVATE : null; boolean fdToFinal = (fieldDefaults != null && makeFinalIsExplicit) ? fd.makeFinal() : defaultToFinal; diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java index 7418ac87..913f838c 100644 --- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java @@ -336,6 +336,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { injectMethod(job.builderType, sfvm); } + // Create the setter methods in the abstract builder. + for (BuilderFieldData bfd : job.builderFields) { + generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + } + // Generate abstract self() and build() methods in the abstract builder. JCMethodDecl asm = generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName); recursiveSetGeneratedBy(asm, annotationNode); @@ -344,11 +349,6 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { recursiveSetGeneratedBy(abm, annotationNode); injectMethod(job.builderType, abm); - // Create the setter methods in the abstract builder. - 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 : job.builderFields) { @@ -1051,9 +1051,28 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { } } + // 4. Add extends and implements clauses. + addFirstToken(usedNames, Javac.getExtendsClause(td)); + for (JCExpression impl : td.getImplementsClause()) { + addFirstToken(usedNames, impl); + } + return usedNames; } + private void addFirstToken(java.util.Set<String> usedNames, JCTree type) { + if (type == null) + return; + if (type instanceof JCTypeApply) { + type = ((JCTypeApply)type).clazz; + } + while (type instanceof JCFieldAccess && ((JCFieldAccess)type).selected != null) { + // Add the first token, because only that can collide. + type = ((JCFieldAccess)type).selected; + } + usedNames.add(type.toString()); + } + private String generateNonclashingNameFor(String classGenericName, java.util.HashSet<String> typeParamStrings) { if (!typeParamStrings.contains(classGenericName)) return classGenericName; int counter = 2; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index b17e34d8..9d153a72 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -2069,6 +2069,10 @@ public class JavacHandlerUtil { return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION | RECORD); } + public static boolean isClassOrEnumOrInterface(JavacNode typeNode) { + return isClassAndDoesNotHaveFlags(typeNode, Flags.ANNOTATION | RECORD); + } + /** * Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface). */ diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java index 605b9391..13836d77 100644 --- a/src/delombok/lombok/delombok/PrettyPrinter.java +++ b/src/delombok/lombok/delombok/PrettyPrinter.java @@ -1448,6 +1448,31 @@ public class PrettyPrinter extends JCTree.Visitor { print(")"); } + void printConstantCaseLabel(JCTree tree) { + print((JCTree) readObject(tree, "expr", null)); + } + + void printPatternCaseLabel(JCTree tree) { + print((JCTree) readObject(tree, "pat", null)); + JCTree guard = readObject(tree, "guard", null); + if (guard != null) { + print(" when "); + print(guard); + } + } + + void printRecordPattern(JCTree tree) { + print((JCTree) readObject(tree, "deconstructor", null)); + print("("); + print(readObject(tree, "nested", List.<JCTree>nil()), ", "); + print(")"); + JCVariableDecl var = readObject(tree, "var", null); + if (var != null) { + print(" "); + print(var.name); + } + } + @Override public void visitTry(JCTry tree) { aPrint("try "); List<?> resources = readObject(tree, "resources", List.nil()); @@ -1672,6 +1697,12 @@ public class PrettyPrinter extends JCTree.Visitor { printGuardPattern(tree); } else if (className.endsWith("$JCParenthesizedPattern")) { // Introduced in JDK17 printParenthesizedPattern(tree); + } else if (className.endsWith("$JCConstantCaseLabel")) { // Introduced in JDK19 + printConstantCaseLabel(tree); + } else if (className.endsWith("$JCPatternCaseLabel")) { // Introduced in JDK19 + printPatternCaseLabel(tree); + } else if (className.endsWith("$JCRecordPattern")) { // Introduced in JDK19 + printRecordPattern(tree); } else { throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index d893b724..c0bfbe09 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -109,6 +109,8 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { patchRenameField(sm); patchNullCheck(sm); + patchForTests(sm); + if (reloadExistingClasses) sm.reloadClasses(instrumentation); } @@ -1007,5 +1009,13 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .transplant() .build()); } + + private static void patchForTests(ScriptManager sm) { + sm.addScriptIfWitness(new String[] {"lombok/eclipse/EclipseTests"}, ScriptBuilder.wrapReturnValue() + .target(new MethodTarget("org.osgi.framework.FrameworkUtil", "getBundle", "org.osgi.framework.Bundle", "java.lang.Class")) + .request(StackRequest.RETURN_VALUE, StackRequest.PARAM1) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "getBundle", "java.lang.Object", "java.lang.Object", "java.lang.Class")) + .build()); + } } diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java index a844239f..c7bdbc31 100755 --- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java +++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java @@ -27,6 +27,7 @@ import java.io.OutputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.security.CodeSource; import java.util.ArrayList; import java.util.List; import java.util.Stack; @@ -854,4 +855,28 @@ final class PatchFixesHider { return isGenerated(adjustment.getMember()); } } + + public static class Tests { + public static Object getBundle(Object original, Class<?> c) { + if (original != null) { + return original; + } + + CodeSource codeSource = c.getProtectionDomain().getCodeSource(); + if (codeSource == null) { + return null; + } + + String jar = codeSource.getLocation().getFile(); + String bundleName = jar.substring(jar.lastIndexOf("/") + 1, jar.indexOf("_")); + + org.osgi.framework.Bundle[] bundles = org.eclipse.core.runtime.adaptor.EclipseStarter.getSystemBundleContext().getBundles(); + for (org.osgi.framework.Bundle bundle : bundles) { + if (bundleName.equals(bundle.getSymbolicName())) { + return bundle; + } + } + return null; + } + } } diff --git a/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java b/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java new file mode 100644 index 00000000..06e26bb6 --- /dev/null +++ b/src/support/lombok/eclipse/dependencies/DownloadEclipseDependencies.java @@ -0,0 +1,131 @@ +package lombok.eclipse.dependencies; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Download eclipse bundles. + */ +public class DownloadEclipseDependencies { + + public static void main(String[] args) throws IOException { + String target = args[0]; + String eclipseVersion = args[1]; + String updatePage = args[2]; + String[] packages = Arrays.copyOfRange(args, 3, args.length); + + String pluginTarget = target + "/" + eclipseVersion + "/plugins/"; + + String indexData = readUrlAsString(updatePage); + + for (String pkg : packages) { + Matcher matcher = Pattern.compile("(" + pkg.replace(".", "\\.") + "_.*?\\.jar)").matcher(indexData); + if (matcher.find()) { + String path = matcher.group(1); + + try { + downloadFile(path, updatePage, pluginTarget); + } catch (Exception e) { + } + try { + int index = path.lastIndexOf("_"); + String source = path.substring(0, index) + ".source" + path.substring(index); + downloadFile(source, updatePage, pluginTarget); + } catch (Exception e) { + } + } else { + System.out.println("Bundle \"" + pkg + "\" not found"); + } + } + + writeEclipseLibrary(target, eclipseVersion); + } + + private static String readUrlAsString(String url) throws MalformedURLException, IOException { + InputStream in = getStreamForUrl(url); + + StringBuilder sb = new StringBuilder(); + + int bufferSize = 1024; + char[] buffer = new char[bufferSize]; + InputStreamReader reader = new InputStreamReader(in, "UTF-8"); + for (int count = 0; (count = reader.read(buffer, 0, bufferSize)) > 0;) { + sb.append(buffer, 0, count); + } + return sb.toString(); + } + + private static void downloadFile(String filename, String repositoryUrl, String target) throws IOException { + Files.createDirectories(Paths.get(target)); + Path targetFile = Paths.get(target, filename); + if (Files.exists(targetFile)) { + System.out.println("File '" + filename + "' already exists"); + return; + } + System.out.print("Downloading '" + filename + "'... "); + try { + Files.copy(getStreamForUrl(repositoryUrl + filename), targetFile, StandardCopyOption.REPLACE_EXISTING); + System.out.println("[done]"); + } catch(IOException e) { + System.out.println("[error]"); + } + } + + private static InputStream getStreamForUrl(String url) throws IOException, MalformedURLException { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setRequestProperty("User-Agent", "lombok"); + connection.setRequestProperty("Accept", "*/*"); + InputStream in = new BufferedInputStream(connection.getInputStream()); + return in; + } + + private static void writeEclipseLibrary(String target, String eclipseVersion) throws IOException { + StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); + sb.append("<eclipse-userlibraries version=\"2\">\n"); + sb.append("<library name=\""); + sb.append(eclipseVersion); + sb.append("\" systemlibrary=\"false\">\n"); + + File[] files = new File(new File(target, eclipseVersion), "plugins").listFiles(new FilenameFilter() { + @Override public boolean accept(File dir, String name) { + return name.endsWith(".jar") && !name.contains(".source_"); + } + }); + Arrays.sort(files); + + for (File file : files) { + sb.append("<archive path=\""); + sb.append(file.getAbsolutePath()); + sb.append("\""); + + String path = file.getAbsolutePath(); + int index = path.lastIndexOf("_"); + + sb.append(" source=\""); + sb.append(path.substring(0, index) + ".source" + path.substring(index)); + sb.append("\""); + + sb.append(" />\n"); + } + + sb.append("</library>\n"); + sb.append("</eclipse-userlibraries>\n"); + + Files.writeString(Paths.get(target, eclipseVersion + ".userlibraries"), sb.toString()); + } +} diff --git a/src/utils/lombok/javac/JavacTreeMaker.java b/src/utils/lombok/javac/JavacTreeMaker.java index d369b4e4..09855951 100644 --- a/src/utils/lombok/javac/JavacTreeMaker.java +++ b/src/utils/lombok/javac/JavacTreeMaker.java @@ -610,6 +610,8 @@ public class JavacTreeMaker { List<JCTree> labels; if (pat == null) { labels = tryResolve(DefaultCaseLabel) ? List.of(DefaultCaseLabel()) : List.<JCTree>nil(); + } else if (tryResolve(ConstantCaseLabel)) { + labels = List.<JCTree>of(ConstantCaseLabel(pat)); } else { labels = List.<JCTree>of(pat); } @@ -622,6 +624,12 @@ public class JavacTreeMaker { return invoke(DefaultCaseLabel); } + //javac versions: 19 + private static final MethodId<JCTree> ConstantCaseLabel = MethodId("ConstantCaseLabel", JCTree.class, JCExpression.class); + public JCTree ConstantCaseLabel(JCExpression expr) { + return invoke(ConstantCaseLabel, expr); + } + //javac versions: 6-8 private static final MethodId<JCSynchronized> Synchronized = MethodId("Synchronized"); public JCSynchronized Synchronized(JCExpression lock, JCBlock body) { diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index 60a6e92a..699b33ed 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -289,6 +289,10 @@ public class RunTestsViaEcj extends AbstractRunTests { @Override public char[][] getPackageName() { return null; } + + @Override public boolean ignoreOptionalProblems() { + return false; + } } private static final class TestCompilationUnitEclipse extends org.eclipse.jdt.internal.core.CompilationUnit { @@ -308,6 +312,14 @@ public class RunTestsViaEcj extends AbstractRunTests { mainTypeName = CharOperation.subarray(fileNameCharArray, start, end); } + @Override public int hashCode() { + return System.identityHashCode(this); + } + + @Override public boolean equals(Object obj) { + return this == obj; + } + @Override public char[] getContents() { return source; } @@ -324,7 +336,7 @@ public class RunTestsViaEcj extends AbstractRunTests { return null; } - @Override public char[] getModuleName() { + public char[] getModuleName() { return null; } } diff --git a/test/eclipse/resource/cleanup/useThis/after/A.java b/test/eclipse/resource/cleanup/useThis/after/A.java new file mode 100644 index 00000000..58913c6c --- /dev/null +++ b/test/eclipse/resource/cleanup/useThis/after/A.java @@ -0,0 +1,18 @@ +package pkg; + +import lombok.Builder; +import lombok.Data; +import lombok.With; +import lombok.experimental.WithBy; + +@Data +@Builder +@With +@WithBy +public class A { + private String string; + + public void a() { + this.string = "a"; + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/cleanup/useThis/before/A.java b/test/eclipse/resource/cleanup/useThis/before/A.java new file mode 100644 index 00000000..2eb74ebe --- /dev/null +++ b/test/eclipse/resource/cleanup/useThis/before/A.java @@ -0,0 +1,18 @@ +package pkg; + +import lombok.Builder; +import lombok.Data; +import lombok.With; +import lombok.experimental.WithBy; + +@Data +@Builder +@With +@WithBy +public class A { + private String string; + + public void a() { + string = "a"; + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/simple/after/A.java b/test/eclipse/resource/extractinterface/simple/after/A.java new file mode 100644 index 00000000..66744a22 --- /dev/null +++ b/test/eclipse/resource/extractinterface/simple/after/A.java @@ -0,0 +1,15 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A implements Interface { + private String string; + private int integer; +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/simple/after/Interface.java b/test/eclipse/resource/extractinterface/simple/after/Interface.java new file mode 100644 index 00000000..f7fa896d --- /dev/null +++ b/test/eclipse/resource/extractinterface/simple/after/Interface.java @@ -0,0 +1,21 @@ +package pkg; + +public interface Interface { + + boolean equals(java.lang.Object o); + + boolean canEqual(java.lang.Object other); + + int hashCode(); + + String getString(); + + int getInteger(); + + void setString(String string); + + void setInteger(int integer); + + java.lang.String toString(); + +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/simple/before/A.java b/test/eclipse/resource/extractinterface/simple/before/A.java new file mode 100644 index 00000000..87a6a8e4 --- /dev/null +++ b/test/eclipse/resource/extractinterface/simple/before/A.java @@ -0,0 +1,15 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String string; + private int integer; +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/usage/after/A.java b/test/eclipse/resource/extractinterface/usage/after/A.java new file mode 100644 index 00000000..66744a22 --- /dev/null +++ b/test/eclipse/resource/extractinterface/usage/after/A.java @@ -0,0 +1,15 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A implements Interface { + private String string; + private int integer; +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/usage/after/B.java b/test/eclipse/resource/extractinterface/usage/after/B.java new file mode 100644 index 00000000..fccd6237 --- /dev/null +++ b/test/eclipse/resource/extractinterface/usage/after/B.java @@ -0,0 +1,12 @@ +package pkg; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class B { + private Interface a = new A(); + private String string = a.getString(); + private int integer = a.getInteger(); +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/usage/after/Interface.java b/test/eclipse/resource/extractinterface/usage/after/Interface.java new file mode 100644 index 00000000..f7fa896d --- /dev/null +++ b/test/eclipse/resource/extractinterface/usage/after/Interface.java @@ -0,0 +1,21 @@ +package pkg; + +public interface Interface { + + boolean equals(java.lang.Object o); + + boolean canEqual(java.lang.Object other); + + int hashCode(); + + String getString(); + + int getInteger(); + + void setString(String string); + + void setInteger(int integer); + + java.lang.String toString(); + +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/usage/before/A.java b/test/eclipse/resource/extractinterface/usage/before/A.java new file mode 100644 index 00000000..87a6a8e4 --- /dev/null +++ b/test/eclipse/resource/extractinterface/usage/before/A.java @@ -0,0 +1,15 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String string; + private int integer; +}
\ No newline at end of file diff --git a/test/eclipse/resource/extractinterface/usage/before/B.java b/test/eclipse/resource/extractinterface/usage/before/B.java new file mode 100644 index 00000000..0034a8a6 --- /dev/null +++ b/test/eclipse/resource/extractinterface/usage/before/B.java @@ -0,0 +1,12 @@ +package pkg; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class B { + private A a = new A(); + private String string = a.getString(); + private int integer = a.getInteger(); +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/builderField/after/A.java b/test/eclipse/resource/rename/builderField/after/A.java new file mode 100644 index 00000000..4d2ac69a --- /dev/null +++ b/test/eclipse/resource/rename/builderField/after/A.java @@ -0,0 +1,8 @@ +package pkg; + +import lombok.Builder; + +@Builder +public class A { + private String newString; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/builderField/before/A.java b/test/eclipse/resource/rename/builderField/before/A.java new file mode 100644 index 00000000..3f4ec235 --- /dev/null +++ b/test/eclipse/resource/rename/builderField/before/A.java @@ -0,0 +1,8 @@ +package pkg; + +import lombok.Builder; + +@Builder +public class A { + private String string; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/simple/after/A.java b/test/eclipse/resource/rename/simple/after/A.java new file mode 100644 index 00000000..5a564be2 --- /dev/null +++ b/test/eclipse/resource/rename/simple/after/A.java @@ -0,0 +1,14 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String newString; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/simple/before/A.java b/test/eclipse/resource/rename/simple/before/A.java new file mode 100644 index 00000000..b0d4c41e --- /dev/null +++ b/test/eclipse/resource/rename/simple/before/A.java @@ -0,0 +1,14 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String string; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetter/after/A.java b/test/eclipse/resource/rename/withGetter/after/A.java new file mode 100644 index 00000000..81237a7e --- /dev/null +++ b/test/eclipse/resource/rename/withGetter/after/A.java @@ -0,0 +1,18 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String newString; + + public String test() { + return getNewString(); + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetter/before/A.java b/test/eclipse/resource/rename/withGetter/before/A.java new file mode 100644 index 00000000..c9d9e4e5 --- /dev/null +++ b/test/eclipse/resource/rename/withGetter/before/A.java @@ -0,0 +1,18 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String string; + + public String test() { + return getString(); + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetterDifferentFile/after/A.java b/test/eclipse/resource/rename/withGetterDifferentFile/after/A.java new file mode 100644 index 00000000..5a564be2 --- /dev/null +++ b/test/eclipse/resource/rename/withGetterDifferentFile/after/A.java @@ -0,0 +1,14 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String newString; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetterDifferentFile/after/B.java b/test/eclipse/resource/rename/withGetterDifferentFile/after/B.java new file mode 100644 index 00000000..f7cd35c4 --- /dev/null +++ b/test/eclipse/resource/rename/withGetterDifferentFile/after/B.java @@ -0,0 +1,7 @@ +package pkg; + +public class B { + public String test() { + return new A().getNewString(); + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetterDifferentFile/before/A.java b/test/eclipse/resource/rename/withGetterDifferentFile/before/A.java new file mode 100644 index 00000000..b0d4c41e --- /dev/null +++ b/test/eclipse/resource/rename/withGetterDifferentFile/before/A.java @@ -0,0 +1,14 @@ +package pkg; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@EqualsAndHashCode +@Getter +@Setter +@ToString +public class A { + private String string; +}
\ No newline at end of file diff --git a/test/eclipse/resource/rename/withGetterDifferentFile/before/B.java b/test/eclipse/resource/rename/withGetterDifferentFile/before/B.java new file mode 100644 index 00000000..24a74d6f --- /dev/null +++ b/test/eclipse/resource/rename/withGetterDifferentFile/before/B.java @@ -0,0 +1,7 @@ +package pkg; + +public class B { + public String test() { + return new A().getString(); + } +}
\ No newline at end of file diff --git a/test/eclipse/resource/select/builderField/A.java b/test/eclipse/resource/select/builderField/A.java new file mode 100644 index 00000000..18b4b150 --- /dev/null +++ b/test/eclipse/resource/select/builderField/A.java @@ -0,0 +1,8 @@ +package pkg; + +import lombok.Builder; + +@Builder +public class A { + private String id; +}
\ No newline at end of file diff --git a/test/eclipse/resource/select/superbuilderField/A.java b/test/eclipse/resource/select/superbuilderField/A.java new file mode 100644 index 00000000..d9df476c --- /dev/null +++ b/test/eclipse/resource/select/superbuilderField/A.java @@ -0,0 +1,8 @@ +package pkg; + +import lombok.experimental.SuperBuilder; + +@SuperBuilder +public class A { + private String id; +}
\ No newline at end of file diff --git a/test/eclipse/src/lombok/eclipse/EclipseRunner.java b/test/eclipse/src/lombok/eclipse/EclipseRunner.java new file mode 100644 index 00000000..1e1c17fe --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/EclipseRunner.java @@ -0,0 +1,154 @@ +package lombok.eclipse; + +import java.io.File; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.adaptor.EclipseStarter; +import org.eclipse.osgi.container.Module; +import org.eclipse.osgi.container.Module.StartOptions; +import org.eclipse.osgi.container.Module.State; +import org.eclipse.osgi.internal.location.EquinoxLocations; +import org.junit.runner.Description; +import org.junit.runner.Runner; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.InitializationError; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.wiring.BundleRevision; +import org.osgi.framework.wiring.BundleWire; +import org.osgi.framework.wiring.BundleWiring; + +/** + * We have to load the osgi/eclipse classes before we run the test case. This is only possible using a custom runner. + * + */ +public class EclipseRunner extends Runner { + private Runner runner; + private boolean debug = false; + private static boolean setupDone; + + public EclipseRunner(Class<?> klass) throws InitializationError { + try { + if (!setupDone) { + debug = System.getProperty("lombok.debug") != null; + startEclipse(System.getProperty("lombok.testenv")); + setupDone = true; + } + } catch (Throwable e) { + throw new InitializationError(e); + } + + runner = new BlockJUnit4ClassRunner(klass); + + } + + @Override + public Description getDescription() { + return runner.getDescription(); + } + + @Override + public void run(RunNotifier notifier) { + runner.run(notifier); + } + + private void startEclipse(String path) throws Exception { + Map<String, String> initialProperties = new HashMap<String, String>(); + + File rootDir = new File(path); + File pluginDir = new File(rootDir, "plugins/"); + + StringBuilder bundleString = new StringBuilder(); + String osgiPlugin = null; + File[] bundles = pluginDir.listFiles(); + Arrays.sort(bundles); + for (File plugin : bundles) { + String fileName = plugin.getName(); + String bundleName = fileName.substring(0, fileName.indexOf("_")); + + if (bundleName.equals("org.eclipse.osgi")) { + osgiPlugin = plugin.toURI().toString(); + } + + if (bundleString.length() > 0) { + bundleString.append(","); + } + bundleString.append(bundleName); + } + + initialProperties.put(EclipseStarter.PROP_BUNDLES, bundleString.toString()); + initialProperties.put(EclipseStarter.PROP_INSTALL_AREA, "file:" + path); + initialProperties.put(EquinoxLocations.PROP_INSTANCE_AREA, "file:" + path); + initialProperties.put(EclipseStarter.PROP_FRAMEWORK, osgiPlugin); + initialProperties.put("osgi.framework.useSystemProperties", "false"); + initialProperties.put(EclipseStarter.PROP_NOSHUTDOWN, "false"); + + initialProperties.put("osgi.parentClassloader", "fwk"); + initialProperties.put("osgi.frameworkParentClassloader", "fwk"); + initialProperties.put("osgi.contextClassLoaderParent", "ext"); + initialProperties.put("osgi.context.bootdelegation", "*"); + initialProperties.put("org.osgi.framework.bootdelegation", "*"); + + EclipseStarter.setInitialProperties(initialProperties); + String[] args = new String[] {"-clean"}; + if (debug) args = new String[] {"-clean", "-console", "-consoleLog", "-debug"}; + BundleContext context = EclipseStarter.startup(args, null); + + Map<String, Module> moduleMap = new HashMap<String, Module>(); + for (Bundle b : context.getBundles()) { + Module module = b.adapt(Module.class); + moduleMap.put(b.getSymbolicName(), module); + } + + Set<String> startedBundles = new HashSet<String>(); + // Mark the debug bundle as started, it will fail anyway... + startedBundles.add("org.eclipse.debug.ui"); + + startBundle(moduleMap, startedBundles, "org.apache.felix.scr"); + startBundle(moduleMap, startedBundles, "org.eclipse.jdt.core.manipulation"); + startBundle(moduleMap, startedBundles, "org.eclipse.jdt.ui"); + + if (debug) { + for (Bundle b : context.getBundles()) { + System.out.println("BUNDLE: " + b.getSymbolicName() + " " + b.getVersion() + " " + b.getLocation() + " " + b.getState()); + } + } + } + + private void startBundle(Map<String, Module> moduleMap, Set<String> started, String bundle) throws BundleException { + if (started.contains(bundle)) return; + + Module module = moduleMap.get(bundle); + started.add(bundle); + + BundleWiring wiring = module.getBundle().adapt(BundleWiring.class); + List<BundleWire> requiredWires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE); + requiredWires.addAll(wiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE)); + + for (BundleWire bundleWire : requiredWires) { + startBundle(moduleMap, started, bundleWire.getProvider().getSymbolicName()); + } + + startModule(module); + } + + private void startModule(Module module) throws BundleException { + if (module.getState() == State.LAZY_STARTING || module.getState() == State.RESOLVED) { + if (debug) System.out.print("Starting bundle " + module.getBundle().getSymbolicName() + "..."); + try { + module.start(StartOptions.LAZY_TRIGGER); + if (debug) System.out.println(" [done]"); + } catch (Exception e) { + if (debug) System.out.println(" [error]"); + e.printStackTrace(); + } + } + } +} diff --git a/test/eclipse/src/lombok/eclipse/EclipseTests.java b/test/eclipse/src/lombok/eclipse/EclipseTests.java new file mode 100644 index 00000000..ba017fd2 --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/EclipseTests.java @@ -0,0 +1,16 @@ +package lombok.eclipse; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +import lombok.eclipse.cleanup.CleanupTest; +import lombok.eclipse.edit.SelectTest; +import lombok.eclipse.refactoring.ExtractInterfaceTest; +import lombok.eclipse.refactoring.RenameTest; + +@RunWith(Suite.class) +@SuiteClasses({ExtractInterfaceTest.class, RenameTest.class, SelectTest.class, CleanupTest.class}) +public class EclipseTests { + +} diff --git a/test/eclipse/src/lombok/eclipse/RefactoringUtils.java b/test/eclipse/src/lombok/eclipse/RefactoringUtils.java new file mode 100644 index 00000000..38349d2d --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/RefactoringUtils.java @@ -0,0 +1,30 @@ +package lombok.eclipse; + +import static org.junit.Assert.assertTrue; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ltk.core.refactoring.CheckConditionsOperation; +import org.eclipse.ltk.core.refactoring.CreateChangeOperation; +import org.eclipse.ltk.core.refactoring.PerformChangeOperation; +import org.eclipse.ltk.core.refactoring.Refactoring; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring; +import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; + +public class RefactoringUtils { + public static void performRefactoring(RefactoringProcessor proccessor) throws CoreException { + performRefactoring(new ProcessorBasedRefactoring(proccessor)); + } + + public static void performRefactoring(Refactoring refactoring) throws CoreException { + CheckConditionsOperation checkConditionsOperation = new CheckConditionsOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS); + CreateChangeOperation change = new CreateChangeOperation(checkConditionsOperation, RefactoringStatus.FATAL); + final PerformChangeOperation perform = new PerformChangeOperation(change); + + ResourcesPlugin.getWorkspace().run(perform, null); + + assertTrue("Condition failed", change.getConditionCheckingStatus().isOK()); + assertTrue("Perform failed", perform.changeExecuted()); + } +} diff --git a/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java b/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java new file mode 100644 index 00000000..96e21d4b --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/SetupBeforeAfterTest.java @@ -0,0 +1,52 @@ +package lombok.eclipse; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.JavaModelException; +import org.junit.runner.Description; + +public class SetupBeforeAfterTest extends SetupTest { + + private File before; + private File after; + + @Override + protected void starting(Description description) { + super.starting(description); + + before = new File(root, "/before/"); + after = new File(root, "/after/"); + + try { + copyBeforeFiles(); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + @Override + protected void succeeded(Description description) { + try { + compareWithAfter(); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + private void compareWithAfter() throws FileNotFoundException, JavaModelException { + for (ICompilationUnit result : packageFragment.getCompilationUnits()) { + assertEquals(getContent(new File(after, result.getElementName())), result.getSource()); + } + } + + void copyBeforeFiles() throws JavaModelException, FileNotFoundException { + for (File file : before.listFiles()) { + createCompilationUnit(file, packageFragment); + } + + } +} diff --git a/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java b/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java new file mode 100644 index 00000000..47010f0c --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/SetupSingleFileTest.java @@ -0,0 +1,28 @@ +package lombok.eclipse; + +import java.io.File; +import java.io.FileNotFoundException; + +import org.eclipse.jdt.core.JavaModelException; +import org.junit.runner.Description; + +public class SetupSingleFileTest extends SetupTest { + + @Override + protected void starting(Description description) { + super.starting(description); + + try { + copyRootFiles(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void copyRootFiles() throws JavaModelException, FileNotFoundException { + for (File file : root.listFiles()) { + createCompilationUnit(file, packageFragment); + } + + } +} diff --git a/test/eclipse/src/lombok/eclipse/SetupTest.java b/test/eclipse/src/lombok/eclipse/SetupTest.java new file mode 100644 index 00000000..fe8d469c --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/SetupTest.java @@ -0,0 +1,107 @@ +package lombok.eclipse; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.junit.rules.TestWatcher; +import org.junit.runner.Description; + +public abstract class SetupTest extends TestWatcher { + + private IJavaProject javaProject; + protected IPackageFragment packageFragment; + private IWorkspace workspace; + protected File root; + + public IJavaProject getJavaProject() { + return javaProject; + } + + public IPackageFragment getPackageFragment() { + return packageFragment; + } + + public IWorkspace getWorkspace() { + return workspace; + } + + @Override + protected void starting(Description description) { + String category = description.getTestClass().getSimpleName().toLowerCase().replaceAll("test$", ""); + String testname = description.getMethodName(); + + root = new File("test/eclipse/resource/" + category + "/" + testname); + + try { + createProject(category, description.getMethodName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void createProject(String category, String test) throws CoreException { + workspace = ResourcesPlugin.getWorkspace(); + + IWorkspaceRoot root = getWorkspace().getRoot(); + IProject project = root.getProject(category + "_" + test); + + if (project.exists()) { + project.delete(true, true, null); + } + project.create(null); + project.open(null); + + IFolder targetFolder = createFolder(project, "target"); + IFolder srcFolder = createFolder(project, "src"); + + IProjectDescription description = project.getDescription(); + description.setNatureIds(new String[] {JavaCore.NATURE_ID}); + project.setDescription(description, null); + + javaProject = JavaCore.create(project); + javaProject.setOutputLocation(targetFolder.getFullPath(), null); + JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, javaProject.getOptions(false)); + + IClasspathEntry classpathEntry = JavaCore.newSourceEntry(srcFolder.getFullPath()); + IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(new Path(new File("dist/lombok.jar").getAbsolutePath()), null, null); + IClasspathEntry javaRtEntry = JavaCore.newLibraryEntry(new Path(new File("lib/rtstubs18.jar").getAbsolutePath()), null, null); + javaProject.setRawClasspath(new IClasspathEntry[] {classpathEntry, newLibraryEntry, javaRtEntry}, null); + + packageFragment = javaProject.getPackageFragmentRoot(srcFolder).createPackageFragment("pkg", false, null); + } + + protected IFolder createFolder(IProject project, String name) throws CoreException { + IFolder folder = project.getFolder(name); + if (folder.exists()) { + folder.delete(true, null); + } + folder.create(false, true, null); + return folder; + } + + protected ICompilationUnit createCompilationUnit(File file, IPackageFragment pkg) throws JavaModelException, FileNotFoundException { + return pkg.createCompilationUnit(file.getName(), getContent(file), true, null); + } + + protected String getContent(File f) throws FileNotFoundException { + Scanner scanner = new Scanner(f); + String text = scanner.useDelimiter("\\A").next(); + scanner.close(); + return text; + } +}
\ No newline at end of file diff --git a/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java b/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java new file mode 100644 index 00000000..2d018228 --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/cleanup/CleanupTest.java @@ -0,0 +1,45 @@ +package lombok.eclipse.cleanup; + +import static lombok.eclipse.RefactoringUtils.performRefactoring; + +import java.util.Map.Entry; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.internal.corext.fix.CleanUpConstants; +import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring; +import org.eclipse.jdt.internal.corext.fix.CleanUpRegistry; +import org.eclipse.jdt.internal.ui.JavaPlugin; +import org.eclipse.jdt.internal.ui.fix.CodeStyleCleanUp; +import org.eclipse.jdt.internal.ui.fix.MapCleanUpOptions; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import lombok.eclipse.EclipseRunner; +import lombok.eclipse.SetupBeforeAfterTest; + +@RunWith(EclipseRunner.class) +public class CleanupTest { + + @Rule + public SetupBeforeAfterTest setup = new SetupBeforeAfterTest(); + + @Test + public void useThis() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + + CleanUpRegistry cleanUpRegistry = JavaPlugin.getDefault().getCleanUpRegistry(); + MapCleanUpOptions options = cleanUpRegistry.getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS); + for (Entry<String, String> entry : options.getMap().entrySet()) { + entry.setValue(MapCleanUpOptions.FALSE); + } + options.setOption(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, MapCleanUpOptions.TRUE); + options.setOption(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, MapCleanUpOptions.TRUE); + + CleanUpRefactoring ref = new CleanUpRefactoring(); + ref.addCompilationUnit(cu); + ref.addCleanUp(new CodeStyleCleanUp(options.getMap())); + + performRefactoring(ref); + } +} diff --git a/test/eclipse/src/lombok/eclipse/edit/SelectTest.java b/test/eclipse/src/lombok/eclipse/edit/SelectTest.java new file mode 100644 index 00000000..9f348a0c --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/edit/SelectTest.java @@ -0,0 +1,48 @@ +package lombok.eclipse.edit; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.IType; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import lombok.eclipse.EclipseRunner; +import lombok.eclipse.SetupSingleFileTest; + +@RunWith(EclipseRunner.class) +public class SelectTest { + + @Rule + public SetupSingleFileTest setup = new SetupSingleFileTest(); + + @Test + public void builderField() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("id"); + + ISourceRange sourceRange = field.getNameRange(); + IJavaElement[] codeSelect = cu.codeSelect(sourceRange.getOffset(), sourceRange.getLength()); + + assertEquals(1, codeSelect.length); + assertEquals(field, codeSelect[0]); + } + + @Test + public void superbuilderField() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("id"); + + ISourceRange sourceRange = field.getNameRange(); + IJavaElement[] codeSelect = cu.codeSelect(sourceRange.getOffset(), sourceRange.getLength()); + + assertEquals(1, codeSelect.length); + assertEquals(field, codeSelect[0]); + } +} diff --git a/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java b/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java new file mode 100644 index 00000000..d4c892f3 --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/refactoring/ExtractInterfaceTest.java @@ -0,0 +1,47 @@ +package lombok.eclipse.refactoring; + +import static lombok.eclipse.RefactoringUtils.performRefactoring; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor; +import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import lombok.eclipse.EclipseRunner; +import lombok.eclipse.SetupBeforeAfterTest; + +@RunWith(EclipseRunner.class) +public class ExtractInterfaceTest { + + @Rule + public SetupBeforeAfterTest setup = new SetupBeforeAfterTest(); + + @Test + public void simple() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + + ExtractInterfaceProcessor extractInterfaceProcessor = new ExtractInterfaceProcessor(type, JavaPreferencesSettings.getCodeGenerationSettings(setup.getJavaProject())); + extractInterfaceProcessor.setExtractedMembers(type.getMethods()); + extractInterfaceProcessor.setTypeName("Interface"); + + performRefactoring(extractInterfaceProcessor); + } + + @Test + public void usage() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + + ExtractInterfaceProcessor extractInterfaceProcessor = new ExtractInterfaceProcessor(type, JavaPreferencesSettings.getCodeGenerationSettings(setup.getJavaProject())); + extractInterfaceProcessor.setExtractedMembers(type.getMethods()); + extractInterfaceProcessor.setTypeName("Interface"); + extractInterfaceProcessor.setReplace(true); + + performRefactoring(extractInterfaceProcessor); + } + +} diff --git a/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java b/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java new file mode 100644 index 00000000..c1a86736 --- /dev/null +++ b/test/eclipse/src/lombok/eclipse/refactoring/RenameTest.java @@ -0,0 +1,71 @@ +package lombok.eclipse.refactoring; + +import static lombok.eclipse.RefactoringUtils.performRefactoring; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.internal.corext.refactoring.rename.RenameFieldProcessor; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import lombok.eclipse.EclipseRunner; +import lombok.eclipse.SetupBeforeAfterTest; + +@RunWith(EclipseRunner.class) +public class RenameTest { + + @Rule + public SetupBeforeAfterTest setup = new SetupBeforeAfterTest(); + + @Test + public void simple() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("string"); + + RenameFieldProcessor renameFieldProcessor = new RenameFieldProcessor(field); + renameFieldProcessor.setNewElementName("newString"); + + performRefactoring(renameFieldProcessor); + } + + @Test + public void withGetter() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("string"); + + RenameFieldProcessor renameFieldProcessor = new RenameFieldProcessor(field); + renameFieldProcessor.setNewElementName("newString"); + renameFieldProcessor.setRenameGetter(true); + + performRefactoring(renameFieldProcessor); + } + + @Test + public void withGetterDifferentFile() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("string"); + + RenameFieldProcessor renameFieldProcessor = new RenameFieldProcessor(field); + renameFieldProcessor.setNewElementName("newString"); + renameFieldProcessor.setRenameGetter(true); + + performRefactoring(renameFieldProcessor); + } + + @Test + public void builderField() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("A.java"); + IType type = cu.findPrimaryType(); + IField field = type.getField("string"); + + RenameFieldProcessor renameFieldProcessor = new RenameFieldProcessor(field); + renameFieldProcessor.setNewElementName("newString"); + + performRefactoring(renameFieldProcessor); + } +} diff --git a/test/pretty/resource/after/RecordPattern.java b/test/pretty/resource/after/RecordPattern.java new file mode 100644 index 00000000..ad9fae0b --- /dev/null +++ b/test/pretty/resource/after/RecordPattern.java @@ -0,0 +1,15 @@ +record Point(int x, int y) { +} +record Rectangle(Point upperLeft, Point lowerRight) { +} + +public class RecordPattern { + void recordPattern(Object o) { + if (o instanceof Point(int x, int y)) { + } + if (o instanceof Point(int x, int y) p) { + } + if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) { + } + } +}
\ No newline at end of file diff --git a/test/pretty/resource/after/Switch19.java b/test/pretty/resource/after/Switch19.java new file mode 100644 index 00000000..5947830b --- /dev/null +++ b/test/pretty/resource/after/Switch19.java @@ -0,0 +1,32 @@ +public class Switch19 { + String switchPatternMatching(Object o) { + return switch (o) { + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format("double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + String switchNull(Object o) { + return switch (o) { + case null, default -> "?"; + }; + } + + String switchGuardPattern(Object o) { + return switch (o) { + case String s when s.length() > 1 -> s; + case String s -> s; + default -> o.toString(); + }; + } + + String switchParenthesizedPattern(Object o) { + return switch (o) { + case (String s) -> s; + default -> o.toString(); + }; + } +} diff --git a/test/pretty/resource/before/RecordPattern.java b/test/pretty/resource/before/RecordPattern.java new file mode 100644 index 00000000..93c07965 --- /dev/null +++ b/test/pretty/resource/before/RecordPattern.java @@ -0,0 +1,16 @@ +// version 19: +record Point(int x, int y) { +} +record Rectangle(Point upperLeft, Point lowerRight) { +} + +public class RecordPattern { + void recordPattern(Object o) { + if (o instanceof Point(int x, int y)) { + } + if (o instanceof Point(int x, int y) p) { + } + if (o instanceof Rectangle(Point(int x1, int y1), Point(int x2, int y2))) { + } + } +}
\ No newline at end of file diff --git a/test/pretty/resource/before/Switch17.java b/test/pretty/resource/before/Switch17.java index 17754e82..42a8f181 100644 --- a/test/pretty/resource/before/Switch17.java +++ b/test/pretty/resource/before/Switch17.java @@ -1,4 +1,4 @@ -// version 17: +// version 17:18 public class Switch17 { String switchPatternMatching(Object o) { return switch (o) { diff --git a/test/pretty/resource/before/Switch19.java b/test/pretty/resource/before/Switch19.java new file mode 100644 index 00000000..05b27928 --- /dev/null +++ b/test/pretty/resource/before/Switch19.java @@ -0,0 +1,33 @@ +// version 19: +public class Switch19 { + String switchPatternMatching(Object o) { + return switch (o) { + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format("double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + String switchNull(Object o) { + return switch (o) { + case null, default -> "?"; + }; + } + + String switchGuardPattern(Object o) { + return switch (o) { + case String s when s.length() > 1 -> s; + case String s -> s; + default -> o.toString(); + }; + } + + String switchParenthesizedPattern(Object o) { + return switch (o) { + case (String s) -> s; + default -> o.toString(); + }; + } +} diff --git a/test/transform/resource/after-delombok/BuilderCustomName.java b/test/transform/resource/after-delombok/BuilderCustomName.java index 2e5924d3..900fbb03 100644 --- a/test/transform/resource/after-delombok/BuilderCustomName.java +++ b/test/transform/resource/after-delombok/BuilderCustomName.java @@ -5,10 +5,6 @@ class BuilderCustomName<T> { public static abstract class SimpleTestBuilder<T, C extends BuilderCustomName<T>, B extends BuilderCustomName.SimpleTestBuilder<T, C, B>> { @java.lang.SuppressWarnings("all") private int field; - @java.lang.SuppressWarnings("all") - protected abstract B self(); - @java.lang.SuppressWarnings("all") - public abstract C build(); /** * @return {@code this}. */ @@ -17,6 +13,10 @@ class BuilderCustomName<T> { this.field = field; 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() { diff --git a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java index 99245e11..64f07c37 100644 --- a/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java +++ b/test/transform/resource/after-delombok/CheckerFrameworkBuilder.java @@ -1,3 +1,5 @@ +//version 8: +//skip-idempotent import java.util.List; class CheckerFrameworkBuilder { int x; diff --git a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java index cab11f3c..cf00f5fc 100644 --- a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java @@ -23,12 +23,6 @@ class CheckerFrameworkSuperBuilder { private int z; @java.lang.SuppressWarnings("all") private java.util.ArrayList<String> names; - @org.checkerframework.dataflow.qual.Pure - @java.lang.SuppressWarnings("all") - protected abstract @org.checkerframework.common.returnsreceiver.qual.This B self(); - @org.checkerframework.dataflow.qual.SideEffectFree - @java.lang.SuppressWarnings("all") - public abstract C build(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilder<C, B> this); /** * @return {@code this}. */ @@ -74,6 +68,12 @@ class CheckerFrameworkSuperBuilder { if (this.names != null) this.names.clear(); return self(); } + @org.checkerframework.dataflow.qual.Pure + @java.lang.SuppressWarnings("all") + protected abstract @org.checkerframework.common.returnsreceiver.qual.This B self(); + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.SuppressWarnings("all") + public abstract C build(CheckerFrameworkSuperBuilder.Parent.@org.checkerframework.checker.calledmethods.qual.CalledMethods({"y", "z"}) ParentBuilder<C, B> this); @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.Override @java.lang.SuppressWarnings("all") @@ -140,14 +140,6 @@ class CheckerFrameworkSuperBuilder { private int a$value; @java.lang.SuppressWarnings("all") private int b; - @java.lang.Override - @org.checkerframework.dataflow.qual.Pure - @java.lang.SuppressWarnings("all") - protected abstract @org.checkerframework.common.returnsreceiver.qual.This B self(); - @org.checkerframework.dataflow.qual.SideEffectFree - @java.lang.Override - @java.lang.SuppressWarnings("all") - public abstract C build(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilder<C, B> this); /** * @return {@code this}. */ @@ -165,6 +157,14 @@ class CheckerFrameworkSuperBuilder { this.b = b; return self(); } + @java.lang.Override + @org.checkerframework.dataflow.qual.Pure + @java.lang.SuppressWarnings("all") + protected abstract @org.checkerframework.common.returnsreceiver.qual.This B self(); + @org.checkerframework.dataflow.qual.SideEffectFree + @java.lang.Override + @java.lang.SuppressWarnings("all") + public abstract C build(CheckerFrameworkSuperBuilder.ZChild.@org.checkerframework.checker.calledmethods.qual.CalledMethods("b") ZChildBuilder<C, B> this); @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.Override @java.lang.SuppressWarnings("all") diff --git a/test/transform/resource/after-delombok/ConstructorsWithSuperBuilderDefaults.java b/test/transform/resource/after-delombok/ConstructorsWithSuperBuilderDefaults.java index e7811dd5..c5188bb3 100644 --- a/test/transform/resource/after-delombok/ConstructorsWithSuperBuilderDefaults.java +++ b/test/transform/resource/after-delombok/ConstructorsWithSuperBuilderDefaults.java @@ -17,12 +17,6 @@ class ConstructorsWithSuperBuilderDefaults { @java.lang.SuppressWarnings("all") private int y; - @java.lang.SuppressWarnings("all") - protected abstract B self(); - - @java.lang.SuppressWarnings("all") - public abstract C build(); - /** * @return {@code this}. */ @@ -42,6 +36,12 @@ class ConstructorsWithSuperBuilderDefaults { 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() { diff --git a/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java b/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java index 88a51f41..a07d9dfc 100644 --- a/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java +++ b/test/transform/resource/after-delombok/JacksonizedSuperBuilderSimple.java @@ -8,10 +8,6 @@ public class JacksonizedSuperBuilderSimple { 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}. */ @@ -20,6 +16,10 @@ public class JacksonizedSuperBuilderSimple { this.field1 = field1; 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() { diff --git a/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java b/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java index 1ed38f05..307537ae 100644 --- a/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java +++ b/test/transform/resource/after-delombok/JacksonizedSuperBuilderWithJsonDeserialize.java @@ -6,10 +6,6 @@ public class JacksonizedSuperBuilderWithJsonDeserialize { public static abstract class JacksonizedSuperBuilderWithJsonDeserializeBuilder<C extends JacksonizedSuperBuilderWithJsonDeserialize, B extends JacksonizedSuperBuilderWithJsonDeserialize.JacksonizedSuperBuilderWithJsonDeserializeBuilder<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}. */ @@ -18,6 +14,10 @@ public class JacksonizedSuperBuilderWithJsonDeserialize { this.field1 = field1; 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() { diff --git a/test/transform/resource/after-delombok/LoggerFloggerRecord.java b/test/transform/resource/after-delombok/LoggerFloggerRecord.java index 9cc0c9c0..bd51d056 100644 --- a/test/transform/resource/after-delombok/LoggerFloggerRecord.java +++ b/test/transform/resource/after-delombok/LoggerFloggerRecord.java @@ -1,5 +1,6 @@ +// version 14: class LoggerFloggerRecord { - record Inner(String x) { + public record Inner(String x) { @java.lang.SuppressWarnings("all") private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass(); } diff --git a/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java index 25a76c6d..ae2bcdfd 100644 --- a/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-delombok/NullAnnotatedCheckerFrameworkSuperBuilder.java @@ -29,12 +29,6 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { @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}. */ @@ -92,6 +86,12 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { 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.@org.checkerframework.checker.nullness.qual.NonNull String toString() { @@ -165,14 +165,6 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { @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}. */ @@ -196,6 +188,14 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { @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.@org.checkerframework.checker.nullness.qual.NonNull String toString() { return "NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString() + ", a$value=" + this.a$value + ", b=" + this.b + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderAbstract.java b/test/transform/resource/after-delombok/SuperBuilderAbstract.java index 727c5beb..f92eede2 100644 --- a/test/transform/resource/after-delombok/SuperBuilderAbstract.java +++ b/test/transform/resource/after-delombok/SuperBuilderAbstract.java @@ -5,10 +5,6 @@ public class SuperBuilderAbstract { 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}. */ @@ -17,6 +13,10 @@ public class SuperBuilderAbstract { this.parentField = parentField; 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() { @@ -54,12 +54,6 @@ public class SuperBuilderAbstract { 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}. */ @@ -70,6 +64,12 @@ public class SuperBuilderAbstract { } @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 "SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")"; } @@ -86,12 +86,6 @@ public class SuperBuilderAbstract { 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}. */ @@ -102,6 +96,12 @@ public class SuperBuilderAbstract { } @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 "SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java index 53962c60..c9ed6ad7 100644 --- a/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java +++ b/test/transform/resource/after-delombok/SuperBuilderAbstractToBuilder.java @@ -14,10 +14,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -26,6 +22,10 @@ public class SuperBuilderAbstractToBuilder { this.parentField = parentField; 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() { @@ -78,12 +78,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -94,6 +88,12 @@ public class SuperBuilderAbstractToBuilder { } @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 "SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString() + ", childField=" + this.childField + ")"; } @@ -121,12 +121,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -137,6 +131,12 @@ public class SuperBuilderAbstractToBuilder { } @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 "SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString() + ", grandChildField=" + this.grandChildField + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderBasic.java b/test/transform/resource/after-delombok/SuperBuilderBasic.java index 7fff2ef8..31b6692d 100644 --- a/test/transform/resource/after-delombok/SuperBuilderBasic.java +++ b/test/transform/resource/after-delombok/SuperBuilderBasic.java @@ -9,10 +9,6 @@ public class SuperBuilderBasic { 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}. */ @@ -41,6 +37,10 @@ public class SuperBuilderBasic { if (this.items != null) this.items.clear(); 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() { @@ -90,12 +90,6 @@ public class SuperBuilderBasic { 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}. */ @@ -106,6 +100,12 @@ public class SuperBuilderBasic { } @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 "SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java index add6f841..f57937ec 100644 --- a/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java +++ b/test/transform/resource/after-delombok/SuperBuilderBasicToBuilder.java @@ -37,10 +37,6 @@ public class SuperBuilderBasicToBuilder { 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}. */ @@ -93,6 +89,10 @@ public class SuperBuilderBasicToBuilder { if (this.items != null) this.items.clear(); 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() { @@ -160,12 +160,6 @@ public class SuperBuilderBasicToBuilder { 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}. */ @@ -176,6 +170,12 @@ public class SuperBuilderBasicToBuilder { } @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 "SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderCustomized.java b/test/transform/resource/after-delombok/SuperBuilderCustomized.java index 3a0bbd9b..5f41cdde 100644 --- a/test/transform/resource/after-delombok/SuperBuilderCustomized.java +++ b/test/transform/resource/after-delombok/SuperBuilderCustomized.java @@ -71,12 +71,6 @@ public class SuperBuilderCustomized { 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}. */ @@ -87,6 +81,12 @@ public class SuperBuilderCustomized { } @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 "SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString() + ", field2=" + this.field2 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderInitializer.java b/test/transform/resource/after-delombok/SuperBuilderInitializer.java index 95943aa9..19ed0c68 100644 --- a/test/transform/resource/after-delombok/SuperBuilderInitializer.java +++ b/test/transform/resource/after-delombok/SuperBuilderInitializer.java @@ -19,12 +19,6 @@ class SuperBuilderInitializer { @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}. */ @@ -34,6 +28,12 @@ class SuperBuilderInitializer { 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() { diff --git a/test/transform/resource/after-delombok/SuperBuilderNameClashes.java b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java index 8cef4e11..5b0db135 100644 --- a/test/transform/resource/after-delombok/SuperBuilderNameClashes.java +++ b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java @@ -81,10 +81,6 @@ public class SuperBuilderNameClashes { 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}. */ @@ -93,6 +89,10 @@ public class SuperBuilderNameClashes { this.c2 = c2; return self(); } + @java.lang.SuppressWarnings("all") + protected abstract B self(); + @java.lang.SuppressWarnings("all") + public abstract C3 build(); @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { @@ -124,4 +124,50 @@ public class SuperBuilderNameClashes { return new SuperBuilderNameClashes.C.CBuilderImpl(); } } + interface B2 { + interface B4<X> { + } + } + interface B3<Y> { + } + public static class ExtendsClauseCollision extends B implements B2.B4<Object>, B3<Object> { + @java.lang.SuppressWarnings("all") + public static abstract class ExtendsClauseCollisionBuilder<C extends SuperBuilderNameClashes.ExtendsClauseCollision, B4 extends SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<C, B4>> extends B.BBuilder<C, B4> { + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected abstract B4 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 "SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder(super=" + super.toString() + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class ExtendsClauseCollisionBuilderImpl extends SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<SuperBuilderNameClashes.ExtendsClauseCollision, SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl> { + @java.lang.SuppressWarnings("all") + private ExtendsClauseCollisionBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public SuperBuilderNameClashes.ExtendsClauseCollision build() { + return new SuperBuilderNameClashes.ExtendsClauseCollision(this); + } + } + @java.lang.SuppressWarnings("all") + protected ExtendsClauseCollision(final SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<?, ?> b) { + super(b); + } + @java.lang.SuppressWarnings("all") + public static SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<?, ?> builder() { + return new SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl(); + } + } } diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java index ad51816a..6e2fdca2 100644 --- a/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java +++ b/test/transform/resource/after-delombok/SuperBuilderSingularAnnotatedTypes.java @@ -19,10 +19,6 @@ class SuperBuilderSingularAnnotatedTypes { @java.lang.SuppressWarnings("all") private java.util.ArrayList<@MyAnnotation @NonNull Integer> bars$value; @java.lang.SuppressWarnings("all") - protected abstract B self(); - @java.lang.SuppressWarnings("all") - public abstract C build(); - @java.lang.SuppressWarnings("all") public B foo(@MyAnnotation @NonNull final String foo) { if (foo == null) { throw new java.lang.NullPointerException("foo is marked non-null but is null"); @@ -84,6 +80,10 @@ class SuperBuilderSingularAnnotatedTypes { } 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() { diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java index 04cfd9f2..1f07c448 100644 --- a/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java +++ b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java @@ -8,10 +8,6 @@ class SuperBuilderSingularCustomized { 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); @@ -31,6 +27,10 @@ class SuperBuilderSingularCustomized { if (this.foos != null) this.foos.clear(); 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() { diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularToBuilderGuava.java b/test/transform/resource/after-delombok/SuperBuilderSingularToBuilderGuava.java index ec716fdd..685f3f85 100644 --- a/test/transform/resource/after-delombok/SuperBuilderSingularToBuilderGuava.java +++ b/test/transform/resource/after-delombok/SuperBuilderSingularToBuilderGuava.java @@ -32,10 +32,6 @@ public class SuperBuilderSingularToBuilderGuava { b.users(instance.users == null ? com.google.common.collect.ImmutableTable.<Number, Number, String>of() : instance.users); } @java.lang.SuppressWarnings("all") - protected abstract B self(); - @java.lang.SuppressWarnings("all") - public abstract C build(); - @java.lang.SuppressWarnings("all") public B card(final T card) { if (this.cards == null) this.cards = com.google.common.collect.ImmutableList.builder(); this.cards.add(card); @@ -135,6 +131,10 @@ public class SuperBuilderSingularToBuilderGuava { this.users = null; 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() { @@ -196,12 +196,6 @@ public class SuperBuilderSingularToBuilderGuava { private static <T> void $fillValuesFromInstanceIntoBuilder(final SuperBuilderSingularToBuilderGuava.Child<T> instance, final SuperBuilderSingularToBuilderGuava.Child.ChildBuilder<T, ?, ?> 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}. */ @@ -212,6 +206,12 @@ public class SuperBuilderSingularToBuilderGuava { } @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 "SuperBuilderSingularToBuilderGuava.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java index 9237a148..a2f3231d 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithCustomBuilderMethod.java @@ -10,10 +10,6 @@ public class SuperBuilderWithCustomBuilderMethod { 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}. */ @@ -42,6 +38,10 @@ public class SuperBuilderWithCustomBuilderMethod { if (this.items != null) this.items.clear(); 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() { @@ -94,12 +94,6 @@ public class SuperBuilderWithCustomBuilderMethod { 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}. */ @@ -110,6 +104,12 @@ public class SuperBuilderWithCustomBuilderMethod { } @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 "SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java index a9d92ff9..3fc47f02 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithDefaults.java @@ -21,10 +21,6 @@ public class SuperBuilderWithDefaults { 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}. */ @@ -43,6 +39,10 @@ public class SuperBuilderWithDefaults { numberField$set = true; 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() { @@ -89,12 +89,6 @@ public class SuperBuilderWithDefaults { 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}. */ @@ -106,6 +100,12 @@ public class SuperBuilderWithDefaults { } @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 "SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString() + ", doubleField$value=" + this.doubleField$value + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithDefaultsAndTargetTyping.java b/test/transform/resource/after-delombok/SuperBuilderWithDefaultsAndTargetTyping.java index bc7b3099..9a67573d 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithDefaultsAndTargetTyping.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithDefaultsAndTargetTyping.java @@ -18,12 +18,6 @@ public class SuperBuilderWithDefaultsAndTargetTyping { @java.lang.SuppressWarnings("all") private String foo$value; - @java.lang.SuppressWarnings("all") - protected abstract B self(); - - @java.lang.SuppressWarnings("all") - public abstract C build(); - /** * @return {@code this}. */ @@ -34,6 +28,12 @@ public class SuperBuilderWithDefaultsAndTargetTyping { 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() { @@ -90,14 +90,6 @@ public class SuperBuilderWithDefaultsAndTargetTyping { @java.lang.SuppressWarnings("all") private String foo$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}. */ @@ -110,6 +102,14 @@ public class SuperBuilderWithDefaultsAndTargetTyping { @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 "SuperBuilderWithDefaultsAndTargetTyping.Child.ChildBuilder(super=" + super.toString() + ", foo$value=" + this.foo$value + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java index 017ebf31..0c00cdfc 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics.java @@ -9,10 +9,6 @@ public class SuperBuilderWithGenerics { 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}. */ @@ -41,6 +37,10 @@ public class SuperBuilderWithGenerics { if (this.items != null) this.items.clear(); 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() { @@ -90,12 +90,6 @@ public class SuperBuilderWithGenerics { 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}. */ @@ -106,6 +100,12 @@ public class SuperBuilderWithGenerics { } @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 "SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java index 8c465b0e..011604e9 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics2.java @@ -9,10 +9,6 @@ public class SuperBuilderWithGenerics2 { 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}. */ @@ -41,6 +37,10 @@ public class SuperBuilderWithGenerics2 { if (this.items != null) this.items.clear(); 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() { @@ -90,12 +90,6 @@ public class SuperBuilderWithGenerics2 { 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}. */ @@ -106,6 +100,12 @@ public class SuperBuilderWithGenerics2 { } @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 "SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java b/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java index 991d7cbe..ac33d10f 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithGenerics3.java @@ -6,10 +6,6 @@ public class SuperBuilderWithGenerics3 { public static abstract class ParentBuilder<A, C extends SuperBuilderWithGenerics3.Parent<A>, B extends SuperBuilderWithGenerics3.Parent.ParentBuilder<A, C, B>> { @java.lang.SuppressWarnings("all") private String str; - @java.lang.SuppressWarnings("all") - protected abstract B self(); - @java.lang.SuppressWarnings("all") - public abstract C build(); /** * @return {@code this}. */ @@ -18,6 +14,10 @@ public class SuperBuilderWithGenerics3 { this.str = str; 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() { @@ -57,12 +57,6 @@ public class SuperBuilderWithGenerics3 { public static abstract class ChildBuilder<C extends SuperBuilderWithGenerics3.Child, B extends SuperBuilderWithGenerics3.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<Child.SomeInnerStaticClass, 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}. */ @@ -73,6 +67,12 @@ public class SuperBuilderWithGenerics3 { } @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 "SuperBuilderWithGenerics3.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java b/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java index 28c48db3..b85e233c 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithGenericsAndToBuilder.java @@ -21,10 +21,6 @@ public class SuperBuilderWithGenericsAndToBuilder { 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}. */ @@ -66,6 +62,10 @@ public class SuperBuilderWithGenericsAndToBuilder { } 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() { @@ -132,12 +132,6 @@ public class SuperBuilderWithGenericsAndToBuilder { 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}. */ @@ -148,6 +142,12 @@ public class SuperBuilderWithGenericsAndToBuilder { } @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 "SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java index a3e15e8d..f51b204d 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithNonNull.java @@ -14,10 +14,6 @@ public class SuperBuilderWithNonNull { 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}. */ @@ -30,6 +26,10 @@ public class SuperBuilderWithNonNull { nonNullParentField$set = true; 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() { @@ -72,12 +72,6 @@ public class SuperBuilderWithNonNull { 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}. */ @@ -91,6 +85,12 @@ public class SuperBuilderWithNonNull { } @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 "SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString() + ", nonNullChildField=" + this.nonNullChildField + ")"; } diff --git a/test/transform/resource/after-delombok/SuperBuilderWithOverloadedGeneratedMethods.java b/test/transform/resource/after-delombok/SuperBuilderWithOverloadedGeneratedMethods.java new file mode 100644 index 00000000..4c8b77a8 --- /dev/null +++ b/test/transform/resource/after-delombok/SuperBuilderWithOverloadedGeneratedMethods.java @@ -0,0 +1,106 @@ +public class SuperBuilderWithOverloadedGeneratedMethods { + public static class Parent { + int self; + @java.lang.SuppressWarnings("all") + public static abstract class ParentBuilder<C extends SuperBuilderWithOverloadedGeneratedMethods.Parent, B extends SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<C, B>> { + @java.lang.SuppressWarnings("all") + private int self; + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + public B self(final int self) { + this.self = self; + 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 "SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder(self=" + this.self + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class ParentBuilderImpl extends SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<SuperBuilderWithOverloadedGeneratedMethods.Parent, SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl> { + @java.lang.SuppressWarnings("all") + private ParentBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public SuperBuilderWithOverloadedGeneratedMethods.Parent build() { + return new SuperBuilderWithOverloadedGeneratedMethods.Parent(this); + } + } + @java.lang.SuppressWarnings("all") + protected Parent(final SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<?, ?> b) { + this.self = b.self; + } + @java.lang.SuppressWarnings("all") + public static SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<?, ?> builder() { + return new SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl(); + } + } + public static class Child extends Parent { + double build; + @java.lang.SuppressWarnings("all") + public static abstract class ChildBuilder<C extends SuperBuilderWithOverloadedGeneratedMethods.Child, B extends SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> { + @java.lang.SuppressWarnings("all") + private double build; + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + public B build(final double build) { + this.build = build; + return self(); + } + @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 "SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder(super=" + super.toString() + ", build=" + this.build + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class ChildBuilderImpl extends SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<SuperBuilderWithOverloadedGeneratedMethods.Child, SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl> { + @java.lang.SuppressWarnings("all") + private ChildBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public SuperBuilderWithOverloadedGeneratedMethods.Child build() { + return new SuperBuilderWithOverloadedGeneratedMethods.Child(this); + } + } + @java.lang.SuppressWarnings("all") + protected Child(final SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<?, ?> b) { + super(b); + this.build = b.build; + } + @java.lang.SuppressWarnings("all") + public static SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<?, ?> builder() { + return new SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl(); + } + } + public static void test() { + Child x = Child.builder().build(0.0).self(5).build(); + } +} diff --git a/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java b/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java index 16325113..04c23051 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithPrefixes.java @@ -10,10 +10,6 @@ class SuperBuilderWithPrefixes { private int otherField; @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}. */ @@ -50,6 +46,10 @@ class SuperBuilderWithPrefixes { if (this.items != null) this.items.clear(); 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() { diff --git a/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java index 88db8511..a82e2eac 100644 --- a/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java +++ b/test/transform/resource/after-delombok/SuperBuilderWithSetterPrefix.java @@ -37,10 +37,6 @@ public class SuperBuilderWithSetterPrefix { 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}. */ @@ -93,6 +89,10 @@ public class SuperBuilderWithSetterPrefix { if (this.items != null) this.items.clear(); 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() { @@ -160,12 +160,6 @@ public class SuperBuilderWithSetterPrefix { 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}. */ @@ -176,6 +170,12 @@ public class SuperBuilderWithSetterPrefix { } @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 "SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString() + ", field3=" + this.field3 + ")"; } diff --git a/test/transform/resource/after-delombok/ValInvalidParameter.java b/test/transform/resource/after-delombok/ValInvalidParameter.java index f3d4229c..787a20bf 100644 --- a/test/transform/resource/after-delombok/ValInvalidParameter.java +++ b/test/transform/resource/after-delombok/ValInvalidParameter.java @@ -1,3 +1,4 @@ +//version 7:8 public class ValInvalidParameter { public void val() { final java.lang.Object a = a(new NonExistingClass()); diff --git a/test/transform/resource/after-delombok/ValSuperDefaultMethod.java b/test/transform/resource/after-delombok/ValSuperDefaultMethod.java new file mode 100644 index 00000000..5275a5e8 --- /dev/null +++ b/test/transform/resource/after-delombok/ValSuperDefaultMethod.java @@ -0,0 +1,12 @@ +// version :9 +class ValSuperDefaultMethod implements Default { + public void test() { + final java.lang.String a = ""; + Default.super.method(); + } +} + +interface Default { + default void method() { + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderCustomName.java b/test/transform/resource/after-ecj/BuilderCustomName.java index 652bdf16..cb578ccd 100644 --- a/test/transform/resource/after-ecj/BuilderCustomName.java +++ b/test/transform/resource/after-ecj/BuilderCustomName.java @@ -5,8 +5,6 @@ import java.util.List; public SimpleTestBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -14,6 +12,8 @@ import java.util.List; this.field = field; 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 (("BuilderCustomName.SimpleTestBuilder(field=" + this.field) + ")"); } diff --git a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java index 74a1c80f..228993e0 100644 --- a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java @@ -11,8 +11,6 @@ class CheckerFrameworkSuperBuilder { public ParentBuilder() { super(); } - protected abstract @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") @org.checkerframework.common.returnsreceiver.qual.This 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}. */ @@ -56,6 +54,8 @@ class CheckerFrameworkSuperBuilder { this.names.clear(); return self(); } + protected abstract @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") @org.checkerframework.common.returnsreceiver.qual.This 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); public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { return (((((((("CheckerFrameworkSuperBuilder.Parent.ParentBuilder(x$value=" + this.x$value) + ", y=") + this.y) + ", z=") + this.z) + ", names=") + this.names) + ")"); } @@ -111,8 +111,6 @@ class CheckerFrameworkSuperBuilder { public ZChildBuilder() { super(); } - protected abstract @java.lang.Override @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") @org.checkerframework.common.returnsreceiver.qual.This 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}. */ @@ -128,6 +126,8 @@ class CheckerFrameworkSuperBuilder { this.b = b; return self(); } + protected abstract @java.lang.Override @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") @org.checkerframework.common.returnsreceiver.qual.This 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); public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { return (((((("CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")"); } diff --git a/test/transform/resource/after-ecj/ConstructorsWithSuperBuilderDefaults.java b/test/transform/resource/after-ecj/ConstructorsWithSuperBuilderDefaults.java index a6c97d3b..16a4ee92 100644 --- a/test/transform/resource/after-ecj/ConstructorsWithSuperBuilderDefaults.java +++ b/test/transform/resource/after-ecj/ConstructorsWithSuperBuilderDefaults.java @@ -10,8 +10,6 @@ import lombok.Builder; public ConstructorsWithSuperBuilderDefaultsBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -27,6 +25,8 @@ import lombok.Builder; this.y = y; 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 (((("ConstructorsWithSuperBuilderDefaults.ConstructorsWithSuperBuilderDefaultsBuilder(x$value=" + this.x$value) + ", y=") + this.y) + ")"); } diff --git a/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java b/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java index 46709a66..348d91a2 100644 --- a/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java +++ b/test/transform/resource/after-ecj/JacksonizedSuperBuilderSimple.java @@ -5,8 +5,6 @@ public class JacksonizedSuperBuilderSimple { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -14,6 +12,8 @@ public class JacksonizedSuperBuilderSimple { this.field1 = field1; 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 (("JacksonizedSuperBuilderSimple.Parent.ParentBuilder(field1=" + this.field1) + ")"); } diff --git a/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java b/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java index 62938eea..a72da70b 100644 --- a/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java +++ b/test/transform/resource/after-ecj/JacksonizedSuperBuilderWithJsonDeserialize.java @@ -4,8 +4,6 @@ public @lombok.extern.jackson.Jacksonized @lombok.experimental.SuperBuilder @com public JacksonizedSuperBuilderWithJsonDeserializeBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -13,6 +11,8 @@ public @lombok.extern.jackson.Jacksonized @lombok.experimental.SuperBuilder @com this.field1 = field1; 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 (("JacksonizedSuperBuilderWithJsonDeserialize.JacksonizedSuperBuilderWithJsonDeserializeBuilder(field1=" + this.field1) + ")"); } diff --git a/test/transform/resource/after-ecj/LoggerFloggerRecord.java b/test/transform/resource/after-ecj/LoggerFloggerRecord.java index 86004b67..fde69e74 100644 --- a/test/transform/resource/after-ecj/LoggerFloggerRecord.java +++ b/test/transform/resource/after-ecj/LoggerFloggerRecord.java @@ -1,6 +1,7 @@ +// version 19: import lombok.extern.flogger.Flogger; class LoggerFloggerRecord { - static @Flogger record Inner(String x) { + public @Flogger record Inner(com log) { private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass(); /* Implicit */ private final String x; <clinit>() { diff --git a/test/transform/resource/after-ecj/NonNullOnRecord3.java b/test/transform/resource/after-ecj/NonNullOnRecord3.java index 44c00098..37f0afcf 100644 --- a/test/transform/resource/after-ecj/NonNullOnRecord3.java +++ b/test/transform/resource/after-ecj/NonNullOnRecord3.java @@ -1,13 +1,9 @@ -// version 14: +// version 19: import lombok.NonNull; public record NonNullOnRecord3(String a) { /* Implicit */ private final String a; public NonNullOnRecord3(String a) { super(); - .a = a; - } - public NonNullOnRecord3(String a) { - super(); this.a = a; } public void method(@NonNull String param) { diff --git a/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java index 94b708d2..f4a1c992 100644 --- a/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-ecj/NullAnnotatedCheckerFrameworkSuperBuilder.java @@ -11,8 +11,6 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -56,6 +54,8 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { this.names.clear(); 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.@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) + ")"); } @@ -111,8 +111,6 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { 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}. */ @@ -128,6 +126,8 @@ class NullAnnotatedCheckerFrameworkSuperBuilder { this.b = b; return self(); } + 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.@org.checkerframework.checker.nullness.qual.NonNull String toString() { return (((((("NullAnnotatedCheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderAbstract.java b/test/transform/resource/after-ecj/SuperBuilderAbstract.java index 2fef9451..c5d97c45 100644 --- a/test/transform/resource/after-ecj/SuperBuilderAbstract.java +++ b/test/transform/resource/after-ecj/SuperBuilderAbstract.java @@ -5,8 +5,6 @@ public class SuperBuilderAbstract { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -14,6 +12,8 @@ public class SuperBuilderAbstract { this.parentField = parentField; 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 (("SuperBuilderAbstract.Parent.ParentBuilder(parentField=" + this.parentField) + ")"); } @@ -44,8 +44,6 @@ public class SuperBuilderAbstract { 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}. */ @@ -53,6 +51,8 @@ public class SuperBuilderAbstract { this.childField = childField; return self(); } + 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 (((("SuperBuilderAbstract.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")"); } @@ -69,8 +69,6 @@ public class SuperBuilderAbstract { 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}. */ @@ -78,6 +76,8 @@ public class SuperBuilderAbstract { this.grandChildField = grandChildField; return self(); } + 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 (((("SuperBuilderAbstract.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java index 2d2cd422..0ed393e9 100644 --- a/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java +++ b/test/transform/resource/after-ecj/SuperBuilderAbstractToBuilder.java @@ -12,8 +12,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -21,6 +19,8 @@ public class SuperBuilderAbstractToBuilder { this.parentField = parentField; 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 (("SuperBuilderAbstractToBuilder.Parent.ParentBuilder(parentField=" + this.parentField) + ")"); } @@ -62,8 +62,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -71,6 +69,8 @@ public class SuperBuilderAbstractToBuilder { this.childField = childField; return self(); } + 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 (((("SuperBuilderAbstractToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", childField=") + this.childField) + ")"); } @@ -95,8 +95,6 @@ public class SuperBuilderAbstractToBuilder { 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}. */ @@ -104,6 +102,8 @@ public class SuperBuilderAbstractToBuilder { this.grandChildField = grandChildField; return self(); } + 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 (((("SuperBuilderAbstractToBuilder.GrandChild.GrandChildBuilder(super=" + super.toString()) + ", grandChildField=") + this.grandChildField) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderBasic.java b/test/transform/resource/after-ecj/SuperBuilderBasic.java index 844206d0..ad31a14b 100644 --- a/test/transform/resource/after-ecj/SuperBuilderBasic.java +++ b/test/transform/resource/after-ecj/SuperBuilderBasic.java @@ -7,8 +7,6 @@ public class SuperBuilderBasic { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -37,6 +35,8 @@ public class SuperBuilderBasic { this.items.clear(); 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 (((("SuperBuilderBasic.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")"); } @@ -80,8 +80,6 @@ public class SuperBuilderBasic { 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}. */ @@ -89,6 +87,8 @@ public class SuperBuilderBasic { this.field3 = field3; return self(); } + 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 (((("SuperBuilderBasic.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java index 67ee62f6..f29dfd37 100644 --- a/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java +++ b/test/transform/resource/after-ecj/SuperBuilderBasicToBuilder.java @@ -21,8 +21,6 @@ public class SuperBuilderBasicToBuilder { 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}. */ @@ -72,6 +70,8 @@ public class SuperBuilderBasicToBuilder { this.items.clear(); 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 (((((((((("SuperBuilderBasicToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")"); } @@ -138,8 +138,6 @@ public class SuperBuilderBasicToBuilder { 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}. */ @@ -147,6 +145,8 @@ public class SuperBuilderBasicToBuilder { this.field3 = field3; return self(); } + 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 (((("SuperBuilderBasicToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderCustomized.java b/test/transform/resource/after-ecj/SuperBuilderCustomized.java index 1fb41367..e84ffe14 100644 --- a/test/transform/resource/after-ecj/SuperBuilderCustomized.java +++ b/test/transform/resource/after-ecj/SuperBuilderCustomized.java @@ -60,8 +60,6 @@ public class SuperBuilderCustomized { 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}. */ @@ -69,6 +67,8 @@ public class SuperBuilderCustomized { this.field2 = field2; return self(); } + 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 (((("SuperBuilderCustomized.Child.ChildBuilder(super=" + super.toString()) + ", field2=") + this.field2) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderInitializer.java b/test/transform/resource/after-ecj/SuperBuilderInitializer.java index 0425fb89..9143be94 100644 --- a/test/transform/resource/after-ecj/SuperBuilderInitializer.java +++ b/test/transform/resource/after-ecj/SuperBuilderInitializer.java @@ -6,8 +6,6 @@ class SuperBuilderInitializer { public OneBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -15,6 +13,8 @@ class SuperBuilderInitializer { this.world = world; 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 (("SuperBuilderInitializer.One.OneBuilder(world=" + this.world) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderNameClashes.java b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java index 44d3db92..7f8507ce 100644 --- a/test/transform/resource/after-ecj/SuperBuilderNameClashes.java +++ b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java @@ -68,8 +68,6 @@ public class SuperBuilderNameClashes { public CBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C3 build(); /** * @return {@code this}. */ @@ -77,6 +75,8 @@ public class SuperBuilderNameClashes { this.c2 = c2; return self(); } + protected abstract @java.lang.SuppressWarnings("all") B self(); + public abstract @java.lang.SuppressWarnings("all") C3 build(); public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { return (("SuperBuilderNameClashes.C.CBuilder(c2=" + this.c2) + ")"); } @@ -101,6 +101,41 @@ public class SuperBuilderNameClashes { return new SuperBuilderNameClashes.C.CBuilderImpl(); } } + interface B2 { + interface B4<X> { + } + } + interface B3<Y> { + } + public static @lombok.experimental.SuperBuilder class ExtendsClauseCollision extends B implements B2.B4<Object>, B3<Object> { + public static abstract @java.lang.SuppressWarnings("all") class ExtendsClauseCollisionBuilder<C extends SuperBuilderNameClashes.ExtendsClauseCollision, B4 extends SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<C, B4>> extends B.BBuilder<C, B4> { + public ExtendsClauseCollisionBuilder() { + super(); + } + protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B4 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 (("SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder(super=" + super.toString()) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class ExtendsClauseCollisionBuilderImpl extends SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<SuperBuilderNameClashes.ExtendsClauseCollision, SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl> { + private ExtendsClauseCollisionBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderNameClashes.ExtendsClauseCollision build() { + return new SuperBuilderNameClashes.ExtendsClauseCollision(this); + } + } + protected @java.lang.SuppressWarnings("all") ExtendsClauseCollision(final SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<?, ?> b) { + super(b); + } + public static @java.lang.SuppressWarnings("all") SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilder<?, ?> builder() { + return new SuperBuilderNameClashes.ExtendsClauseCollision.ExtendsClauseCollisionBuilderImpl(); + } + } public SuperBuilderNameClashes() { super(); } diff --git a/test/transform/resource/after-ecj/SuperBuilderSingularAnnotatedTypes.java b/test/transform/resource/after-ecj/SuperBuilderSingularAnnotatedTypes.java index eac26153..1915e765 100644 --- a/test/transform/resource/after-ecj/SuperBuilderSingularAnnotatedTypes.java +++ b/test/transform/resource/after-ecj/SuperBuilderSingularAnnotatedTypes.java @@ -14,8 +14,6 @@ import lombok.Singular; public SuperBuilderSingularAnnotatedTypesBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); public @java.lang.SuppressWarnings("all") B foo(final @MyAnnotation @NonNull String foo) { if ((foo == null)) { @@ -84,6 +82,8 @@ import lombok.Singular; } 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 (((((("SuperBuilderSingularAnnotatedTypes.SuperBuilderSingularAnnotatedTypesBuilder(foos=" + this.foos) + ", bars$key=") + this.bars$key) + ", bars$value=") + this.bars$value) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java index 613edb03..da9d0c3b 100644 --- a/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java +++ b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java @@ -8,8 +8,6 @@ import java.util.Set; 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>(); @@ -31,6 +29,8 @@ import java.util.Set; this.foos.clear(); 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 (("SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder(foos=" + this.foos) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderSingularToBuilderGuava.java b/test/transform/resource/after-ecj/SuperBuilderSingularToBuilderGuava.java index 76a80781..62146b99 100644 --- a/test/transform/resource/after-ecj/SuperBuilderSingularToBuilderGuava.java +++ b/test/transform/resource/after-ecj/SuperBuilderSingularToBuilderGuava.java @@ -20,8 +20,6 @@ public class SuperBuilderSingularToBuilderGuava { b.passes(((instance.passes == null) ? com.google.common.collect.ImmutableSortedSet.<String>of() : instance.passes)); b.users(((instance.users == null) ? com.google.common.collect.ImmutableTable.<Number, Number, String>of() : instance.users)); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); public @java.lang.SuppressWarnings("all") B card(final T card) { if ((this.cards == null)) this.cards = com.google.common.collect.ImmutableList.builder(); @@ -122,6 +120,8 @@ public class SuperBuilderSingularToBuilderGuava { this.users = null; 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 (((((((((("SuperBuilderSingularToBuilderGuava.Parent.ParentBuilder(cards=" + this.cards) + ", frogs=") + this.frogs) + ", rawSet=") + this.rawSet) + ", passes=") + this.passes) + ", users=") + this.users) + ")"); } @@ -176,8 +176,6 @@ public class SuperBuilderSingularToBuilderGuava { private static @java.lang.SuppressWarnings("all") <T>void $fillValuesFromInstanceIntoBuilder(final SuperBuilderSingularToBuilderGuava.Child<T> instance, final SuperBuilderSingularToBuilderGuava.Child.ChildBuilder<T, ?, ?> 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}. */ @@ -185,6 +183,8 @@ public class SuperBuilderSingularToBuilderGuava { this.field3 = field3; return self(); } + 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 (((("SuperBuilderSingularToBuilderGuava.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java index 93b78c3d..7706e788 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithCustomBuilderMethod.java @@ -7,8 +7,6 @@ public class SuperBuilderWithCustomBuilderMethod { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -37,6 +35,8 @@ public class SuperBuilderWithCustomBuilderMethod { this.items.clear(); 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 (((("SuperBuilderWithCustomBuilderMethod.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")"); } @@ -80,8 +80,6 @@ public class SuperBuilderWithCustomBuilderMethod { 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}. */ @@ -89,6 +87,8 @@ public class SuperBuilderWithCustomBuilderMethod { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithCustomBuilderMethod.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java b/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java index 7c5a344a..b4edad5b 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithDefaults.java @@ -9,8 +9,6 @@ public class SuperBuilderWithDefaults { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -27,6 +25,8 @@ public class SuperBuilderWithDefaults { numberField$set = true; 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 (((("SuperBuilderWithDefaults.Parent.ParentBuilder(millis$value=" + this.millis$value) + ", numberField$value=") + this.numberField$value) + ")"); } @@ -72,8 +72,6 @@ public class SuperBuilderWithDefaults { 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}. */ @@ -82,6 +80,8 @@ public class SuperBuilderWithDefaults { doubleField$set = true; return self(); } + 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 (((("SuperBuilderWithDefaults.Child.ChildBuilder(super=" + super.toString()) + ", doubleField$value=") + this.doubleField$value) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithDefaultsAndTargetTyping.java b/test/transform/resource/after-ecj/SuperBuilderWithDefaultsAndTargetTyping.java index 20fe1351..d4744e9b 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithDefaultsAndTargetTyping.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithDefaultsAndTargetTyping.java @@ -8,8 +8,6 @@ public class SuperBuilderWithDefaultsAndTargetTyping { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -18,6 +16,8 @@ public class SuperBuilderWithDefaultsAndTargetTyping { foo$set = true; 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 (("SuperBuilderWithDefaultsAndTargetTyping.Parent.ParentBuilder(foo$value=" + this.foo$value) + ")"); } @@ -55,8 +55,6 @@ public class SuperBuilderWithDefaultsAndTargetTyping { 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}. */ @@ -65,6 +63,8 @@ public class SuperBuilderWithDefaultsAndTargetTyping { foo$set = true; return self(); } + 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 (((("SuperBuilderWithDefaultsAndTargetTyping.Child.ChildBuilder(super=" + super.toString()) + ", foo$value=") + this.foo$value) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java index db989687..b8a4fab9 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics.java @@ -7,8 +7,6 @@ public class SuperBuilderWithGenerics { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -37,6 +35,8 @@ public class SuperBuilderWithGenerics { this.items.clear(); 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 (((("SuperBuilderWithGenerics.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")"); } @@ -80,8 +80,6 @@ public class SuperBuilderWithGenerics { 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}. */ @@ -89,6 +87,8 @@ public class SuperBuilderWithGenerics { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithGenerics.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java index 96e681f4..d42f9d19 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics2.java @@ -7,8 +7,6 @@ public class SuperBuilderWithGenerics2 { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -37,6 +35,8 @@ public class SuperBuilderWithGenerics2 { this.items.clear(); 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 (((("SuperBuilderWithGenerics2.Parent.ParentBuilder(field1=" + this.field1) + ", items=") + this.items) + ")"); } @@ -80,8 +80,6 @@ public class SuperBuilderWithGenerics2 { 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}. */ @@ -89,6 +87,8 @@ public class SuperBuilderWithGenerics2 { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithGenerics2.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java b/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java index 8184bb05..0b369835 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenerics3.java @@ -6,8 +6,6 @@ public class SuperBuilderWithGenerics3 { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -15,6 +13,8 @@ public class SuperBuilderWithGenerics3 { this.str = str; 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 (("SuperBuilderWithGenerics3.Parent.ParentBuilder(str=" + this.str) + ")"); } @@ -50,8 +50,6 @@ public class SuperBuilderWithGenerics3 { 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}. */ @@ -59,6 +57,8 @@ public class SuperBuilderWithGenerics3 { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithGenerics3.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java b/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java index 829b50b9..e7d5dfae 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithGenericsAndToBuilder.java @@ -16,8 +16,6 @@ public class SuperBuilderWithGenericsAndToBuilder { 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}. */ @@ -60,6 +58,8 @@ public class SuperBuilderWithGenericsAndToBuilder { } 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 (((((("SuperBuilderWithGenericsAndToBuilder.Parent.ParentBuilder(field1=" + this.field1) + ", items$key=") + this.items$key) + ", items$value=") + this.items$value) + ")"); } @@ -117,8 +117,6 @@ public class SuperBuilderWithGenericsAndToBuilder { 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}. */ @@ -126,6 +124,8 @@ public class SuperBuilderWithGenericsAndToBuilder { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithGenericsAndToBuilder.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java b/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java index 28504f29..c7157649 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithNonNull.java @@ -7,8 +7,6 @@ public class SuperBuilderWithNonNull { public ParentBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -21,6 +19,8 @@ public class SuperBuilderWithNonNull { nonNullParentField$set = true; 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 (("SuperBuilderWithNonNull.Parent.ParentBuilder(nonNullParentField$value=" + this.nonNullParentField$value) + ")"); } @@ -61,8 +61,6 @@ public class SuperBuilderWithNonNull { 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}. */ @@ -74,6 +72,8 @@ public class SuperBuilderWithNonNull { this.nonNullChildField = nonNullChildField; return self(); } + 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 (((("SuperBuilderWithNonNull.Child.ChildBuilder(super=" + super.toString()) + ", nonNullChildField=") + this.nonNullChildField) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithOverloadedGeneratedMethods.java b/test/transform/resource/after-ecj/SuperBuilderWithOverloadedGeneratedMethods.java new file mode 100644 index 00000000..1c5e25c2 --- /dev/null +++ b/test/transform/resource/after-ecj/SuperBuilderWithOverloadedGeneratedMethods.java @@ -0,0 +1,86 @@ +public class SuperBuilderWithOverloadedGeneratedMethods { + public static @lombok.experimental.SuperBuilder class Parent { + public static abstract @java.lang.SuppressWarnings("all") class ParentBuilder<C extends SuperBuilderWithOverloadedGeneratedMethods.Parent, B extends SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<C, B>> { + private @java.lang.SuppressWarnings("all") int self; + public ParentBuilder() { + super(); + } + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") B self(final int self) { + this.self = self; + 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 (("SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder(self=" + this.self) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class ParentBuilderImpl extends SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<SuperBuilderWithOverloadedGeneratedMethods.Parent, SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl> { + private ParentBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Parent build() { + return new SuperBuilderWithOverloadedGeneratedMethods.Parent(this); + } + } + int self; + protected @java.lang.SuppressWarnings("all") Parent(final SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<?, ?> b) { + super(); + this.self = b.self; + } + public static @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilder<?, ?> builder() { + return new SuperBuilderWithOverloadedGeneratedMethods.Parent.ParentBuilderImpl(); + } + } + public static @lombok.experimental.SuperBuilder class Child extends Parent { + public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder<C extends SuperBuilderWithOverloadedGeneratedMethods.Child, B extends SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<C, B>> extends Parent.ParentBuilder<C, B> { + private @java.lang.SuppressWarnings("all") double build; + public ChildBuilder() { + super(); + } + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") B build(final double build) { + this.build = build; + return self(); + } + 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 (((("SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder(super=" + super.toString()) + ", build=") + this.build) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<SuperBuilderWithOverloadedGeneratedMethods.Child, SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl> { + private ChildBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Child build() { + return new SuperBuilderWithOverloadedGeneratedMethods.Child(this); + } + } + double build; + protected @java.lang.SuppressWarnings("all") Child(final SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<?, ?> b) { + super(b); + this.build = b.build; + } + public static @java.lang.SuppressWarnings("all") SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilder<?, ?> builder() { + return new SuperBuilderWithOverloadedGeneratedMethods.Child.ChildBuilderImpl(); + } + } + public SuperBuilderWithOverloadedGeneratedMethods() { + super(); + } + public static void test() { + Child x = Child.builder().build(0.0).self(5).build(); + } +} diff --git a/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java b/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java index 303d53f6..ec035ba1 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithPrefixes.java @@ -6,8 +6,6 @@ public SuperBuilderWithPrefixesBuilder() { super(); } - protected abstract @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.SuppressWarnings("all") C build(); /** * @return {@code this}. */ @@ -43,6 +41,8 @@ this.items.clear(); 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 (((((("SuperBuilderWithPrefixes.SuperBuilderWithPrefixesBuilder(field=" + this.field) + ", otherField=") + this.otherField) + ", items=") + this.items) + ")"); } diff --git a/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java index 3a1278c1..9f13b7ac 100644 --- a/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java +++ b/test/transform/resource/after-ecj/SuperBuilderWithSetterPrefix.java @@ -21,8 +21,6 @@ public class SuperBuilderWithSetterPrefix { 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}. */ @@ -72,6 +70,8 @@ public class SuperBuilderWithSetterPrefix { this.items.clear(); 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 (((((((((("SuperBuilderWithSetterPrefix.Parent.ParentBuilder(field1=" + this.field1) + ", obtainViaField=") + this.obtainViaField) + ", obtainViaMethod=") + this.obtainViaMethod) + ", obtainViaStaticMethod=") + this.obtainViaStaticMethod) + ", items=") + this.items) + ")"); } @@ -138,8 +138,6 @@ public class SuperBuilderWithSetterPrefix { 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}. */ @@ -147,6 +145,8 @@ public class SuperBuilderWithSetterPrefix { this.field3 = field3; return self(); } + 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 (((("SuperBuilderWithSetterPrefix.Child.ChildBuilder(super=" + super.toString()) + ", field3=") + this.field3) + ")"); } diff --git a/test/transform/resource/after-ecj/ValSuperDefaultMethod.java b/test/transform/resource/after-ecj/ValSuperDefaultMethod.java new file mode 100644 index 00000000..cb0ec47c --- /dev/null +++ b/test/transform/resource/after-ecj/ValSuperDefaultMethod.java @@ -0,0 +1,14 @@ +import lombok.val; +class ValSuperDefaultMethod implements Default { + ValSuperDefaultMethod() { + super(); + } + public void test() { + final @val java.lang.String a = ""; + Default.super.method(); + } +} +interface Default { + default void method() { + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerFloggerRecord.java b/test/transform/resource/before/LoggerFloggerRecord.java index 908704d6..f8f48f2c 100644 --- a/test/transform/resource/before/LoggerFloggerRecord.java +++ b/test/transform/resource/before/LoggerFloggerRecord.java @@ -4,5 +4,5 @@ import lombok.extern.flogger.Flogger; class LoggerFloggerRecord { @Flogger - record Inner(String x) {} + public record Inner(String x) {} } diff --git a/test/transform/resource/before/SuperBuilderNameClashes.java b/test/transform/resource/before/SuperBuilderNameClashes.java index a0b58452..ec3afbb8 100644 --- a/test/transform/resource/before/SuperBuilderNameClashes.java +++ b/test/transform/resource/before/SuperBuilderNameClashes.java @@ -14,4 +14,16 @@ public class SuperBuilderNameClashes { public static class C { C2 c2; } + + interface B2 { + interface B4<X> { + } + } + + interface B3<Y> { + } + + @lombok.experimental.SuperBuilder + public static class ExtendsClauseCollision extends B implements B2.B4<Object>, B3<Object> { + } } diff --git a/test/transform/resource/before/SuperBuilderWithOverloadedGeneratedMethods.java b/test/transform/resource/before/SuperBuilderWithOverloadedGeneratedMethods.java new file mode 100644 index 00000000..be6fea6a --- /dev/null +++ b/test/transform/resource/before/SuperBuilderWithOverloadedGeneratedMethods.java @@ -0,0 +1,15 @@ +public class SuperBuilderWithOverloadedGeneratedMethods { + @lombok.experimental.SuperBuilder + public static class Parent { + int self; + } + + @lombok.experimental.SuperBuilder + public static class Child extends Parent { + double build; + } + + public static void test() { + Child x = Child.builder().build(0.0).self(5).build(); + } +} diff --git a/test/transform/resource/before/ValInvalidParameter.java b/test/transform/resource/before/ValInvalidParameter.java index f4961c4e..10487e47 100644 --- a/test/transform/resource/before/ValInvalidParameter.java +++ b/test/transform/resource/before/ValInvalidParameter.java @@ -1,4 +1,4 @@ -//version :9 +//version 8:9 import lombok.val; public class ValInvalidParameter { diff --git a/test/transform/resource/before/ValSuperDefaultMethod.java b/test/transform/resource/before/ValSuperDefaultMethod.java new file mode 100644 index 00000000..93bcb153 --- /dev/null +++ b/test/transform/resource/before/ValSuperDefaultMethod.java @@ -0,0 +1,16 @@ +// version :9 +import lombok.val; + +class ValSuperDefaultMethod implements Default { + public void test() { + val a = ""; + Default.super.method(); + } + +} + +interface Default { + default void method() { + + } +}
\ No newline at end of file diff --git a/website/templates/features/experimental/Jacksonized.html b/website/templates/features/experimental/Jacksonized.html index 1182bdef..b3a13864 100644 --- a/website/templates/features/experimental/Jacksonized.html +++ b/website/templates/features/experimental/Jacksonized.html @@ -40,7 +40,7 @@ public class JacksonExample { </li><li> Insert <code>@JsonPOJOBuilder(withPrefix="")</code> on the generated builder class to override Jackson's default prefix "with". If you configured a different prefix in lombok using <code>setterPrefix</code>, this value is used. - If you changed the name of the <code>build()</code> method using using <code>buildMethodName</code>, this is also made known to Jackson. + If you changed the name of the <code>build()</code> method using <code>buildMethodName</code>, this is also made known to Jackson. </li><li> For <code>@SuperBuilder</code>, make the builder implementation class package-private. </li> |