diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-01-20 00:38:10 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-01-20 00:38:10 +0100 |
commit | ce9fa7fb06fda7c459e381022f38564c31b41744 (patch) | |
tree | 87bd0cf8593b008e37a5b152c698e1f3c0ebfea1 /src/core/lombok/javac | |
parent | 00ce9a72e6625f685da485b3338a9f52ce4227e5 (diff) | |
parent | ac2bedb8f31c73a9b92793611c9199ba95f904af (diff) | |
download | lombok-ce9fa7fb06fda7c459e381022f38564c31b41744.tar.gz lombok-ce9fa7fb06fda7c459e381022f38564c31b41744.tar.bz2 lombok-ce9fa7fb06fda7c459e381022f38564c31b41744.zip |
Merge remote-tracking branch 'origin/master' into playNiceWithOtherAP
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index af6bb48f..0b4e839d 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1025,9 +1025,12 @@ public class JavacHandlerUtil { public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return; - if (!Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_GENERATED_ANNOTATIONS))) { + if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_JAVAX_GENERATED_ANNOTATIONS)) { addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok")); } + if (HandlerUtil.shouldAddGenerated(node, ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS)) { + addAnnotation(mods, node, pos, source, context, "lombok.Generated", null); + } } private static void addAnnotation(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context, String annotationTypeFqn, JCExpression arg) { @@ -1041,12 +1044,16 @@ public class JavacHandlerUtil { 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 (annType instanceof JCIdent) { + Name lastPart = ((JCIdent) annType).name; + if (lastPart.contentEquals(simpleName)) return; + } - if (lastPart != null && lastPart.contentEquals(simpleName)) return; + if (annType instanceof JCFieldAccess) { + if (annType.toString().equals(annotationTypeFqn)) return; + } } + JavacTreeMaker maker = node.getTreeMaker(); JCExpression annType = isJavaLangBased ? genJavaLangTypeRef(node, simpleName) : chainDotsString(node, annotationTypeFqn); annType.pos = pos; |