diff options
Diffstat (limited to 'src')
5 files changed, 25 insertions, 10 deletions
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 8d8fb03b..e18fe66c 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -35,6 +35,15 @@ public class ConfigurationKeys { // ##### main package features ##### + // ----- global ----- + + /** + * lombok configuration: {@code lombok.addGeneratedAnnotation} = {@code true} | {@code false}. + * + * If unset or {@code true}, lombok generates {@code @javax.annotation.Generated("lombok")} on all fields, methods, and types that are generated. + */ + public static final ConfigurationKey<Boolean> ADD_GENERATED_ANNOTATIONS = new ConfigurationKey<Boolean>("lombok.addGeneratedAnnotation", "Generate @javax.annotation.Generated on all generated code (default: true).") {}; + // ----- *ArgsConstructor ----- /** diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 1b27fce5..23a5f4bc 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1216,7 +1216,7 @@ public class EclipseHandlerUtil { */ public static EclipseNode injectFieldAndMarkGenerated(EclipseNode type, FieldDeclaration field) { field.annotations = addSuppressWarningsAll(field, field.annotations); - field.annotations = addGenerated(field, field.annotations); + field.annotations = addGenerated(type, field, field.annotations); return injectField(type, field); } @@ -1262,7 +1262,7 @@ public class EclipseHandlerUtil { */ public static EclipseNode injectMethod(EclipseNode type, AbstractMethodDeclaration method) { method.annotations = addSuppressWarningsAll(method, method.annotations); - method.annotations = addGenerated(method, method.annotations); + method.annotations = addGenerated(type, method, method.annotations); TypeDeclaration parent = (TypeDeclaration) type.get(); if (parent.methods == null) { @@ -1305,7 +1305,7 @@ public class EclipseHandlerUtil { */ public static EclipseNode injectType(final EclipseNode typeNode, final TypeDeclaration type) { type.annotations = addSuppressWarningsAll(type, type.annotations); - type.annotations = addGenerated(type, type.annotations); + type.annotations = addGenerated(typeNode, type, type.annotations); TypeDeclaration parent = (TypeDeclaration) typeNode.get(); if (parent.memberTypes == null) { @@ -1328,7 +1328,8 @@ public class EclipseHandlerUtil { return addAnnotation(source, originalAnnotationArray, TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, new StringLiteral(ALL, 0, 0, 0)); } - public static Annotation[] addGenerated(ASTNode source, Annotation[] originalAnnotationArray) { + public static Annotation[] addGenerated(EclipseNode node, ASTNode source, Annotation[] originalAnnotationArray) { + if (Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_GENERATED_ANNOTATIONS))) return originalAnnotationArray; return addAnnotation(source, originalAnnotationArray, JAVAX_ANNOTATION_GENERATED, new StringLiteral(LOMBOK, 0, 0, 0)); } diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index a6bc388a..599a4753 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -956,6 +956,7 @@ public class JavacHandlerUtil { } public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) { + if (Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_GENERATED_ANNOTATIONS))) return; if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return; addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok")); } diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 53e01ebb..7fca01ae 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -231,13 +231,13 @@ public class JavacSingularsRecipes { if (typeArgs != null) for (JCExpression orig : typeArgs) { if (!addExtends) { if (orig.getKind() == Kind.UNBOUNDED_WILDCARD || orig.getKind() == Kind.SUPER_WILDCARD) { - arguments.append(chainDots(node, "java", "lang", "Object")); + arguments.append(genJavaLangTypeRef(node, "Object")); } else if (orig.getKind() == Kind.EXTENDS_WILDCARD) { JCExpression inner; try { inner = (JCExpression) ((JCWildcard) orig).inner; } catch (Exception e) { - inner = chainDots(node, "java", "lang", "Object"); + inner = genJavaLangTypeRef(node, "Object"); } arguments.append(cloneType(maker, inner, source, context)); } else { @@ -259,7 +259,7 @@ public class JavacSingularsRecipes { if (addExtends) { arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null)); } else { - arguments.append(chainDots(node, "java", "lang", "Object")); + arguments.append(genJavaLangTypeRef(node, "Object")); } } @@ -280,16 +280,16 @@ public class JavacSingularsRecipes { protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JCTree source) { if (typeArgs == null || typeArgs.size() <= index) { - return chainDots(builderType, "java", "lang", "Object"); + return genJavaLangTypeRef(builderType, "Object"); } else { JCExpression originalType = typeArgs.get(index); if (originalType.getKind() == Kind.UNBOUNDED_WILDCARD || originalType.getKind() == Kind.SUPER_WILDCARD) { - return chainDots(builderType, "java", "lang", "Object"); + return genJavaLangTypeRef(builderType, "Object"); } else if (originalType.getKind() == Kind.EXTENDS_WILDCARD) { try { return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source, builderType.getContext()); } catch (Exception e) { - return chainDots(builderType, "java", "lang", "Object"); + return genJavaLangTypeRef(builderType, "Object"); } } else { return cloneType(maker, originalType, source, builderType.getContext()); diff --git a/src/delombok/lombok/delombok/FormatPreferences.java b/src/delombok/lombok/delombok/FormatPreferences.java index 1479a740..5ba3b8cd 100644 --- a/src/delombok/lombok/delombok/FormatPreferences.java +++ b/src/delombok/lombok/delombok/FormatPreferences.java @@ -138,4 +138,8 @@ public final class FormatPreferences { public boolean generateConstructorProperties() { return generateConstructorProperties; } + + @Override public String toString() { + return rawMap.toString(); + } } |