diff options
author | Peter Grant <Peter.Grant@concur.com> | 2015-01-26 13:41:07 -0800 |
---|---|---|
committer | Peter Grant <Peter.Grant@concur.com> | 2015-01-26 13:41:07 -0800 |
commit | 5a5f465a0433bef33ddb1260c338b26e1598501c (patch) | |
tree | 8e6eca1962ddd6e4ccd66ddbdbcb46b2b2f8004c /src/core | |
parent | 5c7493511dc3108c593617922cbc62285e4475f4 (diff) | |
download | lombok-5a5f465a0433bef33ddb1260c338b26e1598501c.tar.gz lombok-5a5f465a0433bef33ddb1260c338b26e1598501c.tar.bz2 lombok-5a5f465a0433bef33ddb1260c338b26e1598501c.zip |
[i623] Added javac impl of javax.annotation.Generated
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 8a8c5acd..bf364641 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -893,6 +893,7 @@ public class JavacHandlerUtil { } addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext()); + addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext()); type.defs = type.defs.append(method); typeNode.add(method, Kind.METHOD); @@ -908,6 +909,7 @@ public class JavacHandlerUtil { public static JavacNode injectType(JavacNode typeNode, final JCClassDecl type) { JCClassDecl typeDecl = (JCClassDecl) typeNode.get(); addSuppressWarningsAll(type.mods, typeNode, type.pos, getGeneratedBy(type), typeNode.getContext()); + addGenerated(type.mods, typeNode, type.pos, getGeneratedBy(type), typeNode.getContext()); typeDecl.defs = typeDecl.defs.append(type); return typeNode.add(type, Kind.TYPE); } @@ -965,7 +967,27 @@ public class JavacHandlerUtil { annotation.pos = pos; mods.annotations = mods.annotations.append(annotation); } - + + public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { + if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) 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("Generated")) return; + } + JavacTreeMaker maker = node.getTreeMaker(); + JCExpression generatedType = chainDots(node, "javax", "annotation", "Generated"); + JCExpression lombokLiteral = maker.Literal("lombok"); + generatedType.pos = pos; + lombokLiteral.pos = pos; + JCAnnotation annotation = recursiveSetGeneratedBy(maker.Annotation(generatedType, List.<JCExpression>of(lombokLiteral)), source, context); + annotation.pos = pos; + mods.annotations = mods.annotations.append(annotation); + } + private static List<JCTree> addAllButOne(List<JCTree> defs, int idx) { ListBuffer<JCTree> out = new ListBuffer<JCTree>(); int i = 0; |