aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java50
-rw-r--r--src/core/lombok/extern/apachecommons/CommonsLog.java (renamed from src/core/lombok/extern/apachecommons/Log.java)30
-rw-r--r--src/core/lombok/extern/java/Log.java (renamed from src/core/lombok/extern/jul/Log.java)28
-rw-r--r--src/core/lombok/extern/log4j/Log4j.java (renamed from src/core/lombok/extern/log4j/Log.java)30
-rw-r--r--src/core/lombok/extern/slf4j/Slf4j.java (renamed from src/core/lombok/extern/slf4j/Log.java)30
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java49
6 files changed, 54 insertions, 163 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index 1df33e89..be856208 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -52,12 +52,6 @@ public class HandleLog {
}
public static boolean processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
- Expression annotationValue = (Expression) annotation.getActualExpression("value");
- if (annotationValue != null && !(annotationValue instanceof ClassLiteralAccess)) {
- return true;
- }
- ClassLiteralAccess loggingType = (ClassLiteralAccess)annotationValue;
-
EclipseNode owner = annotationNode.up();
switch (owner.getKind()) {
case TYPE:
@@ -78,9 +72,7 @@ public class HandleLog {
return true;
}
- if (loggingType == null) {
- loggingType = selfType(owner, source);
- }
+ ClassLiteralAccess loggingType = selfType(owner, source);
injectField(owner, createField(framework, source, loggingType));
owner.rebuild();
@@ -158,51 +150,51 @@ public class HandleLog {
}
/**
- * Handles the {@link lombok.extern.apachecommons.Log} annotation for Eclipse.
+ * Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for Eclipse.
*/
@ProviderFor(EclipseAnnotationHandler.class)
- public static class HandleCommonsLog implements EclipseAnnotationHandler<lombok.extern.apachecommons.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.apachecommons.Log> annotation, Annotation source, EclipseNode annotationNode) {
+ public static class HandleCommonsLog implements EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
return processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
}
}
/**
- * Handles the {@link lombok.extern.jul.Log} annotation for Eclipse.
+ * Handles the {@link lombok.extern.java.Log} annotation for Eclipse.
*/
@ProviderFor(EclipseAnnotationHandler.class)
- public static class HandleJulLog implements EclipseAnnotationHandler<lombok.extern.jul.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.jul.Log> annotation, Annotation source, EclipseNode annotationNode) {
+ public static class HandleJulLog implements EclipseAnnotationHandler<lombok.extern.java.Log> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
return processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
}
}
/**
- * Handles the {@link lombok.extern.log4j.Log} annotation for Eclipse.
+ * Handles the {@link lombok.extern.log4j.Log4j} annotation for Eclipse.
*/
@ProviderFor(EclipseAnnotationHandler.class)
- public static class HandleLog4jLog implements EclipseAnnotationHandler<lombok.extern.log4j.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.log4j.Log> annotation, Annotation source, EclipseNode annotationNode) {
+ public static class HandleLog4jLog implements EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
return processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
}
}
/**
- * Handles the {@link lombok.extern.slf4j.Log} annotation for Eclipse.
+ * Handles the {@link lombok.extern.slf4j.Slf4j} annotation for Eclipse.
*/
@ProviderFor(EclipseAnnotationHandler.class)
- public static class HandleSlf4jLog implements EclipseAnnotationHandler<lombok.extern.slf4j.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.slf4j.Log> annotation, Annotation source, EclipseNode annotationNode) {
+ public static class HandleSlf4jLog implements EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
return processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode);
}
}
enum LoggingFramework {
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
- COMMONS(lombok.extern.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog"),
+ COMMONS("org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog"),
// private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName());
- JUL(lombok.extern.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger", "getLogger") {
+ JUL("java.util.logging.Logger", "java.util.logging.Logger", "getLogger") {
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
@@ -222,29 +214,23 @@ public class HandleLog {
},
// private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class);
- LOG4J(lombok.extern.jul.Log.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger", "getLogger"),
+ LOG4J("org.apache.log4j.Logger", "org.apache.log4j.Logger", "getLogger"),
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class);
- SLF4J(lombok.extern.slf4j.Log.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory", "getLogger"),
+ SLF4J("org.slf4j.Logger", "org.slf4j.LoggerFactory", "getLogger"),
;
- private final Class<? extends java.lang.annotation.Annotation> annotationClass;
private final String loggerTypeName;
private final String loggerFactoryTypeName;
private final String loggerFactoryMethodName;
- LoggingFramework(Class<? extends java.lang.annotation.Annotation> annotationClass, String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName) {
- this.annotationClass = annotationClass;
+ LoggingFramework(String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName) {
this.loggerTypeName = loggerTypeName;
this.loggerFactoryTypeName = loggerFactoryTypeName;
this.loggerFactoryMethodName = loggerFactoryMethodName;
}
- final Class<? extends java.lang.annotation.Annotation> getAnnotationClass() {
- return annotationClass;
- }
-
final String getLoggerTypeName() {
return loggerTypeName;
}
diff --git a/src/core/lombok/extern/apachecommons/Log.java b/src/core/lombok/extern/apachecommons/CommonsLog.java
index 87e7ab2c..452f97f0 100644
--- a/src/core/lombok/extern/apachecommons/Log.java
+++ b/src/core/lombok/extern/apachecommons/CommonsLog.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* Causes lombok to generate a logger field.
* Example:
* <pre>
- * &#64;Log
+ * &#64;CommonsLog
* public class LogExample {
* }
* </pre>
@@ -43,35 +43,15 @@ import java.lang.annotation.Target;
* }
* </pre>
*
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class.
- * Example:
- * <pre>
- * &#64;Log(java.util.List.class)
- * public class LogExample {
- * }
- * </pre>
- *
- * will generate:
- *
- * <pre>
- * public class LogExample {
- * private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(java.util.List.class);
- * }
- * </pre>
- *
* This annotation is valid for classes and enumerations.<br />
*
* @see org.apache.commons.logging.Log org.apache.commons.logging.Log
* @see org.apache.commons.logging.LogFactory#getLog(java.lang.Class) org.apache.commons.logging.LogFactory.getLog(Class target)
- * @see lombok.extern.jul.Log lombok.extern.jul.Log
- * @see lombok.extern.log4j.Log lombok.extern.log4j.Log
- * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log
+ * @see lombok.extern.java.Log &#64;Log
+ * @see lombok.extern.log4j.Log4j &#64;Log4j
+ * @see lombok.extern.slf4j.Slf4j &#64;Slf4j
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-public @interface Log {
- /**
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here.
- */
- Class<?> value() default void.class;
+public @interface CommonsLog {
} \ No newline at end of file
diff --git a/src/core/lombok/extern/jul/Log.java b/src/core/lombok/extern/java/Log.java
index 8b2ec3af..e6e01736 100644
--- a/src/core/lombok/extern/jul/Log.java
+++ b/src/core/lombok/extern/java/Log.java
@@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-package lombok.extern.jul;
+package lombok.extern.java;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -43,34 +43,14 @@ import java.lang.annotation.Target;
* }
* </pre>
*
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class.
- * Example:
- * <pre>
- * &#64;Log(java.util.List.class)
- * public class LogExample {
- * }
- * </pre>
- *
- * will generate:
- *
- * <pre>
- * public class LogExample {
- * private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.util.List.class.getName());
- * }
- * </pre>
- *
* This annotation is valid for classes and enumerations.<br />
* @see java.util.logging.Logger java.util.logging.Logger
* @see java.util.logging.Logger#getLogger(java.lang.String) java.util.logging.Logger.getLogger(String name)
- * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log
- * @see lombok.extern.log4j.Log lombok.extern.log4j.Log
- * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log
+ * @see lombok.extern.apachecommons.CommonsLog &#64;CommonsLog
+ * @see lombok.extern.log4j.Log4j &#64;Log4j
+ * @see lombok.extern.slf4j.Slf4j &#64;Slf4j
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Log {
- /**
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here.
- */
- Class<?> value() default void.class;
} \ No newline at end of file
diff --git a/src/core/lombok/extern/log4j/Log.java b/src/core/lombok/extern/log4j/Log4j.java
index 9d07f46d..eeaf80be 100644
--- a/src/core/lombok/extern/log4j/Log.java
+++ b/src/core/lombok/extern/log4j/Log4j.java
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* Causes lombok to generate a logger field.
* Example:
* <pre>
- * &#64;Log
+ * &#64;Log4j
* public class LogExample {
* }
* </pre>
@@ -43,35 +43,15 @@ import java.lang.annotation.Target;
* }
* </pre>
*
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class.
- * Example:
- * <pre>
- * &#64;Log(java.util.List.class)
- * public class LogExample {
- * }
- * </pre>
- *
- * will generate:
- *
- * <pre>
- * public class LogExample {
- * private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(java.util.List.class);
- * }
- * </pre>
- *
* This annotation is valid for classes and enumerations.<br />
*
* @see org.apache.log4j.Logger org.apache.log4j.Logger
* @see org.apache.log4j.Logger#getLogger(java.lang.Class) org.apache.log4j.Logger.getLogger(Class target)
- * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log
- * @see lombok.extern.jul.Log lombok.extern.jul.Log
- * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log
+ * @see lombok.extern.apachecommons.CommonsLog &#64;CommonsLog
+ * @see lombok.extern.java.Log &#64;Log
+ * @see lombok.extern.slf4j.Slf4j &#64;Slf4j
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-public @interface Log {
- /**
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here.
- */
- Class<?> value() default void.class;
+public @interface Log4j {
} \ No newline at end of file
diff --git a/src/core/lombok/extern/slf4j/Log.java b/src/core/lombok/extern/slf4j/Slf4j.java
index 63307008..4986fd0c 100644
--- a/src/core/lombok/extern/slf4j/Log.java
+++ b/src/core/lombok/extern/slf4j/Slf4j.java
@@ -29,7 +29,7 @@ import java.lang.annotation.Target;
* Causes lombok to generate a logger field.
* Example:
* <pre>
- * &#64;Log
+ * &#64;Slf4j
* public class LogExample {
* }
* </pre>
@@ -42,34 +42,14 @@ import java.lang.annotation.Target;
* }
* </pre>
*
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class.
- * Example:
- * <pre>
- * &#64;Log(java.util.List.class)
- * public class LogExample {
- * }
- * </pre>
- *
- * will generate:
- *
- * <pre>
- * public class LogExample {
- * private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.util.List.class);
- * }
- * </pre>
- *
* This annotation is valid for classes and enumerations.<br />
* @see org.slf4j.Logger org.slf4j.Logger
* @see org.slf4j.LoggerFactory#getLogger(java.lang.Class) org.slf4j.LoggerFactory.getLogger(Class target)
- * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log
- * @see lombok.extern.jul.Log lombok.extern.jul.Log
- * @see lombok.extern.log4j.Log lombok.extern.log4j.Log
+ * @see lombok.extern.apachecommons.CommonsLog &#64;CommonsLog
+ * @see lombok.extern.java.Log &#64;Log
+ * @see lombok.extern.log4j.Log4j &#64;Log4j
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-public @interface Log {
- /**
- * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here.
- */
- Class<?> value() default void.class;
+public @interface Slf4j {
}
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index c72892cc..53d327af 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -52,19 +52,6 @@ public class HandleLog {
public static boolean processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode) {
markAnnotationAsProcessed(annotationNode, framework.getAnnotationClass());
-// String loggingClassName = annotation.getRawExpression("value");
-// if (loggingClassName == null) loggingClassName = "void";
-// if (loggingClassName.endsWith(".class")) loggingClassName = loggingClassName.substring(0, loggingClassName.length() - 6);
-
- JCExpression annotationValue = (JCExpression) annotation.getActualExpression("value");
- JCFieldAccess loggingType = null;
- if (annotationValue != null) {
- if (!(annotationValue instanceof JCFieldAccess)) return true;
- loggingType = (JCFieldAccess) annotationValue;
- if (!loggingType.name.contentEquals("class")) return true;
- }
-
-
JavacNode typeNode = annotationNode.up();
switch (typeNode.getKind()) {
case TYPE:
@@ -78,9 +65,7 @@ public class HandleLog {
return true;
}
- if (loggingType == null) {
- loggingType = selfType(typeNode);
- }
+ JCFieldAccess loggingType = selfType(typeNode);
createField(framework, typeNode, loggingType);
return true;
default:
@@ -114,11 +99,11 @@ public class HandleLog {
}
/**
- * Handles the {@link lombok.extern.apachecommons.Log} annotation for javac.
+ * Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for javac.
*/
@ProviderFor(JavacAnnotationHandler.class)
- public static class HandleCommonsLog implements JavacAnnotationHandler<lombok.extern.apachecommons.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.apachecommons.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ public static class HandleCommonsLog implements JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
return processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode);
}
@@ -128,11 +113,11 @@ public class HandleLog {
}
/**
- * Handles the {@link lombok.extern.jul.Log} annotation for javac.
+ * Handles the {@link lombok.extern.java.Log} annotation for javac.
*/
@ProviderFor(JavacAnnotationHandler.class)
- public static class HandleJulLog implements JavacAnnotationHandler<lombok.extern.jul.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.jul.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ public static class HandleJulLog implements JavacAnnotationHandler<lombok.extern.java.Log> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
return processAnnotation(LoggingFramework.JUL, annotation, annotationNode);
}
@@ -142,11 +127,11 @@ public class HandleLog {
}
/**
- * Handles the {@link lombok.extern.log4j.Log} annotation for javac.
+ * Handles the {@link lombok.extern.log4j.Log4j} annotation for javac.
*/
@ProviderFor(JavacAnnotationHandler.class)
- public static class HandleLog4jLog implements JavacAnnotationHandler<lombok.extern.log4j.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.log4j.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ public static class HandleLog4jLog implements JavacAnnotationHandler<lombok.extern.log4j.Log4j> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
return processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode);
}
@@ -156,11 +141,11 @@ public class HandleLog {
}
/**
- * Handles the {@link lombok.extern.slf4j.Log} annotation for javac.
+ * Handles the {@link lombok.extern.slf4j.Slf4j} annotation for javac.
*/
@ProviderFor(JavacAnnotationHandler.class)
- public static class HandleSlf4jLog implements JavacAnnotationHandler<lombok.extern.slf4j.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.slf4j.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ public static class HandleSlf4jLog implements JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> {
+ @Override public boolean handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
return processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode);
}
@@ -171,10 +156,10 @@ public class HandleLog {
enum LoggingFramework {
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
- COMMONS(lombok.extern.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"),
+ COMMONS(lombok.extern.apachecommons.CommonsLog.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"),
// private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName());
- JUL(lombok.extern.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger.getLogger") {
+ JUL(lombok.extern.java.Log.class, "java.util.logging.Logger", "java.util.logging.Logger.getLogger") {
@Override public JCExpression createFactoryParameter(JavacNode typeNode, JCFieldAccess loggingType) {
TreeMaker maker = typeNode.getTreeMaker();
JCExpression method = maker.Select(loggingType, typeNode.toName("getName"));
@@ -183,10 +168,10 @@ public class HandleLog {
},
// private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class);
- LOG4J(lombok.extern.jul.Log.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger.getLogger"),
+ LOG4J(lombok.extern.log4j.Log4j.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger.getLogger"),
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class);
- SLF4J(lombok.extern.slf4j.Log.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory.getLogger"),
+ SLF4J(lombok.extern.slf4j.Slf4j.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory.getLogger"),
;