diff options
69 files changed, 1533 insertions, 63 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 49d04b94..8dacf88a 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -87,7 +87,7 @@ Lombok Changelog ### v1.18.10 (September 10th, 2019) * PROMOTION: `@Wither` has been promoted to the main package, renamed to `@With`. Otherwise, no changes have been made to the annotation. The old experimental annotation will remain for a few versions as a deprecated annotation. If you had `lombok.config` configuration for this annotation, the configuration keys for this feature have been renamed. -* FEATURE: You can now configure a custom logger framework using the new `@CustomLog` annotation in combination with the `lombok.log.custom.declaration` configuration key. See the [log documentation](https://projectlombok.org/features/Log) for more information. [Pullrequest #2086](https://github.com/projectlombok/lombok/pull/2086) with thanks to Adam Juraszek. +* FEATURE: You can now configure a custom logger framework using the new `@CustomLog` annotation in combination with the `lombok.log.custom.declaration` configuration key. See the [log documentation](https://projectlombok.org/features/log) for more information. [Pullrequest #2086](https://github.com/projectlombok/lombok/pull/2086) with thanks to Adam Juraszek. * ENHANCEMENT: Thanks to Mark Haynes, the `staticConstructor` will now also be generated if a (private) constructor already exists. [Issue #2100](https://github.com/projectlombok/lombok/issues/2100) * ENHANCEMENT: `val` is now capable of decoding the type of convoluted expressions (particularly if the right hand side involves lambdas and conditional (ternary) expressions). [Pull Request #2109](https://github.com/projectlombok/lombok/pull/2109) with thanks to Alexander Bulgakov. * ENHANCEMENT: You can now configure the generated builder class name via the config system, using key `lombok.builder.className`. See the [Builder documentation](https://projectlombok.org/features/Builder) and [SuperBuilder documentation](https://projectlombok.org/features/experimental/SuperBuilder) @@ -175,7 +175,7 @@ Lombok Changelog * BUGFIX: Solved some issues in eclipse that resulted in error 'A save participant caused problems'. [Issue #879](https://github.com/projectlombok/lombok/issues/879) * BUGFIX: Netbeans on jdk9. [Issue #1617](https://github.com/projectlombok/lombok/issues/1617) * BUGFIX: Netbeans < 9. [Issue #1555](https://github.com/projectlombok/lombok/issues/1555) -* PROMOTION: `var` has been promoted from experimental to the main package with no changes. The 'old' experimental one is still around but is deprecated, and is an alias for the new main package one. [var documentation](https://projectlombok.org/features/var.html). +* PROMOTION: `var` has been promoted from experimental to the main package with no changes. The 'old' experimental one is still around but is deprecated, and is an alias for the new main package one. [var documentation](https://projectlombok.org/features/var). * OLD-CRUFT: `lombok.experimental.Builder` and `lombok.experimental.Value` are deprecated remnants of when these features were still in experimental. They are now removed entirely. If your project is dependent on an older version of lombok which still has those; fret not, lombok still processes these annotations. It just no longer includes them in the jar. ### v1.16.20 (January 9th, 2018) @@ -195,9 +195,9 @@ Lombok Changelog * FEATURE: Lombok has a new [website](https://projectlombok.org/)! A few very minor changes to the code to be more consistent with it have been added, mostly to the javadoc. ### v1.16.16 "Dancing Elephant" (March 23rd, 2017) -* FEATURE: `@Builder.Default` lets you configure default values for your fields when using `@Builder`. See the [Builder feature page](https://projectlombok.org/features/Builder.html) for more information. [Issue #1201](https://github.com/projectlombok/lombok/issues/1201) +* FEATURE: `@Builder.Default` lets you configure default values for your fields when using `@Builder`. See the [Builder feature page](https://projectlombok.org/features/Builder) for more information. [Issue #1201](https://github.com/projectlombok/lombok/issues/1201) * PLATFORM: JDK9 now supported for compilation (delomboking with java9 not yet possible). Note, you'll have to do some command line wrangling. See [Issue #985](https://github.com/projectlombok/lombok/issues/985) -* BUGFIX: The `onX` feature (which lets you add annotations to generated methods) did not work if the annotation you added contained named parameters, and you are compiling with JDK8's javac. We can't fix this (it's a bug in javac), but we have provided an alternate, prettier way to do `onX` on javac8+. [Issue #778](https://github.com/projectlombok/lombok/issues/778) [onX documentation](https://projectlombok.org/features/experimental/onX.html) +* BUGFIX: The `onX` feature (which lets you add annotations to generated methods) did not work if the annotation you added contained named parameters, and you are compiling with JDK8's javac. We can't fix this (it's a bug in javac), but we have provided an alternate, prettier way to do `onX` on javac8+. [Issue #778](https://github.com/projectlombok/lombok/issues/778) [onX documentation](https://projectlombok.org/features/experimental/onX) * BUGFIX: `@Data` and `@Value` now respect the configuration for field access when generating equals, hashCode and toString. [Issue #1329](https://github.com/projectlombok/lombok/issues/1329) * BUGFIX: `@Builder` now marks generated builder 'setters' as `@Deprecated` if the source field is deprecated. [Issue #1342](https://github.com/projectlombok/lombok/issues/1342) * CHANGE: `@ConstructorProperties` will now also be generated for private and package private constructors. This is useful for Jackson [Issue #1180](https://github.com/projectlombok/lombok/issues/1180) @@ -241,8 +241,8 @@ Lombok Changelog * ENHANCEMENT: Putting `@NonNull` on a parameter of an abstract method no longer generates a warning, to allow you to use this annotation to document intended behaviour [Issue #807](https://github.com/projectlombok/lombok/issues/807). ### v1.16.6 (August 18th, 2015) -* FEATURE: `@Helper` can be placed on method-local inner classes to make all methods in the class accessible to the rest of the method. [Full documentation](https://projectlombok.org/features/experimental/Helper.html). -* FEATURE: `@Builder(toBuilder = true)` is now available. It produces an instance method that creates a new builder, initialized with all the values of that instance. For more, read the [Feature page on Builder](https://projectlombok.org/features/Builder.html). +* FEATURE: `@Helper` can be placed on method-local inner classes to make all methods in the class accessible to the rest of the method. [Full documentation](https://projectlombok.org/features/experimental/Helper). +* FEATURE: `@Builder(toBuilder = true)` is now available. It produces an instance method that creates a new builder, initialized with all the values of that instance. For more, read the [Feature page on Builder](https://projectlombok.org/features/Builder). * FEATURE: the `hashCode()` method generated by lombok via `@EqualsAndHashCode`, `@Data`, and `@Value` is now smarter about nulls; they are treated as if they hash to a magic prime instead of 0, which reduces hash collisions. * FEATURE: `@NoArgsConstructor(force = true)` can be used to create no args constructors even if final fields are present. * BUGFIX: Parameterized static methods with `@Builder` would produce compiler errors in javac. [Issue #828](https://github.com/projectlombok/lombok/issues/828). @@ -257,7 +257,7 @@ Lombok Changelog ### v1.16.2 (February 10th, 2015) * FEATURE: The config key `lombok.extern.findbugs.addSuppressFBWarnings` can now be used to add findbugs suppress warnings annotations to all code lombok generates. This addresses feature request [Issue #737](https://github.com/projectlombok/lombok/issues/737). -* FEATURE: New lombok annotation: `@UtilityClass`, for making utility classes (not instantiable, contains only static 'function' methods). See the [feature documentation](https://projectlombok.org/features/experimental/UtilityClass.html) for more information. +* FEATURE: New lombok annotation: `@UtilityClass`, for making utility classes (not instantiable, contains only static 'function' methods). See the [feature documentation](https://projectlombok.org/features/experimental/UtilityClass) for more information. * BUGFIX: The ant `delombok` task was broken starting with v1.16.0. Note that the task def class has been changed; taskdef `lombok.delombok.ant.Tasks$Delombok` instead of the old `lombok.delombok.ant.DelombokTask`. [Issue #810](https://github.com/projectlombok/lombok/issues/810). * BUGFIX: `val` in javac would occasionally fail if used inside inner classes. This is (probably) fixed. [Issue #729](https://github.com/projectlombok/lombok/issues/729) and [Issue #616](https://github.com/projectlombok/lombok/issues/616). * BUGFIX: Starting with v1.16.0, lombok would fail to execute as an executable jar if it was in a path with spaces in it. [Issue #812](https://github.com/projectlombok/lombok/issues/812). @@ -267,7 +267,7 @@ Lombok Changelog * BUGFIX: `@ExtensionMethod` was broken in Eclipse using java 8. [Issue #777](https://github.com/projectlombok/lombok/issues/777), [Issue #782](https://github.com/projectlombok/lombok/issues/782) * BUGFIX: delombok: Using exotic characters in your source files would overzealously backslash-u escape them. Now, all characters are printed unescaped, assuming your chosen encoding can support them. Otherwise, they are escaped. [Issue #794](https://github.com/projectlombok/lombok/issues/794) * PROMOTION: `@Builder` has graduated from experimental to the main package with a few changes (addition of `@Singular`, removal of the `fluent` and `chain` options). The old one still exists and has been deprecated. -* FEATURE: `@Builder` now supports adding the `@Singular` annotation to any field/parameter that represents a collection, which results in a method in the generated builder that takes in one element of that collection and adds it. Lombok takes care of generating the appropriate code to produce a compacted immutable version of the appropriate type. In this version, java.util collections and guava's ImmutableCollections are supported. See the [feature documentation](https://projectlombok.org/features/Builder.html) for more information. +* FEATURE: `@Builder` now supports adding the `@Singular` annotation to any field/parameter that represents a collection, which results in a method in the generated builder that takes in one element of that collection and adds it. Lombok takes care of generating the appropriate code to produce a compacted immutable version of the appropriate type. In this version, java.util collections and guava's ImmutableCollections are supported. See the [feature documentation](https://projectlombok.org/features/Builder) for more information. * FEATURE: Added a launcher to the lombok boot process which removes the need for `-Xbootclasspath` to be in your `eclipse.ini` file, and removes all non-public API and third party dependencies (such as ASM) from the lombok jar, thus removing them from your IDE's auto complete offerings in any project that uses lombok. For those debugging lombok, the launcher enables hot code replace which makes debugging a lot easier, as previously one was required to shut down the IDE, rebuild the jar, and relaunch. Add `-Dshadow.override.lombok=/path/to/lombok/bin` to the launch target for hot code replace. ### v1.14.8 (September 15th, 2014) @@ -291,8 +291,8 @@ Lombok Changelog * BUGFIX: mvn builds fail with a 'URI not absolute' exception. [Issue #718](https://github.com/projectlombok/lombok/issues/718) ### v1.14.0 "Branching Cobra" (May 27th, 2014) -* FEATURE: You can now configure aspects of lombok project wide (or even workspace wide, or just for a single package) via the [configuration system](https://projectlombok.org/features/configuration.html). You can configure many things; run `java -jar lombok.jar config -gv` for the complete list. -* DEPRECATION: `@Delegate` has been moved to `lombok.experimental.Delegate`, and corner cases such as recursive delegation (delegating a type that itself has fields or methods annotated with `@Delegate`) are now error conditions. See the [feature documentation](https://projectlombok.org/features/experimental/Delegate.html) for more information. +* FEATURE: You can now configure aspects of lombok project wide (or even workspace wide, or just for a single package) via the [configuration system](https://projectlombok.org/features/configuration). You can configure many things; run `java -jar lombok.jar config -gv` for the complete list. +* DEPRECATION: `@Delegate` has been moved to `lombok.experimental.Delegate`, and corner cases such as recursive delegation (delegating a type that itself has fields or methods annotated with `@Delegate`) are now error conditions. See the [feature documentation](https://projectlombok.org/features/experimental/Delegate) for more information. * FEATURE: It is now possible to put annotations, such as `@Nullable`, on the one parameter of generated `equals()` methods by specifying the `onParam=` option on `@EqualsAndHashCode`, similar to how that feature already exists for `@Setter`. [Issue #709](https://github.com/projectlombok/lombok/issues/709) * CHANGE: suppressConstructorProperties should now be configured via lombok configuration. [Issue #694](https://github.com/projectlombok/lombok/issues/694) * CHANGE: The `canEqual` method generated by `@EqualsAndHashCode`, `@Value` and `@Data` is now `protected` instead of `public`. [Issue #695](https://github.com/projectlombok/lombok/issues/695) @@ -331,10 +331,10 @@ Lombok Changelog * GERMANY: Major version bumped from 0 to 1, because allegedly this is important. Rest assured, this change is nevertheless backwards compatible. ### v0.12.0 "Angry Butterfly" (July 16th, 2013) -* FEATURE: javadoc on fields will now be copied to generated getters / setters / withers. There are ways to specify separate javadoc for the field, the setter, and the getter, and `@param` and `@return` are handled appropriately. Addresses feature request [Issue #132](https://github.com/projectlombok/lombok/issues/132). [@Getter and @Setter documentation](https://projectlombok.org/features/GetterSetter.html). [@Wither documentation](https://projectlombok.org/features/experimental/Wither.html). -* CHANGE: The desugaring of @Getter(lazy=true) is now less object creation intensive. Documentation has been updated to reflect what the new desugaring looks like. [@Getter(lazy=true) documentation](https://projectlombok.org/features/GetterLazy.html). -* PROMOTION: `@Value` has been promoted from experimental to the main package with no changes. The 'old' experimental one is still around but is deprecated, and is an alias for the new main package one. [@Value documentation](https://projectlombok.org/features/Value.html). -* FEATURE: {Experimental} `@Builder` support. One of our earliest feature request issues, [Issue #89](https://github.com/projectlombok/lombok/issues/89), has finally been addressed. [@Builder documentation](https://projectlombok.org/features/experimental/Builder.html). +* FEATURE: javadoc on fields will now be copied to generated getters / setters / withers. There are ways to specify separate javadoc for the field, the setter, and the getter, and `@param` and `@return` are handled appropriately. Addresses feature request [Issue #132](https://github.com/projectlombok/lombok/issues/132). [@Getter and @Setter documentation](https://projectlombok.org/features/GetterSetter). [@Wither documentation](https://projectlombok.org/features/experimental/Wither). +* CHANGE: The desugaring of @Getter(lazy=true) is now less object creation intensive. Documentation has been updated to reflect what the new desugaring looks like. [@Getter(lazy=true) documentation](https://projectlombok.org/features/GetterLazy). +* PROMOTION: `@Value` has been promoted from experimental to the main package with no changes. The 'old' experimental one is still around but is deprecated, and is an alias for the new main package one. [@Value documentation](https://projectlombok.org/features/Value). +* FEATURE: {Experimental} `@Builder` support. One of our earliest feature request issues, [Issue #89](https://github.com/projectlombok/lombok/issues/89), has finally been addressed. [@Builder documentation](https://projectlombok.org/features/experimental/Builder). * FEATURE: `@NonNull` on a method or constructor parameter now generates a null-check statement at the start of your method. This nullcheck will throw a `NullPointerException` with the name of the parameter as the message. [Issue #549](https://github.com/projectlombok/lombok/issues/549) * BUGFIX: Usage of `Lombok.sneakyThrow()` or `@SneakyThrows` would sometimes result in invalid classes (classes which fail with `VerifyError`). [Issue #543](https://github.com/projectlombok/lombok/issues/543) * BUGFIX: Using `val` in try-with-resources did not work for javac. [Issue #555](https://github.com/projectlombok/lombok/issues/555) @@ -344,7 +344,7 @@ Lombok Changelog ### v0.11.8 (April 23rd, 2013) * FEATURE: Major performance improvements in eclipse by profiling the project clean process. * CHANGE: {Experimental} The experimental `@Value` feature no longer implies the also experimental `@Wither`. If you like your `@Value` classes to make withers, add `@Wither` to the class right next to `@Value`. -* FEATURE: {Experimental} Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](https://projectlombok.org/features/experimental/onX.html) +* FEATURE: {Experimental} Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](https://projectlombok.org/features/experimental/onX) * FEATURE: Added support for Log4j v2.0 via `@Log4j2` [Issue #505](https://github.com/projectlombok/lombok/issues/505) * ENHANCEMENT: The Lombok installer can now find and install lombok into [JBoss Developer Studio](http://www.redhat.com/products/jbossenterprisemiddleware/developer-studio/). The installer will now also look for eclipse and eclipse variants in your home directory. [Issue #507](https://github.com/projectlombok/lombok/issues/507) * BUGFIX: `@ExtensionMethods` no longer causes `VerifyError` exceptions when running eclipse-compiled code if extension methods are called on expressions which are method calls whose return type is a type variable. For example, `someList.get(i).extensionMethod()` would fail that way. [Issue #509](https://github.com/projectlombok/lombok/issues/509) @@ -359,7 +359,7 @@ Lombok Changelog * BUGFIX: `@Deprecated` on a field that gets a generated setter in eclipse would result in `IllegalArgumentException`, which you wouldn't see unless you have the error log open. If you have save actions defined, you'd get a popup box with the exception. Now fixed. [Issue #481](https://github.com/projectlombok/lombok/issues/481) ### v0.11.4 (August 13th, 2012) -* FEATURE: {Experimental} `@Value`, `@Wither` and `@FieldDefaults` are now available. These are a lot like `@Data` but geared towards immutable classes. [Documentation on @Value](https://projectlombok.org/features/experimental/Value.html), [Documentation on @Wither](https://projectlombok.org/features/experimental/Wither.html) and [Documentation on @FieldDefaults](https://projectlombok.org/features/experimental/FieldDefaults.html). +* FEATURE: {Experimental} `@Value`, `@Wither` and `@FieldDefaults` are now available. These are a lot like `@Data` but geared towards immutable classes. [Documentation on @Value](https://projectlombok.org/features/experimental/Value), [Documentation on @Wither](https://projectlombok.org/features/experimental/Wither) and [Documentation on @FieldDefaults](https://projectlombok.org/features/experimental/FieldDefaults). * BUGFIX: Eclipse would throw an OOME if using `@ExtensionMethod`. [Issue #463](https://github.com/projectlombok/lombok/issues/463) * BUGFIX: {Netbeans} `@Cleanup` and `@Synchronized` cause far fewer issues in the netbeans editor. [Issue #466](https://github.com/projectlombok/lombok/issues/466) * BUGFIX: {Installer} Erroneous messages about the installer complaining about needing root access when installing or removing lombok from eclipse installs has been fixed. The installer edge of this problem was actually already fixed in v0.11.2. [Issue #436](https://github.com/projectlombok/lombok/issues/436) @@ -369,7 +369,7 @@ Lombok Changelog ### v0.11.2 "Dashing Kakapo" (July 3rd, 2012) * FEATURE: {Experimental} `@ExtensionMethod` is now available to add extensions to -any type in the form of static methods that take as first parameter an object of that type. [Documentation on @ExtensionMethod](https://projectlombok.org/features/experimental/ExtensionMethod.html) +any type in the form of static methods that take as first parameter an object of that type. [Documentation on @ExtensionMethod](https://projectlombok.org/features/experimental/ExtensionMethod) * FEATURE: ONGOING: Fix for using lombok together with gwt-designer. * ENHANCEMENT: Small performance enhancements in `equals` and `hashCode`. [Issue #439](https://github.com/projectlombok/lombok/issues/439) * BUGFIX: Eclipse would display an error message regarding an invalid super constructor in the wrong location. [Issue #409](https://github.com/projectlombok/lombok/issues/409) @@ -380,9 +380,9 @@ any type in the form of static methods that take as first parameter an object of * BUGFIX: Setting breakpoints on code above the first generated method was not possible. [Issue #450](https://github.com/projectlombok/lombok/issues/450) ### v0.11.0 (March 26th, 2012) -* FEATURE: {Experimental} 'fluent' getters and setters (using just `fieldName` as methodname instead of `getFieldName`), setters that return `this` instead of `void`, and support for fields with prefixes is introduced with this lombok version. Also, the number of parameters of any existing methods with the same name that lombok would generate are now taken into account; previously if you had any method named `setX` regardless of how many parameters it has, lombok would avoid generating a `setX` method. Now lombok generates the method if all present `setX` methods have a number of parameters other than 1. [documentation](https://projectlombok.org/features/experimental/Accessors.html). +* FEATURE: {Experimental} 'fluent' getters and setters (using just `fieldName` as methodname instead of `getFieldName`), setters that return `this` instead of `void`, and support for fields with prefixes is introduced with this lombok version. Also, the number of parameters of any existing methods with the same name that lombok would generate are now taken into account; previously if you had any method named `setX` regardless of how many parameters it has, lombok would avoid generating a `setX` method. Now lombok generates the method if all present `setX` methods have a number of parameters other than 1. [documentation](https://projectlombok.org/features/experimental/Accessors). * FEATURE: The combination of `@Delegate` and `@Getter` or `@Data` will now delegate to the result of a generated getter. [Issue #401](https://github.com/projectlombok/lombok/issues/401) -* FEATURE: Developing android apps on eclipse with lombok is now possible by running `java -jar lombok.jar publicApi` and including the generated jar in your project. [Documentation on using lombok for android development](https://projectlombok.org/setup/android.html). +* FEATURE: Developing android apps on eclipse with lombok is now possible by running `java -jar lombok.jar publicApi` and including the generated jar in your project. [Documentation on using lombok for android development](https://projectlombok.org/setup/android). * BUGFIX: In NetBeans the generated default constructor would still be generated even if Lombok also generated constructors. [Issue #399](https://github.com/projectlombok/lombok/issues/399) * BUGFIX: Some classes that contain @SneakyThrows would not compile (throw ClassFormatError). [Issue #412](https://github.com/projectlombok/lombok/issues/412) * BUGFIX: delombok: When `@Delegate` would generate a method with type parameters of the type `T extends package.Class`, a dot would be prepended to the type name. [Issue #414](https://github.com/projectlombok/lombok/issues/414) @@ -394,7 +394,7 @@ any type in the form of static methods that take as first parameter an object of * BUGFIX: PrettyCommentsPrinter now prints default clause of annotation methods. Fixes [Issue #423](https://github.com/projectlombok/lombok/issues/423) ### v0.10.8 (January 19th, 2012) -* FEATURE: `@Delegate` can now be used on a no-argument method, which works similarly to adding it to fields. See [documentation](https://projectlombok.org/features/Delegate.html). +* FEATURE: `@Delegate` can now be used on a no-argument method, which works similarly to adding it to fields. See [documentation](https://projectlombok.org/features/Delegate). * BUGFIX: Eclipse refactoring Extract Interface was broken when using lombok annotation to generate methods. [Issue #159](https://github.com/projectlombok/lombok/issues/159) * BUGFIX: Eclipse action Sort Members was broken when using lombok annotations to generate methods or fields. [Issue #338](https://github.com/projectlombok/lombok/issues/338) * BUGFIX: Eclipse action Refactor/Rename on an inner type was broken when using lombok annotations. [Issue #389](https://github.com/projectlombok/lombok/issues/389) @@ -432,15 +432,15 @@ any type in the form of static methods that take as first parameter an object of * ENHANCEMENT: `@NotNull` is now also recognized as an annotation indicating that lombok should generate nullcheck guards in generated constructors and setters. [Issue #344](https://github.com/projectlombok/lombok/issues/344) ### v0.10.0 "Burning Emu" (August 19th, 2011) -* FEATURE: New annotation: @Delegate. This annotation lets lombok generate delegation methods for a given field. [More…](https://projectlombok.org/features/Delegate.html) -* FEATURE: Added support for 'val'. Val is an immutable variable that infers its type from the right hand side of the initializing expression. [More…](https://projectlombok.org/features/val.html) -* FEATURE: Added support for several logging frameworks via the `@Log`, `@Slf4j`, etc. annotation. [More…](https://projectlombok.org/features/Log.html) +* FEATURE: New annotation: @Delegate. This annotation lets lombok generate delegation methods for a given field. [More…](https://projectlombok.org/features/Delegate) +* FEATURE: Added support for 'val'. Val is an immutable variable that infers its type from the right hand side of the initializing expression. [More…](https://projectlombok.org/features/val) +* FEATURE: Added support for several logging frameworks via the `@Log`, `@Slf4j`, etc. annotation. [More…](https://projectlombok.org/features/log) * FEATURE: Lombok now supports post-compile transformers. [Issue #217](https://github.com/projectlombok/lombok/issues/217) * FEATURE: Using `@SneakyThrows` no longer requires a runtime dependency on lombok.jar. In fact, any call to `Lombok.sneakyThrows(ex)` is optimized at the bytecode level and no longer requires you to actually have lombok.jar or lombok-runtime.jar on the classpath. * FEATURE: @*X*ArgsConstructor, @Getter, and @ToString can now be used on enum declarations. Previously, behaviour of these annotations on enums was undefined. * FEATURE: @Getter/@Setter (and by extension, @Data) in v0.9.3 and earlier would generate getter and setter method names that did not conform to the beanspec, primarily when faced with boolean properties. This has been fixed. In practice this won't affect you unless you have properties named `isFoo` or `hasFoo`. Now the setter generated for this will be called `setFoo` (as the property name is `foo`) and not `setIsFoo`. Also, `hasFoo` is now no longer special; the names would be `isHasFoo` and `setHasFoo`. The java bean spec does not give `has` special meaning. -* FEATURE: `@EqualsAndHashCode` (and by extension, `@Data`) now add a `canEqual` method which improves the sanity of equality amongst a hierarchy of classes. [More…](https://projectlombok.org/features/EqualsAndHashCode.html) -* FEATURE: `@Getter` now supports a `lazy=true` attribute. [More…](https://projectlombok.org/features/GetterLazy.html) +* FEATURE: `@EqualsAndHashCode` (and by extension, `@Data`) now add a `canEqual` method which improves the sanity of equality amongst a hierarchy of classes. [More…](https://projectlombok.org/features/EqualsAndHashCode) +* FEATURE: `@Getter` now supports a `lazy=true` attribute. [More…](https://projectlombok.org/features/GetterLazy) * ENHANCEMENT: The installer will now find Eclipse installations when they are located in a subdirectory of a directory containing the word 'eclipse' . [Issue #283](https://github.com/projectlombok/lombok/issues/283) * ENHANCEMENT: Add null check for `@Cleanup` [Issue #227](https://github.com/projectlombok/lombok/issues/227) * BUGFIX: Lombok is now compatible with javac 7. @@ -475,7 +475,7 @@ any type in the form of static methods that take as first parameter an object of ### v0.9.2 "Hailbunny" (December 15th, 2009) * preliminary support for lombok on NetBeans! - thanks go to Jan Lahoda from NetBeans. [Issue #93](https://github.com/projectlombok/lombok/issues/93) -* lombok now ships with the delombok tool, which copies an entire directory filled with sources to a new directory, desugaring any java files to what it would look like without lombok's transformations. Compiling the sources in this new directory without lombok support should result in the same class files as compiling the original with lombok support. Great to double check on what lombok is doing, and for chaining the delombok-ed sources to source-based java tools such as Google Web Toolkit or javadoc. lombok.jar itself also provides an ant task for delombok. [Full documentation of delombok](https://projectlombok.org/features/delombok.html). +* lombok now ships with the delombok tool, which copies an entire directory filled with sources to a new directory, desugaring any java files to what it would look like without lombok's transformations. Compiling the sources in this new directory without lombok support should result in the same class files as compiling the original with lombok support. Great to double check on what lombok is doing, and for chaining the delombok-ed sources to source-based java tools such as Google Web Toolkit or javadoc. lombok.jar itself also provides an ant task for delombok. [Full documentation of delombok](https://projectlombok.org/features/delombok). * Lombok now works on openjdk7 (tested with JDK7m5)! For all the folks on the cutting edge, this should be very good news. [Issue #134](https://github.com/projectlombok/lombok/issues/134) - thanks go to Jan Lahoda from NetBeans. * lombok now has various command-line accessible utilities bundled with it. Run `java -jar lombok.jar --help` to see them. Included (aside from the already mentioned delombok): * Ability to create a tiny jar named lombok-runtime.jar with runtime dependencies. The lombok transformations that have a runtime dependency on this jar can be listed as well. Run `java -jar lombok.jar createRuntime --help` for more information. diff --git a/src/core/lombok/CustomLog.java b/src/core/lombok/CustomLog.java index d1f45f7c..c6ea400d 100644 --- a/src/core/lombok/CustomLog.java +++ b/src/core/lombok/CustomLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field based on a custom logger implementation. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> 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/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java index 02403305..19e7c391 100644 --- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java @@ -947,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); diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java index ca808329..973f556f 100644 --- a/src/core/lombok/extern/apachecommons/CommonsLog.java +++ b/src/core/lombok/extern/apachecommons/CommonsLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/flogger/Flogger.java b/src/core/lombok/extern/flogger/Flogger.java index 3446e949..893032ed 100644 --- a/src/core/lombok/extern/flogger/Flogger.java +++ b/src/core/lombok/extern/flogger/Flogger.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java index f2b5024f..96e52191 100644 --- a/src/core/lombok/extern/java/Log.java +++ b/src/core/lombok/extern/java/Log.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/jbosslog/JBossLog.java b/src/core/lombok/extern/jbosslog/JBossLog.java index 960a111b..a6e5e353 100644 --- a/src/core/lombok/extern/jbosslog/JBossLog.java +++ b/src/core/lombok/extern/jbosslog/JBossLog.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java index 1b4a973b..3db01029 100644 --- a/src/core/lombok/extern/log4j/Log4j.java +++ b/src/core/lombok/extern/log4j/Log4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index 571b0563..3e59a532 100644 --- a/src/core/lombok/extern/log4j/Log4j2.java +++ b/src/core/lombok/extern/log4j/Log4j2.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java index c4aded24..da65e27c 100644 --- a/src/core/lombok/extern/slf4j/Slf4j.java +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java index b99554a5..2dfef265 100644 --- a/src/core/lombok/extern/slf4j/XSlf4j.java +++ b/src/core/lombok/extern/slf4j/XSlf4j.java @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Causes lombok to generate a logger field. * <p> - * Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>. + * Complete documentation is found at <a href="https://projectlombok.org/features/log">the project lombok features page for lombok log annotations</a>. * <p> * Example: * <pre> 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/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/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/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-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/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/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/website/templates/setup/vscode.html b/website/templates/setup/vscode.html index bf9c3e58..c3712291 100644 --- a/website/templates/setup/vscode.html +++ b/website/templates/setup/vscode.html @@ -5,11 +5,11 @@ <p> The <a href="https://code.visualstudio.com/">Microsoft Visual Studio Code</a> editor is compatible with lombok. </p><p> - Add the <a href="https://marketplace.visualstudio.com/items?itemName=GabrielBB.vscode-lombok">vscode-lombok</a> plugin to your Visual Studio Code IDE to add lombok support. + The <a href="https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack">Extension Pack for Java</a> provides built-in support for Lombok. <ul><li> press <code>Ctrl + Shift + X</code> to open the extension manager. </li><li> - Type <code>lombok</code> to find the plugin, and click <code>install</code>. + Type <code>java</code> to find the plugin, and click <code>install</code>. </li><li> Reload VS Code when asked. </li></ul> |