From 685ddfd52ebba4ca85ff93e08de14f38ecd8714b Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Jan 2014 04:46:59 +0100 Subject: Added code to NOT add @SuppressWarnings to things if a @SuppressWarnings is already there. Lombok itself can't ever do that anyway (we don't add @SW except to things we just generated fresh), but some lombok extension builders do, and this helps them. --- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 5e322c90..467ae0c3 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1388,6 +1388,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]; -- cgit From a40a86ad532881acd311200a665b5f55790c55cc Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Jan 2014 21:00:44 +0100 Subject: [#625] Instead of '31' as a prime number for hashCode(), use something else. 31, probably owing to its inclusion in Effective Java, is overused, as proven by Maaartinus in issue 625. Switching to 277 instead. Also, 1231/1237 pair used for booleans has been replaced by 2591/2609. --- src/core/lombok/core/handlers/HandlerUtil.java | 6 +++++- .../eclipse/handlers/HandleEqualsAndHashCode.java | 17 +++++++++-------- .../lombok/javac/handlers/HandleEqualsAndHashCode.java | 10 ++++++---- test/transform/resource/after-delombok/Accessors.java | 2 +- .../transform/resource/after-delombok/DataExtended.java | 2 +- test/transform/resource/after-delombok/DataIgnore.java | 2 +- .../resource/after-delombok/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-delombok/DataPlain.java | 8 ++++---- .../resource/after-delombok/DataWithGetter.java | 2 +- .../resource/after-delombok/DataWithGetterNone.java | 2 +- .../resource/after-delombok/EqualsAndHashCode.java | 6 +++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- .../resource/after-delombok/GetterLazyBoolean.java | 4 ++-- .../resource/after-delombok/GetterLazyEahcToString.java | 2 +- .../resource/after-delombok/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-delombok/ValuePlain.java | 6 +++--- test/transform/resource/after-ecj/Accessors.java | 2 +- test/transform/resource/after-ecj/DataExtended.java | 2 +- test/transform/resource/after-ecj/DataIgnore.java | 2 +- test/transform/resource/after-ecj/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-ecj/DataPlain.java | 8 ++++---- test/transform/resource/after-ecj/DataWithGetter.java | 2 +- .../resource/after-ecj/DataWithGetterNone.java | 2 +- .../transform/resource/after-ecj/EqualsAndHashCode.java | 6 +++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- .../transform/resource/after-ecj/GetterLazyBoolean.java | 4 ++-- .../resource/after-ecj/GetterLazyEahcToString.java | 2 +- .../resource/after-ecj/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-ecj/ValuePlain.java | 6 +++--- usage_examples/DataExample_post.jpage | 4 ++-- usage_examples/EqualsAndHashCodeExample_post.jpage | 4 ++-- usage_examples/ValueExample_post.jpage | 4 ++-- 32 files changed, 72 insertions(+), 65 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 3d386054..c8076ab6 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.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 @@ -27,6 +27,10 @@ import lombok.core.LombokNode; public class HandlerUtil { private HandlerUtil() {} + public static final int PRIME_FOR_HASHCODE = 277; + public static final int PRIME_FOR_TRUE = 2591; + public static final int PRIME_FOR_FALSE = 2609; + /** 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/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 3c8a7039..0b054159 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -35,6 +35,7 @@ import java.util.Set; import lombok.AccessLevel; 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; @@ -271,7 +272,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler Date: Wed, 15 Jan 2014 21:43:39 +0100 Subject: added package-infos to lots of packages, updated the javadoc in these, and made lots of private/package private methods 'public' in packages that aren't actually public API. Tumi asked for this, and I can imagine this is useful for others who are hacking add-ons to lombok. The package-info files clarify that we aren't committing to long-term stability of anything except the stuff directly in the lombok package, lombok.experimental, and lombok.extern. --- src/core/lombok/bytecode/package-info.java | 30 +++++++++++++++++++ src/core/lombok/core/debug/DebugSnapshot.java | 22 ++++++++++++++ src/core/lombok/core/debug/DebugSnapshotStore.java | 22 ++++++++++++++ src/core/lombok/core/debug/package-info.java | 31 ++++++++++++++++++++ src/core/lombok/core/handlers/package-info.java | 30 +++++++++++++++++++ src/core/lombok/core/package-info.java | 3 ++ .../core/runtimeDependencies/package-info.java | 34 ++++++++++++++++++++++ .../eclipse/handlers/EclipseHandlerUtil.java | 8 ++--- .../lombok/eclipse/handlers/HandleBuilder.java | 14 ++++----- .../lombok/eclipse/handlers/HandleCleanup.java | 6 ++-- .../lombok/eclipse/handlers/HandleConstructor.java | 10 +++---- .../eclipse/handlers/HandleEqualsAndHashCode.java | 26 ++++++++--------- src/core/lombok/eclipse/handlers/HandleGetter.java | 16 +++++----- src/core/lombok/eclipse/handlers/HandleLog.java | 8 ++--- .../lombok/eclipse/handlers/HandleNonNull.java | 6 ++-- src/core/lombok/eclipse/handlers/HandleSetter.java | 6 ++-- .../eclipse/handlers/HandleSneakyThrows.java | 6 ++-- .../eclipse/handlers/HandleSynchronized.java | 4 +-- .../lombok/eclipse/handlers/HandleToString.java | 12 ++++---- src/core/lombok/eclipse/handlers/HandleWither.java | 6 ++-- .../eclipse/handlers/SetGeneratedByVisitor.java | 21 +++++++++++++ src/core/lombok/eclipse/handlers/package-info.java | 5 +++- src/core/lombok/eclipse/package-info.java | 5 +++- src/core/lombok/experimental/package-info.java | 33 +++++++++++++++++++++ src/core/lombok/javac/apt/package-info.java | 3 ++ src/core/lombok/javac/handlers/HandleBuilder.java | 14 ++++----- src/core/lombok/javac/handlers/HandleCleanup.java | 8 ++--- .../lombok/javac/handlers/HandleConstructor.java | 16 +++++----- src/core/lombok/javac/handlers/HandleDelegate.java | 22 +++++++------- .../javac/handlers/HandleEqualsAndHashCode.java | 20 ++++++------- .../javac/handlers/HandleExtensionMethod.java | 8 ++--- src/core/lombok/javac/handlers/HandleGetter.java | 20 ++++++------- src/core/lombok/javac/handlers/HandleLog.java | 6 ++-- src/core/lombok/javac/handlers/HandleNonNull.java | 6 ++-- src/core/lombok/javac/handlers/HandleSetter.java | 10 +++---- .../lombok/javac/handlers/HandleSneakyThrows.java | 10 +++---- src/core/lombok/javac/handlers/HandleToString.java | 6 ++-- src/core/lombok/javac/handlers/HandleWither.java | 8 ++--- .../lombok/javac/handlers/JavacHandlerUtil.java | 12 ++++---- src/core/lombok/javac/handlers/package-info.java | 5 +++- src/core/lombok/javac/package-info.java | 7 +++-- src/core/lombok/package-info.java | 11 +++++-- 42 files changed, 402 insertions(+), 154 deletions(-) create mode 100644 src/core/lombok/bytecode/package-info.java create mode 100644 src/core/lombok/core/debug/package-info.java create mode 100644 src/core/lombok/core/handlers/package-info.java create mode 100644 src/core/lombok/core/runtimeDependencies/package-info.java create mode 100644 src/core/lombok/experimental/package-info.java (limited to 'src/core/lombok/eclipse/handlers') 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. + * + * 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. + */ +package lombok.bytecode; 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. + * + * 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. + */ +package lombok.core.debug; \ No newline at end of file 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. + * + * 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. + */ +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. + * + * 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. */ 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 467ae0c3..a40cb0c8 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 @@ -1320,7 +1320,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)); } @@ -1612,7 +1612,7 @@ public class EclipseHandlerUtil { return true; } - static List unboxAndRemoveAnnotationParameter(Annotation annotation, String annotationName, String errorName, EclipseNode errorNode) { + public static List 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 @@ -1704,7 +1704,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; diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index 981d77dc..ea282b3b 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.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 @@ -228,7 +228,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { } } - 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; @@ -247,7 +247,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { return out; } - private MethodDeclaration generateBuildMethod(String name, char[] staticName, TypeReference returnType, List fieldNames, EclipseNode type, ASTNode source, TypeReference[] thrownExceptions) { + public MethodDeclaration generateBuildMethod(String name, char[] staticName, TypeReference returnType, List fieldNames, EclipseNode type, ASTNode source, TypeReference[] thrownExceptions) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long) pS << 32 | pE; @@ -300,7 +300,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { return out; } - private List addFieldsToBuilder(EclipseNode builderType, List namesOfParameters, List typesOfParameters, ASTNode source) { + public List addFieldsToBuilder(EclipseNode builderType, List namesOfParameters, List typesOfParameters, ASTNode source) { int len = namesOfParameters.size(); TypeDeclaration td = (TypeDeclaration) builderType.get(); FieldDeclaration[] existing = td.fields; @@ -332,7 +332,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { 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; @@ -353,7 +353,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { source, Collections.emptyList(), Collections.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; @@ -363,7 +363,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { 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 cbf84e8b..b8ea1669 100644 --- a/src/core/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 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 @@ -225,7 +225,7 @@ public class HandleCleanup extends EclipseAnnotationHandler { ancestor.rebuild(); } - private MessageSend preventNullAnalysis(Annotation ast, Expression expr) { + public MessageSend preventNullAnalysis(Annotation ast, Expression expr) { MessageSend singletonList = new MessageSend(); setGeneratedBy(singletonList, ast); @@ -254,7 +254,7 @@ public class HandleCleanup extends EclipseAnnotationHandler { 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 22285b2d..d86aadee 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -211,7 +211,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 fields) { + public static Annotation[] createConstructorProperties(ASTNode source, Collection fields) { if (fields.isEmpty()) return null; int pS = source.sourceStart, pE = source.sourceEnd; @@ -242,7 +242,7 @@ public class HandleConstructor { return new Annotation[] { ann }; } - static ConstructorDeclaration createConstructor( + public static ConstructorDeclaration createConstructor( AccessLevel level, EclipseNode type, Collection fields, boolean suppressConstructorProperties, ASTNode source, List onConstructor) { @@ -316,14 +316,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 fields, ASTNode source) { + public MethodDeclaration createStaticConstructor(AccessLevel level, String name, EclipseNode type, Collection 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 0b054159..8d95ca64 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.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 @@ -92,10 +92,10 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList( + public static final Set BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); - private void checkForBogusFieldNames(EclipseNode type, AnnotationValues annotation) { + public void checkForBogusFieldNames(EclipseNode type, AnnotationValues 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); @@ -248,7 +248,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { + public MethodDeclaration createHashCode(EclipseNode type, Collection fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -403,7 +403,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler list = new ArrayList(); list.add(type.getName()); EclipseNode tNode = type.up(); @@ -458,7 +458,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual) { + public MethodDeclaration createEquals(EclipseNode type, Collection 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(); @@ -718,7 +718,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler>> 32 ^ ref) */ IntLiteral int32 = makeIntLiteral("32".toCharArray(), source); @@ -804,7 +804,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler { } } - private void createGetterForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List onMethod) { + public void createGetterForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy, List 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 onMethod) { if (fieldNode.getKind() != Kind.FIELD) { errorNode.addError("@Getter is only supported on a class or a field."); @@ -220,7 +220,7 @@ public class HandleGetter extends EclipseAnnotationHandler { injectMethod(fieldNode.up(), method); } - private static Annotation[] findDelegatesAndMarkAsHandled(EclipseNode fieldNode) { + public static Annotation[] findDelegatesAndMarkAsHandled(EclipseNode fieldNode) { List delegates = new ArrayList(); for (EclipseNode child : fieldNode.down()) { if (annotationTypeMatches(Delegate.class, child)) { @@ -232,7 +232,7 @@ public class HandleGetter extends EclipseAnnotationHandler { return delegates.toArray(EMPTY_ANNOTATIONS_ARRAY); } - private MethodDeclaration createGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy, List onMethod) { + public MethodDeclaration createGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy, List onMethod) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); // Remember the type; lazy will change it; @@ -281,7 +281,7 @@ public class HandleGetter extends EclipseAnnotationHandler { 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); @@ -290,7 +290,7 @@ public class HandleGetter extends EclipseAnnotationHandler { private static final char[][] AR = fromQualifiedName("java.util.concurrent.atomic.AtomicReference"); - private static final java.util.Map TYPE_MAP; + public static final java.util.Map TYPE_MAP; static { Map m = new HashMap(); m.put("int", fromQualifiedName("java.lang.Integer")); @@ -309,7 +309,7 @@ public class HandleGetter extends EclipseAnnotationHandler { 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 dd2c7ea8..6b1e94be 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -83,7 +83,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; @@ -97,7 +97,7 @@ public class HandleLog { return result; } - private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType) { + public static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -128,7 +128,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; diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java index 634cb2d9..7fd12ca3 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 @@ -142,11 +142,11 @@ public class HandleNonNull extends EclipseAnnotationHandler { 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 3bfcc51c..caa5329a 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.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 @@ -141,13 +141,13 @@ public class HandleSetter extends EclipseAnnotationHandler { } } - private void createSetterForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List onMethod, List onParam) { + public void createSetterForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List onMethod, List 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 onMethod, List onParam) { diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java index d3a95db8..d8261326 100644 --- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 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 @@ -145,7 +145,7 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler { // return true; // } - private void handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List exceptions) { + public void handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List exceptions) { if (method.isAbstract()) { annotation.addError("@SneakyThrows can only be used on concrete methods."); return; @@ -177,7 +177,7 @@ public class HandleSneakyThrows extends EclipseAnnotationHandler { 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 f76f06ed..b3e51da0 100644 --- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java +++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 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 @@ -67,7 +67,7 @@ public class HandleSynchronized extends EclipseAnnotationHandler { createLockField(annotation, annotationNode, method.isStatic(), false); } - private char[] createLockField(AnnotationValues annotation, EclipseNode annotationNode, boolean isStatic, boolean reportErrors) { + public char[] createLockField(AnnotationValues 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 1193af31..31ff3021 100644 --- a/src/core/lombok/eclipse/handlers/HandleToString.java +++ b/src/core/lombok/eclipse/handlers/HandleToString.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 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 @@ -67,7 +67,7 @@ import org.mangosdk.spi.ProviderFor; */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleToString extends EclipseAnnotationHandler { - private void checkForBogusFieldNames(EclipseNode type, AnnotationValues annotation) { + public void checkForBogusFieldNames(EclipseNode type, AnnotationValues 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); @@ -170,7 +170,7 @@ public class HandleToString extends EclipseAnnotationHandler { } } - static MethodDeclaration createToString(EclipseNode type, Collection fields, + public static MethodDeclaration createToString(EclipseNode type, Collection fields, boolean includeFieldNames, boolean callSuper, ASTNode source, FieldAccess fieldAccess) { String typeName = getTypeName(type); char[] suffix = ")".toCharArray(); @@ -282,7 +282,7 @@ public class HandleToString extends EclipseAnnotationHandler { 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) { @@ -292,7 +292,7 @@ public class HandleToString extends EclipseAnnotationHandler { 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); @@ -301,7 +301,7 @@ public class HandleToString extends EclipseAnnotationHandler { private static final Set BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet(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/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java index 27fbc635..305e0a16 100644 --- a/src/core/lombok/eclipse/handlers/HandleWither.java +++ b/src/core/lombok/eclipse/handlers/HandleWither.java @@ -143,13 +143,13 @@ public class HandleWither extends EclipseAnnotationHandler { } } - private void createWitherForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List onMethod, List onParam) { + public void createWitherForFields(AccessLevel level, Collection fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, List onMethod, List 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 onMethod, List onParam) { @@ -207,7 +207,7 @@ public class HandleWither extends EclipseAnnotationHandler { injectMethod(fieldNode.up(), method); } - private MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, List onMethod, List onParam) { + public MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, List onMethod, List 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. + * + * 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. */ 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. + * + * 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. */ 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 Lombok features (experimental) + */ +package lombok.experimental; 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. + * + * 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. */ package lombok.javac.apt; diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index e6e49337..1fc2941e 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.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 @@ -218,7 +218,7 @@ public class HandleBuilder extends JavacAnnotationHandler { } } - private JCMethodDecl generateBuildMethod(String name, Name staticName, JCExpression returnType, java.util.List fieldNames, JavacNode type, List thrownExceptions) { + public JCMethodDecl generateBuildMethod(String name, Name staticName, JCExpression returnType, java.util.List fieldNames, JavacNode type, List thrownExceptions) { JavacTreeMaker maker = type.getTreeMaker(); JCExpression call; @@ -252,7 +252,7 @@ public class HandleBuilder extends JavacAnnotationHandler { return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName(name), returnType, List.nil(), List.nil(), thrownExceptions, body, null); } - private JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, JavacNode type, List typeParams) { + public JCMethodDecl generateBuilderMethod(String builderMethodName, String builderClassName, JavacNode type, List typeParams) { JavacTreeMaker maker = type.getTreeMaker(); ListBuffer typeArgs = new ListBuffer(); @@ -267,7 +267,7 @@ public class HandleBuilder extends JavacAnnotationHandler { return maker.MethodDef(maker.Modifiers(Flags.STATIC | Flags.PUBLIC), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(maker, typeParams), List.nil(), List.nil(), body, null); } - private java.util.List addFieldsToBuilder(JavacNode builderType, java.util.List namesOfParameters, java.util.List typesOfParameters, JCTree source) { + public java.util.List addFieldsToBuilder(JavacNode builderType, java.util.List namesOfParameters, java.util.List typesOfParameters, JCTree source) { int len = namesOfParameters.size(); java.util.List existing = new ArrayList(); for (JavacNode child : builderType.down()) { @@ -297,7 +297,7 @@ public class HandleBuilder extends JavacAnnotationHandler { } - 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()) { @@ -313,7 +313,7 @@ public class HandleBuilder extends JavacAnnotationHandler { return HandleSetter.createSetter(Flags.PUBLIC, fieldNode, maker, setterName, chain, source, List.nil(), List.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(); @@ -322,7 +322,7 @@ public class HandleBuilder extends JavacAnnotationHandler { return null; } - private JavacNode makeBuilderClass(JavacNode tdParent, String builderClassName, List typeParams, JCAnnotation ast) { + public JavacNode makeBuilderClass(JavacNode tdParent, String builderClassName, List 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.nil(), List.nil()); diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index 7aae6303..12e7227d 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 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 @@ -141,7 +141,7 @@ public class HandleCleanup extends JavacAnnotationHandler { 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.nil(), chainDotsString(node, "java.util.Collections.singletonList"), List.of(expression)); JCMethodInvocation cleanedExpr = maker.Apply(List.nil(), maker.Select(singletonList, node.toName("get")) , List.of(maker.Literal(CTC_INT, 0))); @@ -151,11 +151,11 @@ public class HandleCleanup extends JavacAnnotationHandler { } } - private void doAssignmentCheck(JavacNode node, List statements, Name name) { + public void doAssignmentCheck(JavacNode node, List 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 adde3093..b8762ed8 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -91,7 +91,7 @@ public class HandleConstructor { } } - private static List findRequiredFields(JavacNode typeNode) { + public static List findRequiredFields(JavacNode typeNode) { ListBuffer fields = new ListBuffer(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; @@ -126,7 +126,7 @@ public class HandleConstructor { } } - static List findAllFields(JavacNode typeNode) { + public static List findAllFields(JavacNode typeNode) { ListBuffer fields = new ListBuffer(); for (JavacNode child : typeNode.down()) { if (child.getKind() != Kind.FIELD) continue; @@ -143,7 +143,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; @@ -206,7 +206,7 @@ public class HandleConstructor { } } - private static void addConstructorProperties(JCModifiers mods, JavacNode node, List fields) { + public static void addConstructorProperties(JCModifiers mods, JavacNode node, List fields) { if (fields.isEmpty()) return; JavacTreeMaker maker = node.getTreeMaker(); JCExpression constructorPropertiesType = chainDots(node, "java", "beans", "ConstructorProperties"); @@ -220,7 +220,7 @@ public class HandleConstructor { mods.annotations = mods.annotations.append(annotation); } - static JCMethodDecl createConstructor(AccessLevel level, List onConstructor, JavacNode typeNode, List fields, boolean suppressConstructorProperties, JCTree source) { + public static JCMethodDecl createConstructor(AccessLevel level, List onConstructor, JavacNode typeNode, List fields, boolean suppressConstructorProperties, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0; @@ -259,14 +259,14 @@ public class HandleConstructor { null, List.nil(), params.toList(), List.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 fields, JCTree source) { + public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List 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 89ab97e4..c9da4738 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/src/core/lombok/javac/handlers/HandleDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2012 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -190,7 +190,7 @@ public class HandleDelegate extends JavacAnnotationHandler { 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 toAdd = new ArrayList(); try { toAdd.add(createDelegateMethod(sig, annotation, delegateName, delegateReceiver)); @@ -207,7 +207,7 @@ public class HandleDelegate extends JavacAnnotationHandler { } } - private static class CantMakeDelegates extends Exception { + public static class CantMakeDelegates extends Exception { Set conflicted; } @@ -218,7 +218,7 @@ public class HandleDelegate extends JavacAnnotationHandler { * * @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; @@ -258,7 +258,7 @@ public class HandleDelegate extends JavacAnnotationHandler { } } - 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 ReturnType methodName(ParamType1 name1, ParamType2 name2, ...) throws T1, T2, ... { * (return) delegate.methodName(name1, name2); * } @@ -320,11 +320,11 @@ public class HandleDelegate extends JavacAnnotationHandler { return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation.get(), annotation.getContext()); } - private static com.sun.tools.javac.util.List toList(ListBuffer collection) { + public static com.sun.tools.javac.util.List toList(ListBuffer collection) { return collection == null ? com.sun.tools.javac.util.List.nil() : collection.toList(); } - private void addMethodBindings(List signatures, ClassType ct, JavacTypes types, Set banList) { + public void addMethodBindings(List signatures, ClassType ct, JavacTypes types, Set banList) { TypeSymbol tsym = ct.asElement(); if (tsym == null) return; @@ -347,7 +347,7 @@ public class HandleDelegate extends JavacAnnotationHandler { } } - private static class MethodSig { + public static class MethodSig { final Name name; final ExecutableType type; final boolean isDeprecated; @@ -374,7 +374,7 @@ public class HandleDelegate extends JavacAnnotationHandler { } } - 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; @@ -386,12 +386,12 @@ public class HandleDelegate extends JavacAnnotationHandler { 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 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 3f72f8a1..92eee893 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.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 @@ -71,7 +71,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler annotation) { + public void checkForBogusFieldNames(JavacNode type, AnnotationValues 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); @@ -219,7 +219,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler fields, boolean callSuper, FieldAccess fieldAccess, JCTree source) { + public JCMethodDecl createHashCode(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.nil()); @@ -323,7 +323,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil(), List.nil(), List.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); @@ -333,14 +333,14 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler>> 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 list = new ArrayList(); list.add(type.getName()); JavacNode tNode = type.up(); @@ -360,7 +360,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source) { + public JCMethodDecl createEquals(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCClassDecl type = (JCClassDecl) typeNode.get(); @@ -494,7 +494,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil(), params, List.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; * } @@ -515,7 +515,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil(), params, List.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"); @@ -525,7 +525,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler getExtensions(final JavacNode typeNode, final List extensionProviders) { + + + public List getExtensions(final JavacNode typeNode, final List extensionProviders) { List extensions = new ArrayList(); for (Object extensionProvider : extensionProviders) { if (!(extensionProvider instanceof JCFieldAccess)) continue; @@ -104,7 +104,7 @@ public class HandleExtensionMethod extends JavacAnnotationHandler extensionMethods = new ArrayList(); 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 24121021..6b055193 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -159,13 +159,13 @@ public class HandleGetter extends JavacAnnotationHandler { } } - private void createGetterForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, boolean lazy, List onMethod) { + public void createGetterForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, boolean lazy, List 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 onMethod) { if (fieldNode.getKind() != Kind.FIELD) { source.addError("@Getter is only supported on a class or a field."); @@ -215,7 +215,7 @@ public class HandleGetter extends JavacAnnotationHandler { 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 onMethod) { + public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, boolean lazy, List onMethod) { JCVariableDecl fieldNode = (JCVariableDecl) field.get(); // Remember the type; lazy will change it @@ -259,7 +259,7 @@ public class HandleGetter extends JavacAnnotationHandler { return decl; } - private static List findDelegatesAndRemoveFromField(JavacNode field) { + public static List findDelegatesAndRemoveFromField(JavacNode field) { JCVariableDecl fieldNode = (JCVariableDecl) field.get(); List delegates = List.nil(); @@ -282,14 +282,14 @@ public class HandleGetter extends JavacAnnotationHandler { return delegates; } - private List createSimpleGetterBody(JavacTreeMaker treeMaker, JavacNode field) { + public List createSimpleGetterBody(JavacTreeMaker treeMaker, JavacNode field) { return List.of(treeMaker.Return(createFieldAccessor(treeMaker, field, FieldAccess.ALWAYS_FIELD))); } private static final String AR = "java.util.concurrent.atomic.AtomicReference"; private static final List NIL_EXPRESSION = List.nil(); - private static final java.util.Map TYPE_MAP; + public static final java.util.Map TYPE_MAP; static { Map m = new HashMap(); m.put(CTC_INT, "Integer"); @@ -303,7 +303,7 @@ public class HandleGetter extends JavacAnnotationHandler { TYPE_MAP = Collections.unmodifiableMap(m); } - private List createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) { + public List createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) { /* java.lang.Object value = this.fieldName.get(); if (value == null) { @@ -423,17 +423,17 @@ public class HandleGetter extends JavacAnnotationHandler { 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.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 296f5e92..cb22496e 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -73,13 +73,13 @@ 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) { + public static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source) { JavacTreeMaker maker = typeNode.getTreeMaker(); // private static final log = (); diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java index 03b2e111..4cab48cf 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 @@ -141,7 +141,7 @@ public class HandleNonNull extends JavacAnnotationHandler { declaration.body.stats = newList; } - private boolean isNullCheck(JCStatement stat) { + public boolean isNullCheck(JCStatement stat) { return returnVarNameIfNullCheck(stat) != null; } @@ -150,7 +150,7 @@ public class HandleNonNull extends JavacAnnotationHandler { * 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 bd11b06c..ae8741de 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.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 @@ -141,13 +141,13 @@ public class HandleSetter extends JavacAnnotationHandler { } } - private void createSetterForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { + public void createSetterForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { for (JavacNode fieldNode : fieldNodes) { createSetterForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); } } - private void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List onMethod, List onParam) { + public void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List onMethod, List onParam) { if (fieldNode.getKind() != Kind.FIELD) { fieldNode.addError("@Setter is only supported on a class or a field."); return; @@ -190,13 +190,13 @@ public class HandleSetter extends JavacAnnotationHandler { injectMethod(fieldNode.up(), createdSetter); } - static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, List onMethod, List onParam) { + public static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, List onMethod, List 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 onMethod, List onParam) { + public static JCMethodDecl createSetter(long access, JavacNode field, JavacTreeMaker treeMaker, String setterName, boolean shouldReturnThis, JCTree source, List onMethod, List onParam) { if (setterName == null) return null; JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); diff --git a/src/core/lombok/javac/handlers/HandleSneakyThrows.java b/src/core/lombok/javac/handlers/HandleSneakyThrows.java index 02c0de7a..0b444801 100644 --- a/src/core/lombok/javac/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/javac/handlers/HandleSneakyThrows.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 @@ -77,7 +77,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler { } } - private void handleMethod(JavacNode annotation, JCMethodDecl method, Collection exceptions) { + public void handleMethod(JavacNode annotation, JCMethodDecl method, Collection exceptions) { JavacNode methodNode = annotation.up(); if ( (method.mods.flags & Flags.ABSTRACT) != 0) { @@ -107,15 +107,15 @@ public class HandleSneakyThrows extends JavacAnnotationHandler { 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 contents, String exception, JCTree source) { + + public JCStatement buildTryCatchBlock(JavacNode node, List contents, String exception, JCTree source) { JavacTreeMaker maker = node.getTreeMaker(); Context context = node.getContext(); diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java index af65202a..f1edae0c 100644 --- a/src/core/lombok/javac/handlers/HandleToString.java +++ b/src/core/lombok/javac/handlers/HandleToString.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 @@ -57,7 +57,7 @@ import com.sun.tools.javac.util.ListBuffer; */ @ProviderFor(JavacAnnotationHandler.class) public class HandleToString extends JavacAnnotationHandler { - private void checkForBogusFieldNames(JavacNode type, AnnotationValues annotation) { + public void checkForBogusFieldNames(JavacNode type, AnnotationValues 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); @@ -243,7 +243,7 @@ public class HandleToString extends JavacAnnotationHandler { List.nil(), List.nil(), List.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 aff84c8e..f6277bc3 100644 --- a/src/core/lombok/javac/handlers/HandleWither.java +++ b/src/core/lombok/javac/handlers/HandleWither.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 The Project Lombok Authors. + * 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 @@ -142,13 +142,13 @@ public class HandleWither extends JavacAnnotationHandler { } } - private void createWitherForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { + public void createWitherForFields(AccessLevel level, Collection fieldNodes, JavacNode errorNode, boolean whineIfExists, List onMethod, List onParam) { for (JavacNode fieldNode : fieldNodes) { createWitherForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); } } - private void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List onMethod, List onParam) { + public void createWitherForField(AccessLevel level, JavacNode fieldNode, JavacNode source, boolean whineIfExists, List onMethod, List onParam) { if (fieldNode.getKind() != Kind.FIELD) { fieldNode.addError("@Wither is only supported on a class or a field."); return; @@ -201,7 +201,7 @@ public class HandleWither extends JavacAnnotationHandler { injectMethod(fieldNode.up(), createdWither); } - private JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JCTree source, List onMethod, List onParam) { + public JCMethodDecl createWither(long access, JavacNode field, JavacTreeMaker maker, JCTree source, List onMethod, List onParam) { String witherName = toWitherName(field); if (witherName == null) return null; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index d6d47b6c..80ba9405 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.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 @@ -841,7 +841,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; } @@ -916,7 +916,7 @@ 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(); @@ -1203,7 +1203,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; @@ -1288,13 +1288,13 @@ 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[] splitJavadocOnSectionIfPresent(String javadoc, String sectionName) { Matcher m = SECTION_FINDER.matcher(javadoc); int getterSectionHeaderStart = -1; int getterSectionStart = -1; 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. + * + * 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. */ 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. + * + * 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. */ 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: + * + *
    + *
  • {@code lombok.extern.*} – These packages contains lombok annotations that solve boilerplate issues for libraries not part of the JRE itself. + *
  • {@code lombok.experimental} – This package contains lombok features that are new or likely to change before committing to long-term support. + *
+ * + * @see Lombok features */ package lombok; -- cgit From 14cc54527663018cdf7343eefffc8c37fbce93bb Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Sun, 19 Jan 2014 21:49:35 +0100 Subject: Issue 625: use (even) better primes for hashcodes --- doc/changelog.markdown | 1 + src/core/lombok/core/handlers/HandlerUtil.java | 14 +++++++++++--- .../lombok/eclipse/handlers/HandleEqualsAndHashCode.java | 12 ++++++------ .../lombok/javac/handlers/HandleEqualsAndHashCode.java | 8 ++++---- test/transform/resource/after-delombok/Accessors.java | 2 +- test/transform/resource/after-delombok/DataExtended.java | 2 +- test/transform/resource/after-delombok/DataIgnore.java | 2 +- .../resource/after-delombok/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-delombok/DataPlain.java | 8 ++++---- test/transform/resource/after-delombok/DataWithGetter.java | 2 +- .../resource/after-delombok/DataWithGetterNone.java | 2 +- .../resource/after-delombok/EqualsAndHashCode.java | 9 ++++++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- .../resource/after-delombok/GetterLazyBoolean.java | 4 ++-- .../resource/after-delombok/GetterLazyEahcToString.java | 2 +- .../resource/after-delombok/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-delombok/ValuePlain.java | 6 +++--- test/transform/resource/after-ecj/Accessors.java | 2 +- test/transform/resource/after-ecj/DataExtended.java | 2 +- test/transform/resource/after-ecj/DataIgnore.java | 2 +- test/transform/resource/after-ecj/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-ecj/DataPlain.java | 8 ++++---- test/transform/resource/after-ecj/DataWithGetter.java | 2 +- test/transform/resource/after-ecj/DataWithGetterNone.java | 2 +- test/transform/resource/after-ecj/EqualsAndHashCode.java | 10 +++++++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- test/transform/resource/after-ecj/GetterLazyBoolean.java | 4 ++-- .../resource/after-ecj/GetterLazyEahcToString.java | 2 +- test/transform/resource/after-ecj/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-ecj/ValuePlain.java | 6 +++--- test/transform/resource/before/EqualsAndHashCode.java | 1 + usage_examples/DataExample_post.jpage | 4 ++-- usage_examples/EqualsAndHashCodeExample_post.jpage | 4 ++-- usage_examples/ValueExample_post.jpage | 4 ++-- 34 files changed, 82 insertions(+), 65 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/doc/changelog.markdown b/doc/changelog.markdown index d4a29177..72291c5b 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,6 +3,7 @@ Lombok Changelog ### v1.12.5 "Edgy Guinea Pig" * DETAIL: {Delombok} Inside enum bodies the delombok formatter didn't respect the emptyLines directive [Issue #529](https://code.google.com/p/projectlombok/issues/detail?id=629). +* DETAIL: Use smaller primes (<127) for generating hashcodes [Issue #625](https://code.google.com/p/projectlombok/issues/detail?id=625) ### v1.12.4 (January 15th, 2014) * BUGFIX: v1.12.2's delombok turns all operator+assignments into just assignment. Fixed. [Issue #598](https://code.google.com/p/projectlombok/issues/detail?id=598) diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index c8076ab6..23b8ccc7 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -27,9 +27,17 @@ import lombok.core.LombokNode; public class HandlerUtil { private HandlerUtil() {} - public static final int PRIME_FOR_HASHCODE = 277; - public static final int PRIME_FOR_TRUE = 2591; - public static final int PRIME_FOR_FALSE = 2609; + 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. * diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 8d95ca64..0cc0836e 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -272,7 +272,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler>> 32 ^ $d); + result = result * PRIME + (this.b ? 79 : 97); return result; } } @@ -111,7 +114,7 @@ class EqualsAndHashCode4 extends EqualsAndHashCode { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + super.hashCode(); return result; diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java index e1bdc7f7..aa9b984f 100644 --- a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java @@ -69,7 +69,7 @@ class EqualsAndHashCodeWithNoExistingMethods { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; return result; diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java index ba26e7b7..eb6662e2 100644 --- a/test/transform/resource/after-delombok/GetterLazyBoolean.java +++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java @@ -21,9 +21,9 @@ class GetterLazyBoolean { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; - result = result * PRIME + (this.isBooleanValue() ? 2609 : 2591); + result = result * PRIME + (this.isBooleanValue() ? 79 : 97); return result; } @java.lang.Override diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java index 29e2f51c..3e98a25e 100644 --- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java +++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java @@ -27,7 +27,7 @@ class GetterLazyEahcToString { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = result * PRIME + ($value == null ? 0 : $value.hashCode()); diff --git a/test/transform/resource/after-delombok/GetterSetterJavadoc.java b/test/transform/resource/after-delombok/GetterSetterJavadoc.java index 5b12a395..743a3aac 100644 --- a/test/transform/resource/after-delombok/GetterSetterJavadoc.java +++ b/test/transform/resource/after-delombok/GetterSetterJavadoc.java @@ -41,7 +41,7 @@ class GetterSetterJavadoc1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getFieldName(); return result; diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java index af87d1ba..e880454b 100644 --- a/test/transform/resource/after-delombok/ValuePlain.java +++ b/test/transform/resource/after-delombok/ValuePlain.java @@ -30,7 +30,7 @@ final class Value1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -80,7 +80,7 @@ class Value2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -123,7 +123,7 @@ final class Value3 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); result = result * PRIME + this.getY(); diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index 52a72d52..c8fdc3bf 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -90,7 +90,7 @@ class AccessorsChain { return (other instanceof AccessorsPrefix3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $fName = this.getName(); result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode())); diff --git a/test/transform/resource/after-ecj/DataExtended.java b/test/transform/resource/after-ecj/DataExtended.java index 35a7ca34..bcfd26e3 100644 --- a/test/transform/resource/after-ecj/DataExtended.java +++ b/test/transform/resource/after-ecj/DataExtended.java @@ -22,7 +22,7 @@ return (other instanceof DataExtended); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java index 4a3c051b..d0e72e15 100644 --- a/test/transform/resource/after-ecj/DataIgnore.java +++ b/test/transform/resource/after-ecj/DataIgnore.java @@ -20,7 +20,7 @@ return (other instanceof DataIgnore); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 4a247542..511291c2 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -36,7 +36,7 @@ class DataOnLocalClass1 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -86,7 +86,7 @@ class DataOnLocalClass2 { return (other instanceof Local.InnerLocal); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $name = this.getName(); result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); @@ -124,7 +124,7 @@ class DataOnLocalClass2 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index 2105c6f2..aa47fdaa 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -31,7 +31,7 @@ import lombok.Data; return (other instanceof Data1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -78,7 +78,7 @@ import lombok.Data; return (other instanceof Data2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -120,7 +120,7 @@ final @Data class Data3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -167,7 +167,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java return (other instanceof Data4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); result = ((result * PRIME) + this.getX()); diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index 9676e851..2ce74ceb 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetter); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index d5e190d8..087d0762 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetterNone); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + this.y); diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java index 492f9344..625a0f87 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCode.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java @@ -35,7 +35,7 @@ return (other instanceof EqualsAndHashCode); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + java.util.Arrays.hashCode(this.y)); @@ -52,6 +52,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { long y; float f; double d; + boolean b; EqualsAndHashCode2() { super(); } @@ -69,10 +70,12 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { return false; if ((java.lang.Double.compare(this.d, other.d) != 0)) return false; + if ((this.b != other.b)) + return false; return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); final long $y = this.y; @@ -80,6 +83,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { result = ((result * PRIME) + java.lang.Float.floatToIntBits(this.f)); final long $d = java.lang.Double.doubleToLongBits(this.d); result = ((result * PRIME) + (int) ($d ^ ($d >>> 32))); + result = ((result * PRIME) + (this.b ? 79 : 97)); return result; } } @@ -125,7 +129,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte return (other instanceof EqualsAndHashCode4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); return result; diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java index 83878675..05f7ad97 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java @@ -57,7 +57,7 @@ import static lombok.AccessLevel.NONE; return (other instanceof EqualsAndHashCodeWithNoExistingMethods); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); return result; diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index d3b257a7..c37eece2 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -57,9 +57,9 @@ return (other instanceof GetterLazyBoolean); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; - result = ((result * PRIME) + (this.isBooleanValue() ? 2609 : 2591)); + result = ((result * PRIME) + (this.isBooleanValue() ? 79 : 97)); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index d8a90350..da9f6a83 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -46,7 +46,7 @@ return (other instanceof GetterLazyEahcToString); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = ((result * PRIME) + (($value == null) ? 0 : $value.hashCode())); diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java index 10d9a0be..b7fc15b8 100644 --- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java +++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java @@ -22,7 +22,7 @@ return (other instanceof GetterSetterJavadoc1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getFieldName()); return result; diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index a23944de..5ca32af8 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -23,7 +23,7 @@ final @lombok.Value class Value1 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -68,7 +68,7 @@ final @lombok.Value class Value1 { return (other instanceof Value2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -106,7 +106,7 @@ final @Value class Value3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/before/EqualsAndHashCode.java b/test/transform/resource/before/EqualsAndHashCode.java index 0a1e3290..660f923a 100644 --- a/test/transform/resource/before/EqualsAndHashCode.java +++ b/test/transform/resource/before/EqualsAndHashCode.java @@ -13,6 +13,7 @@ final class EqualsAndHashCode2 { long y; float f; double d; + boolean b; } @lombok.EqualsAndHashCode(callSuper=false) diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage index 896839de..29e7e328 100644 --- a/usage_examples/DataExample_post.jpage +++ b/usage_examples/DataExample_post.jpage @@ -55,7 +55,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.getScore()); result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); @@ -101,7 +101,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); result = (result*PRIME) + (this.getValue() == null ? 0 : this.getValue().hashCode()); diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage index 57191f55..aa6a44ba 100644 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ b/usage_examples/EqualsAndHashCodeExample_post.jpage @@ -24,7 +24,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.score); result = (result*PRIME) + (this.name == null ? 0 : this.name.hashCode()); @@ -57,7 +57,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = (result*PRIME) + super.hashCode(); result = (result*PRIME) + this.width; diff --git a/usage_examples/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage index c5971262..4ac8654e 100644 --- a/usage_examples/ValueExample_post.jpage +++ b/usage_examples/ValueExample_post.jpage @@ -46,7 +46,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); @@ -103,7 +103,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); -- cgit From 83efe294663fd173410b29a80578f54e84b55e03 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 5 Feb 2014 00:50:32 +0100 Subject: Fix for issue 631. Martin, thanks for the contribution. --- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index a40cb0c8..b703dd68 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -435,21 +435,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; } @@ -1519,7 +1519,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); } @@ -1718,4 +1718,8 @@ public class EclipseHandlerUtil { setGeneratedBy(nameReference, source); return nameReference; } + + private static long[] copy(long[] array) { + return array == null ? null : array.clone(); + } } -- cgit From c38a64a5564996b552d88448bfb00722403bf194 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Fri, 7 Feb 2014 16:14:01 +0100 Subject: Handlers and testcases for @Slf4j --- src/core/lombok/eclipse/handlers/HandleLog.java | 26 ++++++++------ src/core/lombok/extern/slf4j/Slf4j.java | 4 +++ src/core/lombok/javac/handlers/HandleLog.java | 40 +++++++++++++--------- .../resource/after-delombok/LoggerSlf4j.java | 5 +++ test/transform/resource/after-ecj/LoggerSlf4j.java | 9 +++++ test/transform/resource/before/LoggerSlf4j.java | 4 +++ 6 files changed, 62 insertions(+), 26 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 6b1e94be..ee9986b1 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -38,6 +38,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; @@ -48,7 +49,7 @@ public class HandleLog { throw new UnsupportedOperationException(); } - public static void processAnnotation(LoggingFramework framework, AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { + public static void processAnnotation(LoggingFramework framework, AnnotationValues annotation, Annotation source, EclipseNode annotationNode, String loggerCategory) { EclipseNode owner = annotationNode.up(); switch (owner.getKind()) { case TYPE: @@ -71,7 +72,7 @@ public class HandleLog { ClassLiteralAccess loggingType = selfType(owner, source); - FieldDeclaration fieldDeclaration = createField(framework, source, loggingType); + FieldDeclaration fieldDeclaration = createField(framework, source, loggingType, loggerCategory); 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); @@ -97,7 +98,7 @@ public class HandleLog { return result; } - public static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType) { + public static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String loggerCategory) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -116,7 +117,12 @@ public class HandleLog { factoryMethodCall.receiver = createNameReference(framework.getLoggerFactoryTypeName(), source); factoryMethodCall.selector = framework.getLoggerFactoryMethodName().toCharArray(); - Expression parameter = framework.createFactoryParameter(loggingType, source); + Expression parameter; + if (loggerCategory == null || loggerCategory.trim().length() == 0) { + parameter = framework.createFactoryParameter(loggingType, source); + } else { + parameter = new StringLiteral(loggerCategory.toCharArray(), pS, pE, 0); + } factoryMethodCall.arguments = new Expression[] { parameter }; factoryMethodCall.nameSourcePosition = p; @@ -155,7 +161,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleCommonsLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode); + processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, ""); } } @@ -165,7 +171,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleJulLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode); + processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, ""); } } @@ -175,7 +181,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, ""); } } @@ -185,7 +191,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4j2Log extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode); + processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, ""); } } @@ -195,7 +201,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleSlf4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().value()); } } @@ -205,7 +211,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleXSlf4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode); + processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, ""); } } diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java index 8490b6b6..c4495990 100644 --- a/src/core/lombok/extern/slf4j/Slf4j.java +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -57,4 +57,8 @@ import java.lang.annotation.Target; @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 value() default ""; } diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index cb22496e..12aa07fb 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -25,7 +25,9 @@ import static lombok.javac.handlers.JavacHandlerUtil.*; import java.lang.annotation.Annotation; +import lombok.NoArgsConstructor; import lombok.core.AnnotationValues; +import lombok.extern.slf4j.Slf4j; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -47,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 loggerCategory) { deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass()); - + JavacNode typeNode = annotationNode.up(); switch (typeNode.getKind()) { case TYPE: @@ -58,14 +60,14 @@ public class HandleLog { annotationNode.addError("@Log is legal only on classes and enums."); return; } - + if (fieldExists("log", typeNode)!= MemberExistsResult.NOT_EXISTS) { annotationNode.addWarning("Field 'log' already exists."); return; } - + JCFieldAccess loggingType = selfType(typeNode); - createField(framework, typeNode, loggingType, annotationNode.get()); + createField(framework, typeNode, loggingType, annotationNode.get(), loggerCategory); break; default: annotationNode.addError("@Log is legal only on types."); @@ -79,16 +81,22 @@ public class HandleLog { return maker.Select(maker.Ident(name), typeNode.toName("class")); } - public static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source) { + public static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String loggerCategory) { JavacTreeMaker maker = typeNode.getTreeMaker(); // private static final log = (); JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName()); JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName()); - - JCExpression loggerName = framework.createFactoryParameter(typeNode, loggingType); + + JCExpression loggerName; + if (loggerCategory == null || loggerCategory.trim().length() == 0) { + loggerName = framework.createFactoryParameter(typeNode, loggingType); + } else { + loggerName = maker.Literal(loggerCategory); + } + JCMethodInvocation factoryMethodCall = maker.Apply(List.nil(), factoryMethod, List.of(loggerName)); - + JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef( maker.Modifiers(Flags.PRIVATE | Flags.FINAL | Flags.STATIC), typeNode.toName("log"), loggerType, factoryMethodCall), source, typeNode.getContext()); @@ -103,7 +111,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleCommonsLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode); + processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, ""); } } @@ -113,7 +121,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleJulLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, annotationNode); + processAnnotation(LoggingFramework.JUL, annotation, annotationNode, ""); } } @@ -123,7 +131,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode); + processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, ""); } } @@ -133,7 +141,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4j2Log extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode); + processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, ""); } } @@ -143,7 +151,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleSlf4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode); + processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().value()); } } @@ -153,7 +161,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleXSlf4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode); + processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, ""); } } diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java index a07c8546..3c6e6d2f 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerSlf4j.java @@ -11,4 +11,9 @@ class LoggerSlf4jOuter { @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); } +} + +class LoggerSlf4jWithDifferentLoggerName { + @java.lang.SuppressWarnings("all") + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java index 1ccf5c9e..a34f85d7 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerSlf4j.java @@ -27,4 +27,13 @@ class LoggerSlf4jOuter { LoggerSlf4jOuter() { super(); } +} + +@Slf4j("DifferentLogger") class LoggerSlf4jWithDifferentLoggerName { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger"); + () { + } + LoggerSlf4jWithDifferentLoggerName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java index 133ee36e..b620e056 100644 --- a/test/transform/resource/before/LoggerSlf4j.java +++ b/test/transform/resource/before/LoggerSlf4j.java @@ -13,4 +13,8 @@ class LoggerSlf4jOuter { static class Inner { } +} + +@Slf4j("DifferentLogger") +class LoggerSlf4jWithDifferentLoggerName { } \ No newline at end of file -- cgit From f13191e02c1b8e8e8857cadfcf29cfd15dd1f1ad Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 8 Feb 2014 14:43:48 +0100 Subject: Handlers and testcases for @CommonsLog --- src/core/lombok/eclipse/handlers/HandleLog.java | 2 +- src/core/lombok/extern/apachecommons/CommonsLog.java | 4 ++++ src/core/lombok/javac/handlers/HandleLog.java | 2 +- test/transform/resource/after-delombok/LoggerCommons.java | 4 ++++ test/transform/resource/after-ecj/LoggerCommons.java | 8 ++++++++ test/transform/resource/before/LoggerCommons.java | 6 +++++- 6 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index ee9986b1..0f77bf76 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -161,7 +161,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleCommonsLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java index 024e3744..34ac0fe6 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 value() default ""; } \ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index 12aa07fb..2ad16b80 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -111,7 +111,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleCommonsLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerCommons.java b/test/transform/resource/after-delombok/LoggerCommons.java index 6feea5b6..32ace53a 100644 --- a/test/transform/resource/after-delombok/LoggerCommons.java +++ b/test/transform/resource/after-delombok/LoggerCommons.java @@ -5,4 +5,8 @@ class LoggerCommons { class LoggerCommonsWithImport { @java.lang.SuppressWarnings("all") private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class); +} +class LoggerCommonsWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerCommons.java b/test/transform/resource/after-ecj/LoggerCommons.java index d63bb9c1..50d07a14 100644 --- a/test/transform/resource/after-ecj/LoggerCommons.java +++ b/test/transform/resource/after-ecj/LoggerCommons.java @@ -14,4 +14,12 @@ import lombok.extern.apachecommons.CommonsLog; LoggerCommonsWithImport() { super(); } +} +@CommonsLog("DifferentName") class LoggerCommonsWithDifferentName { + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName"); + () { + } + LoggerCommonsWithDifferentName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerCommons.java b/test/transform/resource/before/LoggerCommons.java index 52210d25..ce9e4ec4 100644 --- a/test/transform/resource/before/LoggerCommons.java +++ b/test/transform/resource/before/LoggerCommons.java @@ -6,4 +6,8 @@ class LoggerCommons { @CommonsLog class LoggerCommonsWithImport { -} \ No newline at end of file +} + +@CommonsLog("DifferentName") +class LoggerCommonsWithDifferentName { +} -- cgit From e1153c16562dba545f4cc2ecbc26befde6c1a781 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 8 Feb 2014 15:16:39 +0100 Subject: Handler and testcases for @Log --- src/core/lombok/eclipse/handlers/HandleLog.java | 2 +- src/core/lombok/extern/java/Log.java | 4 ++++ src/core/lombok/javac/handlers/HandleLog.java | 2 +- test/transform/resource/after-delombok/LoggerJul.java | 4 ++++ test/transform/resource/after-ecj/LoggerJul.java | 8 ++++++++ test/transform/resource/before/LoggerJul.java | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 0f77bf76..891d4df2 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -171,7 +171,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleJulLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java index 7ae4e07b..dfa2e2aa 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 value() default ""; } \ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index 2ad16b80..bdb80ccb 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -121,7 +121,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleJulLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java index 20f0d24d..ad119777 100644 --- a/test/transform/resource/after-delombok/LoggerJul.java +++ b/test/transform/resource/after-delombok/LoggerJul.java @@ -5,4 +5,8 @@ class LoggerJul { class LoggerJulWithImport { @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName()); +} +class LoggerJulWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java index c98dfe27..3aa8181d 100644 --- a/test/transform/resource/after-ecj/LoggerJul.java +++ b/test/transform/resource/after-ecj/LoggerJul.java @@ -14,4 +14,12 @@ import lombok.extern.java.Log; LoggerJulWithImport() { super(); } +} +@Log("DifferentName") class LoggerJulWithDifferentName { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName"); + () { + } + LoggerJulWithDifferentName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerJul.java b/test/transform/resource/before/LoggerJul.java index 52869e81..41e36220 100644 --- a/test/transform/resource/before/LoggerJul.java +++ b/test/transform/resource/before/LoggerJul.java @@ -6,4 +6,8 @@ class LoggerJul { @Log class LoggerJulWithImport { +} + +@Log("DifferentName") +class LoggerJulWithDifferentName { } \ No newline at end of file -- cgit From ebc9ee5f6d6bc89af65d27f472d13f18b34bef18 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 8 Feb 2014 15:38:54 +0100 Subject: Handler and testcases for @Log4j --- src/core/lombok/eclipse/handlers/HandleLog.java | 2 +- src/core/lombok/extern/log4j/Log4j.java | 4 ++++ src/core/lombok/javac/handlers/HandleLog.java | 2 +- test/transform/resource/after-delombok/LoggerLog4j.java | 4 ++++ test/transform/resource/after-ecj/LoggerLog4j.java | 8 ++++++++ test/transform/resource/before/LoggerLog4j.java | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 891d4df2..1cd933e3 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -181,7 +181,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java index 29e1b27c..0fe74599 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 value() default ""; } \ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index bdb80ccb..b01dd564 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -131,7 +131,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerLog4j.java b/test/transform/resource/after-delombok/LoggerLog4j.java index 7d54b259..99eac34f 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j.java +++ b/test/transform/resource/after-delombok/LoggerLog4j.java @@ -5,4 +5,8 @@ class LoggerLog4j { class LoggerLog4jWithImport { @java.lang.SuppressWarnings("all") private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class); +} +class LoggerLog4jWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j.java b/test/transform/resource/after-ecj/LoggerLog4j.java index 6814be7b..a6c52d61 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j.java +++ b/test/transform/resource/after-ecj/LoggerLog4j.java @@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j; LoggerLog4jWithImport() { super(); } +} +@Log4j("DifferentName") class LoggerLog4jWithDifferentName { + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName"); + () { + } + LoggerLog4jWithDifferentName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j.java b/test/transform/resource/before/LoggerLog4j.java index 03735bff..fa7dad4a 100644 --- a/test/transform/resource/before/LoggerLog4j.java +++ b/test/transform/resource/before/LoggerLog4j.java @@ -6,4 +6,8 @@ class LoggerLog4j { @Log4j class LoggerLog4jWithImport { +} + +@Log4j("DifferentName") +class LoggerLog4jWithDifferentName { } \ No newline at end of file -- cgit From 1045006fa9d19c6daf51b2c200176ba789c2372f Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 8 Feb 2014 20:24:23 +0100 Subject: Handler and testcases for @Log4j2 --- src/core/lombok/eclipse/handlers/HandleLog.java | 2 +- src/core/lombok/extern/log4j/Log4j2.java | 4 ++++ src/core/lombok/javac/handlers/HandleLog.java | 2 +- test/transform/resource/after-delombok/LoggerLog4j2.java | 4 ++++ test/transform/resource/after-ecj/LoggerLog4j2.java | 8 ++++++++ test/transform/resource/before/LoggerLog4j2.java | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 1cd933e3..583aa0af 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -191,7 +191,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4j2Log extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index 2a0f09e1..96fab793 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 value() default ""; } \ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index b01dd564..a5d12964 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -141,7 +141,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4j2Log extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java index 7e4c01de..8473134b 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j2.java +++ b/test/transform/resource/after-delombok/LoggerLog4j2.java @@ -5,4 +5,8 @@ class LoggerLog4j2 { class LoggerLog4j2WithImport { @java.lang.SuppressWarnings("all") private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class); +} +class LoggerLog4j2WithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j2.java b/test/transform/resource/after-ecj/LoggerLog4j2.java index c1368e5d..3243ef2d 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j2.java +++ b/test/transform/resource/after-ecj/LoggerLog4j2.java @@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j2; LoggerLog4j2WithImport() { super(); } +} +@Log4j2("DifferentName") class LoggerLog4j2WithDifferentName { + private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); + () { + } + LoggerLog4j2WithDifferentName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java index b7ea99ee..13b3605f 100644 --- a/test/transform/resource/before/LoggerLog4j2.java +++ b/test/transform/resource/before/LoggerLog4j2.java @@ -6,4 +6,8 @@ class LoggerLog4j2 { @Log4j2 class LoggerLog4j2WithImport { +} + +@Log4j2("DifferentName") +class LoggerLog4j2WithDifferentName { } \ No newline at end of file -- cgit From c0e00edb7bf369470c55d59307bbf80cc3abb9d9 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 8 Feb 2014 20:35:56 +0100 Subject: Handler and testcases for @XSlf4j --- src/core/lombok/eclipse/handlers/HandleLog.java | 2 +- src/core/lombok/extern/slf4j/XSlf4j.java | 4 ++++ src/core/lombok/javac/handlers/HandleLog.java | 2 +- test/transform/resource/after-delombok/LoggerXSlf4j.java | 4 ++++ test/transform/resource/after-ecj/LoggerXSlf4j.java | 8 ++++++++ test/transform/resource/before/LoggerXSlf4j.java | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 583aa0af..56160b39 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -211,7 +211,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleXSlf4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, ""); + processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().value()); } } diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java index 599c68ab..306057f0 100644 --- a/src/core/lombok/extern/slf4j/XSlf4j.java +++ b/src/core/lombok/extern/slf4j/XSlf4j.java @@ -57,4 +57,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 value() default ""; } diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index a5d12964..12b0cb5c 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -161,7 +161,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleXSlf4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, ""); + processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().value()); } } diff --git a/test/transform/resource/after-delombok/LoggerXSlf4j.java b/test/transform/resource/after-delombok/LoggerXSlf4j.java index 981bcca6..d0654b51 100644 --- a/test/transform/resource/after-delombok/LoggerXSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerXSlf4j.java @@ -5,4 +5,8 @@ class LoggerXSlf4j { class LoggerXSlf4jWithImport { @java.lang.SuppressWarnings("all") private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithImport.class); +} +class LoggerXSlf4jWithDifferentName { + @java.lang.SuppressWarnings("all") + private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName"); } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerXSlf4j.java b/test/transform/resource/after-ecj/LoggerXSlf4j.java index f05e1ae7..4cd4cb94 100644 --- a/test/transform/resource/after-ecj/LoggerXSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerXSlf4j.java @@ -14,4 +14,12 @@ import lombok.extern.slf4j.XSlf4j; LoggerXSlf4jWithImport() { super(); } +} +@XSlf4j("DifferentName") class LoggerXSlf4jWithDifferentName { + private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName"); + () { + } + LoggerXSlf4jWithDifferentName() { + super(); + } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerXSlf4j.java b/test/transform/resource/before/LoggerXSlf4j.java index 6dbbf2d1..408bd134 100644 --- a/test/transform/resource/before/LoggerXSlf4j.java +++ b/test/transform/resource/before/LoggerXSlf4j.java @@ -6,4 +6,8 @@ class LoggerXSlf4j { @XSlf4j class LoggerXSlf4jWithImport { +} + +@XSlf4j("DifferentName") +class LoggerXSlf4jWithDifferentName { } \ No newline at end of file -- cgit From d78135180c8f9e9f4c6c361679759d3eacb63be3 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 10 Feb 2014 21:56:35 +0100 Subject: [deps] Updated eclipse deps to 3.9 tree. This also enables testing java7 features on ecj. [Log] updated naming for @Log (topic= instead of mchmulder's 'value'). --- AUTHORS | 2 +- .../ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml | 14 ++++++++++++++ buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml | 14 ++++++++++++++ .../org.eclipse.custom-equinox.common-3.6.200.xml | 14 ++++++++++++++ .../ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml | 14 ++++++++++++++ .../ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml | 14 ++++++++++++++ .../ivy-repo/org.eclipse.custom-osgi-3.9.0.xml | 14 ++++++++++++++ buildScripts/ivy.xml | 12 ++++++------ src/core/lombok/eclipse/handlers/HandleLog.java | 12 ++++++------ src/core/lombok/extern/apachecommons/CommonsLog.java | 2 +- src/core/lombok/extern/java/Log.java | 2 +- src/core/lombok/extern/log4j/Log4j.java | 2 +- src/core/lombok/extern/log4j/Log4j2.java | 2 +- src/core/lombok/extern/slf4j/Slf4j.java | 2 +- src/core/lombok/extern/slf4j/XSlf4j.java | 2 +- src/core/lombok/javac/handlers/HandleLog.java | 14 ++++++-------- test/core/src/lombok/AbstractRunTests.java | 13 +++++++++++-- test/core/src/lombok/RunTestsViaEcj.java | 3 ++- test/transform/resource/after-ecj/LoggerCommons.java | 2 +- test/transform/resource/after-ecj/LoggerJul.java | 2 +- test/transform/resource/after-ecj/LoggerLog4j.java | 2 +- test/transform/resource/after-ecj/LoggerLog4j2.java | 2 +- test/transform/resource/after-ecj/LoggerSlf4j.java | 2 +- test/transform/resource/after-ecj/LoggerXSlf4j.java | 2 +- .../resource/after-ecj/NonNullWithSneakyThrows.java | 3 ++- .../resource/after-ecj/SneakyThrowsMultiple.java | 18 ++++++++++++------ .../resource/after-ecj/SneakyThrowsPlain.java | 12 ++++++++---- .../resource/after-ecj/SneakyThrowsSingle.java | 9 ++++++--- test/transform/resource/after-ecj/ValComplex.java | 2 +- .../resource/after-ecj/ValInTryWithResources.java | 14 ++++++++++++++ test/transform/resource/after-ecj/ValLessSimple.java | 3 ++- test/transform/resource/before/LoggerCommons.java | 2 +- test/transform/resource/before/LoggerJul.java | 2 +- test/transform/resource/before/LoggerLog4j.java | 2 +- test/transform/resource/before/LoggerLog4j2.java | 2 +- test/transform/resource/before/LoggerSlf4j.java | 2 +- test/transform/resource/before/LoggerXSlf4j.java | 2 +- usage_examples/LogExample_pre.jpage | 2 +- website/features/Log.html | 7 ++----- 39 files changed, 182 insertions(+), 64 deletions(-) create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml create mode 100644 buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml create mode 100644 test/transform/resource/after-ecj/ValInTryWithResources.java (limited to 'src/core/lombok/eclipse/handlers') diff --git a/AUTHORS b/AUTHORS index 32369734..f79ca61e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,12 +1,12 @@ Lombok contributors in alphabetical order: Jappe van der Hel +Maarten Mulders Philipp Eichhorn Reinier Zwitserloot Robbert Jan Grootjans Roel Spilker Sander Koning Taiki Sugawara -Maarten Mulders By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok. diff --git a/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml new file mode 100644 index 00000000..45d6a9c3 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-core.runtime-3.9.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml new file mode 100644 index 00000000..4ebfc8a4 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-ecj-4.3.1.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml new file mode 100644 index 00000000..74f7a705 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-equinox.common-3.6.200.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml new file mode 100644 index 00000000..0e7c5363 --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.core-3.9.1.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml new file mode 100644 index 00000000..0577ee8a --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-jdt.ui-3.9.1.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml new file mode 100644 index 00000000..247d76de --- /dev/null +++ b/buildScripts/ivy-repo/org.eclipse.custom-osgi-3.9.0.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index bcf5ecd1..eed69ac3 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -35,17 +35,17 @@ - + - - - - - + + + + + diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 56160b39..cf1e8018 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -161,7 +161,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleCommonsLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -171,7 +171,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleJulLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -181,7 +181,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -191,7 +191,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleLog4j2Log extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -201,7 +201,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleSlf4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } @@ -211,7 +211,7 @@ public class HandleLog { @ProviderFor(EclipseAnnotationHandler.class) public static class HandleXSlf4jLog extends EclipseAnnotationHandler { @Override public void handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().topic()); } } diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java index 34ac0fe6..2e31edf7 100644 --- a/src/core/lombok/extern/apachecommons/CommonsLog.java +++ b/src/core/lombok/extern/apachecommons/CommonsLog.java @@ -62,5 +62,5 @@ public @interface CommonsLog { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } \ No newline at end of file diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java index dfa2e2aa..f8cbf03f 100644 --- a/src/core/lombok/extern/java/Log.java +++ b/src/core/lombok/extern/java/Log.java @@ -61,5 +61,5 @@ public @interface Log { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } \ No newline at end of file diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java index 0fe74599..d3164047 100644 --- a/src/core/lombok/extern/log4j/Log4j.java +++ b/src/core/lombok/extern/log4j/Log4j.java @@ -62,5 +62,5 @@ public @interface Log4j { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } \ No newline at end of file diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java index 96fab793..0267d98c 100644 --- a/src/core/lombok/extern/log4j/Log4j2.java +++ b/src/core/lombok/extern/log4j/Log4j2.java @@ -62,5 +62,5 @@ public @interface Log4j2 { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } \ No newline at end of file diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java index c4495990..5d6e7d8c 100644 --- a/src/core/lombok/extern/slf4j/Slf4j.java +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -60,5 +60,5 @@ public @interface Slf4j { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java index 306057f0..0f2efe26 100644 --- a/src/core/lombok/extern/slf4j/XSlf4j.java +++ b/src/core/lombok/extern/slf4j/XSlf4j.java @@ -60,5 +60,5 @@ public @interface XSlf4j { /** * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed. */ - String value() default ""; + String topic() default ""; } diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index 12b0cb5c..36f3bbb5 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -25,9 +25,7 @@ import static lombok.javac.handlers.JavacHandlerUtil.*; import java.lang.annotation.Annotation; -import lombok.NoArgsConstructor; import lombok.core.AnnotationValues; -import lombok.extern.slf4j.Slf4j; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -111,7 +109,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleCommonsLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -121,7 +119,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleJulLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -131,7 +129,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -141,7 +139,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleLog4j2Log extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -151,7 +149,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleSlf4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().topic()); } } @@ -161,7 +159,7 @@ public class HandleLog { @ProviderFor(JavacAnnotationHandler.class) public static class HandleXSlf4jLog extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().value()); + processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().topic()); } } diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index 2f3f0988..e84aec0d 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -225,8 +225,8 @@ public abstract class AbstractRunTests { actualLines = removeBlanks(actualLines); int size = Math.min(expectedLines.length, actualLines.length); for (int i = 0; i < size; i++) { - String expected = expectedLines[i]; - String actual = actualLines[i]; + String expected = trimRight(expectedLines[i]); + String actual = trimRight(actualLines[i]); assertEquals(String.format("Difference in %s on line %d", name, i + 1), expected, actual); } if (expectedLines.length > actualLines.length) { @@ -237,6 +237,15 @@ public abstract class AbstractRunTests { } } + private static String trimRight(String in) { + int endIdx = in.length() - 1; + while (endIdx > -1 && Character.isWhitespace(in.charAt(endIdx))) { + endIdx--; + } + + return in.substring(0, endIdx); + } + private static String[] removeBlanks(String[] in) { List out = new ArrayList(); for (String s : in) { diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index 586c124a..4f3e2794 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2013 The Project Lombok Authors. + * Copyright (C) 2010-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -70,6 +70,7 @@ public class RunTestsViaEcj extends AbstractRunTests { warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore"); warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore"); + warnings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); options.set(warnings); return options; } diff --git a/test/transform/resource/after-ecj/LoggerCommons.java b/test/transform/resource/after-ecj/LoggerCommons.java index 50d07a14..df102a12 100644 --- a/test/transform/resource/after-ecj/LoggerCommons.java +++ b/test/transform/resource/after-ecj/LoggerCommons.java @@ -15,7 +15,7 @@ import lombok.extern.apachecommons.CommonsLog; super(); } } -@CommonsLog("DifferentName") class LoggerCommonsWithDifferentName { +@CommonsLog(topic = "DifferentName") class LoggerCommonsWithDifferentName { private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName"); () { } diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java index 3aa8181d..8aa4f59a 100644 --- a/test/transform/resource/after-ecj/LoggerJul.java +++ b/test/transform/resource/after-ecj/LoggerJul.java @@ -15,7 +15,7 @@ import lombok.extern.java.Log; super(); } } -@Log("DifferentName") class LoggerJulWithDifferentName { +@Log(topic = "DifferentName") class LoggerJulWithDifferentName { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName"); () { } diff --git a/test/transform/resource/after-ecj/LoggerLog4j.java b/test/transform/resource/after-ecj/LoggerLog4j.java index a6c52d61..948412e2 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j.java +++ b/test/transform/resource/after-ecj/LoggerLog4j.java @@ -15,7 +15,7 @@ import lombok.extern.log4j.Log4j; super(); } } -@Log4j("DifferentName") class LoggerLog4jWithDifferentName { +@Log4j(topic = "DifferentName") class LoggerLog4jWithDifferentName { private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName"); () { } diff --git a/test/transform/resource/after-ecj/LoggerLog4j2.java b/test/transform/resource/after-ecj/LoggerLog4j2.java index 3243ef2d..c2fcd428 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j2.java +++ b/test/transform/resource/after-ecj/LoggerLog4j2.java @@ -15,7 +15,7 @@ import lombok.extern.log4j.Log4j2; super(); } } -@Log4j2("DifferentName") class LoggerLog4j2WithDifferentName { +@Log4j2(topic = "DifferentName") class LoggerLog4j2WithDifferentName { private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName"); () { } diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java index a34f85d7..9c5405cb 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerSlf4j.java @@ -29,7 +29,7 @@ class LoggerSlf4jOuter { } } -@Slf4j("DifferentLogger") class LoggerSlf4jWithDifferentLoggerName { +@Slf4j(topic = "DifferentLogger") class LoggerSlf4jWithDifferentLoggerName { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger"); () { } diff --git a/test/transform/resource/after-ecj/LoggerXSlf4j.java b/test/transform/resource/after-ecj/LoggerXSlf4j.java index 4cd4cb94..916859a4 100644 --- a/test/transform/resource/after-ecj/LoggerXSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerXSlf4j.java @@ -15,7 +15,7 @@ import lombok.extern.slf4j.XSlf4j; super(); } } -@XSlf4j("DifferentName") class LoggerXSlf4jWithDifferentName { +@XSlf4j(topic = "DifferentName") class LoggerXSlf4jWithDifferentName { private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName"); () { } diff --git a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java index fac8dcdd..1a57be29 100644 --- a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java +++ b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java @@ -11,7 +11,8 @@ class NonNullWithSneakyThrows { } System.out.println(in); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsMultiple.java b/test/transform/resource/after-ecj/SneakyThrowsMultiple.java index 82eda411..65862c2b 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsMultiple.java +++ b/test/transform/resource/after-ecj/SneakyThrowsMultiple.java @@ -13,11 +13,13 @@ class SneakyThrowsMultiple { System.out.println("test1"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -36,11 +38,13 @@ class SneakyThrowsMultiple { throw new AWTException("WHAT"); } } - catch (final AWTException $ex) { + catch (final AWTException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -52,11 +56,13 @@ class SneakyThrowsMultiple { System.out.println("test3"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsPlain.java b/test/transform/resource/after-ecj/SneakyThrowsPlain.java index 1b45dc5a..df436891 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsPlain.java +++ b/test/transform/resource/after-ecj/SneakyThrowsPlain.java @@ -6,7 +6,8 @@ class SneakyThrowsPlain { { System.out.println("constructor"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -16,7 +17,8 @@ class SneakyThrowsPlain { { System.out.println("constructor2"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -25,7 +27,8 @@ class SneakyThrowsPlain { { System.out.println("test1"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -34,7 +37,8 @@ class SneakyThrowsPlain { { System.out.println("test2"); } - catch (final java.lang.Throwable $ex) { + catch (final java.lang.Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/SneakyThrowsSingle.java b/test/transform/resource/after-ecj/SneakyThrowsSingle.java index eea593f2..073d690a 100644 --- a/test/transform/resource/after-ecj/SneakyThrowsSingle.java +++ b/test/transform/resource/after-ecj/SneakyThrowsSingle.java @@ -8,7 +8,8 @@ class SneakyThrowsSingle { { System.out.println("test1"); } - catch (final Throwable $ex) { + catch (final Throwable $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -18,7 +19,8 @@ class SneakyThrowsSingle { System.out.println("test2"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } @@ -28,7 +30,8 @@ class SneakyThrowsSingle { System.out.println("test3"); throw new IOException(); } - catch (final IOException $ex) { + catch (final IOException $ex) + { throw lombok.Lombok.sneakyThrow($ex); } } diff --git a/test/transform/resource/after-ecj/ValComplex.java b/test/transform/resource/after-ecj/ValComplex.java index 6e435e56..746e3088 100644 --- a/test/transform/resource/after-ecj/ValComplex.java +++ b/test/transform/resource/after-ecj/ValComplex.java @@ -16,7 +16,7 @@ public class ValComplex { final @val int field = 20; final @val int inner = 10; switch (field) { - case 5 : ; + case 5 : final @val char[] shouldBeCharArray2 = shouldBeCharArray; final @val int innerInner = inner; } diff --git a/test/transform/resource/after-ecj/ValInTryWithResources.java b/test/transform/resource/after-ecj/ValInTryWithResources.java new file mode 100644 index 00000000..a532d48c --- /dev/null +++ b/test/transform/resource/after-ecj/ValInTryWithResources.java @@ -0,0 +1,14 @@ +import lombok.val; +import java.io.IOException; +public class ValInTryWithResources { + public ValInTryWithResources() { + super(); + } + public void whyTryInsteadOfCleanup() throws IOException { + try (final @val java.io.InputStream in = getClass().getResourceAsStream("ValInTryWithResources.class")) + { + final @val java.io.InputStream i = in; + final @val int j = in.read(); + } + } +} diff --git a/test/transform/resource/after-ecj/ValLessSimple.java b/test/transform/resource/after-ecj/ValLessSimple.java index c7587f91..28772d68 100644 --- a/test/transform/resource/after-ecj/ValLessSimple.java +++ b/test/transform/resource/after-ecj/ValLessSimple.java @@ -32,7 +32,8 @@ public class ValLessSimple { { final @val int x = (1 / 0); } - catch (ArithmeticException e) { + catch (ArithmeticException e) + { final @val int y = 0; } } diff --git a/test/transform/resource/before/LoggerCommons.java b/test/transform/resource/before/LoggerCommons.java index ce9e4ec4..00419d00 100644 --- a/test/transform/resource/before/LoggerCommons.java +++ b/test/transform/resource/before/LoggerCommons.java @@ -8,6 +8,6 @@ class LoggerCommons { class LoggerCommonsWithImport { } -@CommonsLog("DifferentName") +@CommonsLog(topic="DifferentName") class LoggerCommonsWithDifferentName { } diff --git a/test/transform/resource/before/LoggerJul.java b/test/transform/resource/before/LoggerJul.java index 41e36220..006cc344 100644 --- a/test/transform/resource/before/LoggerJul.java +++ b/test/transform/resource/before/LoggerJul.java @@ -8,6 +8,6 @@ class LoggerJul { class LoggerJulWithImport { } -@Log("DifferentName") +@Log(topic="DifferentName") class LoggerJulWithDifferentName { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j.java b/test/transform/resource/before/LoggerLog4j.java index fa7dad4a..351049c5 100644 --- a/test/transform/resource/before/LoggerLog4j.java +++ b/test/transform/resource/before/LoggerLog4j.java @@ -8,6 +8,6 @@ class LoggerLog4j { class LoggerLog4jWithImport { } -@Log4j("DifferentName") +@Log4j(topic="DifferentName") class LoggerLog4jWithDifferentName { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java index 13b3605f..c9cf9412 100644 --- a/test/transform/resource/before/LoggerLog4j2.java +++ b/test/transform/resource/before/LoggerLog4j2.java @@ -8,6 +8,6 @@ class LoggerLog4j2 { class LoggerLog4j2WithImport { } -@Log4j2("DifferentName") +@Log4j2(topic="DifferentName") class LoggerLog4j2WithDifferentName { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java index b620e056..1113a63e 100644 --- a/test/transform/resource/before/LoggerSlf4j.java +++ b/test/transform/resource/before/LoggerSlf4j.java @@ -15,6 +15,6 @@ class LoggerSlf4jOuter { } } -@Slf4j("DifferentLogger") +@Slf4j(topic="DifferentLogger") class LoggerSlf4jWithDifferentLoggerName { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerXSlf4j.java b/test/transform/resource/before/LoggerXSlf4j.java index 408bd134..a8bcb0c3 100644 --- a/test/transform/resource/before/LoggerXSlf4j.java +++ b/test/transform/resource/before/LoggerXSlf4j.java @@ -8,6 +8,6 @@ class LoggerXSlf4j { class LoggerXSlf4jWithImport { } -@XSlf4j("DifferentName") +@XSlf4j(topic="DifferentName") class LoggerXSlf4jWithDifferentName { } \ No newline at end of file diff --git a/usage_examples/LogExample_pre.jpage b/usage_examples/LogExample_pre.jpage index fa746dba..ba27dd27 100644 --- a/usage_examples/LogExample_pre.jpage +++ b/usage_examples/LogExample_pre.jpage @@ -17,7 +17,7 @@ public class LogExampleOther { } } -@CommonsLog("CounterLog") +@CommonsLog(topic="CounterLog") public class LogExampleCategory { public static void main(String... args) { diff --git a/website/features/Log.html b/website/features/Log.html index e6b3ece6..bc9e017e 100644 --- a/website/features/Log.html +++ b/website/features/Log.html @@ -34,7 +34,7 @@
Creates private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LogExample.class);

