aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2015-01-30 14:35:47 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2015-01-30 14:35:47 +0100
commit7efbecfe49af452f117e6a16c969a4b2071e80cd (patch)
treebc383202f69d02c6dcf5f18da070558c7e421083 /src/core/lombok/javac
parent8ed49ce0b5c0dbddb66a5519086a033889e6e2e2 (diff)
parent8a6c581bf6b4126c0dfd2dfb53bd03160712e8ae (diff)
downloadlombok-7efbecfe49af452f117e6a16c969a4b2071e80cd.tar.gz
lombok-7efbecfe49af452f117e6a16c969a4b2071e80cd.tar.bz2
lombok-7efbecfe49af452f117e6a16c969a4b2071e80cd.zip
Merge branch 'master' of https://github.com/petercgrant/lombok into i623
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java24
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;