diff options
author | Maarten Mulders <m.th.mulders@xs4all.nl> | 2014-02-08 20:35:56 +0100 |
---|---|---|
committer | Maarten Mulders <m.th.mulders@xs4all.nl> | 2014-02-08 20:35:56 +0100 |
commit | c0e00edb7bf369470c55d59307bbf80cc3abb9d9 (patch) | |
tree | 3243e425833f1f084575b4c148fabb57afd11d81 | |
parent | 1045006fa9d19c6daf51b2c200176ba789c2372f (diff) | |
download | lombok-c0e00edb7bf369470c55d59307bbf80cc3abb9d9.tar.gz lombok-c0e00edb7bf369470c55d59307bbf80cc3abb9d9.tar.bz2 lombok-c0e00edb7bf369470c55d59307bbf80cc3abb9d9.zip |
Handler and testcases for @XSlf4j
6 files changed, 22 insertions, 2 deletions
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<lombok.extern.slf4j.XSlf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> 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<lombok.extern.slf4j.XSlf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> 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"); + <clinit>() { + } + 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 |