- By default, the category (or name) of the logger will be the type where the annotation was placed. This can be customised by specifying a value for the category. + By default, the topic (or name) of the logger will be the class name of the class annotated with the @Log annotation. This can be customised by specifying the topic parameter. For example: @XSlf4j(topic="reporting").

@@ -54,10 +54,7 @@

If a field called log already exists, a warning will be emitted and no code will be generated.

- A future feature of lombok's diverse log annotations is to find calls to the logger field and, if the chosen logging framework supports - it and the log level can be compile-time determined from the log call, guard it with an if statement. This way if - the log statement ends up being ignored, the potentially expensive calculation of the log string is avoided entirely. This does mean - that you should NOT put any side-effects in the expression that you log. + A future feature of lombok's diverse log annotations is to find calls to the logger field and, if the chosen logging framework supports it and the log level can be compile-time determined from the log call, guard it with an if statement. This way if the log statement ends up being ignored, the potentially expensive calculation of the log string is avoided entirely. This does mean that you should NOT put any side-effects in the expression that you log.

-- cgit From 3355ed89f3ab12a84b3494f5eb2e361e0e3df262 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 10 Feb 2014 22:15:02 +0100 Subject: Improved error reporting in Eclipse --- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index b703dd68..fbad53d4 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -197,7 +197,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; } -- cgit From c4761096715a8388e683b9b7f86f2c6a3be4f7a0 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 27 Feb 2014 02:57:00 +0100 Subject: Fixed some issues when using lambda expressions in eclipse using the beta JDK8 support plugin for Kepler. --- src/core/lombok/eclipse/handlers/HandleVal.java | 4 ++++ .../lombok/eclipse/agent/PatchVal.java | 27 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src/core/lombok/eclipse/handlers') diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java index e7849952..c8339f35 100644 --- a/src/core/lombok/eclipse/handlers/HandleVal.java +++ b/src/core/lombok/eclipse/handlers/HandleVal.java @@ -64,5 +64,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/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java index 16f11769..59fbe9d0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java @@ -53,12 +53,20 @@ public class PatchVal { public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) { if (expr.resolvedType != null) return expr.resolvedType; - return expr.resolveType(scope); + try { + return expr.resolveType(scope); + } catch (NullPointerException e) { + return null; + } } public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) { if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType; - return expr.resolveType(scope); + try { + return expr.resolveType(scope); + } catch (NullPointerException e) { + return null; + } } public static boolean matches(String key, char[] array) { @@ -143,7 +151,20 @@ public class PatchVal { TypeReference replacement = null; if (init != null) { - TypeBinding resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope); + if (init.getClass().getName().equals("org.eclipse.jdt.internal.compiler.ast.LambdaExpression")) { + return false; + } + + TypeBinding resolved = null; + try { + resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope); + } catch (NullPointerException e) { + // This definitely occurs if as part of resolving the initializer expression, a + // lambda expression in it must also be resolved (such as when lambdas are part of + // a ternary expression). This can't result in a viable 'val' matching, so, we + // just go with 'Object' and let the IDE print the appropriate errors. + resolved = null; + } if (resolved != null) { replacement = makeType(resolved, local.type, false); } -- cgit