diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-12-11 22:38:59 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-12-11 22:40:49 +0100 |
commit | 7d51842ca381c491d5dfb44bc76b0cea345e7170 (patch) | |
tree | 0755b629d11d88b15713bac67d9c12751fe8294b | |
parent | 5f92913a52f46300235e6f31b356025998d9f859 (diff) | |
download | lombok-7d51842ca381c491d5dfb44bc76b0cea345e7170.tar.gz lombok-7d51842ca381c491d5dfb44bc76b0cea345e7170.tar.bz2 lombok-7d51842ca381c491d5dfb44bc76b0cea345e7170.zip |
semi-fix for issue 602, but not complete as adding annotations to generated fields leads to crazy issues (see issue 217): generated LOG field now has @SuppressWarnings on it.
11 files changed, 24 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 2e7b4475..dd2c7ea8 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -73,6 +73,8 @@ public class HandleLog { FieldDeclaration fieldDeclaration = createField(framework, source, loggingType); 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); injectField(owner, fieldDeclaration); owner.rebuild(); break; diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index 75a490a5..296f5e92 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -93,7 +93,7 @@ public class HandleLog { maker.Modifiers(Flags.PRIVATE | Flags.FINAL | Flags.STATIC), typeNode.toName("log"), loggerType, factoryMethodCall), source, typeNode.getContext()); - injectField(typeNode, fieldDecl); + injectFieldSuppressWarnings(typeNode, fieldDecl); return true; } diff --git a/test/transform/resource/after-delombok/InjectField.java b/test/transform/resource/after-delombok/InjectField.java index a9b4b1c4..59896400 100644 --- a/test/transform/resource/after-delombok/InjectField.java +++ b/test/transform/resource/after-delombok/InjectField.java @@ -4,6 +4,7 @@ enum InjectField1 { A, B; + @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField1.class.getName()); @java.lang.SuppressWarnings("all") private final java.lang.Object $lock = new java.lang.Object[0]; @@ -34,6 +35,7 @@ enum InjectField1 { } class InjectField2 { + @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField2.class.getName()); @java.lang.SuppressWarnings("all") private final java.lang.Object $lock = new java.lang.Object[0]; @@ -52,6 +54,7 @@ class InjectField2 { } class InjectField3 { + @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField3.class.getName()); static { log.log(Level.FINE, "static initializer"); diff --git a/test/transform/resource/after-delombok/LoggerCommons.java b/test/transform/resource/after-delombok/LoggerCommons.java index dfe3e88d..6feea5b6 100644 --- a/test/transform/resource/after-delombok/LoggerCommons.java +++ b/test/transform/resource/after-delombok/LoggerCommons.java @@ -1,6 +1,8 @@ class LoggerCommons { + @java.lang.SuppressWarnings("all") private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommons.class); } class LoggerCommonsWithImport { + @java.lang.SuppressWarnings("all") private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java index b020c540..20f0d24d 100644 --- a/test/transform/resource/after-delombok/LoggerJul.java +++ b/test/transform/resource/after-delombok/LoggerJul.java @@ -1,6 +1,8 @@ class LoggerJul { + @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName()); } class LoggerJulWithImport { + @java.lang.SuppressWarnings("all") private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName()); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerLog4j.java b/test/transform/resource/after-delombok/LoggerLog4j.java index dfbad89a..7d54b259 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j.java +++ b/test/transform/resource/after-delombok/LoggerLog4j.java @@ -1,6 +1,8 @@ class LoggerLog4j { + @java.lang.SuppressWarnings("all") private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4j.class); } class LoggerLog4jWithImport { + @java.lang.SuppressWarnings("all") private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java index 3447a9a5..7e4c01de 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j2.java +++ b/test/transform/resource/after-delombok/LoggerLog4j2.java @@ -1,6 +1,8 @@ class LoggerLog4j2 { + @java.lang.SuppressWarnings("all") private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2.class); } class LoggerLog4j2WithImport { + @java.lang.SuppressWarnings("all") private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class); }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java index 4cc7c107..a07c8546 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerSlf4j.java @@ -1,11 +1,14 @@ class LoggerSlf4j { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4j.class); } class LoggerSlf4jWithImport { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithImport.class); } class LoggerSlf4jOuter { static class Inner { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); } }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerSlf4jTypes.java b/test/transform/resource/after-delombok/LoggerSlf4jTypes.java index 4950bc88..5ea59924 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4jTypes.java +++ b/test/transform/resource/after-delombok/LoggerSlf4jTypes.java @@ -4,14 +4,17 @@ interface LoggerSlf4jTypesInterface { } enum LoggerSlf4jTypesEnum { ; + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnum.class); } enum LoggerSlf4jTypesEnumWithElement { FOO; + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnumWithElement.class); } interface LoggerSlf4jTypesInterfaceOuter { class Inner { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); } }
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerSlf4jWithPackage.java b/test/transform/resource/after-delombok/LoggerSlf4jWithPackage.java index b337bd02..b82ed6ec 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4jWithPackage.java +++ b/test/transform/resource/after-delombok/LoggerSlf4jWithPackage.java @@ -1,9 +1,11 @@ package before; class LoggerSlf4jWithPackage { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithPackage.class); } class LoggerSlf4jWithPackageOuter { static class Inner { + @java.lang.SuppressWarnings("all") private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); } } diff --git a/test/transform/resource/after-delombok/LoggerXSlf4j.java b/test/transform/resource/after-delombok/LoggerXSlf4j.java index 7d8f3236..981bcca6 100644 --- a/test/transform/resource/after-delombok/LoggerXSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerXSlf4j.java @@ -1,6 +1,8 @@ class LoggerXSlf4j { + @java.lang.SuppressWarnings("all") private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4j.class); } class LoggerXSlf4jWithImport { + @java.lang.SuppressWarnings("all") private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithImport.class); }
\ No newline at end of file |