diff options
author | Roel Spilker <r.spilker@gmail.com> | 2017-01-06 01:05:16 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2017-01-06 01:05:16 +0100 |
commit | 9e4292dae4ab63439315b3a4015085fe4913170e (patch) | |
tree | ab1bf4fa3109d333e81db6395474a7372a8963b8 /src/core/lombok/javac/handlers/JavacHandlerUtil.java | |
parent | d1ee4d5809663098de525bb096145bbc367c2831 (diff) | |
download | lombok-9e4292dae4ab63439315b3a4015085fe4913170e.tar.gz lombok-9e4292dae4ab63439315b3a4015085fe4913170e.tar.bz2 lombok-9e4292dae4ab63439315b3a4015085fe4913170e.zip |
add `@lombok.Generated` to generated classes, methods and fields
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index efa67604..98c6a340 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 The Project Lombok Authors. + * Copyright (C) 2009-2017 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -999,9 +999,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) { @@ -1015,12 +1018,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; |