diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-03-04 23:16:49 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-03-04 23:16:49 +0100 |
commit | f956ba1e337699206052a016da65f4f02ac6825b (patch) | |
tree | 53b0c638275ebfa8a3d1133c1d389ef700460572 | |
parent | e5574133363c8b718329e07a73bf161416485da5 (diff) | |
parent | fbab1ca77cb8306843e26c5bad91186b34563282 (diff) | |
download | lombok-f956ba1e337699206052a016da65f4f02ac6825b.tar.gz lombok-f956ba1e337699206052a016da65f4f02ac6825b.tar.bz2 lombok-f956ba1e337699206052a016da65f4f02ac6825b.zip |
[configuration] Merge branch 'master' as we work on configuration.
* Conflict due to adding topic() feature to logger in master, and 'field name' feature in config branch.
* master has since updated to shiny new eclipse dep versions and the 'ant eclipseForDebugging' feature, but this branch added deps. Addressed that.
* Renamed 'loggerCategory' to 'loggerTopic'. I know, that wasn't exactly right to do in a merge, but, there you have it.
* Test infrastructure changed in configuration branch, and tests had been added in master branch.
Conflicts:
build.xml
buildScripts/ivy.xml
src/core/lombok/eclipse/handlers/HandleLog.java
src/core/lombok/extern/apachecommons/CommonsLog.java
src/core/lombok/extern/java/Log.java
src/core/lombok/extern/log4j/Log4j.java
src/core/lombok/extern/log4j/Log4j2.java
src/core/lombok/javac/handlers/HandleLog.java
test/transform/resource/after-ecj/ValInTryWithResources.java
148 files changed, 1162 insertions, 373 deletions
@@ -17,3 +17,4 @@ /.idea *.markdown.html /junit*.properties +/eclipse.location @@ -1,6 +1,7 @@ Lombok contributors in alphabetical order: Jappe van der Hel <jappe.vanderhel@gmail.com> +Maarten Mulders <mthmulders@users.noreply.github.com> Philipp Eichhorn <peichhor@web.de> Reinier Zwitserloot <reinier@zwitserloot.com> Robbert Jan Grootjans <grootjans@gmail.com> @@ -1,4 +1,4 @@ -Copyright (C) 2009-2013 The Project Lombok Authors. +Copyright (C) 2009-2014 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 @@ -1,5 +1,5 @@ <!-- - Copyright (C) 2010-2011 The Project Lombok Authors. + Copyright (C) 2010-2014 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 @@ -256,7 +256,15 @@ the common tasks and can be called on to run the main aspects of all the sub-scr </ivy:intellijgen> </target> - <target name="eclipse" depends="deps, contrib" description="Creates eclipse project files and downloads all dependencies. Open this directory as project in eclipse after running this target."> + <target name="-skipEclipseDeps"> + <property name="eclipse.build.configname" value="buildWithoutEclipse" /> + </target> + + <target name="-addEclipseDeps"> + <property name="eclipse.build.configname" value="build" /> + </target> + + <target name="eclipse" depends="-addEclipseDeps, deps, contrib" description="Creates eclipse project files and downloads all dependencies. Open this directory as project in eclipse after running this target. This will NOT let you start a debug session for eclipse; use target 'eclipseForDebugging' instead to do that."> <ivy:eclipsegen source="1.6"> <srcdir dir="src/core" /> <srcdir dir="src/utils" /> @@ -269,20 +277,109 @@ the common tasks and can be called on to run the main aspects of all the sub-scr <srcdir dir="test/core/src" /> <srcdir dir="test/bytecode/src" /> <srcdir dir="test/configuration/src" /> - <conf name="build" sources="contrib" /> + <conf name="${eclipse.build.configname}" sources="contrib" /> <conf name="test" sources="contrib" /> + <local org="org.projectlombok" name="lombok.patcher" dir="../lombok.patcher" /> <settings> <url url="http://projectlombok.org/downloads/lombok.eclipse.settings" /> </settings> <apt location="lib/build/projectlombok.org-spi.jar" /> </ivy:eclipsegen> - + </target> + + <target name="ensureEcjDebugDeps" depends="config-ivy"> + <ivy:resolve file="buildScripts/ivy.xml" refresh="true" conf="buildWithoutEclipse" /> + <ivy:retrieve /> + </target> + + <target name="loadEclipseLocation"> + <loadfile property="eclipse.location" srcFile="eclipse.location" encoding="UTF-8" quiet="true" /> + </target> + + <target name="setupEclipseLocation" depends="loadEclipseLocation" unless="eclipse.location"> + <echo>To add your eclipse installation's own plugins as dependencies, the build script needs to know where your eclipse is installed. Please enter this now (it's saved for future executions of this task). For example: + + /Applications/eclipse + C:\Program Files\eclipse +</echo> + <input message="Path to eclipse: " addproperty="eclipse.location" /> + <available property="eclipse.found" file="${eclipse.location}/plugins" /> + <fail unless="eclipse.found">Eclipse can't be found in this location; I expect that directory to contain a subdirectory called 'plugins'.</fail> + <echo file="eclipse.location" message="${eclipse.location}" /> + </target> + + <target name="eclipseForDebugging" depends="-skipEclipseDeps, ensureEcjDebugDeps, eclipse, setupEclipseLocation" description="Creates eclipse project files and downloads all dependencies, but borrows all eclipse dependencies (and more) from your existing eclipse installation. This is very useful if you wish to start a debugging eclipse from inside eclipse, and then breakpoint eclipse code itself. Because the deps are inherited, line numbers will line up and such."> <copy file="buildScripts/eclipse-debug-target.template" tofile="LombokizedEclipse.launch" preservelastmodified="true" overwrite="true"> </copy> + + <!-- These are dependencies --> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.core.runtime" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.equinox.common" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.osgi" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.jdt.core" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.jdt.ui" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.core.resources" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.core.jobs" /></antcall> + + <!-- These are merely useful --> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.text" /></antcall> + <antcall target="-augmentClasspath"><param name="pluginName" value="org.eclipse.ltk.core.refactoring" /></antcall> + </target> + + <target name="-augmentClasspath"> + <pathconvert property="augment.bin" setonempty="false" pathsep=" :: "> + <fileset dir="${eclipse.location}/plugins" includes="${pluginName}_*" /> + </pathconvert> + + <fail unless="augment.bin"> + You do not have the eclipse plugin '${pluginName}'. I expected it to be in your eclipse plugins directory (followed by an underscore and a version number). + </fail> + + <condition property="multiples"> + <contains string="${augment.bin}" substring=" :: " /> + </condition> + + <condition property="augment.jar" value="${augment.bin}"> + <not><isset property="multiples" /></not> + </condition> + + <input message="You have multiple versions of the same plugin. These are: ${augment.bin}. Please copy/paste the complete path to the one you want to use, press enter to abort:" addproperty="augment.jar" /> + + <condition property="emptyTarget"> + <equals arg1="${augment.jar}" arg2="" /> + </condition> + + <fail> + <condition> + <equals arg1="${augment.jar}" arg2="" /> + </condition> + </fail> + + <pathconvert property="augment.src"> + <map from="${eclipse.location}/plugins/${pluginName}_" to="${eclipse.location}/plugins/${pluginName}.source_" /> + <fileset file="${augment.jar}" /> + </pathconvert> + + <available property="sourceAddition" file="${augment.src}" value=" sourcepath="${augment.src}"" /> + <property name="sourceAddition" value="" /> + + <condition property="sourceWarning" value="WARNING: No source available for this plugin!"> + <equals arg1="${sourceAddition}" arg2="" /> + </condition> + <property name="sourceWarning" value="" /> + + <replaceregexp file=".classpath" flags="is" encoding="UTF-8"> + <regexp pattern="^(.*?)(.)(<classpathentry kind=.lib. path=)(.*)$" /> + <substitution expression="\1\2<classpathentry kind="lib" path="____AUGMENT_BIN____"____AUGMENT_SRC____/>\${line.separator}\2\3\4" /> + </replaceregexp> + <replace file=".classpath" token="____AUGMENT_BIN____" value="${augment.jar}" /> + <replace file=".classpath" token="____AUGMENT_SRC____" value="${sourceAddition}" /> + <echo>Added to project classpath from your eclipse installation: ${pluginName}. +${sourceWarning}</echo> </target> <target name="-test-compile" depends="ensureTestDeps, compile" unless="skipTests"> diff --git a/buildScripts/eclipse-debug-target.template b/buildScripts/eclipse-debug-target.template index bb45cd69..78e01575 100644 --- a/buildScripts/eclipse-debug-target.template +++ b/buildScripts/eclipse-debug-target.template @@ -9,12 +9,12 @@ <booleanAttribute key="clearConfig" value="false"/> <booleanAttribute key="clearws" value="false"/> <booleanAttribute key="clearwslog" value="true"/> -<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Lombokized DebugEclipse"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/LombokizedEclipse"/> <booleanAttribute key="default" value="true"/> <booleanAttribute key="includeOptional" value="true"/> <stringAttribute key="location" value="${project_loc:lombok}/debug/workspace"/> <stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"/> -<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;javaProject name=&quot;lombok.patcher&quot;/&gt;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;default/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> +<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;javaProject name=&quot;lombok&quot;/&gt;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;javaProject name=&quot;lombok.patcher&quot;/&gt;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;default/&gt;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> </listAttribute> @@ -27,8 +27,9 @@ <booleanAttribute key="show_selected_only" value="false"/> <stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/> <booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="false"/> <booleanAttribute key="useDefaultConfig" value="true"/> <booleanAttribute key="useDefaultConfigArea" value="true"/> -<booleanAttribute key="useProduct" value="true"/> +<booleanAttribute key="useProduct" value="false"/> <booleanAttribute key="usefeatures" value="false"/> </launchConfiguration> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-core.jobs-3.5.300.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.jobs-3.5.300.xml new file mode 100644 index 00000000..4ac11822 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.jobs-3.5.300.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="core.jobs" revision="3.5.300" publication="20130429181300"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.300.v20130429-1813.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.jobs_3.5.300.v20130429-1813-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-core.resources-3.8.100.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.resources-3.8.100.xml new file mode 100644 index 00000000..c76dba24 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.resources-3.8.100.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="core.resources" revision="3.8.100" publication="20130521202600"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.8.100.v20130521-2026.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.resources_3.8.100.v20130521-2026-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml new file mode 100644 index 00000000..45d6a9c3 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="core.runtime" revision="3.9.0" publication="20130326125500"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.9.0.v20130326-1255.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.core.runtime_3.9.0.v20130326-1255-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml new file mode 100644 index 00000000..4ebfc8a4 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="ecj" revision="4.3.1" publication="20140210214200"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/ecj-4.3.1.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/ecjsrc-4.3.1.zip" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml new file mode 100644 index 00000000..74f7a705 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="equinox.common" revision="3.6.200" publication="20130402150500"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.equinox.common_3.6.200.v20130402-1505-sources.jar" /> + </publications> +</ivy-module>
\ No newline at end of file diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml new file mode 100644 index 00000000..0e7c5363 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="jdt.core" revision="3.9.1" publication="20130905083700"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.9.1.v20130905-0837.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.core_3.9.1.v20130905-0837-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml new file mode 100644 index 00000000..0577ee8a --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="jdt.ui" revision="3.9.1" publication="20130820142700"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.9.1.v20130820-1427.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.jdt.ui_3.9.1.v20130820-1427-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml new file mode 100644 index 00000000..247d76de --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml @@ -0,0 +1,14 @@ +<ivy-module version="2.0"> + <info organisation="org.eclipse.custom" module="osgi" revision="3.9.0" publication="20130529171000"> + <license name="Eclipse Public Licence v1.0" url="http://www.eclipse.org/org/documents/epl-v10.php" /> + <description homepage="http://www.eclipse.org/eclipse/" /> + </info> + <configurations> + <conf name="default" /> + <conf name="sources" /> + </configurations> + <publications> + <artifact conf="default" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.9.0.v20130529-1710.jar" /> + <artifact type="zip" conf="sources" url="http://projectlombok.org/ivyrepo/eclipse/org.eclipse.osgi_3.9.0.v20130529-1710-sources.jar" /> + </publications> +</ivy-module> diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.6.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.12.xml index e952ce9d..f402dcc9 100644 --- a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.6.xml +++ b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.12.xml @@ -1,5 +1,5 @@ <ivy-module version="2.0"> - <info organisation="org.projectlombok" module="lombok.patcher" revision="0.6" publication="20120109234200"> + <info organisation="org.projectlombok" module="lombok.patcher" revision="0.12" publication="20140301023600"> <license name="MIT License" url="http://www.opensource.org/licenses/mit-license.php" /> <ivyauthor name="rzwitserloot" url="http://zwitserloot.com/" /> <ivyauthor name="rspilker" url="http://github.com/rspilker" /> @@ -9,6 +9,6 @@ <conf name="default" /> </configurations> <publications> - <artifact conf="default" url="http://projectlombok.org/downloads/lombok.patcher-0.6.jar" /> + <artifact conf="default" url="http://projectlombok.org/downloads/lombok.patcher-0.12.jar" /> </publications> </ivy-module> diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.7.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.7.xml deleted file mode 100644 index ca41f64c..00000000 --- a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.7.xml +++ /dev/null @@ -1,14 +0,0 @@ -<ivy-module version="2.0"> - <info organisation="org.projectlombok" module="lombok.patcher" revision="0.7" publication="20130708220900"> - <license name="MIT License" url="http://www.opensource.org/licenses/mit-license.php" /> - <ivyauthor name="rzwitserloot" url="http://zwitserloot.com/" /> - <ivyauthor name="rspilker" url="http://github.com/rspilker" /> - <description homepage="http://projectlombok.org/" /> - </info> - <configurations> - <conf name="default" /> - </configurations> - <publications> - <artifact conf="default" url="http://projectlombok.org/downloads/lombok.patcher-0.7.jar" /> - </publications> -</ivy-module> diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index e7515ae4..b2d3ab21 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -3,7 +3,9 @@ <configurations> <conf name="eclipseBuild" /> <conf name="netbeansBuild" /> - <conf name="build" extends="eclipseBuild, netbeansBuild, javac6" /> + <conf name="buildBase" extends="netbeansBuild, javac6" /> + <conf name="build" extends="buildBase, eclipseBuild" /> + <conf name="buildWithoutEclipse" extends="buildBase" /> <conf name="runtime" /> <conf name="test" extends="runtime" /> <conf name="contrib" /> @@ -12,8 +14,8 @@ <conf name="javac7" /> </configurations> <dependencies> - <dependency org="org.projectlombok" name="lombok.patcher" rev="0.7" conf="build->default; runtime->default" /> - <dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="build->runtime; runtime" /> + <dependency org="org.projectlombok" name="lombok.patcher" rev="0.12" conf="buildBase->default; runtime->default" /> + <dependency org="zwitserloot.com" name="cmdreader" rev="1.2" conf="buildBase->runtime; runtime" /> <dependency org="junit" name="junit" rev="4.8.2" conf="test->default; contrib->sources" /> <dependency org="log4j" name="log4j" rev="1.2.16" conf="test->default; contrib->sources" /> @@ -21,31 +23,31 @@ <dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="test->default; contrib->sources"/> <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" conf="test->default; contrib->sources"/> <dependency org="org.slf4j" name="slf4j-ext" rev="1.6.1" conf="test->default; contrib->sources"/> - <dependency org="com.googlecode.jarjar" name="jarjar" rev="1.1" conf="build->default" /> + <dependency org="com.googlecode.jarjar" name="jarjar" rev="1.1" conf="buildBase->default" /> - <dependency org="org.apache.ant" name="ant" rev="1.8.1" conf="build->default; contrib->sources" /> - <dependency org="projectlombok.org" name="spi" rev="0.2.7" conf="build" /> - <dependency org="projectlombok.org" name="ant-googlecode" rev="0.0.2" conf="build" /> - <dependency org="com.jcraft" name="jsch" rev="0.1.42" conf="build->default" /> - <dependency org="projectlombok.org" name="jsch-ant-fixed" rev="0.1.42" conf="build" /> - <dependency org="projectlombok.org" name="markdownj" rev="1.02b4" conf="build" /> - <dependency org="de.java2html" name="java2html" rev="5.0" conf="build->default" /> + <dependency org="org.apache.ant" name="ant" rev="1.8.1" conf="buildBase->default; contrib->sources" /> + <dependency org="projectlombok.org" name="spi" rev="0.2.7" conf="buildBase->build" /> + <dependency org="projectlombok.org" name="ant-googlecode" rev="0.0.2" conf="buildBase->build" /> + <dependency org="com.jcraft" name="jsch" rev="0.1.42" conf="buildBase->default" /> + <dependency org="projectlombok.org" name="jsch-ant-fixed" rev="0.1.42" conf="buildBase->build" /> + <dependency org="projectlombok.org" name="markdownj" rev="1.02b4" conf="buildBase->build" /> + <dependency org="de.java2html" name="java2html" rev="5.0" conf="buildBase->default" /> <dependency org="net.java.openjdk.custom" name="javac6" rev="1.6.0.18" conf="javac6->runtime; contrib->sources" /> <dependency org="net.java.openjdk.custom" name="javac7" rev="1.7.0" conf="javac7->runtime; contrib->sources" /> - <dependency org="org.eclipse.custom" name="ecj" rev="3.6.2" conf="ecj->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="ecj" rev="4.3.1" conf="ecj->default; contrib->sources" /> <dependency org="netbeans.org" name="boot" rev="6.8beta" conf="netbeansBuild->build" /> <dependency org="netbeans.org" name="openide.modules" rev="6.8beta" conf="netbeansBuild->build" /> <dependency org="netbeans.org" name="openide.util" rev="6.8beta" conf="netbeansBuild->build" /> <dependency org="netbeans.org" name="modules.java.source" rev="6.8beta" conf="netbeansBuild->build" /> - <dependency org="org.eclipse.custom" name="core.runtime" rev="3.6.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="core.resources" rev="3.7.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="jdt.core" rev="3.6.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="jdt.ui" rev="3.6.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="equinox.common" rev="3.6.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="osgi" rev="3.6.0" conf="eclipseBuild->default; contrib->sources" /> - <dependency org="org.eclipse.custom" name="core.jobs" rev="3.5.200" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="core.runtime" rev="3.9.0" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="jdt.core" rev="3.9.1" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="jdt.ui" rev="3.9.1" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="equinox.common" rev="3.6.200" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="osgi" rev="3.9.0" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="core.resources" rev="3.8.100" conf="eclipseBuild->default; contrib->sources" /> + <dependency org="org.eclipse.custom" name="core.jobs" rev="3.5.300" conf="eclipseBuild->default; contrib->sources" /> </dependencies> </ivy-module> diff --git a/doc/changelog.markdown b/doc/changelog.markdown index de6abef4..472aa0f5 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -1,10 +1,24 @@ Lombok Changelog ---------------- -### v1.12.3 "Edgy Guinea Pig" +### v1.12.5 "Edgy Guinea Pig" +* GOOSECHASE: We're trying to fix a deadlock/race condition in the EquinoxClassLoader when Eclipse works with SVN or Gradle. (v2) +* PLATFORM: Added support for Eclipse Luna. [Issue #609](https://code.google.com/p/projectlombok/issues/detail?id=609) +* PLATFORM: Initial JDK8 support for eclipse's alpha support in kepler. [Issue #597](https://code.google.com/p/projectlombok/issues/detail?id=597) +* FEATURE: The various `@Log` annotations now support the `topic` parameter, which sets the logger's name. The default remains the fully qualified type name of the class itself. [Issue #632](https://code.google.com/p/projectlombok/issues/detail?id=632). +* BUGFIX: Eclipse quickfix _Surround with try/catch block_ didn't work inside `@SneakyThrows` annotated methods [Issue #438](https://code.google.com/p/projectlombok/issues/detail?id=438). +* BUGFIX: Eclipse refactoring _Extract Local Variable_ didn't work inside `@SneakyThrows` annotated methods [Issue #633](https://code.google.com/p/projectlombok/issues/detail?id=633). +* BUGFIX: {Netbeans} @SneakyThrows would lead to unused import and break refactorings [Issue #471](https://code.google.com/p/projectlombok/issues/detail?id=471). +* BUGFIX: Eclipse Organize Imports would generate error: AST must not be null [Issue #631](https://code.google.com/p/projectlombok/issues/detail?id=631). +* BUGFIX: Copying javadoc to getters / setters / withers would copy non-relevant sections too. [Issue #585](https://code.google.com/p/projectlombok/issues/detail?id=585). +* DETAIL: {Delombok} Inside enum bodies the delombok formatter didn't respect the emptyLines directive [Issue #629](https://code.google.com/p/projectlombok/issues/detail?id=629). +* DETAIL: Use smaller primes (<127) for generating hashcodes [Issue #625](https://code.google.com/p/projectlombok/issues/detail?id=625) + +### v1.12.4 (January 15th, 2014) * BUGFIX: v1.12.2's delombok turns all operator+assignments into just assignment. Fixed. [Issue #598](https://code.google.com/p/projectlombok/issues/detail?id=598) * BUGFIX: {Netbeans} v1.12.2 doesn't well with netbeans. [Issue #591](https://code.google.com/p/projectlombok/issues/detail?id=591) * ENHANCEMENT: Delombok now supports varied options for how it formats the resulting source files. This includes scanning the source for things like the preferred indent. Use option `--format-help` for more information. [Issue #608](http://code.google.com/p/projectlombok/issues/detail?id=608) +* DETAIL: The primes lombok generates for use in generated hashCode() methods used to be direct copies from Effective Java. It turns out these particular primes are used so much, they tend to be a bit more collision-prone, so we switched them. Now, '277' is used instead of '31'. The primes for booleans have also been changed. [Issue #625](https://code.google.com/p/projectlombok/issues/detail?id=625) ### v1.12.2 (October 10th, 2013) * PLATFORM: Initial JDK8 support, without affecting existing support for JDK6 and 7. [Issue #451](https://code.google.com/p/projectlombok/issues/detail?id=451). While lombok will now work on JDK8 / javac8, and netbeans 7.4 and up, lombok does not (yet) support new language features introduced with java8, such as lambda expressions. Support for these features will be added in a future version. diff --git a/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java b/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java index 38ce2c2a..d023a399 100644 --- a/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java +++ b/experimental/src/lombok/javac/disableCheckedExceptions/DisableCheckedExceptionsAgent.java @@ -34,6 +34,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; +import lombok.patcher.ClassRootFinder; import lombok.patcher.Hook; import lombok.patcher.MethodTarget; import lombok.patcher.ScriptManager; @@ -56,7 +57,7 @@ public class DisableCheckedExceptionsAgent extends AbstractProcessor { procEnv.getMessager().printMessage(Kind.WARNING, "You aren't using a compiler based around javac v1.6, so disableCheckedExceptions will not work.\n" + "Your processor class is: " + className); } else { - new LiveInjector().inject(LiveInjector.findPathJar(DisableCheckedExceptionsAgent.class)); + new LiveInjector().inject(ClassRootFinder.findClassRootOfClass(DisableCheckedExceptionsAgent.class)); } } diff --git a/src/core/lombok/bytecode/package-info.java b/src/core/lombok/bytecode/package-info.java new file mode 100644 index 00000000..9187c940 --- /dev/null +++ b/src/core/lombok/bytecode/package-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * This package contains utilities and handlers for the 'post-process class files' aspect of + * lombok. Lombok's class file post processing capabilities are based on Objectweb's ASM library. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> + */ +package lombok.bytecode; diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java index e9cf3891..734150cd 100644 --- a/src/core/lombok/core/AnnotationProcessor.java +++ b/src/core/lombok/core/AnnotationProcessor.java @@ -43,7 +43,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; -import lombok.patcher.inject.LiveInjector; +import lombok.patcher.ClassRootFinder; @SupportedAnnotationTypes("*") public class AnnotationProcessor extends AbstractProcessor { @@ -102,7 +102,7 @@ public class AnnotationProcessor extends AbstractProcessor { if (environmentClassLoader != null && environmentClassLoader.getClass().getCanonicalName().equals("org.codehaus.plexus.compiler.javac.IsolatedClassLoader")) { if (lombokAlreadyAddedTo.put(environmentClassLoader, true) == null) { Method m = environmentClassLoader.getClass().getDeclaredMethod("addURL", URL.class); - URL selfUrl = new File(LiveInjector.findPathJar(AnnotationProcessor.class)).toURI().toURL(); + URL selfUrl = new File(ClassRootFinder.findClassRootOfClass(AnnotationProcessor.class)).toURI().toURL(); m.invoke(environmentClassLoader, selfUrl); } return environmentClassLoader; diff --git a/src/core/lombok/core/PublicApiCreatorApp.java b/src/core/lombok/core/PublicApiCreatorApp.java index 24bcf83d..178a45e8 100644 --- a/src/core/lombok/core/PublicApiCreatorApp.java +++ b/src/core/lombok/core/PublicApiCreatorApp.java @@ -35,8 +35,7 @@ import java.util.jar.JarOutputStream; import java.util.zip.ZipEntry; import lombok.Lombok; -import lombok.installer.IdeFinder; -import lombok.patcher.inject.LiveInjector; +import lombok.patcher.ClassRootFinder; import org.mangosdk.spi.ProviderFor; @@ -80,7 +79,7 @@ public class PublicApiCreatorApp extends LombokApp { * a jar that wasn't accessed via the file-system, or if its started via e.g. unpacking the jar. */ private static File findOurJar() { - return new File(LiveInjector.findPathJar(IdeFinder.class)); + return new File(ClassRootFinder.findClassRootOfClass(PublicApiCreatorApp.class)); } private int writeApiJar(File outFile) throws Exception { diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index bf2e199b..6e68f035 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -28,7 +28,7 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.12.3"; + private static final String VERSION = "1.12.5"; private static final String RELEASE_NAME = "Edgy Guinea Pig"; // private static final String RELEASE_NAME = "Angry Butterfly"; diff --git a/src/core/lombok/core/debug/DebugSnapshot.java b/src/core/lombok/core/debug/DebugSnapshot.java index 42bb62fe..3f554335 100644 --- a/src/core/lombok/core/debug/DebugSnapshot.java +++ b/src/core/lombok/core/debug/DebugSnapshot.java @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2012-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package lombok.core.debug; import java.lang.ref.WeakReference; diff --git a/src/core/lombok/core/debug/DebugSnapshotStore.java b/src/core/lombok/core/debug/DebugSnapshotStore.java index 11192bd3..19f4d5b1 100644 --- a/src/core/lombok/core/debug/DebugSnapshotStore.java +++ b/src/core/lombok/core/debug/DebugSnapshotStore.java @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2012-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + package lombok.core.debug; import java.io.File; diff --git a/src/core/lombok/core/debug/package-info.java b/src/core/lombok/core/debug/package-info.java new file mode 100644 index 00000000..10d09c0d --- /dev/null +++ b/src/core/lombok/core/debug/package-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2012-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * This package contains tooling used only to debug issues that cannot be found with research but + * which require releasing a production or edge release with extra introspective facilities in + * an attempt to add clarity to the exceptions or other messages that result when the bug occurs. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> + */ +package lombok.core.debug;
\ No newline at end of file diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index ae651de1..fe2f3406 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -56,6 +56,18 @@ import lombok.experimental.Wither; public class HandlerUtil { private HandlerUtil() {} + public static int primeForHashcode() { + return 59; + } + + public static int primeForTrue() { + return 79; + } + + public static int primeForFalse() { + return 97; + } + /** Checks if the given name is a valid identifier. * * If it is, this returns {@code true} and does nothing else. diff --git a/src/core/lombok/core/handlers/package-info.java b/src/core/lombok/core/handlers/package-info.java new file mode 100644 index 00000000..6496bdb4 --- /dev/null +++ b/src/core/lombok/core/handlers/package-info.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * This package contains utility methods and classes shared between javac-specific feature implementations + * and eclipse-specific feature implementations. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> + */ +package lombok.core.handlers; diff --git a/src/core/lombok/core/package-info.java b/src/core/lombok/core/package-info.java index 153d5ff3..97b5156e 100644 --- a/src/core/lombok/core/package-info.java +++ b/src/core/lombok/core/package-info.java @@ -26,5 +26,8 @@ * an implementation of SPI service loader (to avoid being dependent on a v1.6 JVM), * lombok's version, and annotations and support classes for your normal java code * that's primarily useful for developing and debugging lombok. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.core; diff --git a/src/core/lombok/core/runtimeDependencies/package-info.java b/src/core/lombok/core/runtimeDependencies/package-info.java new file mode 100644 index 00000000..daceeb11 --- /dev/null +++ b/src/core/lombok/core/runtimeDependencies/package-info.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2009-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * This package is the basis for lombok's (the jar, run as an application) ability to spin off + * a clone of itself that only contains files required as a runtime dependency. + * + * This feature was used for a short while to support {@code @SneakyThrows}, but this is no longer + * necessary. Currently no lombok features have any such dependencies though at some point we may + * reintroduce the concept, for example to support properties. + * + * It is possible we'll use a different mechanism at that point; use the infrastructure in this package + * with knowledge that it may be eliminated at any time. + */ +package lombok.core.runtimeDependencies; diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 80c90b65..94fdffad 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2014 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 @@ -198,7 +198,7 @@ public class EclipseHandlerUtil { private void msg(int msgType, String message, String bundleName, Throwable error) { Bundle bundle = Platform.getBundle(bundleName); if (bundle == null) { - System.err.printf("Can't find bundle %s while trying to report error:\n%s\n", bundleName, message); + System.err.printf("Can't find bundle %s while trying to report error:\n%s\n%s\n", bundleName, message, error); return; } @@ -436,21 +436,21 @@ public class EclipseHandlerUtil { } } } - TypeReference typeRef = new ParameterizedQualifiedTypeReference(iRef.tokens, args, iRef.dimensions(), iRef.sourcePositions); + TypeReference typeRef = new ParameterizedQualifiedTypeReference(iRef.tokens, args, iRef.dimensions(), copy(iRef.sourcePositions)); setGeneratedBy(typeRef, source); return typeRef; } if (ref instanceof ArrayQualifiedTypeReference) { ArrayQualifiedTypeReference iRef = (ArrayQualifiedTypeReference) ref; - TypeReference typeRef = new ArrayQualifiedTypeReference(iRef.tokens, iRef.dimensions(), iRef.sourcePositions); + TypeReference typeRef = new ArrayQualifiedTypeReference(iRef.tokens, iRef.dimensions(), copy(iRef.sourcePositions)); setGeneratedBy(typeRef, source); return typeRef; } if (ref instanceof QualifiedTypeReference) { QualifiedTypeReference iRef = (QualifiedTypeReference) ref; - TypeReference typeRef = new QualifiedTypeReference(iRef.tokens, iRef.sourcePositions); + TypeReference typeRef = new QualifiedTypeReference(iRef.tokens, copy(iRef.sourcePositions)); setGeneratedBy(typeRef, source); return typeRef; } @@ -1322,7 +1322,7 @@ public class EclipseHandlerUtil { return type.add(field, Kind.FIELD); } - private static boolean isEnumConstant(final FieldDeclaration field) { + public static boolean isEnumConstant(final FieldDeclaration field) { return ((field.initialization instanceof AllocationExpression) && (((AllocationExpression) field.initialization).enumConstant == field)); } @@ -1390,6 +1390,19 @@ public class EclipseHandlerUtil { private static final char[] ALL = "all".toCharArray(); public static Annotation[] createSuppressWarningsAll(ASTNode source, Annotation[] originalAnnotationArray) { + if (originalAnnotationArray != null) for (Annotation ann : originalAnnotationArray) { + char[] lastToken = null; + + if (ann.type instanceof QualifiedTypeReference) { + char[][] t = ((QualifiedTypeReference) ann.type).tokens; + lastToken = t[t.length - 1]; + } else if (ann.type instanceof SingleTypeReference) { + lastToken = ((SingleTypeReference) ann.type).token; + } + + if (lastToken != null && new String(lastToken).equals("SuppressWarnings")) return originalAnnotationArray; + } + int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; long[] poss = new long[3]; @@ -1508,7 +1521,7 @@ public class EclipseHandlerUtil { } else if (castTo.getClass() == QualifiedTypeReference.class) { QualifiedTypeReference qtr = (QualifiedTypeReference) castTo; //Same here, but for the more complex types, they stay types. - castToConverted = new QualifiedNameReference(qtr.tokens, qtr.sourcePositions, qtr.sourceStart, qtr.sourceEnd); + castToConverted = new QualifiedNameReference(qtr.tokens, copy(qtr.sourcePositions), qtr.sourceStart, qtr.sourceEnd); castToConverted.bits = (castToConverted.bits & ~Binding.VARIABLE) | Binding.TYPE; setGeneratedBy(castToConverted, source); } @@ -1601,7 +1614,7 @@ public class EclipseHandlerUtil { return true; } - static List<Annotation> unboxAndRemoveAnnotationParameter(Annotation annotation, String annotationName, String errorName, EclipseNode errorNode) { + public static List<Annotation> unboxAndRemoveAnnotationParameter(Annotation annotation, String annotationName, String errorName, EclipseNode errorNode) { if ("value".equals(annotationName)) { // We can't unbox this, because SingleMemberAnnotation REQUIRES a value, and this method // is supposed to remove the value. That means we need to replace the SMA with either @@ -1693,7 +1706,7 @@ public class EclipseHandlerUtil { return Collections.emptyList(); } - static NameReference createNameReference(String name, Annotation source) { + public static NameReference createNameReference(String name, Annotation source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -1707,4 +1720,8 @@ public class EclipseHandlerUtil { setGeneratedBy(nameReference, source); return nameReference; } + + private static long[] copy(long[] array) { + return array == null ? null : array.clone(); + } } diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index fd7923b1..12b16934 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -230,7 +230,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { } } - private MethodDeclaration generateBuilderMethod(String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) { + public MethodDeclaration generateBuilderMethod(String builderMethodName, String builderClassName, EclipseNode type, TypeParameter[] typeParams, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long) pS << 32 | pE; @@ -249,7 +249,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { return out; } - private MethodDeclaration generateBuildMethod(String name, char[] staticName, TypeReference returnType, List<char[]> fieldNames, EclipseNode type, ASTNode source, TypeReference[] thrownExceptions) { + public MethodDeclaration generateBuildMethod(String name, char[] staticName, TypeReference returnType, List<char[]> fieldNames, EclipseNode type, ASTNode source, TypeReference[] thrownExceptions) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long) pS << 32 | pE; @@ -302,7 +302,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { return out; } - private List<EclipseNode> addFieldsToBuilder(EclipseNode builderType, List<char[]> namesOfParameters, List<TypeReference> typesOfParameters, ASTNode source) { + public List<EclipseNode> addFieldsToBuilder(EclipseNode builderType, List<char[]> namesOfParameters, List<TypeReference> typesOfParameters, ASTNode source) { int len = namesOfParameters.size(); TypeDeclaration td = (TypeDeclaration) builderType.get(); FieldDeclaration[] existing = td.fields; @@ -334,7 +334,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { private static final AbstractMethodDeclaration[] EMPTY = {}; - private MethodDeclaration makeSetterMethodForBuilder(EclipseNode builderType, EclipseNode fieldNode, ASTNode source, boolean fluent, boolean chain) { + public MethodDeclaration makeSetterMethodForBuilder(EclipseNode builderType, EclipseNode fieldNode, ASTNode source, boolean fluent, boolean chain) { TypeDeclaration td = (TypeDeclaration) builderType.get(); AbstractMethodDeclaration[] existing = td.methods; if (existing == null) existing = EMPTY; @@ -355,7 +355,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { source, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList()); } - private EclipseNode findInnerClass(EclipseNode parent, String name) { + public EclipseNode findInnerClass(EclipseNode parent, String name) { char[] c = name.toCharArray(); for (EclipseNode child : parent.down()) { if (child.getKind() != Kind.TYPE) continue; @@ -365,7 +365,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> { return null; } - private EclipseNode makeBuilderClass(EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, ASTNode source) { + public EclipseNode makeBuilderClass(EclipseNode tdParent, String builderClassName, TypeParameter[] typeParams, ASTNode source) { TypeDeclaration parent = (TypeDeclaration) tdParent.get(); TypeDeclaration builder = new TypeDeclaration(parent.compilationResult); builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG; diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java index 695ea767..dde7cd08 100644 --- a/src/core/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java @@ -229,7 +229,7 @@ public class HandleCleanup extends EclipseAnnotationHandler<Cleanup> { ancestor.rebuild(); } - private MessageSend preventNullAnalysis(Annotation ast, Expression expr) { + public MessageSend preventNullAnalysis(Annotation ast, Expression expr) { MessageSend singletonList = new MessageSend(); setGeneratedBy(singletonList, ast); @@ -258,7 +258,7 @@ public class HandleCleanup extends EclipseAnnotationHandler<Cleanup> { return preventNullAnalysis; } - private void doAssignmentCheck(EclipseNode node, Statement[] tryBlock, char[] varName) { + public void doAssignmentCheck(EclipseNode node, Statement[] tryBlock, char[] varName) { for (Statement statement : tryBlock) doAssignmentCheck0(node, statement, varName); } diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index ec2bf5dc..6b7df349 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -218,7 +218,7 @@ public class HandleConstructor { } private static final char[][] JAVA_BEANS_CONSTRUCTORPROPERTIES = new char[][] { "java".toCharArray(), "beans".toCharArray(), "ConstructorProperties".toCharArray() }; - private static Annotation[] createConstructorProperties(ASTNode source, Collection<EclipseNode> fields) { + public static Annotation[] createConstructorProperties(ASTNode source, Collection<EclipseNode> fields) { if (fields.isEmpty()) return null; int pS = source.sourceStart, pE = source.sourceEnd; @@ -249,7 +249,7 @@ public class HandleConstructor { return new Annotation[] { ann }; } - static ConstructorDeclaration createConstructor( + public static ConstructorDeclaration createConstructor( AccessLevel level, EclipseNode type, Collection<EclipseNode> fields, boolean suppressConstructorProperties, ASTNode source, List<Annotation> onConstructor) { @@ -323,14 +323,14 @@ public class HandleConstructor { return constructor; } - private static boolean isLocalType(EclipseNode type) { + public static boolean isLocalType(EclipseNode type) { Kind kind = type.up().getKind(); if (kind == Kind.COMPILATION_UNIT) return false; if (kind == Kind.TYPE) return isLocalType(type.up()); return true; } - private MethodDeclaration createStaticConstructor(AccessLevel level, String name, EclipseNode type, Collection<EclipseNode> fields, ASTNode source) { + public MethodDeclaration createStaticConstructor(AccessLevel level, String name, EclipseNode type, Collection<EclipseNode> fields, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 3a26e9f3..2ae7aba4 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -37,6 +37,7 @@ import lombok.AccessLevel; import lombok.ConfigurationKeys; import lombok.EqualsAndHashCode; import lombok.core.AST.Kind; +import lombok.core.handlers.HandlerUtil; import lombok.core.AnnotationValues; import lombok.eclipse.Eclipse; import lombok.eclipse.EclipseAnnotationHandler; @@ -93,10 +94,10 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH private final char[] PRIME = "PRIME".toCharArray(); private final char[] RESULT = "result".toCharArray(); - private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( + public static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); - private void checkForBogusFieldNames(EclipseNode type, AnnotationValues<EqualsAndHashCode> annotation) { + public void checkForBogusFieldNames(EclipseNode type, AnnotationValues<EqualsAndHashCode> annotation) { if (annotation.isExplicit("exclude")) { for (int i : createListOfNonExistentFields(Arrays.asList(annotation.getInstance().exclude()), type, true, true)) { annotation.setWarning("exclude", "This field does not exist, or would have been excluded anyway.", i); @@ -250,7 +251,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH injectMethod(typeNode, hashCodeMethod); } - private MethodDeclaration createHashCode(EclipseNode type, Collection<EclipseNode> fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { + public MethodDeclaration createHashCode(EclipseNode type, Collection<EclipseNode> fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -274,7 +275,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH final boolean isEmpty = fields.isEmpty(); - /* final int PRIME = 31; */ { + /* final int PRIME = X; */ { /* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */ if (!isEmpty || callSuper) { LocalDeclaration primeDecl = new LocalDeclaration(PRIME, pS, pE); @@ -283,7 +284,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); primeDecl.type.sourceStart = pS; primeDecl.type.sourceEnd = pE; setGeneratedBy(primeDecl.type, source); - primeDecl.initialization = makeIntLiteral("31".toCharArray(), source); + primeDecl.initialization = makeIntLiteral(String.valueOf(HandlerUtil.primeForHashcode()).toCharArray(), source); statements.add(primeDecl); } } @@ -315,12 +316,12 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH Expression fieldAccessor = createFieldAccessor(field, fieldAccess, source); if (fType.dimensions() == 0 && token != null) { if (Arrays.equals(TypeConstants.BOOLEAN, token)) { - /* booleanField ? 1231 : 1237 */ - IntLiteral int1231 = makeIntLiteral("1231".toCharArray(), source); - IntLiteral int1237 = makeIntLiteral("1237".toCharArray(), source); - ConditionalExpression int1231or1237 = new ConditionalExpression(fieldAccessor, int1231, int1237); - setGeneratedBy(int1231or1237, source); - statements.add(createResultCalculation(source, int1231or1237)); + /* booleanField ? X : Y */ + IntLiteral intTrue = makeIntLiteral(String.valueOf(HandlerUtil.primeForTrue()).toCharArray(), source); + IntLiteral intFalse = makeIntLiteral(String.valueOf(HandlerUtil.primeForFalse()).toCharArray(), source); + ConditionalExpression intForBool = new ConditionalExpression(fieldAccessor, intTrue, intFalse); + setGeneratedBy(intForBool, source); + statements.add(createResultCalculation(source, intForBool)); } else if (Arrays.equals(TypeConstants.LONG, token)) { statements.add(createLocalDeclaration(source, dollarFieldName, TypeReference.baseTypeReference(TypeIds.T_long, 0), fieldAccessor)); SingleNameReference copy1 = new SingleNameReference(dollarFieldName, p); @@ -405,7 +406,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return method; } - private LocalDeclaration createLocalDeclaration(ASTNode source, char[] dollarFieldName, TypeReference type, Expression initializer) { + public LocalDeclaration createLocalDeclaration(ASTNode source, char[] dollarFieldName, TypeReference type, Expression initializer) { int pS = source.sourceStart, pE = source.sourceEnd; LocalDeclaration tempVar = new LocalDeclaration(dollarFieldName, pS, pE); setGeneratedBy(tempVar, source); @@ -417,7 +418,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return tempVar; } - private Expression createResultCalculation(ASTNode source, Expression ex) { + public Expression createResultCalculation(ASTNode source, Expression ex) { /* result = result * PRIME + (ex); */ int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -439,7 +440,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return assignment; } - private TypeReference createTypeReference(EclipseNode type, long p) { + public TypeReference createTypeReference(EclipseNode type, long p) { List<String> list = new ArrayList<String>(); list.add(type.getName()); EclipseNode tNode = type.up(); @@ -460,7 +461,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return new QualifiedTypeReference(tokens, ps); } - private MethodDeclaration createEquals(EclipseNode type, Collection<EclipseNode> fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual) { + public MethodDeclaration createEquals(EclipseNode type, Collection<EclipseNode> fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual) { int pS = source.sourceStart; int pE = source.sourceEnd; long p = (long)pS << 32 | pE; TypeDeclaration typeDecl = (TypeDeclaration)type.get(); @@ -720,7 +721,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH } - private MethodDeclaration createCanEqual(EclipseNode type, ASTNode source) { + public MethodDeclaration createCanEqual(EclipseNode type, ASTNode source) { /* public boolean canEqual(final java.lang.Object other) { * return other instanceof Outer.Inner.MyType; * } @@ -767,7 +768,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH } - private IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) { + public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; /* if (Float.compare(fieldName, other.fieldName) != 0) return false */ MessageSend floatCompare = new MessageSend(); @@ -790,7 +791,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH } /** Give 2 clones! */ - private Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) { + public Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; /* (int)(ref >>> 32 ^ ref) */ IntLiteral int32 = makeIntLiteral("32".toCharArray(), source); @@ -806,7 +807,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return expr; } - private NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) { + public NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -818,7 +819,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH return ref; } - private TypeReference generateQualifiedTypeRef(ASTNode source, char[]... varNames) { + public TypeReference generateQualifiedTypeRef(ASTNode source, char[]... varNames) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 0ad20717..8cffaa2c 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -164,13 +164,13 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } } - private void createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List<Annotation> onMethod) { + public void createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List<Annotation> onMethod) { for (EclipseNode fieldNode : fieldNodes) { createGetterForField(level, fieldNode, errorNode, source, whineIfExists, lazy, onMethod); } } - private void createGetterForField(AccessLevel level, + public void createGetterForField(AccessLevel level, EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List<Annotation> onMethod) { if (fieldNode.getKind() != Kind.FIELD) { errorNode.addError("@Getter is only supported on a class or a field."); @@ -223,7 +223,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { injectMethod(fieldNode.up(), method); } - private static Annotation[] findDelegatesAndMarkAsHandled(EclipseNode fieldNode) { + public static Annotation[] findDelegatesAndMarkAsHandled(EclipseNode fieldNode) { List<Annotation> delegates = new ArrayList<Annotation>(); for (EclipseNode child : fieldNode.down()) { if (annotationTypeMatches(Delegate.class, child)) { @@ -235,7 +235,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { return delegates.toArray(EMPTY_ANNOTATIONS_ARRAY); } - private MethodDeclaration createGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy, List<Annotation> onMethod) { + public MethodDeclaration createGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy, List<Annotation> onMethod) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); // Remember the type; lazy will change it; @@ -284,7 +284,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { return method; } - private Statement[] createSimpleGetterBody(ASTNode source, EclipseNode fieldNode) { + public Statement[] createSimpleGetterBody(ASTNode source, EclipseNode fieldNode) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); Expression fieldRef = createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source); Statement returnStatement = new ReturnStatement(fieldRef, field.sourceStart, field.sourceEnd); @@ -293,7 +293,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { private static final char[][] AR = fromQualifiedName("java.util.concurrent.atomic.AtomicReference"); - private static final java.util.Map<String, char[][]> TYPE_MAP; + public static final java.util.Map<String, char[][]> TYPE_MAP; static { Map<String, char[][]> m = new HashMap<String, char[][]>(); m.put("int", fromQualifiedName("java.lang.Integer")); @@ -312,7 +312,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { private static final int PARENTHESIZED = (1 << ASTNode.ParenthesizedSHIFT) & ASTNode.ParenthesizedMASK; - private Statement[] createLazyGetterBody(ASTNode source, EclipseNode fieldNode) { + public Statement[] createLazyGetterBody(ASTNode source, EclipseNode fieldNode) { /* java.lang.Object value = this.fieldName.get(); if (value == null) { diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index f4cd8d07..830190a2 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -41,6 +41,7 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; +import org.eclipse.jdt.internal.compiler.ast.StringLiteral; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -51,7 +52,7 @@ public class HandleLog { throw new UnsupportedOperationException(); } - public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) { + public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode, String loggerTopic) { EclipseNode owner = annotationNode.up(); switch (owner.getKind()) { @@ -80,7 +81,7 @@ public class HandleLog { ClassLiteralAccess loggingType = selfType(owner, source); - FieldDeclaration fieldDeclaration = createField(framework, source, loggingType, logFieldName, useStatic); + FieldDeclaration fieldDeclaration = createField(framework, source, loggingType, logFieldName, useStatic, loggerTopic); fieldDeclaration.traverse(new SetGeneratedByVisitor(source), typeDecl.staticInitializerScope); // TODO temporary workaround for issue 217. http://code.google.com/p/projectlombok/issues/detail?id=217 // injectFieldSuppressWarnings(owner, fieldDeclaration); @@ -92,7 +93,7 @@ public class HandleLog { } } - private static ClassLiteralAccess selfType(EclipseNode type, Annotation source) { + public static ClassLiteralAccess selfType(EclipseNode type, Annotation source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -106,7 +107,7 @@ public class HandleLog { return result; } - private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic) { + private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, String loggerTopic) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -124,7 +125,12 @@ public class HandleLog { factoryMethodCall.receiver = createNameReference(framework.getLoggerFactoryTypeName(), source); factoryMethodCall.selector = framework.getLoggerFactoryMethodName().toCharArray(); - Expression parameter = framework.createFactoryParameter(loggingType, source); + Expression parameter; + if (loggerTopic == null || loggerTopic.trim().length() == 0) { + parameter = framework.createFactoryParameter(loggingType, source); + } else { + parameter = new StringLiteral(loggerTopic.toCharArray(), pS, pE, 0); + } factoryMethodCall.arguments = new Expression[] { parameter }; factoryMethodCall.nameSourcePosition = p; @@ -136,7 +142,7 @@ public class HandleLog { return fieldDecl; } - private static TypeReference createTypeReference(String typeName, Annotation source) { + public static TypeReference createTypeReference(String typeName, Annotation source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -164,8 +170,7 @@ public class HandleLog { public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> { @Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode); + processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -176,8 +181,7 @@ public class HandleLog { public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> { @Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode); + processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -188,8 +192,7 @@ public class HandleLog { public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -200,8 +203,7 @@ public class HandleLog { public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode); + processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -212,8 +214,7 @@ public class HandleLog { public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -224,8 +225,7 @@ public class HandleLog { public static class HandleXSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.XSlf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, Annotation source, EclipseNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java index af32af84..79bb7a08 100644 --- a/src/core/lombok/eclipse/handlers/HandleNonNull.java +++ b/src/core/lombok/eclipse/handlers/HandleNonNull.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Project Lombok Authors. + * Copyright (C) 2013-2014 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 @@ -146,11 +146,11 @@ public class HandleNonNull extends EclipseAnnotationHandler<NonNull> { annotationNode.up().up().rebuild(); } - private boolean isNullCheck(Statement stat) { + public boolean isNullCheck(Statement stat) { return returnVarNameIfNullCheck(stat) != null; } - private char[] returnVarNameIfNullCheck(Statement stat) { + public char[] returnVarNameIfNullCheck(Statement stat) { if (!(stat instanceof IfStatement)) return null; /* Check that the if's statement is a throw statement, possibly in a block. */ { diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java index 01d1a7ac..74ef07b5 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.java @@ -144,13 +144,13 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { } } - private void createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { + public void createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { for (EclipseNode fieldNode : fieldNodes) { createSetterForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, onParam); } } - private void createSetterForField( + public void createSetterForField( AccessLevel level, EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java index 11762323..481dbcde 100644 --- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java @@ -149,7 +149,7 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> { // return true; // } - private void handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List<DeclaredException> exceptions) { + public void handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List<DeclaredException> exceptions) { if (method.isAbstract()) { annotation.addError("@SneakyThrows can only be used on concrete methods."); return; @@ -181,7 +181,7 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> { annotation.up().rebuild(); } - private Statement buildTryCatchBlock(Statement[] contents, DeclaredException exception, ASTNode source, AbstractMethodDeclaration method) { + public Statement buildTryCatchBlock(Statement[] contents, DeclaredException exception, ASTNode source, AbstractMethodDeclaration method) { int methodStart = method.bodyStart; int methodEnd = method.bodyEnd; long methodPosEnd = ((long) methodEnd) << 32 | (methodEnd & 0xFFFFFFFFL); diff --git a/src/core/lombok/eclipse/handlers/HandleSynchronized.java b/src/core/lombok/eclipse/handlers/HandleSynchronized.java index 66894153..a45a499c 100644 --- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java +++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java @@ -69,7 +69,7 @@ public class HandleSynchronized extends EclipseAnnotationHandler<Synchronized> { createLockField(annotation, annotationNode, method.isStatic(), false); } - private char[] createLockField(AnnotationValues<Synchronized> annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) { + public char[] createLockField(AnnotationValues<Synchronized> annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) { char[] lockName = annotation.getInstance().value().toCharArray(); Annotation source = (Annotation) annotationNode.get(); boolean autoMake = false; diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java index 19c34c2e..a4ed254a 100644 --- a/src/core/lombok/eclipse/handlers/HandleToString.java +++ b/src/core/lombok/eclipse/handlers/HandleToString.java @@ -70,7 +70,7 @@ import org.mangosdk.spi.ProviderFor; */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleToString extends EclipseAnnotationHandler<ToString> { - private void checkForBogusFieldNames(EclipseNode type, AnnotationValues<ToString> annotation) { + public void checkForBogusFieldNames(EclipseNode type, AnnotationValues<ToString> annotation) { if (annotation.isExplicit("exclude")) { for (int i : createListOfNonExistentFields(Arrays.asList(annotation.getInstance().exclude()), type, true, false)) { annotation.setWarning("exclude", "This field does not exist, or would have been excluded anyway.", i); @@ -181,7 +181,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> { } } - static MethodDeclaration createToString(EclipseNode type, Collection<EclipseNode> fields, + public static MethodDeclaration createToString(EclipseNode type, Collection<EclipseNode> fields, boolean includeFieldNames, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { String typeName = getTypeName(type); char[] suffix = ")".toCharArray(); @@ -293,7 +293,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> { return method; } - private static String getTypeName(EclipseNode type) { + public static String getTypeName(EclipseNode type) { String typeName = getSingleTypeName(type); EclipseNode upType = type.up(); while (upType.getKind() == Kind.TYPE) { @@ -303,7 +303,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> { return typeName; } - private static String getSingleTypeName(EclipseNode type) { + public static String getSingleTypeName(EclipseNode type) { TypeDeclaration typeDeclaration = (TypeDeclaration)type.get(); char[] rawTypeName = typeDeclaration.name; return rawTypeName == null ? "" : new String(rawTypeName); @@ -312,7 +312,7 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> { private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); - private static NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) { + public static NameReference generateQualifiedNameRef(ASTNode source, char[]... varNames) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; NameReference ref; diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java index a280c500..d4ae417c 100644 --- a/src/core/lombok/eclipse/handlers/HandleVal.java +++ b/src/core/lombok/eclipse/handlers/HandleVal.java @@ -68,5 +68,9 @@ public class HandleVal extends EclipseASTAdapter { localNode.addError("'val' is not allowed in old-style for loops"); return; } + + if (local.initialization != null && local.initialization.getClass().getName().equals("org.eclipse.jdt.internal.compiler.ast.LambdaExpression")) { + localNode.addError("'val' is not allowed with lambda expressions."); + } } } diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java index afe573b9..30306b72 100644 --- a/src/core/lombok/eclipse/handlers/HandleWither.java +++ b/src/core/lombok/eclipse/handlers/HandleWither.java @@ -146,13 +146,13 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> { } } - private void createWitherForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { + public void createWitherForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { for (EclipseNode fieldNode : fieldNodes) { createWitherForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, onParam); } } - private void createWitherForField( + public void createWitherForField( AccessLevel level, EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) { @@ -210,7 +210,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> { injectMethod(fieldNode.up(), method); } - private MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, List<Annotation> onMethod, List<Annotation> onParam) { + public MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, List<Annotation> onMethod, List<Annotation> onParam) { if (name == null) return null; FieldDeclaration field = (FieldDeclaration) fieldNode.get(); int pS = source.sourceStart, pE = source.sourceEnd; diff --git a/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java b/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java index 954c948c..7217a396 100644 --- a/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java +++ b/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java @@ -1,3 +1,24 @@ +/* + * Copyright (C) 2011-2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package lombok.eclipse.handlers; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; diff --git a/src/core/lombok/eclipse/handlers/package-info.java b/src/core/lombok/eclipse/handlers/package-info.java index 6372d62a..abca4665 100644 --- a/src/core/lombok/eclipse/handlers/package-info.java +++ b/src/core/lombok/eclipse/handlers/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,5 +22,8 @@ /** * Contains the classes that implement the transformations for all of lombok's various features on the eclipse platform. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.eclipse.handlers; diff --git a/src/core/lombok/eclipse/package-info.java b/src/core/lombok/eclipse/package-info.java index c7bc6a78..7b5172e1 100644 --- a/src/core/lombok/eclipse/package-info.java +++ b/src/core/lombok/eclipse/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,5 +22,8 @@ /** * Includes the eclipse-specific implementations of the lombok AST and annotation introspection support. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.eclipse; diff --git a/src/core/lombok/experimental/package-info.java b/src/core/lombok/experimental/package-info.java new file mode 100644 index 00000000..776f2c27 --- /dev/null +++ b/src/core/lombok/experimental/package-info.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2009-2014 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * This package contains the annotations and support classes you need as a user of lombok, for + * all features which aren't (yet) supported as a first class feature. Features that involve the + * annotations and support classes in this package may change or may be removed entirely in future versions, + * and bugs may not be solved as expediently. For the status and likely future of any feature, refer + * to the official feature documentation. + * + * @see lombok + * @see <a href="http://projectlombok.org/features/experimental/index.html">Lombok features (experimental)</a> + */ +package lombok.experimental; diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java index 127e1f0a..45345098 100644 --- a/src/core/lombok/extern/apachecommons/CommonsLog.java +++ b/src/core/lombok/extern/apachecommons/CommonsLog.java @@ -59,4 +59,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface CommonsLog { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java index 86271c7d..bac2742e 100644 --- a/src/core/lombok/extern/java/Log.java +++ b/src/core/lombok/extern/java/Log.java @@ -58,4 +58,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface Log { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java index 940331a7..9490acb8 100644 --- a/src/core/lombok/extern/log4j/Log4j.java +++ b/src/core/lombok/extern/log4j/Log4j.java @@ -59,4 +59,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface Log4j { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index a105df2b..43125e6b 100644 --- a/src/core/lombok/extern/log4j/Log4j2.java +++ b/src/core/lombok/extern/log4j/Log4j2.java @@ -59,4 +59,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface Log4j2 { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java index 396e8353..04df6498 100644 --- a/src/core/lombok/extern/slf4j/Slf4j.java +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -53,9 +53,14 @@ import java.lang.annotation.Target; * @see lombok.extern.java.Log @Log * @see lombok.extern.log4j.Log4j @Log4j * @see lombok.extern.log4j.Log4j2 @Log4j2 - */ + * @see lombok.extern.slf4j.XSlf4j @XSlf4j + * */ @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface Slf4j { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java index 5b3b2712..8a311c79 100644 --- a/src/core/lombok/extern/slf4j/XSlf4j.java +++ b/src/core/lombok/extern/slf4j/XSlf4j.java @@ -58,4 +58,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) public @interface XSlf4j { + /** + * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. + */ + String topic() default ""; } diff --git a/src/core/lombok/javac/LombokOptions.java b/src/core/lombok/javac/LombokOptions.java index 60d0ce5e..034cbafd 100644 --- a/src/core/lombok/javac/LombokOptions.java +++ b/src/core/lombok/javac/LombokOptions.java @@ -25,13 +25,14 @@ import java.util.HashSet; import java.util.Set; import lombok.delombok.FormatPreferences; +import lombok.delombok.LombokOptionsFactory; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Options; public abstract class LombokOptions extends Options { - private boolean deleteLombokAnnotations = true; + private boolean deleteLombokAnnotations = false; private final Set<JCCompilationUnit> changed = new HashSet<JCCompilationUnit>(); private FormatPreferences formatPreferences = new FormatPreferences(null); @@ -48,13 +49,13 @@ public abstract class LombokOptions extends Options { } public static void markChanged(Context context, JCCompilationUnit ast) { - Options options = context.get(Options.optionsKey); - if (options instanceof LombokOptions) ((LombokOptions) options).changed.add(ast); + LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + options.changed.add(ast); } public static boolean shouldDeleteLombokAnnotations(Context context) { - Options options = context.get(Options.optionsKey); - return (options instanceof LombokOptions) && ((LombokOptions) options).deleteLombokAnnotations; + LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + return options.deleteLombokAnnotations; } protected LombokOptions(Context context) { @@ -62,4 +63,8 @@ public abstract class LombokOptions extends Options { } public abstract void putJavacOption(String optionName, String value); + + public void deleteLombokAnnotations() { + this.deleteLombokAnnotations = true; + } } diff --git a/src/core/lombok/javac/apt/package-info.java b/src/core/lombok/javac/apt/package-info.java index 63be9638..aa9e7aac 100644 --- a/src/core/lombok/javac/apt/package-info.java +++ b/src/core/lombok/javac/apt/package-info.java @@ -22,5 +22,8 @@ /** * Contains the mechanism that instruments javac as an annotation processor. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.javac.apt; diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index fc578f0f..b382395e 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -220,7 +220,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { } } - private JCMethodDecl generateBuildMethod(String name, Name staticName, JCExpression returnType, java.util.List<Name> fieldNames, JavacNode type, List<JCExpression> thrownExceptions) { + public JCMethodDecl generateBuildMethod(String name, Name staticName, JCExpression returnType, java.util.List<Name> fieldNames, JavacNode type, List<JCExpression> thrownExceptions) { JavacTreeMaker maker = type.getTreeMaker(); JCExpression call; @@ -254,7 +254,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName(name), returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), thrownExceptions, body, null); } - private JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams) { + public JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams) { JavacTreeMaker maker = type.getTreeMaker(); ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>(); @@ -269,7 +269,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { return maker.MethodDef(maker.Modifiers(Flags.STATIC | Flags.PUBLIC), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(maker, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null); } - private java.util.List<JavacNode> addFieldsToBuilder(JavacNode builderType, java.util.List<Name> namesOfParameters, java.util.List<JCExpression> typesOfParameters, JCTree source) { + public java.util.List<JavacNode> addFieldsToBuilder(JavacNode builderType, java.util.List<Name> namesOfParameters, java.util.List<JCExpression> typesOfParameters, JCTree source) { int len = namesOfParameters.size(); java.util.List<JavacNode> existing = new ArrayList<JavacNode>(); for (JavacNode child : builderType.down()) { @@ -299,7 +299,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { } - private JCMethodDecl makeSetterMethodForBuilder(JavacNode builderType, JavacNode fieldNode, JCTree source, boolean fluent, boolean chain) { + public JCMethodDecl makeSetterMethodForBuilder(JavacNode builderType, JavacNode fieldNode, JCTree source, boolean fluent, boolean chain) { Name fieldName = ((JCVariableDecl) fieldNode.get()).name; for (JavacNode child : builderType.down()) { @@ -315,7 +315,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { return HandleSetter.createSetter(Flags.PUBLIC, fieldNode, maker, setterName, chain, source, List.<JCAnnotation>nil(), List.<JCAnnotation>nil()); } - private JavacNode findInnerClass(JavacNode parent, String name) { + public JavacNode findInnerClass(JavacNode parent, String name) { for (JavacNode child : parent.down()) { if (child.getKind() != Kind.TYPE) continue; JCClassDecl td = (JCClassDecl) child.get(); @@ -324,7 +324,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> { return null; } - private JavacNode makeBuilderClass(JavacNode tdParent, String builderClassName, List<JCTypeParameter> typeParams, JCAnnotation ast) { + public JavacNode makeBuilderClass(JavacNode tdParent, String builderClassName, List<JCTypeParameter> typeParams, JCAnnotation ast) { JavacTreeMaker maker = tdParent.getTreeMaker(); JCModifiers mods = maker.Modifiers(Flags.PUBLIC | Flags.STATIC); JCClassDecl builder = maker.ClassDef(mods, tdParent.toName(builderClassName), copyTypeParams(maker, typeParams), null, List.<JCExpression>nil(), List.<JCTree>nil()); diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index 55a96df7..4aa61764 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -145,7 +145,7 @@ public class HandleCleanup extends JavacAnnotationHandler<Cleanup> { ancestor.rebuild(); } - private JCExpression preventNullAnalysis(JavacTreeMaker maker, JavacNode node, JCExpression expression) { + public JCExpression preventNullAnalysis(JavacTreeMaker maker, JavacNode node, JCExpression expression) { if (LombokOptionsFactory.getDelombokOptions(node.getContext()).getFormatPreferences().danceAroundIdeChecks()) { JCMethodInvocation singletonList = maker.Apply(List.<JCExpression>nil(), chainDotsString(node, "java.util.Collections.singletonList"), List.of(expression)); JCMethodInvocation cleanedExpr = maker.Apply(List.<JCExpression>nil(), maker.Select(singletonList, node.toName("get")) , List.<JCExpression>of(maker.Literal(CTC_INT, 0))); @@ -155,11 +155,11 @@ public class HandleCleanup extends JavacAnnotationHandler<Cleanup> { } } - private void doAssignmentCheck(JavacNode node, List<JCStatement> statements, Name name) { + public void doAssignmentCheck(JavacNode node, List<JCStatement> statements, Name name) { for (JCStatement statement : statements) doAssignmentCheck0(node, statement, name); } - private void doAssignmentCheck0(JavacNode node, JCTree statement, Name name) { + public void doAssignmentCheck0(JavacNode node, JCTree statement, Name name) { if (statement instanceof JCAssign) doAssignmentCheck0(node, ((JCAssign)statement).rhs, name); if (statement instanceof JCExpressionStatement) doAssignmentCheck0(node, ((JCExpressionStatement)statement).expr, name); diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 8fc01ffe..adfa253f 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -96,7 +96,7 @@ public class HandleConstructor { } } - private static List<JavacNode> findRequiredFields(JavacNode typeNode) { + public static List<JavacNode> findRequiredFields(JavacNode typeNode) { ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; @@ -133,7 +133,7 @@ public class HandleConstructor { } } - static List<JavacNode> findAllFields(JavacNode typeNode) { + public static List<JavacNode> findAllFields(JavacNode typeNode) { ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; @@ -150,7 +150,7 @@ public class HandleConstructor { return fields.toList(); } - static boolean checkLegality(JavacNode typeNode, JavacNode errorNode, String name) { + public static boolean checkLegality(JavacNode typeNode, JavacNode errorNode, String name) { JCClassDecl typeDecl = null; if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get(); long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags; @@ -213,7 +213,7 @@ public class HandleConstructor { } } - private static void addConstructorProperties(JCModifiers mods, JavacNode node, List<JavacNode> fields) { + public static void addConstructorProperties(JCModifiers mods, JavacNode node, List<JavacNode> fields) { if (fields.isEmpty()) return; JavacTreeMaker maker = node.getTreeMaker(); JCExpression constructorPropertiesType = chainDots(node, "java", "beans", "ConstructorProperties"); @@ -227,7 +227,7 @@ public class HandleConstructor { mods.annotations = mods.annotations.append(annotation); } - static JCMethodDecl createConstructor(AccessLevel level, List<JCAnnotation> onConstructor, JavacNode typeNode, List<JavacNode> fields, boolean suppressConstructorProperties, JCTree source) { + public static JCMethodDecl createConstructor(AccessLevel level, List<JCAnnotation> onConstructor, JavacNode typeNode, List<JavacNode> fields, boolean suppressConstructorProperties, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0; @@ -266,14 +266,14 @@ public class HandleConstructor { null, List.<JCTypeParameter>nil(), params.toList(), List.<JCExpression>nil(), maker.Block(0L, nullChecks.appendList(assigns).toList()), null), source, typeNode.getContext()); } - private static boolean isLocalType(JavacNode type) { + public static boolean isLocalType(JavacNode type) { Kind kind = type.up().getKind(); if (kind == Kind.COMPILATION_UNIT) return false; if (kind == Kind.TYPE) return isLocalType(type.up()); return true; } - private JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JCTree source) { + public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCClassDecl type = (JCClassDecl) typeNode.get(); diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java index 6f7eaa0a..ec6ea20c 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/src/core/lombok/javac/handlers/HandleDelegate.java @@ -64,6 +64,7 @@ import com.sun.tools.javac.code.Type.ClassType; import com.sun.tools.javac.code.Type.TypeVar; import com.sun.tools.javac.code.Types; import com.sun.tools.javac.model.JavacTypes; +import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCBlock; import com.sun.tools.javac.tree.JCTree.JCClassDecl; @@ -95,6 +96,8 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { "clone()", "finalize()")); + private static final String LEGALITY_OF_DELEGATE = "@Delegate is legal only on instance fields or no-argument instance methods."; + @Override public void handle(AnnotationValues<Delegate> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.DELEGATE_FLAG_USAGE, "@Delegate"); @@ -104,19 +107,24 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { Name delegateName = annotationNode.toName(annotationNode.up().getName()); DelegateReceiver delegateReceiver; JavacResolution reso = new JavacResolution(annotationNode.getContext()); + JCTree member = annotationNode.up().get(); if (annotationNode.up().getKind() == Kind.FIELD) { + if ((((JCVariableDecl) member).mods.flags & Flags.STATIC) != 0) { + annotationNode.addError(LEGALITY_OF_DELEGATE); + return; + } delegateReceiver = DelegateReceiver.FIELD; - delegateType = annotationNode.up().get().type; + delegateType = member.type; if (delegateType == null) reso.resolveClassMember(annotationNode.up()); - delegateType = annotationNode.up().get().type; + delegateType = member.type; } else if (annotationNode.up().getKind() == Kind.METHOD) { - if (!(annotationNode.up().get() instanceof JCMethodDecl)) { - annotationNode.addError("@Delegate is legal only on no-argument methods."); + if (!(member instanceof JCMethodDecl)) { + annotationNode.addError(LEGALITY_OF_DELEGATE); return; } - JCMethodDecl methodDecl = (JCMethodDecl) annotationNode.up().get(); - if (!methodDecl.params.isEmpty()) { - annotationNode.addError("@Delegate is legal only on no-argument methods."); + JCMethodDecl methodDecl = (JCMethodDecl) member; + if (!methodDecl.params.isEmpty() || (methodDecl.mods.flags & Flags.STATIC) != 0) { + annotationNode.addError(LEGALITY_OF_DELEGATE); return; } delegateReceiver = DelegateReceiver.METHOD; @@ -194,7 +202,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { for (MethodSig sig : signaturesToDelegate) generateAndAdd(sig, annotationNode, delegateName, delegateReceiver); } - private void generateAndAdd(MethodSig sig, JavacNode annotation, Name delegateName, DelegateReceiver delegateReceiver) { + public void generateAndAdd(MethodSig sig, JavacNode annotation, Name delegateName, DelegateReceiver delegateReceiver) { List<JCMethodDecl> toAdd = new ArrayList<JCMethodDecl>(); try { toAdd.add(createDelegateMethod(sig, annotation, delegateName, delegateReceiver)); @@ -211,7 +219,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { } } - private static class CantMakeDelegates extends Exception { + public static class CantMakeDelegates extends Exception { Set<String> conflicted; } @@ -222,7 +230,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { * * @throws CantMakeDelegates If there's a conflict. Conflict list is in ex.conflicted. */ - private void checkConflictOfTypeVarNames(MethodSig sig, JavacNode annotation) throws CantMakeDelegates { + public void checkConflictOfTypeVarNames(MethodSig sig, JavacNode annotation) throws CantMakeDelegates { // As first step, we check if there's a conflict between the delegate method's type vars and our own class. if (sig.elem.getTypeParameters().isEmpty()) return; @@ -262,7 +270,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { } } - private JCMethodDecl createDelegateMethod(MethodSig sig, JavacNode annotation, Name delegateName, DelegateReceiver delegateReceiver) throws TypeNotConvertibleException, CantMakeDelegates { + public JCMethodDecl createDelegateMethod(MethodSig sig, JavacNode annotation, Name delegateName, DelegateReceiver delegateReceiver) throws TypeNotConvertibleException, CantMakeDelegates { /* public <T, U, ...> ReturnType methodName(ParamType1 name1, ParamType2 name2, ...) throws T1, T2, ... { * (return) delegate.<T, U>methodName(name1, name2); * } @@ -324,11 +332,11 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation.get(), annotation.getContext()); } - private static <T> com.sun.tools.javac.util.List<T> toList(ListBuffer<T> collection) { + public static <T> com.sun.tools.javac.util.List<T> toList(ListBuffer<T> collection) { return collection == null ? com.sun.tools.javac.util.List.<T>nil() : collection.toList(); } - private void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) { + public void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) { TypeSymbol tsym = ct.asElement(); if (tsym == null) return; @@ -351,7 +359,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { } } - private static class MethodSig { + public static class MethodSig { final Name name; final ExecutableType type; final boolean isDeprecated; @@ -378,7 +386,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { } } - private static String printSig(ExecutableType method, Name name, JavacTypes types) { + public static String printSig(ExecutableType method, Name name, JavacTypes types) { StringBuilder sb = new StringBuilder(); sb.append(name.toString()).append("("); boolean first = true; @@ -390,12 +398,12 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> { return sb.append(")").toString(); } - private static String typeBindingToSignature(TypeMirror binding, JavacTypes types) { + public static String typeBindingToSignature(TypeMirror binding, JavacTypes types) { binding = types.erasure(binding); return binding.toString(); } - private enum DelegateReceiver { + public enum DelegateReceiver { METHOD { public JCExpression get(final JavacNode node, final Name name) { com.sun.tools.javac.util.List<JCExpression> nilExprs = com.sun.tools.javac.util.List.nil(); diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index f61b48ad..2c998f48 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -33,6 +33,7 @@ import lombok.ConfigurationKeys; import lombok.EqualsAndHashCode; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; +import lombok.core.handlers.HandlerUtil; import lombok.javac.Javac; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; @@ -72,7 +73,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas private static final String RESULT_NAME = "result"; private static final String PRIME_NAME = "PRIME"; - private void checkForBogusFieldNames(JavacNode type, AnnotationValues<EqualsAndHashCode> annotation) { + public void checkForBogusFieldNames(JavacNode type, AnnotationValues<EqualsAndHashCode> annotation) { if (annotation.isExplicit("exclude")) { for (int i : createListOfNonExistentFields(List.from(annotation.getInstance().exclude()), type, true, true)) { annotation.setWarning("exclude", "This field does not exist, or would have been excluded anyway.", i); @@ -222,7 +223,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas injectMethod(typeNode, hashCodeMethod); } - private JCMethodDecl createHashCode(JavacNode typeNode, List<JavacNode> fields, boolean callSuper, FieldAccess fieldAccess, JCTree source) { + public JCMethodDecl createHashCode(JavacNode typeNode, List<JavacNode> fields, boolean callSuper, FieldAccess fieldAccess, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil()); @@ -234,9 +235,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas Name resultName = typeNode.toName(RESULT_NAME); long finalFlag = JavacHandlerUtil.addFinalIfNeeded(0L, typeNode.getContext()); - /* final int PRIME = 31; */ { + /* final int PRIME = X; */ { if (!fields.isEmpty() || callSuper) { - statements.append(maker.VarDef(maker.Modifiers(finalFlag), primeName, maker.TypeIdent(CTC_INT), maker.Literal(31))); + statements.append(maker.VarDef(maker.Modifiers(finalFlag), primeName, maker.TypeIdent(CTC_INT), maker.Literal(HandlerUtil.primeForHashcode()))); } } @@ -258,8 +259,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas if (fType instanceof JCPrimitiveTypeTree) { switch (((JCPrimitiveTypeTree)fType).getPrimitiveTypeKind()) { case BOOLEAN: - /* this.fieldName ? 1231 : 1237 */ - statements.append(createResultCalculation(typeNode, maker.Conditional(fieldAccessor, maker.Literal(1231), maker.Literal(1237)))); + /* this.fieldName ? X : Y */ + statements.append(createResultCalculation(typeNode, maker.Conditional(fieldAccessor, + maker.Literal(HandlerUtil.primeForTrue()), maker.Literal(HandlerUtil.primeForFalse())))); break; case LONG: { Name dollarFieldName = dollar.append(((JCVariableDecl)fieldNode.get()).name); @@ -325,7 +327,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source, typeNode.getContext()); } - private JCExpressionStatement createResultCalculation(JavacNode typeNode, JCExpression expr) { + public JCExpressionStatement createResultCalculation(JavacNode typeNode, JCExpression expr) { /* result = result * PRIME + (expr); */ JavacTreeMaker maker = typeNode.getTreeMaker(); Name resultName = typeNode.toName(RESULT_NAME); @@ -335,14 +337,14 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas } /** The 2 references must be clones of each other. */ - private JCExpression longToIntForHashCode(JavacTreeMaker maker, JCExpression ref1, JCExpression ref2) { + public JCExpression longToIntForHashCode(JavacTreeMaker maker, JCExpression ref1, JCExpression ref2) { /* (int)(ref >>> 32 ^ ref) */ JCExpression shift = maker.Binary(CTC_UNSIGNED_SHIFT_RIGHT, ref1, maker.Literal(32)); JCExpression xorBits = maker.Binary(CTC_BITXOR, shift, ref2); return maker.TypeCast(maker.TypeIdent(CTC_INT), xorBits); } - private JCExpression createTypeReference(JavacNode type) { + public JCExpression createTypeReference(JavacNode type) { java.util.List<String> list = new ArrayList<String>(); list.add(type.getName()); JavacNode tNode = type.up(); @@ -362,7 +364,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas return chain; } - private JCMethodDecl createEquals(JavacNode typeNode, List<JavacNode> fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source) { + public JCMethodDecl createEquals(JavacNode typeNode, List<JavacNode> fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCClassDecl type = (JCClassDecl) typeNode.get(); @@ -496,7 +498,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("equals"), returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext()); } - private JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source) { + public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source) { /* public boolean canEqual(final java.lang.Object other) { * return other instanceof Outer.Inner.MyType; * } @@ -517,7 +519,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext()); } - private JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField, + public JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField, JavacTreeMaker maker, JavacNode node, boolean isDouble) { /* if (Float.compare(fieldName, other.fieldName) != 0) return false; */ JCExpression clazz = genJavaLangTypeRef(node, isDouble ? "Double" : "Float"); @@ -527,7 +529,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas return maker.If(compareCallEquals0, returnBool(maker, false), null); } - private JCStatement returnBool(JavacTreeMaker maker, boolean bool) { + public JCStatement returnBool(JavacTreeMaker maker, boolean bool) { return maker.Return(maker.Literal(CTC_BOOLEAN, bool ? 1 : 0)); } } diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java index 91ecd4d0..345c5f8e 100644 --- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java +++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java @@ -91,9 +91,9 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho annotationNode.rebuild(); } - - - private List<Extension> getExtensions(final JavacNode typeNode, final List<Object> extensionProviders) { + + + public List<Extension> getExtensions(final JavacNode typeNode, final List<Object> extensionProviders) { List<Extension> extensions = new ArrayList<Extension>(); for (Object extensionProvider : extensionProviders) { if (!(extensionProvider instanceof JCFieldAccess)) continue; @@ -108,7 +108,7 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho return extensions; } - private Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) { + public Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) { List<MethodSymbol> extensionMethods = new ArrayList<MethodSymbol>(); TypeSymbol tsym = extensionMethodProviderType.asElement(); if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) { diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 4414ae24..48a13bde 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -162,13 +162,13 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { } } - private void createGetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) { + public void createGetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) { for (JavacNode fieldNode : fieldNodes) { createGetterForField(level, fieldNode, errorNode, whineIfExists, lazy, onMethod); } } - private void createGetterForField(AccessLevel level, + public void createGetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) { if (fieldNode.getKind() != Kind.FIELD) { source.addError("@Getter is only supported on a class or a field."); @@ -218,7 +218,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source.get(), lazy, onMethod)); } - private JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, boolean lazy, List<JCAnnotation> onMethod) { + public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, boolean lazy, List<JCAnnotation> onMethod) { JCVariableDecl fieldNode = (JCVariableDecl) field.get(); // Remember the type; lazy will change it @@ -228,7 +228,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { List<JCStatement> statements; JCTree toClearOfMarkers = null; - if (lazy) { + if (lazy && !inNetbeansEditor(field)) { toClearOfMarkers = fieldNode.init; statements = createLazyGetterBody(treeMaker, field, source); } else { @@ -262,7 +262,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { return decl; } - private static List<JCAnnotation> findDelegatesAndRemoveFromField(JavacNode field) { + public static List<JCAnnotation> findDelegatesAndRemoveFromField(JavacNode field) { JCVariableDecl fieldNode = (JCVariableDecl) field.get(); List<JCAnnotation> delegates = List.nil(); @@ -285,14 +285,14 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { return delegates; } - private List<JCStatement> createSimpleGetterBody(JavacTreeMaker treeMaker, JavacNode field) { + public List<JCStatement> createSimpleGetterBody(JavacTreeMaker treeMaker, JavacNode field) { return List.<JCStatement>of(treeMaker.Return(createFieldAccessor(treeMaker, field, FieldAccess.ALWAYS_FIELD))); } private static final String AR = "java.util.concurrent.atomic.AtomicReference"; private static final List<JCExpression> NIL_EXPRESSION = List.nil(); - private static final java.util.Map<TypeTag, String> TYPE_MAP; + public static final java.util.Map<TypeTag, String> TYPE_MAP; static { Map<TypeTag, String> m = new HashMap<TypeTag, String>(); m.put(CTC_INT, "Integer"); @@ -306,7 +306,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { TYPE_MAP = Collections.unmodifiableMap(m); } - private List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) { + public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) { /* java.lang.Object value = this.fieldName.get(); if (value == null) { @@ -426,17 +426,17 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { return statements.toList(); } - private JCMethodInvocation callGet(JavacNode source, JCExpression receiver) { + public JCMethodInvocation callGet(JavacNode source, JCExpression receiver) { JavacTreeMaker maker = source.getTreeMaker(); return maker.Apply(NIL_EXPRESSION, maker.Select(receiver, source.toName("get")), NIL_EXPRESSION); } - private JCStatement callSet(JavacNode source, JCExpression receiver, JCExpression value) { + public JCStatement callSet(JavacNode source, JCExpression receiver, JCExpression value) { JavacTreeMaker maker = source.getTreeMaker(); return maker.Exec(maker.Apply(NIL_EXPRESSION, maker.Select(receiver, source.toName("set")), List.<JCExpression>of(value))); } - private JCExpression copyType(JavacTreeMaker treeMaker, JCVariableDecl fieldNode) { + public JCExpression copyType(JavacTreeMaker treeMaker, JCVariableDecl fieldNode) { return fieldNode.type != null ? treeMaker.Type(fieldNode.type) : fieldNode.vartype; } } diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index 1b384847..ee7268f7 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -49,10 +49,10 @@ public class HandleLog { private HandleLog() { throw new UnsupportedOperationException(); } - - public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode) { + + public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerTopic) { deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass()); - + JavacNode typeNode = annotationNode.up(); switch (typeNode.getKind()) { case TYPE: @@ -65,14 +65,13 @@ public class HandleLog { annotationNode.addError("@Log is legal only on classes and enums."); return; } - - if (fieldExists(logFieldName, typeNode)!= MemberExistsResult.NOT_EXISTS) { + if (fieldExists(logFieldName, typeNode) != MemberExistsResult.NOT_EXISTS) { annotationNode.addWarning("Field '" + logFieldName + "' already exists."); return; } - + JCFieldAccess loggingType = selfType(typeNode); - createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName, useStatic); + createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName, useStatic, loggerTopic); break; default: annotationNode.addError("@Log is legal only on types."); @@ -80,22 +79,28 @@ public class HandleLog { } } - private static JCFieldAccess selfType(JavacNode typeNode) { + public static JCFieldAccess selfType(JavacNode typeNode) { JavacTreeMaker maker = typeNode.getTreeMaker(); Name name = ((JCClassDecl) typeNode.get()).name; return maker.Select(maker.Ident(name), typeNode.toName("class")); } - private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic) { + private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, String loggerTopic) { JavacTreeMaker maker = typeNode.getTreeMaker(); // private static final <loggerType> log = <factoryMethod>(<parameter>); JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName()); JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName()); - - JCExpression loggerName = framework.createFactoryParameter(typeNode, loggingType); + + JCExpression loggerName; + if (loggerTopic == null || loggerTopic.trim().length() == 0) { + loggerName = framework.createFactoryParameter(typeNode, loggingType); + } else { + loggerName = maker.Literal(loggerTopic); + } + JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, List.<JCExpression>of(loggerName)); - + JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef( maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)), typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext()); @@ -111,8 +116,7 @@ public class HandleLog { public static class HandleCommonsLog extends JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> { @Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_COMMONS_FLAG_USAGE, "@apachecommons.CommonsLog", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode); + processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -123,8 +127,7 @@ public class HandleLog { public static class HandleJulLog extends JavacAnnotationHandler<lombok.extern.java.Log> { @Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_JUL_FLAG_USAGE, "@java.Log", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.JUL, annotation, annotationNode); + processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -135,8 +138,7 @@ public class HandleLog { public static class HandleLog4jLog extends JavacAnnotationHandler<lombok.extern.log4j.Log4j> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J_FLAG_USAGE, "@Log4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode); + processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -147,8 +149,7 @@ public class HandleLog { public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_LOG4J2_FLAG_USAGE, "@Log4j2", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode); + processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -159,8 +160,7 @@ public class HandleLog { public static class HandleSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_SLF4J_FLAG_USAGE, "@Slf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode); + processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -171,8 +171,7 @@ public class HandleLog { public static class HandleXSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.XSlf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, JCAnnotation ast, JavacNode annotationNode) { handleFlagUsage(annotationNode, ConfigurationKeys.LOG_XSLF4J_FLAG_USAGE, "@XSlf4j", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log"); - - processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode); + processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().topic()); } } diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java index e57c63dd..172e70b3 100644 --- a/src/core/lombok/javac/handlers/HandleNonNull.java +++ b/src/core/lombok/javac/handlers/HandleNonNull.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Project Lombok Authors. + * Copyright (C) 2013-2014 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 @@ -145,7 +145,7 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> { declaration.body.stats = newList; } - private boolean isNullCheck(JCStatement stat) { + public boolean isNullCheck(JCStatement stat) { return returnVarNameIfNullCheck(stat) != null; } @@ -154,7 +154,7 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> { * where the block braces are optional. If it is of this form, returns "x". * If it is not of this form, returns null. */ - private String returnVarNameIfNullCheck(JCStatement stat) { + public String returnVarNameIfNullCheck(JCStatement stat) { if (!(stat instanceof JCIf)) return null; /* Check that the if's statement is a throw statement, possibly in a block. */ { diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index d73dce7c..fbc9ef46 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -144,13 +144,13 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { } } - private void createSetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public void createSetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { for (JavacNode fieldNode : fieldNodes) { createSetterForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); } } - private void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { if (fieldNode.getKind() != Kind.FIELD) { fieldNode.addError("@Setter is only supported on a class or a field."); return; @@ -193,13 +193,13 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { injectMethod(fieldNode.up(), createdSetter); } - static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { String setterName = toSetterName(field); boolean returnThis = shouldReturnThis(field); return createSetter(access, field, treeMaker, setterName, returnThis, source, onMethod, onParam); } - static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, String setterName, boolean shouldReturnThis, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, String setterName, boolean shouldReturnThis, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { if (setterName == null) return null; JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); @@ -214,7 +214,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { Name methodName = field.toName(setterName); List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(nonNulls).appendList(nullables); - long flags = JavacHandlerUtil.addFinalIfNeeded(0L, field.getContext()); + long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext()); JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null); if (nonNulls.isEmpty()) { diff --git a/src/core/lombok/javac/handlers/HandleSneakyThrows.java b/src/core/lombok/javac/handlers/HandleSneakyThrows.java index 4bd08bbb..ffe37a4c 100644 --- a/src/core/lombok/javac/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/javac/handlers/HandleSneakyThrows.java @@ -42,12 +42,15 @@ import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCBlock; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCStatement; +import com.sun.tools.javac.tree.JCTree.JCTry; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.List; +import lombok.javac.Javac; /** * Handles the {@code lombok.SneakyThrows} annotation for javac. @@ -81,7 +84,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> { } } - private void handleMethod(JavacNode annotation, JCMethodDecl method, Collection<String> exceptions) { + public void handleMethod(JavacNode annotation, JCMethodDecl method, Collection<String> exceptions) { JavacNode methodNode = annotation.up(); if ( (method.mods.flags & Flags.ABSTRACT) != 0) { @@ -111,28 +114,38 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> { methodNode.rebuild(); } - private void generateEmptyBlockWarning(JavacNode methodNode, JavacNode annotation, boolean hasConstructorCall) { + public void generateEmptyBlockWarning(JavacNode methodNode, JavacNode annotation, boolean hasConstructorCall) { if (hasConstructorCall) { annotation.addWarning("Calls to sibling / super constructors are always excluded from @SneakyThrows; @SneakyThrows has been ignored because there is no other code in this constructor."); } else { annotation.addWarning("This method or constructor is empty; @SneakyThrows has been ignored."); } } - - private JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JCTree source) { + + public JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JCTree source) { JavacTreeMaker maker = node.getTreeMaker(); Context context = node.getContext(); JCBlock tryBlock = setGeneratedBy(maker.Block(0, contents), source, context); - JCExpression varType = chainDots(node, exception.split("\\.")); - JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(Flags.FINAL), node.toName("$ex"), varType, null); + JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(Flags.FINAL | Flags.PARAMETER), node.toName("$ex"), varType, null); JCExpression lombokLombokSneakyThrowNameRef = chainDots(node, "lombok", "Lombok", "sneakyThrow"); JCBlock catchBody = maker.Block(0, List.<JCStatement>of(maker.Throw(maker.Apply( List.<JCExpression>nil(), lombokLombokSneakyThrowNameRef, List.<JCExpression>of(maker.Ident(node.toName("$ex"))))))); - - return setGeneratedBy(maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source, context)), null), source, context); + JCTry tryStatement = maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source, context)), null); + if (JavacHandlerUtil.inNetbeansEditor(node)) { + //set span (start and end position) of the try statement and the main block + //this allows NetBeans to dive into the statement correctly: + JCCompilationUnit top = (JCCompilationUnit) node.top().get(); + int startPos = contents.head.pos; + int endPos = Javac.getEndPosition(contents.last().pos(), top); + tryBlock.pos = startPos; + tryStatement.pos = startPos; + Javac.storeEnd(tryBlock, endPos, top); + Javac.storeEnd(tryStatement, endPos, top); + } + return setGeneratedBy(tryStatement, source, context); } } diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java index 98c72645..743e7b26 100644 --- a/src/core/lombok/javac/handlers/HandleToString.java +++ b/src/core/lombok/javac/handlers/HandleToString.java @@ -59,7 +59,7 @@ import com.sun.tools.javac.util.ListBuffer; */ @ProviderFor(JavacAnnotationHandler.class) public class HandleToString extends JavacAnnotationHandler<ToString> { - private void checkForBogusFieldNames(JavacNode type, AnnotationValues<ToString> annotation) { + public void checkForBogusFieldNames(JavacNode type, AnnotationValues<ToString> annotation) { if (annotation.isExplicit("exclude")) { for (int i : createListOfNonExistentFields(List.from(annotation.getInstance().exclude()), type, true, false)) { annotation.setWarning("exclude", "This field does not exist, or would have been excluded anyway.", i); @@ -253,7 +253,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> { List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source, typeNode.getContext()); } - private static String getTypeName(JavacNode typeNode) { + public static String getTypeName(JavacNode typeNode) { String typeName = ((JCClassDecl) typeNode.get()).name.toString(); JavacNode upType = typeNode.up(); while (upType.getKind() == Kind.TYPE) { diff --git a/src/core/lombok/javac/handlers/HandleWither.java b/src/core/lombok/javac/handlers/HandleWither.java index 746f0a2e..7b55b671 100644 --- a/src/core/lombok/javac/handlers/HandleWither.java +++ b/src/core/lombok/javac/handlers/HandleWither.java @@ -145,13 +145,13 @@ public class HandleWither extends JavacAnnotationHandler<Wither> { } } - private void createWitherForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public void createWitherForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { for (JavacNode fieldNode : fieldNodes) { createWitherForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); } } - private void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { if (fieldNode.getKind() != Kind.FIELD) { fieldNode.addError("@Wither is only supported on a class or a field."); return; @@ -204,7 +204,7 @@ public class HandleWither extends JavacAnnotationHandler<Wither> { injectMethod(fieldNode.up(), createdWither); } - private JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { + public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JCTree source, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { String witherName = toWitherName(field); if (witherName == null) return null; @@ -217,7 +217,7 @@ public class HandleWither extends JavacAnnotationHandler<Wither> { Name methodName = field.toName(witherName); List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(nonNulls).appendList(nullables); - long flags = JavacHandlerUtil.addFinalIfNeeded(0L, field.getContext()); + long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext()); JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, fieldDecl.vartype, null); JCExpression selfType = cloneSelfType(field); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 2d859103..37164a6c 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -151,7 +151,7 @@ public class JavacHandlerUtil { if (source == null) generatedNodes.remove(node); else generatedNodes.put(node, new WeakReference<JCTree>(source)); } - if (source != null && !inNetbeansEditor(context)) node.pos = source.pos; + if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos; return node; } @@ -845,7 +845,7 @@ public class JavacHandlerUtil { return typeNode.add(field, Kind.FIELD); } - private static boolean isEnumConstant(final JCVariableDecl field) { + public static boolean isEnumConstant(final JCVariableDecl field) { return (field.mods.flags & Flags.ENUM) != 0; } @@ -920,8 +920,16 @@ public class JavacHandlerUtil { } } - private static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { + public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return; + for (JCAnnotation ann : mods.annotations) { + JCTree annType = ann.getAnnotationType(); + Name lastPart = null; + if (annType instanceof JCIdent) lastPart = ((JCIdent) annType).name; + else if (annType instanceof JCFieldAccess) lastPart = ((JCFieldAccess) annType).name; + + if (lastPart != null && lastPart.contentEquals("SuppressWarnings")) return; + } JavacTreeMaker maker = node.getTreeMaker(); JCExpression suppressWarningsType = genJavaLangTypeRef(node, "SuppressWarnings"); JCLiteral allLiteral = maker.Literal("all"); @@ -1211,7 +1219,7 @@ public class JavacHandlerUtil { return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION); } - private static boolean isClassAndDoesNotHaveFlags(JavacNode typeNode, int flags) { + public static boolean isClassAndDoesNotHaveFlags(JavacNode typeNode, int flags) { JCClassDecl typeDecl = null; if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl)typeNode.get(); else return false; @@ -1296,13 +1304,20 @@ public class JavacHandlerUtil { private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITHER)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); - private static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) { + public static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) { Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(javadoc); return m.replaceAll(""); } - private static String[] splitJavadocOnSectionIfPresent(String javadoc, String sectionName) { + public static String stripSectionsFromJavadoc(String javadoc) { + Matcher m = SECTION_FINDER.matcher(javadoc); + if (!m.find()) return javadoc; + + return javadoc.substring(0, m.start()); + } + + public static String[] splitJavadocOnSectionIfPresent(String javadoc, String sectionName) { Matcher m = SECTION_FINDER.matcher(javadoc); int getterSectionHeaderStart = -1; int getterSectionStart = -1; @@ -1328,15 +1343,17 @@ public class JavacHandlerUtil { } public static enum CopyJavadoc { - VERBATIM, GETTER { + VERBATIM, + GETTER { @Override public String[] split(String javadoc) { // step 1: Check if there is a 'GETTER' section. If yes, that becomes the new method's javadoc and we strip that from the original. String[] out = splitJavadocOnSectionIfPresent(javadoc, "GETTER"); if (out != null) return out; - // failing that, create a copy, but strip @return from the original and @param from the copy. + // failing that, create a copy, but strip @return from the original and @param from the copy, as well as other sections. String copy = javadoc; javadoc = stripLinesWithTagFromJavadoc(javadoc, "@returns?\\s+.*"); copy = stripLinesWithTagFromJavadoc(copy, "@param(?:eter)?\\s+.*"); + copy = stripSectionsFromJavadoc(copy); return new String[] {copy, javadoc}; } }, @@ -1359,6 +1376,7 @@ public class JavacHandlerUtil { String copy = javadoc; javadoc = stripLinesWithTagFromJavadoc(javadoc, "@param(?:eter)?\\s+.*"); copy = stripLinesWithTagFromJavadoc(copy, "@returns?\\s+.*"); + copy = stripSectionsFromJavadoc(copy); return new String[] {copy, javadoc}; } @@ -1372,8 +1390,8 @@ public class JavacHandlerUtil { * Copies javadoc on one node to the other. * * in 'GETTER' copyMode, first a 'GETTER' segment is searched for. If it exists, that will become the javadoc for the 'to' node, and this section is - * stripped out of the 'from' node. If no 'GETTER' segment is found, then the entire javadoc is taken minus any {@code @param} lines. any {@code @return} lines - * are stripped from 'from'. + * stripped out of the 'from' node. If no 'GETTER' segment is found, then the entire javadoc is taken minus any {@code @param} lines and other sections. + * any {@code @return} lines are stripped from 'from'. * * in 'SETTER' mode, stripping works similarly to 'GETTER' mode, except {@code param} are copied and stripped from the original and {@code @return} are skipped. */ diff --git a/src/core/lombok/javac/handlers/package-info.java b/src/core/lombok/javac/handlers/package-info.java index 100a1b96..338feb9b 100644 --- a/src/core/lombok/javac/handlers/package-info.java +++ b/src/core/lombok/javac/handlers/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,5 +22,8 @@ /** * Contains the classes that implement the transformations for all of lombok's various features on the javac v1.6 platform. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.javac.handlers; diff --git a/src/core/lombok/javac/package-info.java b/src/core/lombok/javac/package-info.java index 4093f58e..7ecaea70 100644 --- a/src/core/lombok/javac/package-info.java +++ b/src/core/lombok/javac/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,6 +21,9 @@ */ /** - * Includes the javac v1.6-specific implementations of the lombok AST and annotation introspection support. + * Includes the javac specific implementations of the lombok AST and annotation introspection support. + * + * <strong>NB: This package is not public API in the sense that contents of this package, + * even public classes / methods / etc, may change in point releases.</strong> */ package lombok.javac; diff --git a/src/core/lombok/package-info.java b/src/core/lombok/package-info.java index 1e472074..b5406a74 100644 --- a/src/core/lombok/package-info.java +++ b/src/core/lombok/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,6 +22,13 @@ /** * This package contains all the annotations and support classes you need as a user of lombok. - * All other packages are only relevant to those who are extending lombok for their own uses. + * All other packages are only relevant to those who are extending lombok for their own uses, except: + * + * <ul> + * <li>{@code lombok.extern.*} – These packages contains lombok annotations that solve boilerplate issues for libraries not part of the JRE itself. + * <li>{@code lombok.experimental} – This package contains lombok features that are new or likely to change before committing to long-term support. + * </ul> + * + * @see <a href="http://projectlombok.org/features/index.html">Lombok features</a> */ package lombok; diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 9cb78a82..f64e36a1 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -467,6 +467,7 @@ public class Delombok { public boolean delombok() throws IOException { LombokOptions options = LombokOptionsFactory.getDelombokOptions(context); + options.deleteLombokAnnotations(); options.putJavacOption("ENCODING", charset.name()); if (classpath != null) options.putJavacOption("CLASSPATH", classpath); if (sourcepath != null) options.putJavacOption("SOURCEPATH", sourcepath); diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 506f5a77..1657d2a1 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -591,7 +591,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { for (List<JCTree> l = stats; l.nonEmpty(); l = l.tail) { x++; if (!isEnumerator(l.head)) { - align(); + if (!suppressAlignmentForEmptyLines(l.head)) align(); printStat(l.head); println(); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java index d4b8c763..2370d3ff 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java @@ -256,10 +256,7 @@ public class PatchFixes { org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode) throws Exception { if (internalNode == null || domNode == null) return; boolean isGenerated = internalNode.getClass().getField("$generatedBy").get(internalNode) != null; - if (isGenerated) { - domNode.getClass().getField("$isGenerated").set(domNode, true); - domNode.setFlags(domNode.getFlags() & ~org.eclipse.jdt.core.dom.ASTNode.ORIGINAL); - } + if (isGenerated) domNode.getClass().getField("$isGenerated").set(domNode, true); } public static void setIsGeneratedFlagForName(org.eclipse.jdt.core.dom.Name name, Object internalNode) throws Exception { diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java index 16f11769..59fbe9d0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java @@ -53,12 +53,20 @@ public class PatchVal { public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) { if (expr.resolvedType != null) return expr.resolvedType; - return expr.resolveType(scope); + try { + return expr.resolveType(scope); + } catch (NullPointerException e) { + return null; + } } public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) { if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType; - return expr.resolveType(scope); + try { + return expr.resolveType(scope); + } catch (NullPointerException e) { + return null; + } } public static boolean matches(String key, char[] array) { @@ -143,7 +151,20 @@ public class PatchVal { TypeReference replacement = null; if (init != null) { - TypeBinding resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope); + if (init.getClass().getName().equals("org.eclipse.jdt.internal.compiler.ast.LambdaExpression")) { + return false; + } + + TypeBinding resolved = null; + try { + resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope); + } catch (NullPointerException e) { + // This definitely occurs if as part of resolving the initializer expression, a + // lambda expression in it must also be resolved (such as when lambdas are part of + // a ternary expression). This can't result in a viable 'val' matching, so, we + // just go with 'Object' and let the IDE print the appropriate errors. + resolved = null; + } if (resolved != null) { replacement = makeType(resolved, local.type, false); } diff --git a/src/installer/lombok/installer/IdeLocation.java b/src/installer/lombok/installer/IdeLocation.java index 4d28fb90..4e3a7e41 100644 --- a/src/installer/lombok/installer/IdeLocation.java +++ b/src/installer/lombok/installer/IdeLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ import java.io.IOException; import java.net.URL; import lombok.installer.eclipse.EclipseFinder; -import lombok.patcher.inject.LiveInjector; +import lombok.patcher.ClassRootFinder; /** * Represents a location that contains an IDE. @@ -46,7 +46,7 @@ public abstract class IdeLocation { * a jar that wasn't accessed via the file-system, or if its started via e.g. unpacking the jar. */ public static File findOurJar() { - return new File(LiveInjector.findPathJar(IdeFinder.class)); + return new File(ClassRootFinder.findClassRootOfClass(IdeFinder.class)); } @Override public String toString() { diff --git a/src/installer/lombok/installer/Installer.java b/src/installer/lombok/installer/Installer.java index 29ffde89..b9faeebd 100644 --- a/src/installer/lombok/installer/Installer.java +++ b/src/installer/lombok/installer/Installer.java @@ -39,7 +39,7 @@ import lombok.core.LombokApp; import lombok.core.SpiLoadUtil; import lombok.core.Version; import lombok.installer.IdeFinder.OS; -import lombok.patcher.inject.LiveInjector; +import lombok.patcher.ClassRootFinder; import org.mangosdk.spi.ProviderFor; @@ -101,7 +101,7 @@ public class Installer { } public static boolean isSelf(String jar) { - String self = LiveInjector.findPathJar(Installer.class); + String self = ClassRootFinder.findClassRootOfClass(Installer.class); if (self == null) return false; File a = new File(jar).getAbsoluteFile(); File b = new File(self).getAbsoluteFile(); diff --git a/src/installer/lombok/installer/InstallerGUI.java b/src/installer/lombok/installer/InstallerGUI.java index 69630793..5717948a 100644 --- a/src/installer/lombok/installer/InstallerGUI.java +++ b/src/installer/lombok/installer/InstallerGUI.java @@ -793,7 +793,7 @@ public class InstallerGUI { "<html><font size=\"+1\"><b><i>IDEs</i></b></font></html>"; private static final String IDE_EXPLANATION = - "<html>Lombok can update your Eclipse and Netbeans to fully support all Lombok features.<br>" + + "<html>Lombok can update your Eclipse or eclipse-based IDE to fully support all Lombok features.<br>" + "Select IDE installations below and hit 'Install/Update'.</html>"; private static final String IDE_LOADING_EXPLANATION = @@ -824,13 +824,7 @@ public class InstallerGUI { "<pre>-Xbootclasspath/a:lombok.jar<br>" + "-javaagent:lombok.jar</pre></li></ol>" + "On Mac OS X, eclipse.ini is hidden in<br>" + - "<code>Eclipse.app/Contents/MacOS</code> so that's where I place the jar files.<p>" + - "<h2>Netbeans</h2><ol>" + - "<li>First, I copy myself (lombok.jar) to your Netbeans install directory.</li>" + - "<lI>Then, I edit <i>etc%1$snetbeans.conf</i> to add the following argument to<br><b>netbeans_default_options</b>:<br>" + - "<pre>-J-javaagent:lombok.jar</pre></li></ol>" + - "On Mac OS X, your netbeans directory is hidden in<br>" + - "<code>NetBeans.app/Contents/Resources/NetBeans</code></html>"; + "<code>Eclipse.app/Contents/MacOS</code> so that's where I place the jar files.</html>"; private static class JHyperLink extends JButton { private static final long serialVersionUID = 1L; diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index bdf5e7a0..e207c44a 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -177,7 +177,7 @@ public class Javac { public static final TreeTag CTC_PREINC = treeTag("PREINC"); public static final TreeTag CTC_PREDEC = treeTag("PREDEC"); - private static final Method getExtendsClause, getEndPosition; + private static final Method getExtendsClause, getEndPosition, storeEnd; static { getExtendsClause = getMethod(JCClassDecl.class, "getExtendsClause", new Class<?>[0]); @@ -185,10 +185,32 @@ public class Javac { if (getJavaCompilerVersion() < 8) { getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", java.util.Map.class); + storeEnd = getMethod(java.util.Map.class, "put", Object.class, Object.class); } else { getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", "com.sun.tools.javac.tree.EndPosTable"); + Method storeEndMethodTemp; + Class<?> endPosTable; + try { + endPosTable = Class.forName("com.sun.tools.javac.tree.EndPosTable"); + } catch (ClassNotFoundException ex) { + throw sneakyThrow(ex); + } + try { + storeEndMethodTemp = endPosTable.getMethod("storeEnd", JCTree.class, int.class); + } catch (NoSuchMethodException e) { + try { + endPosTable = Class.forName("com.sun.tools.javac.parser.JavacParser$AbstractEndPosTable"); + storeEndMethodTemp = endPosTable.getDeclaredMethod("storeEnd", JCTree.class, int.class); + } catch (NoSuchMethodException ex) { + throw sneakyThrow(ex); + } catch (ClassNotFoundException ex) { + throw sneakyThrow(ex); + } + } + storeEnd = storeEndMethodTemp; } getEndPosition.setAccessible(true); + storeEnd.setAccessible(true); } private static Method getMethod(Class<?> clazz, String name, Class<?>... paramTypes) { @@ -250,6 +272,17 @@ public class Javac { } } + public static void storeEnd(JCTree tree, int pos, JCCompilationUnit top) { + try { + Object endPositions = JCCOMPILATIONUNIT_ENDPOSITIONS.get(top); + storeEnd.invoke(endPositions, tree, pos); + } catch (IllegalAccessException e) { + throw sneakyThrow(e); + } catch (InvocationTargetException e) { + throw sneakyThrow(e.getCause()); + } + } + private static final Class<?> JC_VOID_TYPE, JC_NO_TYPE; static { diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index 9b256b36..34f6cbf4 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -218,8 +218,8 @@ public abstract class AbstractRunTests { } for (int i = 0; i < size; i++) { - String expected = expectedLines[i]; - String actual = actualLines[i]; + String expected = trimRight(expectedLines[i]); + String actual = trimRight(actualLines[i]); assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual); } if (expectedLines.length > actualLines.length) { @@ -230,6 +230,15 @@ public abstract class AbstractRunTests { } } + private static String trimRight(String in) { + int endIdx = in.length() - 1; + while (endIdx > -1 && Character.isWhitespace(in.charAt(endIdx))) { + endIdx--; + } + + return in.substring(0, endIdx); + } + private static String[] removeBlanks(String[] in) { List<String> out = new ArrayList<String>(); for (String s : in) { diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index 695ff0a9..2734eb43 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -70,6 +70,7 @@ public class RunTestsViaEcj extends AbstractRunTests { warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore"); + warnings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); options.set(warnings); return options; } diff --git a/test/transform/resource/after-delombok/Accessors.java b/test/transform/resource/after-delombok/Accessors.java index 28ffc531..8b984236 100644 --- a/test/transform/resource/after-delombok/Accessors.java +++ b/test/transform/resource/after-delombok/Accessors.java @@ -84,7 +84,7 @@ class AccessorsPrefix3 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $fName = this.getName(); result = result * PRIME + ($fName == null ? 0 : $fName.hashCode()); diff --git a/test/transform/resource/after-delombok/DataExtended.java b/test/transform/resource/after-delombok/DataExtended.java index d580b885..07aa1f7e 100644 --- a/test/transform/resource/after-delombok/DataExtended.java +++ b/test/transform/resource/after-delombok/DataExtended.java @@ -28,7 +28,7 @@ class DataExtended { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); return result; diff --git a/test/transform/resource/after-delombok/DataIgnore.java b/test/transform/resource/after-delombok/DataIgnore.java index b74b6a8f..fa729ada 100644 --- a/test/transform/resource/after-delombok/DataIgnore.java +++ b/test/transform/resource/after-delombok/DataIgnore.java @@ -27,7 +27,7 @@ class DataIgnore { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); return result; diff --git a/test/transform/resource/after-delombok/DataOnLocalClass.java b/test/transform/resource/after-delombok/DataOnLocalClass.java index abe2757b..bbd9ae4b 100644 --- a/test/transform/resource/after-delombok/DataOnLocalClass.java +++ b/test/transform/resource/after-delombok/DataOnLocalClass.java @@ -39,7 +39,7 @@ class DataOnLocalClass1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -99,7 +99,7 @@ class DataOnLocalClass2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); @@ -136,7 +136,7 @@ class DataOnLocalClass2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); return result; diff --git a/test/transform/resource/after-delombok/DataPlain.java b/test/transform/resource/after-delombok/DataPlain.java index a8cb37af..6d536c8a 100644 --- a/test/transform/resource/after-delombok/DataPlain.java +++ b/test/transform/resource/after-delombok/DataPlain.java @@ -38,7 +38,7 @@ class Data1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -91,7 +91,7 @@ class Data2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -139,7 +139,7 @@ final class Data3 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -187,7 +187,7 @@ final class Data4 extends java.util.Timer { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + super.hashCode(); result = result * PRIME + this.getX(); diff --git a/test/transform/resource/after-delombok/DataWithGetter.java b/test/transform/resource/after-delombok/DataWithGetter.java index 95a4bcbc..b429fe53 100644 --- a/test/transform/resource/after-delombok/DataWithGetter.java +++ b/test/transform/resource/after-delombok/DataWithGetter.java @@ -36,7 +36,7 @@ class DataWithGetter { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); result = result * PRIME + this.getY(); diff --git a/test/transform/resource/after-delombok/DataWithGetterNone.java b/test/transform/resource/after-delombok/DataWithGetterNone.java index 2dea5e49..b063b4ff 100644 --- a/test/transform/resource/after-delombok/DataWithGetterNone.java +++ b/test/transform/resource/after-delombok/DataWithGetterNone.java @@ -36,7 +36,7 @@ class DataWithGetterNone { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; result = result * PRIME + this.y; diff --git a/test/transform/resource/after-delombok/EqualsAndHashCode.java b/test/transform/resource/after-delombok/EqualsAndHashCode.java index 8f84fb22..afe03dea 100644 --- a/test/transform/resource/after-delombok/EqualsAndHashCode.java +++ b/test/transform/resource/after-delombok/EqualsAndHashCode.java @@ -29,7 +29,7 @@ class EqualsAndHashCode { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; result = result * PRIME + java.util.Arrays.hashCode(this.y); @@ -46,6 +46,7 @@ final class EqualsAndHashCode2 { long y; float f; double d; + boolean b; @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -56,12 +57,13 @@ final class EqualsAndHashCode2 { if (this.y != other.y) return false; if (java.lang.Float.compare(this.f, other.f) != 0) return false; if (java.lang.Double.compare(this.d, other.d) != 0) return false; + if (this.b != other.b) return false; return true; } @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; final long $y = this.y; @@ -69,6 +71,7 @@ final class EqualsAndHashCode2 { result = result * PRIME + java.lang.Float.floatToIntBits(this.f); final long $d = java.lang.Double.doubleToLongBits(this.d); result = result * PRIME + (int)($d >>> 32 ^ $d); + result = result * PRIME + (this.b ? 79 : 97); return result; } } @@ -111,7 +114,7 @@ class EqualsAndHashCode4 extends EqualsAndHashCode { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + super.hashCode(); return result; diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java index 0a6b1e7f..aa9b984f 100644 --- a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java @@ -69,7 +69,7 @@ class EqualsAndHashCodeWithNoExistingMethods { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; return result; diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java index 08d32013..eb6662e2 100644 --- a/test/transform/resource/after-delombok/GetterLazyBoolean.java +++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java @@ -21,9 +21,9 @@ class GetterLazyBoolean { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; - result = result * PRIME + (this.isBooleanValue() ? 1231 : 1237); + result = result * PRIME + (this.isBooleanValue() ? 79 : 97); return result; } @java.lang.Override diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java index 1358e536..3e98a25e 100644 --- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java +++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java @@ -27,7 +27,7 @@ class GetterLazyEahcToString { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = result * PRIME + ($value == null ? 0 : $value.hashCode()); diff --git a/test/transform/resource/after-delombok/GetterSetterJavadoc.java b/test/transform/resource/after-delombok/GetterSetterJavadoc.java index af9cbb5e..743a3aac 100644 --- a/test/transform/resource/after-delombok/GetterSetterJavadoc.java +++ b/test/transform/resource/after-delombok/GetterSetterJavadoc.java @@ -41,7 +41,7 @@ class GetterSetterJavadoc1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getFieldName(); return result; diff --git a/test/transform/resource/after-delombok/LoggerCommons.java b/test/transform/resource/after-delombok/LoggerCommons.java index 6feea5b6..32ace53a 100644 --- a/test/transform/resource/after-delombok/LoggerCommons.java +++ b/test/transform/resource/after-delombok/LoggerCommons.java @@ -5,4 +5,8 @@ class LoggerCommons { class LoggerCommonsWithImport { @java.lang.SuppressWarnings("all") private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class); +} +class LoggerCommonsWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java index 20f0d24d..ad119777 100644 --- a/test/transform/resource/after-delombok/LoggerJul.java +++ b/test/transform/resource/after-delombok/LoggerJul.java @@ -5,4 +5,8 @@ class LoggerJul { class LoggerJulWithImport { @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName()); +} +class LoggerJulWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerLog4j.java b/test/transform/resource/after-delombok/LoggerLog4j.java index 7d54b259..99eac34f 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j.java +++ b/test/transform/resource/after-delombok/LoggerLog4j.java @@ -5,4 +5,8 @@ class LoggerLog4j { class LoggerLog4jWithImport { @java.lang.SuppressWarnings("all") private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class); +} +class LoggerLog4jWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java index 7e4c01de..8473134b 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j2.java +++ b/test/transform/resource/after-delombok/LoggerLog4j2.java @@ -5,4 +5,8 @@ class LoggerLog4j2 { class LoggerLog4j2WithImport { @java.lang.SuppressWarnings("all") private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class); +} +class LoggerLog4j2WithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java index a07c8546..3c6e6d2f 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerSlf4j.java @@ -11,4 +11,9 @@ class LoggerSlf4jOuter { @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); } +} + +class LoggerSlf4jWithDifferentLoggerName { + @java.lang.SuppressWarnings("all") + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerXSlf4j.java b/test/transform/resource/after-delombok/LoggerXSlf4j.java index 981bcca6..d0654b51 100644 --- a/test/transform/resource/after-delombok/LoggerXSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerXSlf4j.java @@ -5,4 +5,8 @@ class LoggerXSlf4j { class LoggerXSlf4jWithImport { @java.lang.SuppressWarnings("all") private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithImport.class); +} +class LoggerXSlf4jWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName"); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java index d1cfa3d7..e880454b 100644 --- a/test/transform/resource/after-delombok/ValuePlain.java +++ b/test/transform/resource/after-delombok/ValuePlain.java @@ -30,7 +30,7 @@ final class Value1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -80,7 +80,7 @@ class Value2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -123,7 +123,7 @@ final class Value3 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); result = result * PRIME + this.getY(); diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index 292db928..c8fdc3bf 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -90,7 +90,7 @@ class AccessorsChain { return (other instanceof AccessorsPrefix3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $fName = this.getName(); result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode())); diff --git a/test/transform/resource/after-ecj/DataExtended.java b/test/transform/resource/after-ecj/DataExtended.java index 1de635e3..bcfd26e3 100644 --- a/test/transform/resource/after-ecj/DataExtended.java +++ b/test/transform/resource/after-ecj/DataExtended.java @@ -22,7 +22,7 @@ return (other instanceof DataExtended); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java index 7d99a20f..d0e72e15 100644 --- a/test/transform/resource/after-ecj/DataIgnore.java +++ b/test/transform/resource/after-ecj/DataIgnore.java @@ -20,7 +20,7 @@ return (other instanceof DataIgnore); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 2f8dcca1..511291c2 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -36,7 +36,7 @@ class DataOnLocalClass1 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -86,7 +86,7 @@ class DataOnLocalClass2 { return (other instanceof Local.InnerLocal); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $name = this.getName(); result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); @@ -124,7 +124,7 @@ class DataOnLocalClass2 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index 1b33070b..aa47fdaa 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -31,7 +31,7 @@ import lombok.Data; return (other instanceof Data1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -78,7 +78,7 @@ import lombok.Data; return (other instanceof Data2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -120,7 +120,7 @@ final @Data class Data3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -167,7 +167,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java return (other instanceof Data4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); result = ((result * PRIME) + this.getX()); diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index 9d3dfd3e..2ce74ceb 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetter); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index b6b391c8..087d0762 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetterNone); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + this.y); diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java index 33ef799d..625a0f87 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCode.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java @@ -35,7 +35,7 @@ return (other instanceof EqualsAndHashCode); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + java.util.Arrays.hashCode(this.y)); @@ -52,6 +52,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { long y; float f; double d; + boolean b; EqualsAndHashCode2() { super(); } @@ -69,10 +70,12 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { return false; if ((java.lang.Double.compare(this.d, other.d) != 0)) return false; + if ((this.b != other.b)) + return false; return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); final long $y = this.y; @@ -80,6 +83,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { result = ((result * PRIME) + java.lang.Float.floatToIntBits(this.f)); final long $d = java.lang.Double.doubleToLongBits(this.d); result = ((result * PRIME) + (int) ($d ^ ($d >>> 32))); + result = ((result * PRIME) + (this.b ? 79 : 97)); return result; } } @@ -125,7 +129,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte return (other instanceof EqualsAndHashCode4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); return result; diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java index cdd771a4..05f7ad97 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java @@ -57,7 +57,7 @@ import static lombok.AccessLevel.NONE; return (other instanceof EqualsAndHashCodeWithNoExistingMethods); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); return result; diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index a51b164f..c37eece2 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -57,9 +57,9 @@ return (other instanceof GetterLazyBoolean); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; - result = ((result * PRIME) + (this.isBooleanValue() ? 1231 : 1237)); + result = ((result * PRIME) + (this.isBooleanValue() ? 79 : 97)); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index db2d4fcf..da9f6a83 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -46,7 +46,7 @@ return (other instanceof GetterLazyEahcToString); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = ((result * PRIME) + (($value == null) ? 0 : $value.hashCode())); diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java index 73f26180..b7fc15b8 100644 --- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java +++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java @@ -22,7 +22,7 @@ return (other instanceof GetterSetterJavadoc1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getFieldName()); return result; diff --git a/test/transform/resource/after-ecj/LoggerCommons.java b/test/transform/resource/after-ecj/LoggerCommons.java index d63bb9c1..df102a12 100644 --- a/test/transform/resource/after-ecj/LoggerCommons.java +++ b/test/transform/resource/after-ecj/LoggerCommons.java @@ -14,4 +14,12 @@ import lombok.extern.apachecommons.CommonsLog; LoggerCommonsWithImport() { super(); } +} +@CommonsLog(topic = "DifferentName") class LoggerCommonsWithDifferentName { + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName"); + <clinit>() { + } + LoggerCommonsWithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java index c98dfe27..8aa4f59a 100644 --- a/test/transform/resource/after-ecj/LoggerJul.java +++ b/test/transform/resource/after-ecj/LoggerJul.java @@ -14,4 +14,12 @@ import lombok.extern.java.Log; LoggerJulWithImport() { super(); } +} +@Log(topic = "DifferentName") class LoggerJulWithDifferentName { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName"); + <clinit>() { + } + LoggerJulWithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j.java b/test/transform/resource/after-ecj/LoggerLog4j.java index 6814be7b..948412e2 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j.java +++ b/test/transform/resource/after-ecj/LoggerLog4j.java @@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j; LoggerLog4jWithImport() { super(); } +} +@Log4j(topic = "DifferentName") class LoggerLog4jWithDifferentName { + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName"); + <clinit>() { + } + LoggerLog4jWithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j2.java b/test/transform/resource/after-ecj/LoggerLog4j2.java index c1368e5d..c2fcd428 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j2.java +++ b/test/transform/resource/after-ecj/LoggerLog4j2.java @@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j2; LoggerLog4j2WithImport() { super(); } +} +@Log4j2(topic = "DifferentName") class LoggerLog4j2WithDifferentName { + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); + <clinit>() { + } + LoggerLog4j2WithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java index 1ccf5c9e..9c5405cb 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerSlf4j.java @@ -27,4 +27,13 @@ class LoggerSlf4jOuter { LoggerSlf4jOuter() { super(); } +} + +@Slf4j(topic = "DifferentLogger") class LoggerSlf4jWithDifferentLoggerName { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger"); + <clinit>() { + } + LoggerSlf4jWithDifferentLoggerName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerXSlf4j.java b/test/transform/resource/after-ecj/LoggerXSlf4j.java index f05e1ae7..916859a4 100644 --- a/test/transform/resource/after-ecj/LoggerXSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerXSlf4j.java @@ -14,4 +14,12 @@ import lombok.extern.slf4j.XSlf4j; LoggerXSlf4jWithImport() { super(); } +} +@XSlf4j(topic = "DifferentName") class LoggerXSlf4jWithDifferentName { + private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName"); + <clinit>() { + } + LoggerXSlf4jWithDifferentName() { + super(); + } }
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java index fac8dcdd..1a57be29 100644 --- a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java +++ b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java @@ -11,7 +11,8 @@ class NonNullWithSneakyThrows { } System.out.println(in); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsMultiple.java b/test/transform/resource/after-ecj/SneakyThrowsMultiple.java index 82eda411..65862c2b 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsMultiple.java +++ b/test/transform/resource/after-ecj/SneakyThrowsMultiple.java @@ -13,11 +13,13 @@ class SneakyThrowsMultiple { System.out.println("test1"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -36,11 +38,13 @@ class SneakyThrowsMultiple { throw new AWTException("WHAT"); } } - catch (final AWTException $ex) { + catch (final AWTException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -52,11 +56,13 @@ class SneakyThrowsMultiple { System.out.println("test3"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsPlain.java b/test/transform/resource/after-ecj/SneakyThrowsPlain.java index 1b45dc5a..df436891 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsPlain.java +++ b/test/transform/resource/after-ecj/SneakyThrowsPlain.java @@ -6,7 +6,8 @@ class SneakyThrowsPlain { { System.out.println("constructor"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -16,7 +17,8 @@ class SneakyThrowsPlain { { System.out.println("constructor2"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -25,7 +27,8 @@ class SneakyThrowsPlain { { System.out.println("test1"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -34,7 +37,8 @@ class SneakyThrowsPlain { { System.out.println("test2"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsSingle.java b/test/transform/resource/after-ecj/SneakyThrowsSingle.java index eea593f2..073d690a 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsSingle.java +++ b/test/transform/resource/after-ecj/SneakyThrowsSingle.java @@ -8,7 +8,8 @@ class SneakyThrowsSingle { { System.out.println("test1"); } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -18,7 +19,8 @@ class SneakyThrowsSingle { System.out.println("test2"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -28,7 +30,8 @@ class SneakyThrowsSingle { System.out.println("test3"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/ValComplex.java b/test/transform/resource/after-ecj/ValComplex.java index 6e435e56..746e3088 100644 --- a/test/transform/resource/after-ecj/ValComplex.java +++ b/test/transform/resource/after-ecj/ValComplex.java @@ -16,7 +16,7 @@ public class ValComplex { final @val int field = 20; final @val int inner = 10; switch (field) { - case 5 : ; + case 5 : final @val char[] shouldBeCharArray2 = shouldBeCharArray; final @val int innerInner = inner; } diff --git a/test/transform/resource/after-ecj/ValInTryWithResources.java b/test/transform/resource/after-ecj/ValInTryWithResources.java index 5b354bdf..a532d48c 100644 --- a/test/transform/resource/after-ecj/ValInTryWithResources.java +++ b/test/transform/resource/after-ecj/ValInTryWithResources.java @@ -1 +1,14 @@ -//ignore: This is a J7 feature that isn't turned on in the ecj variant we use to run the tests. We need to update that ecj at some point and enable this test.
\ No newline at end of file +import lombok.val; +import java.io.IOException; +public class ValInTryWithResources { + public ValInTryWithResources() { + super(); + } + public void whyTryInsteadOfCleanup() throws IOException { + try (final @val java.io.InputStream in = getClass().getResourceAsStream("ValInTryWithResources.class")) + { + final @val java.io.InputStream i = in; + final @val int j = in.read(); + } + } +} diff --git a/test/transform/resource/after-ecj/ValLessSimple.java b/test/transform/resource/after-ecj/ValLessSimple.java index c7587f91..28772d68 100644 --- a/test/transform/resource/after-ecj/ValLessSimple.java +++ b/test/transform/resource/after-ecj/ValLessSimple.java @@ -32,7 +32,8 @@ public class ValLessSimple { { final @val int x = (1 / 0); } - catch (ArithmeticException e) { + catch (ArithmeticException e) + { final @val int y = 0; } } diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index d095913f..5ca32af8 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -23,7 +23,7 @@ final @lombok.Value class Value1 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -68,7 +68,7 @@ final @lombok.Value class Value1 { return (other instanceof Value2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -106,7 +106,7 @@ final @Value class Value3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/before/DelegateOnStatic.java b/test/transform/resource/before/DelegateOnStatic.java new file mode 100644 index 00000000..84d99636 --- /dev/null +++ b/test/transform/resource/before/DelegateOnStatic.java @@ -0,0 +1,13 @@ +//skip compare content +import lombok.Delegate; +import lombok.Getter; + +class DelegateOnStatic { + @Delegate private static final java.lang.Runnable staticField = null; +} + +class DelegateOnStaticMethod { + @Delegate private static final java.lang.Runnable staticMethod() { + return null; + }; +}
\ No newline at end of file diff --git a/test/transform/resource/before/EqualsAndHashCode.java b/test/transform/resource/before/EqualsAndHashCode.java index 0a1e3290..660f923a 100644 --- a/test/transform/resource/before/EqualsAndHashCode.java +++ b/test/transform/resource/before/EqualsAndHashCode.java @@ -13,6 +13,7 @@ final class EqualsAndHashCode2 { long y; float f; double d; + boolean b; } @lombok.EqualsAndHashCode(callSuper=false) diff --git a/test/transform/resource/before/LoggerCommons.java b/test/transform/resource/before/LoggerCommons.java index 52210d25..00419d00 100644 --- a/test/transform/resource/before/LoggerCommons.java +++ b/test/transform/resource/before/LoggerCommons.java @@ -6,4 +6,8 @@ class LoggerCommons { @CommonsLog class LoggerCommonsWithImport { -}
\ No newline at end of file +} + +@CommonsLog(topic="DifferentName") +class LoggerCommonsWithDifferentName { +} diff --git a/test/transform/resource/before/LoggerJul.java b/test/transform/resource/before/LoggerJul.java index 52869e81..006cc344 100644 --- a/test/transform/resource/before/LoggerJul.java +++ b/test/transform/resource/before/LoggerJul.java @@ -6,4 +6,8 @@ class LoggerJul { @Log class LoggerJulWithImport { +} + +@Log(topic="DifferentName") +class LoggerJulWithDifferentName { }
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j.java b/test/transform/resource/before/LoggerLog4j.java index 03735bff..351049c5 100644 --- a/test/transform/resource/before/LoggerLog4j.java +++ b/test/transform/resource/before/LoggerLog4j.java @@ -6,4 +6,8 @@ class LoggerLog4j { @Log4j class LoggerLog4jWithImport { +} + +@Log4j(topic="DifferentName") +class LoggerLog4jWithDifferentName { }
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java index b7ea99ee..c9cf9412 100644 --- a/test/transform/resource/before/LoggerLog4j2.java +++ b/test/transform/resource/before/LoggerLog4j2.java @@ -6,4 +6,8 @@ class LoggerLog4j2 { @Log4j2 class LoggerLog4j2WithImport { +} + +@Log4j2(topic="DifferentName") +class LoggerLog4j2WithDifferentName { }
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java index 133ee36e..1113a63e 100644 --- a/test/transform/resource/before/LoggerSlf4j.java +++ b/test/transform/resource/before/LoggerSlf4j.java @@ -13,4 +13,8 @@ class LoggerSlf4jOuter { static class Inner { } +} + +@Slf4j(topic="DifferentLogger") +class LoggerSlf4jWithDifferentLoggerName { }
\ No newline at end of file diff --git a/test/transform/resource/before/LoggerXSlf4j.java b/test/transform/resource/before/LoggerXSlf4j.java index 6dbbf2d1..a8bcb0c3 100644 --- a/test/transform/resource/before/LoggerXSlf4j.java +++ b/test/transform/resource/before/LoggerXSlf4j.java @@ -6,4 +6,8 @@ class LoggerXSlf4j { @XSlf4j class LoggerXSlf4jWithImport { +} + +@XSlf4j(topic="DifferentName") +class LoggerXSlf4jWithDifferentName { }
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages b/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages new file mode 100644 index 00000000..51dcf501 --- /dev/null +++ b/test/transform/resource/messages-delombok/DelegateOnStatic.java.messages @@ -0,0 +1,2 @@ +6 @Delegate is legal only on instance fields or no-argument instance methods. +10 @Delegate is legal only on instance fields or no-argument instance methods.
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages b/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages new file mode 100644 index 00000000..51dcf501 --- /dev/null +++ b/test/transform/resource/messages-ecj/DelegateOnStatic.java.messages @@ -0,0 +1,2 @@ +6 @Delegate is legal only on instance fields or no-argument instance methods. +10 @Delegate is legal only on instance fields or no-argument instance methods.
\ No newline at end of file diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage index 3dc675e9..29e7e328 100644 --- a/usage_examples/DataExample_post.jpage +++ b/usage_examples/DataExample_post.jpage @@ -55,7 +55,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.getScore()); result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); @@ -101,7 +101,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); result = (result*PRIME) + (this.getValue() == null ? 0 : this.getValue().hashCode()); diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage index 4a90e7dc..aa6a44ba 100644 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ b/usage_examples/EqualsAndHashCodeExample_post.jpage @@ -24,7 +24,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.score); result = (result*PRIME) + (this.name == null ? 0 : this.name.hashCode()); @@ -57,7 +57,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; result = (result*PRIME) + super.hashCode(); result = (result*PRIME) + this.width; diff --git a/usage_examples/LogExample_post.jpage b/usage_examples/LogExample_post.jpage index cbdc5a9e..eab3b046 100644 --- a/usage_examples/LogExample_post.jpage +++ b/usage_examples/LogExample_post.jpage @@ -1,5 +1,5 @@ public class LogExample { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class); + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName()); public static void main(String... args) { log.error("Something's wrong here"); @@ -7,9 +7,17 @@ public class LogExample { } public class LogExampleOther { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.util.List.class); + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExampleOther.class); public static void main(String... args) { - log.warn("Something might be wrong here"); + log.error("Something else is wrong here"); + } +} + +public class LogExampleCategory { + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("CounterLog"); + + public static void main(String... args) { + log.error("Calling the 'CounterLog' with a message"); } } diff --git a/usage_examples/LogExample_pre.jpage b/usage_examples/LogExample_pre.jpage index 7ab64cd4..ba27dd27 100644 --- a/usage_examples/LogExample_pre.jpage +++ b/usage_examples/LogExample_pre.jpage @@ -1,4 +1,5 @@ -import lombok.extern.slf4j.Log; +import lombok.extern.java.Log; +import lombok.extern.slf4j.Slf4j; @Log public class LogExample { @@ -8,10 +9,18 @@ public class LogExample { } } -@Log(java.util.List.class) +@Slf4j public class LogExampleOther { public static void main(String... args) { - log.warn("Something might be wrong here"); + log.error("Something else is wrong here"); + } +} + +@CommonsLog(topic="CounterLog") +public class LogExampleCategory { + + public static void main(String... args) { + log.error("Calling the 'CounterLog' with a message"); } } diff --git a/usage_examples/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage index ac9b64d1..4ac8654e 100644 --- a/usage_examples/ValueExample_post.jpage +++ b/usage_examples/ValueExample_post.jpage @@ -46,7 +46,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); @@ -103,7 +103,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 31; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); diff --git a/website/features/Constructor.html b/website/features/Constructor.html index cdd5b4e2..272df06e 100644 --- a/website/features/Constructor.html +++ b/website/features/Constructor.html @@ -22,7 +22,7 @@ fulfilled until those fields are properly initialized later. Certain java constructs, such as hibernate and the Service Provider Interface require a no-args constructor. This annotation is useful primarily in combination with either <code>@Data</code> or one of the other constructor generating annotations. </p><p> - <code>@RequiredArgsConstructor</code> generates a constructor with 1 parameter for each field that requires special handling. All <code>final</code> fields get a parameter, + <code>@RequiredArgsConstructor</code> generates a constructor with 1 parameter for each field that requires special handling. All non-initialized <code>final</code> fields get a parameter, as well as any fields that are marked as <code>@NonNull</code> that aren't initialized where they are declared. For those fields marked with <code>@NonNull</code>, an explicit null check is also generated. The constructor will throw a <code>NullPointerException</code> if any of the parameters intended for the fields marked with <code>@NonNull</code> contain <code>null</code>. The order of the parameters match the order in which the fields appear in your class. diff --git a/website/features/Data.html b/website/features/Data.html index ad3aa892..4d6e5609 100644 --- a/website/features/Data.html +++ b/website/features/Data.html @@ -38,7 +38,7 @@ </p><p> If the class already contains a method with the same name as any method that would normally be generated, that method is not generated, and no warning or error is emitted. For example, if you already have a method with signature <code>void hashCode(int a, int b, int c)</code>, no <code>int hashCode()</code> - method will be generated, even though technically <code>int hashCode()</code> is an entirely different method. The same rule applies to the constructor, + method will be generated, even though technically <code>int hashCode()</code> is an entirely different method. The same rule applies to the constructor (any explicit constructor will prevent <code>@Data</code> from generating one), <code>toString</code>, <code>equals</code>, and all getters and setters. </p><p> <code>@Data</code> can handle generics parameters for fields just fine. In order to reduce the boilerplate when constructing objects for classes with diff --git a/website/features/Log.html b/website/features/Log.html index 2d4fa375..bc9e017e 100644 --- a/website/features/Log.html +++ b/website/features/Log.html @@ -31,8 +31,10 @@ <dt><code>@Slf4j</code></dt> <dd>Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/Logger.html">org.slf4j.Logger</a> <span class="staticfield">log</span> = <a href="http://www.slf4j.org/apidocs/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)">org.slf4j.LoggerFactory.getLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd> <dt><code>@XSlf4j</code></dt> - <dd>Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a> <span class="staticfield">log</span> = <a href="http://www.slf4j.org/apidocs/org/slf4j/ext/XLoggerFactory.html#getXLogger(java.lang.Class)">org.slf4j.XLoggerFactory.getXLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd> + <dd>Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a> <span class="staticfield">log</span> = <a href="http://www.slf4j.org/apidocs/org/slf4j/ext/XLoggerFactory.html#getXLogger(java.lang.Class)">org.slf4j.ext.XLoggerFactory.getXLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd> </dl> + </p><p> + By default, the topic (or name) of the logger will be the class name of the class annotated with the <code>@Log</code> annotation. This can be customised by specifying the <code>topic</code> parameter. For example: <code>@XSlf4j(topic="reporting")</code>. </p> </div> <div class="snippets"> @@ -52,10 +54,7 @@ <p> If a field called <code>log</code> already exists, a warning will be emitted and no code will be generated. </p><p> - A future feature of lombok's diverse log annotations is to find calls to the logger field and, if the chosen logging framework supports - it and the log level can be compile-time determined from the log call, guard it with an <code>if</code> statement. This way if - the log statement ends up being ignored, the potentially expensive calculation of the log string is avoided entirely. This does mean - that you should <em>NOT</em> put any side-effects in the expression that you log. + A future feature of lombok's diverse log annotations is to find calls to the logger field and, if the chosen logging framework supports it and the log level can be compile-time determined from the log call, guard it with an <code>if</code> statement. This way if the log statement ends up being ignored, the potentially expensive calculation of the log string is avoided entirely. This does mean that you should <em>NOT</em> put any side-effects in the expression that you log. </p> </div> </div> diff --git a/website/features/Value.html b/website/features/Value.html index 6bbd6f2a..e5dc7d9e 100644 --- a/website/features/Value.html +++ b/website/features/Value.html @@ -27,7 +27,7 @@ <code>@Value</code> is the immutable variant of <a href="Data.html"><code>@Data</code></a>; all fields are made <code>private</code> and <code>final</code> by default, and setters are not generated. The class itself is also made <code>final</code> by default, because immutability is not something that can be forced onto a subclass. Like <code>@Data</code>, useful <code>toString()</code>, <code>equals()</code> and <code>hashCode()</code> methods are also generated, each field gets a getter method, and a constructor that covers every argument (except <code>final</code> fields that are initialized in the field declaration) is also generated. </p><p> - In practice, <code>@Value</code> is shorthand for: <code>final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter</code>. + In practice, <code>@Value</code> is shorthand for: <code>final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter</code>, except that explicitly including an implementation of any of the relevant methods simply means that part won't be generated and no warning will be emitted. For example, if you write your own <code>toString</code>, no error occurs, and lombok will not generate a <code>toString</code>. Also, <em>any</em> explicit constructor, no matter the arguments list, implies lombok will not generate a constructor. If you do want lombok to generate the all-args constructor, add <code>@AllArgsConstructor</code> to the class. </p><p> It is possible to override the final-by-default and private-by-default behaviour using either an explicit access level on a field, or by using the <code>@NonFinal</code> or <code>@PackagePrivate</code> annotations.<br /> It is possible to override any default behaviour for any of the 'parts' that make up <code>@Value</code> by explicitly using that annotation. diff --git a/website/index.html b/website/index.html index 97b51114..17b6ffc6 100644 --- a/website/index.html +++ b/website/index.html @@ -72,7 +72,7 @@ <p> <strong>No video playback capabilities detected.</strong> Why not download it instead?<br /> - <a href="videos/lombok.mov">MPEG4 / H.264 (Windows / Mac)</a> | + <a href="videos/lombok.mp4">MPEG4 / H.264 (Windows / Mac)</a> | <a href="videos/lombok.ogv">Ogg Theora & Vorbis ".ogv" (Linux)</a> </p><p> To play the video in the webpage, please do one of the following: diff --git a/website/novideo.html b/website/novideo.html index 5968fc91..8dc3feb1 100644 --- a/website/novideo.html +++ b/website/novideo.html @@ -27,7 +27,7 @@ <h1>Can't see the video?</h1> <p> Why not download it instead?<br /> - <a href="videos/lombok.mov">MPEG4 / H.264 (Windows / Mac)</a> | + <a href="videos/lombok.mp4">MPEG4 / H.264 (Windows / Mac)</a> | <a href="videos/lombok.ogv">Ogg Theora & Vorbis ".ogv" (Linux)</a> </p><p> If the video won't play on the webpage and you want it to, please do one of the following: |