diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-09 04:46:59 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-09 04:46:59 +0100 |
commit | 685ddfd52ebba4ca85ff93e08de14f38ecd8714b (patch) | |
tree | 74a1c6d51de69414e57ee7e187865d8841b2d091 /src/core/lombok | |
parent | 7bbe19f1b8982e21ef0aa94644397b4961a5c470 (diff) | |
download | lombok-685ddfd52ebba4ca85ff93e08de14f38ecd8714b.tar.gz lombok-685ddfd52ebba4ca85ff93e08de14f38ecd8714b.tar.bz2 lombok-685ddfd52ebba4ca85ff93e08de14f38ecd8714b.zip |
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.
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 13 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 8 |
2 files changed, 21 insertions, 0 deletions
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]; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 03c2dcff..d6d47b6c 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -918,6 +918,14 @@ public class JavacHandlerUtil { private static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return; + for (JCAnnotation ann : mods.annotations) { + JCTree annType = ann.getAnnotationType(); + Name lastPart = null; + if (annType instanceof JCIdent) lastPart = ((JCIdent) annType).name; + else if (annType instanceof JCFieldAccess) lastPart = ((JCFieldAccess) annType).name; + + if (lastPart != null && lastPart.contentEquals("SuppressWarnings")) return; + } JavacTreeMaker maker = node.getTreeMaker(); JCExpression suppressWarningsType = genJavaLangTypeRef(node, "SuppressWarnings"); JCLiteral allLiteral = maker.Literal("all"); |