aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-03-04 23:16:49 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-03-04 23:16:49 +0100
commitf956ba1e337699206052a016da65f4f02ac6825b (patch)
tree53b0c638275ebfa8a3d1133c1d389ef700460572 /src/core
parente5574133363c8b718329e07a73bf161416485da5 (diff)
parentfbab1ca77cb8306843e26c5bad91186b34563282 (diff)
downloadlombok-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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/bytecode/package-info.java30
-rw-r--r--src/core/lombok/core/AnnotationProcessor.java4
-rw-r--r--src/core/lombok/core/PublicApiCreatorApp.java5
-rw-r--r--src/core/lombok/core/Version.java2
-rw-r--r--src/core/lombok/core/debug/DebugSnapshot.java22
-rw-r--r--src/core/lombok/core/debug/DebugSnapshotStore.java22
-rw-r--r--src/core/lombok/core/debug/package-info.java31
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java12
-rw-r--r--src/core/lombok/core/handlers/package-info.java30
-rw-r--r--src/core/lombok/core/package-info.java3
-rw-r--r--src/core/lombok/core/runtimeDependencies/package-info.java34
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java35
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java12
-rw-r--r--src/core/lombok/eclipse/handlers/HandleCleanup.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java8
-rw-r--r--src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java41
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java36
-rw-r--r--src/core/lombok/eclipse/handlers/HandleNonNull.java6
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSneakyThrows.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSynchronized.java2
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleVal.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWither.java6
-rw-r--r--src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java21
-rw-r--r--src/core/lombok/eclipse/handlers/package-info.java5
-rw-r--r--src/core/lombok/eclipse/package-info.java5
-rw-r--r--src/core/lombok/experimental/package-info.java33
-rw-r--r--src/core/lombok/extern/apachecommons/CommonsLog.java4
-rw-r--r--src/core/lombok/extern/java/Log.java4
-rw-r--r--src/core/lombok/extern/log4j/Log4j.java4
-rw-r--r--src/core/lombok/extern/log4j/Log4j2.java4
-rw-r--r--src/core/lombok/extern/slf4j/Slf4j.java7
-rw-r--r--src/core/lombok/extern/slf4j/XSlf4j.java4
-rw-r--r--src/core/lombok/javac/LombokOptions.java15
-rw-r--r--src/core/lombok/javac/apt/package-info.java3
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleCleanup.java6
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java42
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java28
-rw-r--r--src/core/lombok/javac/handlers/HandleExtensionMethod.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java22
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java47
-rw-r--r--src/core/lombok/javac/handlers/HandleNonNull.java6
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java10
-rw-r--r--src/core/lombok/javac/handlers/HandleSneakyThrows.java29
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleWither.java8
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java38
-rw-r--r--src/core/lombok/javac/handlers/package-info.java5
-rw-r--r--src/core/lombok/javac/package-info.java7
-rw-r--r--src/core/lombok/package-info.java11
54 files changed, 569 insertions, 218 deletions
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 &#64;Log
* @see lombok.extern.log4j.Log4j &#64;Log4j
* @see lombok.extern.log4j.Log4j2 &#64;Log4j2
- */
+ * @see lombok.extern.slf4j.XSlf4j &#64;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;