aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2021-01-26 22:55:08 +0100
committerRoel Spilker <r.spilker@gmail.com>2021-01-28 19:40:41 +0100
commita234a8e1d1dadc6990f8b8f1d87e93757beafe1c (patch)
treef22ae294875d08641e5ea300dedc38c873ceb9e8 /src
parent04f17f4dcfbb0e7881d605708467498e3ec56521 (diff)
downloadlombok-a234a8e1d1dadc6990f8b8f1d87e93757beafe1c.tar.gz
lombok-a234a8e1d1dadc6990f8b8f1d87e93757beafe1c.tar.bz2
lombok-a234a8e1d1dadc6990f8b8f1d87e93757beafe1c.zip
[fixes #2691] Add end positions to all generated nodes
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java43
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilderDefault.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleCleanup.java6
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java16
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java25
-rw-r--r--src/core/lombok/javac/handlers/HandleExtensionMethod.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldNameConstants.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java18
-rwxr-xr-xsrc/core/lombok/javac/handlers/HandleHelper.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleJacksonized.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleNonNull.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleSneakyThrows.java13
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java74
-rw-r--r--src/core/lombok/javac/handlers/HandleSynchronized.java8
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleUtilityClass.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleValue.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleWith.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleWithBy.java7
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java85
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java54
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java13
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java11
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java5
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java15
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java3
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java7
31 files changed, 234 insertions, 237 deletions
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index 867d6889..e867fd63 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -109,7 +109,6 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
boolean isStatic;
List<JCTypeParameter> typeParams;
List<JCTypeParameter> builderTypeParams;
- JCTree source;
JavacNode sourceNode;
java.util.List<BuilderFieldData> builderFields;
AccessLevel accessInners, accessOuters;
@@ -197,7 +196,6 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
handleFlagUsage(annotationNode, ConfigurationKeys.BUILDER_FLAG_USAGE, "@Builder");
BuilderJob job = new BuilderJob();
job.sourceNode = annotationNode;
- job.source = ast;
job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
job.isStatic = true;
@@ -274,7 +272,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
bfd.nameOfSetFlag = parent.toName(bfd.name + SET_PREFIX);
bfd.builderFieldName = parent.toName(bfd.name + VALUE_PREFIX);
JCMethodDecl md = generateDefaultProvider(bfd.nameOfDefaultProvider, fieldNode, td.typarams);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
@@ -317,7 +315,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
buildMethodThrownExceptions = jmd.thrown;
nameOfBuilderMethod = jmd.name;
if (buildMethodReturnType instanceof JCTypeApply) {
- buildMethodReturnType = cloneType(job.getTreeMaker(), buildMethodReturnType, ast, annotationNode.getContext());
+ buildMethodReturnType = cloneType(job.getTreeMaker(), buildMethodReturnType, annotationNode);
}
if (job.builderClassName.indexOf('*') > -1) {
String replStr = returnTypeToBuilderClassName(annotationNode, td, buildMethodReturnType, job.typeParams);
@@ -415,7 +413,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
job.builderType = findInnerClass(job.parentType, job.builderClassName);
if (job.builderType == null) {
job.builderType = makeBuilderClass(job);
- recursiveSetGeneratedBy(job.builderType.get(), ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(job.builderType.get(), annotationNode);
} else {
JCClassDecl builderTypeDeclaration = (JCClassDecl) job.builderType.get();
if (job.isStatic && !builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)) {
@@ -463,7 +461,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JavacTreeMaker maker = job.getTreeMaker();
JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), job.builderType.toName(CLEAN_FIELD_NAME), maker.TypeIdent(CTC_BOOLEAN), null);
injectFieldAndMarkGenerated(job.builderType, uncleanField);
- recursiveSetGeneratedBy(uncleanField, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(uncleanField, annotationNode);
}
if (constructorExists(job.builderType) == MemberExistsResult.NOT_EXISTS) {
@@ -481,8 +479,8 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (methodExists == MemberExistsResult.NOT_EXISTS) {
JCMethodDecl md = generateBuildMethod(job, nameOfBuilderMethod, buildMethodReturnType, buildMethodThrownExceptions, addCleaning);
if (md != null) {
+ recursiveSetGeneratedBy(md, annotationNode);
injectMethod(job.builderType, md);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
}
}
}
@@ -495,7 +493,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
}
- JCMethodDecl md = HandleToString.createToString(job.builderType, fieldNodes, true, false, FieldAccess.ALWAYS_FIELD, ast);
+ JCMethodDecl md = HandleToString.createToString(job.builderType, fieldNodes, true, false, FieldAccess.ALWAYS_FIELD, job.sourceNode);
if (md != null) injectMethod(job.builderType, md);
}
@@ -504,7 +502,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (generateBuilderMethod && methodExists(job.builderMethodName, job.parentType, -1) != MemberExistsResult.NOT_EXISTS) generateBuilderMethod = false;
if (generateBuilderMethod) {
JCMethodDecl md = generateBuilderMethod(job);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
if (md != null) injectMethod(job.parentType, md);
}
@@ -525,7 +523,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
JCMethodDecl md = generateToBuilderMethod(job, tps, annInstance.setterPrefix());
if (md != null) {
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
injectMethod(job.parentType, md);
}
}
@@ -645,7 +643,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
// javac appears to cache the type of JCMethodInvocation expressions based on position, meaning, if you have 2 ObtainVia-based method invokes on different types, you get bizarre type mismatch errors.
// going via a local variable declaration solves the problem.
- JCExpression varType = JavacHandlerUtil.cloneType(maker, bfd.type, job.source, job.getContext());
+ JCExpression varType = JavacHandlerUtil.cloneType(maker, bfd.type, job.sourceNode);
if (preStatements == null) preStatements = new ListBuffer<JCStatement>();
preStatements.append(maker.VarDef(maker.Modifiers(Flags.FINAL), bfd.name, varType, inv));
}
@@ -687,14 +685,14 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, job.source, statements);
+ bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, job.builderType, job.sourceNode, statements);
}
}
statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(job.toName("this")), job.toName(CLEAN_FIELD_NAME)), maker.Literal(CTC_BOOLEAN, 0))));
JCBlock body = maker.Block(0, statements.toList());
JCMethodDecl method = maker.MethodDef(maker.Modifiers(toJavacModifier(AccessLevel.PRIVATE)), job.toName(CLEAN_METHOD_NAME), maker.Type(Javac.createVoidType(job.builderType.getSymbolTable(), CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
- recursiveSetGeneratedBy(method, job.source, job.getContext());
+ recursiveSetGeneratedBy(method, job.sourceNode);
return method;
}
@@ -736,7 +734,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
for (BuilderFieldData bfd : job.builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, job.builderType, job.source, statements, bfd.builderFieldName, "this");
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, job.builderType, job.sourceNode, statements, bfd.builderFieldName, "this");
}
}
@@ -744,7 +742,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
Name thisName = job.toName("this");
for (BuilderFieldData bfd : job.builderFields) {
if (bfd.nameOfSetFlag != null) {
- statements.append(maker.VarDef(maker.Modifiers(0L), bfd.builderFieldName, cloneType(maker, bfd.type, job.source, job.getContext()), maker.Select(maker.Ident(thisName), bfd.builderFieldName)));
+ statements.append(maker.VarDef(maker.Modifiers(0L), bfd.builderFieldName, cloneType(maker, bfd.type, job.sourceNode), maker.Select(maker.Ident(thisName), bfd.builderFieldName)));
statements.append(maker.If(maker.Unary(CTC_NOT, maker.Select(maker.Ident(thisName), bfd.nameOfSetFlag)), maker.Exec(maker.Assign(maker.Ident(bfd.builderFieldName), maker.Apply(typeParameterNames(maker, ((JCClassDecl) job.parentType.get()).typarams), maker.Select(maker.Ident(((JCClassDecl) job.parentType.get()).name), bfd.nameOfDefaultProvider), List.<JCExpression>nil()))), null));
}
if (bfd.nameOfSetFlag != null || (bfd.singularData != null && bfd.singularData.getSingularizer().shadowedDuringBuild())) {
@@ -800,7 +798,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
int modifiers = Flags.PRIVATE | Flags.STATIC;
- return maker.MethodDef(maker.Modifiers(modifiers), methodName, cloneType(maker, field.vartype, field, fieldNode.getContext()), copyTypeParams(fieldNode, params), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
+ return maker.MethodDef(maker.Modifiers(modifiers), methodName, cloneType(maker, field.vartype, fieldNode), copyTypeParams(fieldNode, params), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
public JCMethodDecl generateBuilderMethod(BuilderJob job) {
@@ -850,7 +848,11 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
for (int i = len - 1; i >= 0; i--) {
BuilderFieldData bfd = job.builderFields.get(i);
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType, job.source));
+ java.util.List<JavacNode> generateSingularFields = bfd.singularData.getSingularizer().generateFields(bfd.singularData, job.builderType, job.sourceNode);
+ for (JavacNode field : generateSingularFields) {
+ generated.add((JCVariableDecl) field.get());
+ }
+ bfd.createdFields.addAll(generateSingularFields);
} else {
JavacNode field = null, setFlag = null;
for (JavacNode exists : existing) {
@@ -861,7 +863,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JavacTreeMaker maker = job.getTreeMaker();
if (field == null) {
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
- JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, job.source, job.getContext()), null);
+ JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, job.sourceNode), null);
field = injectFieldAndMarkGenerated(job.builderType, newField);
generated.add(newField);
}
@@ -874,7 +876,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
bfd.createdFields.add(field);
}
}
- for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, job.source, job.getContext());
+ for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, job.sourceNode);
}
public void makePrefixedSetterMethodsForBuilder(BuilderJob job, BuilderFieldData bfd, String prefix) {
@@ -911,7 +913,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
newMethod = HandleSetter.createSetterWithRecv(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations, recv);
}
if (newMethod == null) newMethod = HandleSetter.createSetter(toJavacModifier(job.accessInners), deprecate, fieldNode, maker, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, job.sourceNode, methodAnns, bfd.annotations);
- recursiveSetGeneratedBy(newMethod, job.source, job.getContext());
+ recursiveSetGeneratedBy(newMethod, job.sourceNode);
if (job.sourceNode.up().getKind() == Kind.METHOD) {
copyJavadocFromParam(bfd.originalFieldNode.up(), newMethod, bfd.name.toString());
} else {
@@ -938,6 +940,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (job.isStatic) modifiers |= Flags.STATIC;
JCModifiers mods = maker.Modifiers(modifiers);
JCClassDecl builder = maker.ClassDef(mods, job.getBuilderClassName(), job.copyTypeParams(), null, List.<JCExpression>nil(), List.<JCTree>nil());
+ recursiveSetGeneratedBy(builder, job.sourceNode);
return injectType(job.parentType, builder);
}
diff --git a/src/core/lombok/javac/handlers/HandleBuilderDefault.java b/src/core/lombok/javac/handlers/HandleBuilderDefault.java
index df5eebc9..54060233 100644
--- a/src/core/lombok/javac/handlers/HandleBuilderDefault.java
+++ b/src/core/lombok/javac/handlers/HandleBuilderDefault.java
@@ -55,6 +55,7 @@ public class HandleBuilderDefault extends JavacAnnotationHandler<Builder.Default
JCFieldAccess jfa = (JCFieldAccess) ast.annotationType;
if (jfa.selected instanceof JCIdent && ((JCIdent) jfa.selected).name.contentEquals("Builder") && jfa.name.contentEquals("Default")) {
JCFieldAccess newJfaSel = annotationNode.getTreeMaker().Select(annotationNode.getTreeMaker().Ident(annotationNode.toName("lombok")), ((JCIdent) jfa.selected).name);
+ recursiveSetGeneratedBy(newJfaSel, annotationNode);
jfa.selected = newJfaSel;
}
}
diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java
index 4aa61764..12c3b1e9 100644
--- a/src/core/lombok/javac/handlers/HandleCleanup.java
+++ b/src/core/lombok/javac/handlers/HandleCleanup.java
@@ -52,7 +52,6 @@ import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -129,10 +128,9 @@ public class HandleCleanup extends JavacAnnotationHandler<Cleanup> {
JCIf ifNotNullCleanup = maker.If(isNull, maker.Block(0, cleanupCall), null);
- Context context = annotationNode.getContext();
- JCBlock finalizer = recursiveSetGeneratedBy(maker.Block(0, List.<JCStatement>of(ifNotNullCleanup)), ast, context);
+ JCBlock finalizer = recursiveSetGeneratedBy(maker.Block(0, List.<JCStatement>of(ifNotNullCleanup)), annotationNode);
- newStatements.append(setGeneratedBy(maker.Try(setGeneratedBy(maker.Block(0, tryBlock.toList()), ast, context), List.<JCCatch>nil(), finalizer), ast, context));
+ newStatements.append(setGeneratedBy(maker.Try(setGeneratedBy(maker.Block(0, tryBlock.toList()), annotationNode), List.<JCCatch>nil(), finalizer), annotationNode));
if (blockNode instanceof JCBlock) {
((JCBlock)blockNode).stats = newStatements.toList();
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java
index f30320dc..490fd151 100644
--- a/src/core/lombok/javac/handlers/HandleConstructor.java
+++ b/src/core/lombok/javac/handlers/HandleConstructor.java
@@ -55,11 +55,9 @@ import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.core.LombokNode;
import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.delombok.LombokOptionsFactory;
import lombok.javac.Javac;
-import lombok.javac.JavacAST;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -269,11 +267,11 @@ public class HandleConstructor {
generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, allToDefault, fields, source, argTypes_);
}
- private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, LombokNode<JavacAST, JavacNode, JCTree> source, List<Type> argTypes_) {
+ private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, JavacNode source, List<Type> argTypes_) {
if (staticConstrRequired) {
ClassSymbol sym = ((JCClassDecl) typeNode.get()).sym;
Type returnType = sym == null ? null : sym.type;
- JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, allToDefault ? List.<JavacNode>nil() : fields, source.get());
+ JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, allToDefault ? List.<JavacNode>nil() : fields, source);
injectMethod(typeNode, staticConstr, argTypes_, returnType);
}
}
@@ -342,7 +340,7 @@ public class HandleConstructor {
Name rawName = field.name;
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
- JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(fieldNode.getTreeMaker(), field.vartype, source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
params.append(param);
if (hasNonNullAnnotations(fieldNode)) {
@@ -379,7 +377,7 @@ public class HandleConstructor {
if (onConstructor != null) mods.annotations = mods.annotations.appendList(copyAnnotations(onConstructor));
return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("<init>"),
null, List.<JCTypeParameter>nil(), params.toList(), List.<JCExpression>nil(),
- maker.Block(0L, nullChecks.appendList(assigns).toList()), null), source.get(), typeNode.getContext());
+ maker.Block(0L, nullChecks.appendList(assigns).toList()), null), source);
}
/**
@@ -450,7 +448,7 @@ public class HandleConstructor {
return true;
}
- public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JCTree source) {
+ public JCMethodDecl createStaticConstructor(String name, AccessLevel level, JavacNode typeNode, List<JavacNode> fields, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
JCClassDecl type = (JCClassDecl) typeNode.get();
@@ -475,7 +473,7 @@ public class HandleConstructor {
for (JavacNode fieldNode : fields) {
JCVariableDecl field = (JCVariableDecl) fieldNode.get();
Name fieldName = removePrefixFromField(fieldNode);
- JCExpression pType = cloneType(maker, field.vartype, source, typeNode.getContext());
+ JCExpression pType = cloneType(maker, field.vartype, source);
List<JCAnnotation> copyableAnnotations = findCopyableAnnotations(fieldNode);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, copyableAnnotations), fieldName, pType, null);
@@ -487,6 +485,6 @@ public class HandleConstructor {
JCMethodDecl methodDef = maker.MethodDef(mods, typeNode.toName(name), returnType, typeParams.toList(), params.toList(), List.<JCExpression>nil(), body, null);
createRelevantNonNullAnnotation(typeNode, methodDef);
- return recursiveSetGeneratedBy(methodDef, source, typeNode.getContext());
+ return recursiveSetGeneratedBy(methodDef, source);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java
index ac414fbb..3e3891c9 100644
--- a/src/core/lombok/javac/handlers/HandleDelegate.java
+++ b/src/core/lombok/javac/handlers/HandleDelegate.java
@@ -349,7 +349,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
JCStatement body = useReturn ? maker.Return(delegateCall) : maker.Exec(delegateCall);
JCBlock bodyBlock = maker.Block(0, com.sun.tools.javac.util.List.of(body));
- return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation.get(), annotation.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, sig.name, returnType, toList(typeParams), toList(params), toList(thrown), bodyBlock, null), annotation);
}
public static <T> com.sun.tools.javac.util.List<T> toList(ListBuffer<T> collection) {
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index c65fa491..e76d701e 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -34,7 +34,6 @@ import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.BoundKind;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBinary;
@@ -194,12 +193,12 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
//fallthrough
}
- JCMethodDecl equalsMethod = createEquals(typeNode, members, callSuper, fieldAccess, needsCanEqual, source.get(), onParam);
+ JCMethodDecl equalsMethod = createEquals(typeNode, members, callSuper, fieldAccess, needsCanEqual, source, onParam);
injectMethod(typeNode, equalsMethod);
if (needsCanEqual && canEqualExists == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl canEqualMethod = createCanEqual(typeNode, source.get(), onParam);
+ JCMethodDecl canEqualMethod = createCanEqual(typeNode, source, onParam);
injectMethod(typeNode, canEqualMethod);
}
@@ -209,23 +208,23 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
source.addWarning(msg);
cacheHashCode = false;
} else {
- createHashCodeCacheField(typeNode, source.get());
+ createHashCodeCacheField(typeNode, source);
}
}
- JCMethodDecl hashCodeMethod = createHashCode(typeNode, members, callSuper, cacheHashCode, fieldAccess, source.get());
+ JCMethodDecl hashCodeMethod = createHashCode(typeNode, members, callSuper, cacheHashCode, fieldAccess, source);
injectMethod(typeNode, hashCodeMethod);
}
- private void createHashCodeCacheField(JavacNode typeNode, JCTree source) {
+ private void createHashCodeCacheField(JavacNode typeNode, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.PRIVATE | Flags.TRANSIENT);
JCVariableDecl hashCodeCacheField = maker.VarDef(mods, typeNode.toName(HASH_CODE_CACHE_NAME), maker.TypeIdent(CTC_INT), null);
injectFieldAndMarkGenerated(typeNode, hashCodeCacheField);
- recursiveSetGeneratedBy(hashCodeCacheField, source, typeNode.getContext());
+ recursiveSetGeneratedBy(hashCodeCacheField, source);
}
- public JCMethodDecl createHashCode(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, boolean cacheHashCode, FieldAccess fieldAccess, JCTree source) {
+ public JCMethodDecl createHashCode(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, boolean cacheHashCode, FieldAccess fieldAccess, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(typeNode, "Override"), List.<JCExpression>nil());
@@ -364,7 +363,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
JCBlock body = maker.Block(0, statements.toList());
return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("hashCode"), returnType,
- List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null), source);
}
public JCExpressionStatement createResultCalculation(JavacNode typeNode, JCExpression expr) {
@@ -426,7 +425,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
return maker.TypeApply(expr, wildcards.toList());
}
- public JCMethodDecl createEquals(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source, List<JCAnnotation> onParam) {
+ public JCMethodDecl createEquals(JavacNode typeNode, java.util.List<Included<JavacNode, EqualsAndHashCode.Include>> members, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JavacNode source, List<JCAnnotation> onParam) {
JavacTreeMaker maker = typeNode.getTreeMaker();
Name oName = typeNode.toName("o");
@@ -560,10 +559,10 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
}
JCBlock body = maker.Block(0, statements.toList());
- return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("equals"), returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, typeNode.toName("equals"), returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source);
}
- public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source, List<JCAnnotation> onParam) {
+ public JCMethodDecl createCanEqual(JavacNode typeNode, JavacNode source, List<JCAnnotation> onParam) {
/* protected boolean canEqual(final java.lang.Object other) {
* return other instanceof Outer.Inner.MyType;
* }
@@ -588,7 +587,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
JCBlock body = maker.Block(0, List.<JCStatement>of(
maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode, false)))));
- return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext());
+ return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source);
}
public JCStatement generateCompareFloatOrDouble(JCExpression thisDotField, JCExpression otherDotField,
diff --git a/src/core/lombok/javac/handlers/HandleExtensionMethod.java b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
index 805a96f8..bda8c93a 100644
--- a/src/core/lombok/javac/handlers/HandleExtensionMethod.java
+++ b/src/core/lombok/javac/handlers/HandleExtensionMethod.java
@@ -202,6 +202,7 @@ public class HandleExtensionMethod extends JavacAnnotationHandler<ExtensionMetho
if (!types.isAssignable(receiverType, firstArgType)) continue;
methodCall.args = methodCall.args.prepend(receiver);
methodCall.meth = chainDotsString(annotationNode, extensionProvider.toString() + "." + methodName);
+ recursiveSetGeneratedBy(methodCall.meth, methodCallNode);
return;
}
}
diff --git a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
index ec4015c7..f8bcfbfc 100644
--- a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
@@ -78,7 +78,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
if (qualified.isEmpty()) {
errorNode.addWarning("No fields qualify for @FieldNameConstants, therefore this annotation does nothing");
} else {
- createInnerTypeFieldNameConstants(typeNode, errorNode, errorNode.get(), level, qualified, asEnum, innerTypeName, uppercase);
+ createInnerTypeFieldNameConstants(typeNode, errorNode, level, qualified, asEnum, innerTypeName, uppercase);
}
}
@@ -133,7 +133,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
generateFieldNameConstantsForType(node, annotationNode, level, asEnum, innerTypeName, annotationInstance.onlyExplicitlyIncluded(), uppercase);
}
- private void createInnerTypeFieldNameConstants(JavacNode typeNode, JavacNode errorNode, JCTree pos, AccessLevel level, java.util.List<JavacNode> fields, boolean asEnum, IdentifierName innerTypeName, boolean uppercase) {
+ private void createInnerTypeFieldNameConstants(JavacNode typeNode, JavacNode errorNode, AccessLevel level, java.util.List<JavacNode> fields, boolean asEnum, IdentifierName innerTypeName, boolean uppercase) {
if (fields.isEmpty()) return;
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -146,7 +146,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
if (fieldsType == null) {
JCClassDecl innerType = maker.ClassDef(mods, fieldsName, List.<JCTypeParameter>nil(), null, List.<JCExpression>nil(), List.<JCTree>nil());
fieldsType = injectType(typeNode, innerType);
- recursiveSetGeneratedBy(innerType, pos, typeNode.getContext());
+ recursiveSetGeneratedBy(innerType, errorNode);
genConstr = true;
} else {
JCClassDecl builderTypeDeclaration = (JCClassDecl) fieldsType.get();
@@ -166,7 +166,7 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
JCModifiers genConstrMods = maker.Modifiers(Flags.GENERATEDCONSTR | (asEnum ? 0L : Flags.PRIVATE));
JCBlock genConstrBody = maker.Block(0L, List.<JCStatement>of(maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(typeNode.toName("super")), List.<JCExpression>nil()))));
JCMethodDecl c = maker.MethodDef(genConstrMods, typeNode.toName("<init>"), null, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), genConstrBody, null);
- recursiveSetGeneratedBy(c, pos, typeNode.getContext());
+ recursiveSetGeneratedBy(c, errorNode);
injectMethod(fieldsType, c);
}
@@ -187,9 +187,9 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
}
JCVariableDecl constantField = maker.VarDef(constantValueMods, fName, returnType, init);
injectField(fieldsType, constantField, false, true);
- setGeneratedBy(constantField, pos, typeNode.getContext());
+ setGeneratedBy(constantField, errorNode);
generated.add(constantField);
}
- for (JCVariableDecl cf : generated) recursiveSetGeneratedBy(cf, pos, typeNode.getContext());
+ for (JCVariableDecl cf : generated) recursiveSetGeneratedBy(cf, errorNode);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java
index afe2c1b6..200ce1d7 100644
--- a/src/core/lombok/javac/handlers/HandleGetter.java
+++ b/src/core/lombok/javac/handlers/HandleGetter.java
@@ -219,14 +219,14 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC);
- injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source.get(), lazy, onMethod), List.<Type>nil(), getMirrorForFieldType(fieldNode));
+ injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source, lazy, onMethod), List.<Type>nil(), getMirrorForFieldType(fieldNode));
}
- public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JCTree source, boolean lazy, List<JCAnnotation> onMethod) {
+ public JCMethodDecl createGetter(long access, JavacNode field, JavacTreeMaker treeMaker, JavacNode source, boolean lazy, List<JCAnnotation> onMethod) {
JCVariableDecl fieldNode = (JCVariableDecl) field.get();
// Remember the type; lazy will change it
- JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source, field.getContext());
+ JCExpression methodType = cloneType(treeMaker, copyType(treeMaker, fieldNode), source);
// Generate the methodName; lazy will change the field type
Name methodName = field.toName(toGetterName(field));
@@ -267,9 +267,9 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
if (isFieldDeprecated(field)) annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(genJavaLangTypeRef(field, "Deprecated"), List.<JCExpression>nil()));
JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
- methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source, field.getContext());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
- if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null, null);
+ if (toClearOfMarkers != null) recursiveSetGeneratedBy(toClearOfMarkers, null);
if (methodArgPos != null) {
for (int i = 0; i < methodArgPos.length; i++) {
((JCMethodInvocation) toClearOfMarkers).args.get(i).pos = methodArgPos[i];
@@ -283,7 +283,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
suppressions.add(treeMaker.Literal("all"));
}
suppressions.add(treeMaker.Literal("unchecked"));
- addAnnotation(decl.mods, field, source.pos, source, field.getContext(), "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
+ addAnnotation(decl.mods, field, source, "java.lang.SuppressWarnings", treeMaker.NewArray(null, List.<JCExpression>nil(), suppressions.toList()));
}
copyJavadoc(field, decl, CopyJavadoc.GETTER);
@@ -334,7 +334,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
TYPE_MAP = Collections.unmodifiableMap(m);
}
- public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JCTree source) {
+ public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fieldNode, JavacNode source) {
/*
java.lang.Object value = this.fieldName.get();
if (value == null) {
@@ -447,8 +447,8 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
/* private final java.util.concurrent.atomic.AtomicReference<Object> fieldName = new java.util.concurrent.atomic.AtomicReference<Object>(); */ {
field.vartype = recursiveSetGeneratedBy(
- maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source, fieldNode.getContext());
- field.init = recursiveSetGeneratedBy(maker.NewClass(null, NIL_EXPRESSION, copyType(maker, field), NIL_EXPRESSION, null), source, fieldNode.getContext());
+ maker.TypeApply(chainDotsString(fieldNode, AR), List.<JCExpression>of(genJavaLangTypeRef(fieldNode, "Object"))), source);
+ field.init = recursiveSetGeneratedBy(maker.NewClass(null, NIL_EXPRESSION, copyType(maker, field), NIL_EXPRESSION, null), source);
}
return statements.toList();
diff --git a/src/core/lombok/javac/handlers/HandleHelper.java b/src/core/lombok/javac/handlers/HandleHelper.java
index 6f4361c1..bb92090d 100755
--- a/src/core/lombok/javac/handlers/HandleHelper.java
+++ b/src/core/lombok/javac/handlers/HandleHelper.java
@@ -71,7 +71,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
else throw new IllegalArgumentException("Can't set statements on node type: " + tree.getClass());
}
- @Override public void handle(AnnotationValues<Helper> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ @Override public void handle(AnnotationValues<Helper> annotation, JCAnnotation ast, final JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.HELPER_FLAG_USAGE, "@Helper");
deleteAnnotationIfNeccessary(annotationNode, Helper.class);
@@ -120,6 +120,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
JCIdent jci = (JCIdent) jcmi.meth;
if (Arrays.binarySearch(knownMethodNames_, jci.name.toString()) < 0) return;
jcmi.meth = maker.Select(maker.Ident(helperName), jci.name);
+ recursiveSetGeneratedBy(jcmi.meth, annotationNode);
helperUsed[0] = true;
}
};
@@ -144,6 +145,7 @@ public class HandleHelper extends JavacAnnotationHandler<Helper> {
JCExpression init = maker.NewClass(null, List.<JCExpression>nil(), maker.Ident(annotatedType_.name), List.<JCExpression>nil(), null);
JCExpression varType = maker.Ident(annotatedType_.name);
JCVariableDecl decl = maker.VarDef(maker.Modifiers(Flags.FINAL), helperName, varType, init);
+ recursiveSetGeneratedBy(decl, annotationNode);
newStatements.append(decl);
}
setStatementsOfJcNode(containingBlock.get(), newStatements.toList());
diff --git a/src/core/lombok/javac/handlers/HandleJacksonized.java b/src/core/lombok/javac/handlers/HandleJacksonized.java
index 0aa02d1b..f9809865 100644
--- a/src/core/lombok/javac/handlers/HandleJacksonized.java
+++ b/src/core/lombok/javac/handlers/HandleJacksonized.java
@@ -107,7 +107,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JavacTreeMaker maker = annotatedNode.getTreeMaker();
// Now lets find the generated builder class.
- String builderClassName = getBuilderClassName(ast, annotationNode, annotatedNode, td, builderAnnotation, maker);
+ String builderClassName = getBuilderClassName(annotationNode, annotatedNode, td, builderAnnotation, maker);
JCClassDecl builderClass = null;
for (JCTree member : td.getMembers()) {
@@ -132,11 +132,15 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCFieldAccess builderClassReference = maker.Select(builderClassExpression, annotatedNode.toName("class"));
JCExpression assign = maker.Assign(maker.Ident(annotationNode.toName("builder")), builderClassReference);
JCAnnotation annotationJsonDeserialize = maker.Annotation(jsonDeserializeType, List.of(assign));
+ recursiveSetGeneratedBy(annotationJsonDeserialize, annotationNode);
td.mods.annotations = td.mods.annotations.append(annotationJsonDeserialize);
// Copy annotations from the class to the builder class.
List<JCAnnotation> copyableAnnotations = findJacksonAnnotationsOnClass(tdNode);
List<JCAnnotation> copiedAnnotations = copyAnnotations(copyableAnnotations);
+ for (JCAnnotation anno : copiedAnnotations) {
+ recursiveSetGeneratedBy(anno, annotationNode);
+ }
builderClass.mods.annotations = builderClass.mods.annotations.appendList(copiedAnnotations);
// Insert @JsonPOJOBuilder on the builder class.
@@ -144,6 +148,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCExpression withPrefixExpr = maker.Assign(maker.Ident(annotationNode.toName("withPrefix")), maker.Literal(setPrefix));
JCExpression buildMethodNameExpr = maker.Assign(maker.Ident(annotationNode.toName("buildMethodName")), maker.Literal(buildMethodName));
JCAnnotation annotationJsonPOJOBuilder = maker.Annotation(jsonPOJOBuilderType, List.of(withPrefixExpr, buildMethodNameExpr));
+ recursiveSetGeneratedBy(annotationJsonPOJOBuilder, annotatedNode);
builderClass.mods.annotations = builderClass.mods.annotations.append(annotationJsonPOJOBuilder);
// @SuperBuilder? Make it package-private!
@@ -151,7 +156,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
builderClass.mods.flags = builderClass.mods.flags & ~Flags.PRIVATE;
}
- private String getBuilderClassName(JCAnnotation ast, JavacNode annotationNode, JavacNode annotatedNode, JCClassDecl td, AnnotationValues<Builder> builderAnnotation, JavacTreeMaker maker) {
+ private String getBuilderClassName(JavacNode annotationNode, JavacNode annotatedNode, JCClassDecl td, AnnotationValues<Builder> builderAnnotation, JavacTreeMaker maker) {
String builderClassName = builderAnnotation != null ?
builderAnnotation.getInstance().builderClassName() : null;
if (builderClassName == null || builderClassName.isEmpty()) {
@@ -166,7 +171,7 @@ public class HandleJacksonized extends JavacAnnotationHandler<Jacksonized> {
JCExpression returnType = fillParametersFrom.restype;
List<JCTypeParameter> typeParams = fillParametersFrom.typarams;
if (returnType instanceof JCTypeApply) {
- returnType = cloneType(maker, returnType, ast, annotationNode.getContext());
+ returnType = cloneType(maker, returnType, annotatedNode);
}
replacement = HandleBuilder.returnTypeToBuilderClassName(annotationNode, td, returnType, typeParams);
} else {
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index 3173b3ba..7169d33e 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -39,7 +39,6 @@ import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
@@ -90,7 +89,7 @@ public class HandleLog {
}
JCFieldAccess loggingType = selfType(typeNode);
- createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName.getName(), useStatic, loggerTopic);
+ createField(framework, typeNode, loggingType, annotationNode, logFieldName.getName(), useStatic, loggerTopic);
break;
default:
annotationNode.addError("@Log is legal only on types.");
@@ -104,7 +103,7 @@ public class HandleLog {
return maker.Select(maker.Ident(name), typeNode.toName("class"));
}
- private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
+ private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JavacNode source, String logFieldName, boolean useStatic, JCExpression loggerTopic) {
JavacTreeMaker maker = typeNode.getTreeMaker();
LogDeclaration logDeclaration = framework.getDeclaration();
@@ -118,7 +117,7 @@ public class HandleLog {
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)),
- typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext());
+ typeNode.toName(logFieldName), loggerType, factoryMethodCall), source);
injectFieldAndMarkGenerated(typeNode, fieldDecl);
return true;
diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java
index 079d5b04..3dd7e328 100644
--- a/src/core/lombok/javac/handlers/HandleNonNull.java
+++ b/src/core/lombok/javac/handlers/HandleNonNull.java
@@ -111,7 +111,7 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
// and if they exist, create a new method in the class: 'private static <T> T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and
// wrap all references to it in the super/this to a call to this method.
- JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), paramNode, annotationNode), ast, annotationNode.getContext());
+ JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), paramNode, annotationNode), annotationNode);
if (nullCheck == null) {
// @NonNull applied to a primitive. Kinda pointless. Let's generate a warning.
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index 5c4c7681..e6e8e66e 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -220,7 +220,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCAnnotation> annotations = d.mods.annotations;
if (annotations == null) annotations = List.nil();
JCAnnotation anno = treeMaker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
- recursiveSetGeneratedBy(anno, source.get(), field.getContext());
+ recursiveSetGeneratedBy(anno, source);
d.mods.annotations = annotations.prepend(anno);
}
return d;
@@ -239,7 +239,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCAnnotation> annotations = d.mods.annotations;
if (annotations == null) annotations = List.nil();
JCAnnotation anno = treeMaker.Annotation(genTypeRef(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
- recursiveSetGeneratedBy(anno, source.get(), field.getContext());
+ recursiveSetGeneratedBy(anno, source);
d.mods.annotations = annotations.prepend(anno);
}
return d;
@@ -265,7 +265,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
- JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(treeMaker, fieldDecl.vartype, source);
JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(flags, annsOnParam), paramName, pType, null);
if (!hasNonNullAnnotations(field) && !hasNonNullAnnotations(field, onParam)) {
@@ -309,7 +309,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue);
}
if (returnStatement != null) createRelevantNonNullAnnotation(source, methodDef);
- JCMethodDecl decl = recursiveSetGeneratedBy(methodDef, source.get(), field.getContext());
+ JCMethodDecl decl = recursiveSetGeneratedBy(methodDef, source);
copyJavadoc(field, decl, CopyJavadoc.SETTER, returnStatement != null);
return decl;
}
diff --git a/src/core/lombok/javac/handlers/HandleSneakyThrows.java b/src/core/lombok/javac/handlers/HandleSneakyThrows.java
index ffe37a4c..83f97c20 100644
--- a/src/core/lombok/javac/handlers/HandleSneakyThrows.java
+++ b/src/core/lombok/javac/handlers/HandleSneakyThrows.java
@@ -39,7 +39,6 @@ import lombok.javac.JavacTreeMaker;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
@@ -48,7 +47,6 @@ import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTry;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import lombok.javac.Javac;
@@ -107,7 +105,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
}
for (String exception : exceptions) {
- contents = List.of(buildTryCatchBlock(methodNode, contents, exception, annotation.get()));
+ contents = List.of(buildTryCatchBlock(methodNode, contents, exception, annotation));
}
method.body.stats = isConstructorCall ? List.of(constructorCall).appendList(contents) : contents;
@@ -122,11 +120,10 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
}
}
- public JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JCTree source) {
+ public JCStatement buildTryCatchBlock(JavacNode node, List<JCStatement> contents, String exception, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
- Context context = node.getContext();
- JCBlock tryBlock = setGeneratedBy(maker.Block(0, contents), source, context);
+ JCBlock tryBlock = setGeneratedBy(maker.Block(0, contents), source);
JCExpression varType = chainDots(node, exception.split("\\."));
JCVariableDecl catchParam = maker.VarDef(maker.Modifiers(Flags.FINAL | Flags.PARAMETER), node.toName("$ex"), varType, null);
@@ -134,7 +131,7 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
JCBlock catchBody = maker.Block(0, List.<JCStatement>of(maker.Throw(maker.Apply(
List.<JCExpression>nil(), lombokLombokSneakyThrowNameRef,
List.<JCExpression>of(maker.Ident(node.toName("$ex")))))));
- JCTry tryStatement = maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source, context)), null);
+ JCTry tryStatement = maker.Try(tryBlock, List.of(recursiveSetGeneratedBy(maker.Catch(catchParam, catchBody), source)), null);
if (JavacHandlerUtil.inNetbeansEditor(node)) {
//set span (start and end position) of the try statement and the main block
//this allows NetBeans to dive into the statement correctly:
@@ -146,6 +143,6 @@ public class HandleSneakyThrows extends JavacAnnotationHandler<SneakyThrows> {
Javac.storeEnd(tryBlock, endPos, top);
Javac.storeEnd(tryStatement, endPos, top);
}
- return setGeneratedBy(tryStatement, source, context);
+ return setGeneratedBy(tryStatement, source);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 99f0ea6a..a462fa53 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -54,7 +54,6 @@ import com.sun.tools.javac.tree.JCTree.JCTypeApply;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.JCTree.JCWildcard;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -134,7 +133,6 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.SUPERBUILDER_FLAG_USAGE, "@SuperBuilder");
SuperBuilderJob job = new SuperBuilderJob();
job.sourceNode = annotationNode;
- job.source = ast;
job.checkerFramework = getCheckerFrameworkVersion(annotationNode);
job.isStatic = true;
@@ -208,7 +206,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
bfd.nameOfSetFlag = parent.toName(bfd.name + SET_PREFIX);
bfd.builderFieldName = parent.toName(bfd.name + VALUE_PREFIX);
JCMethodDecl md = HandleBuilder.generateDefaultProvider(bfd.nameOfDefaultProvider, fieldNode, td.typarams);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
if (md != null) injectMethod(parent, md);
}
addObtainVia(bfd, fieldNode);
@@ -235,7 +233,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
{
JCExpression annotatedClass = namePlusTypeParamsToTypeReference(maker, parent, job.typeParams);
JCTypeParameter c = maker.TypeParameter(parent.toName(classGenericName), List.<JCExpression>of(annotatedClass));
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
typeParamsForBuilder.add(maker.Ident(parent.toName(classGenericName)));
typeParamsForBuilder.add(maker.Ident(parent.toName(builderGenericName)));
JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, parent, job.getBuilderClassName(), false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
@@ -291,7 +289,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
job.builderAbstractType = findInnerClass(parent, job.builderClassName);
if (job.builderAbstractType == null) {
job.builderAbstractType = generateBuilderAbstractClass(job, superclassBuilderClass, superclassTypeParams, classGenericName, builderGenericName);
- recursiveSetGeneratedBy(job.builderAbstractType.get(), ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(job.builderAbstractType.get(), annotationNode);
} else {
JCClassDecl builderTypeDeclaration = (JCClassDecl) job.builderAbstractType.get();
if (!builderTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)
@@ -315,30 +313,30 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Generate the fields in the abstract builder class that hold the values for the instance.
job.setBuilderToAbstract();
- generateBuilderFields(job.builderType, job.builderFields, ast);
+ generateBuilderFields(job.builderType, job.builderFields, annotationNode);
if (addCleaning) {
JCVariableDecl uncleanField = maker.VarDef(maker.Modifiers(Flags.PRIVATE), job.toName("$lombokUnclean"), maker.TypeIdent(CTC_BOOLEAN), null);
- recursiveSetGeneratedBy(uncleanField, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(uncleanField, annotationNode);
injectFieldAndMarkGenerated(job.builderType, uncleanField);
}
if (job.toBuilder) {
// Generate $fillValuesFrom() method in the abstract builder.
JCMethodDecl fvm = generateFillValuesMethod(job, superclassBuilderClass != null, builderGenericName, classGenericName);
- recursiveSetGeneratedBy(fvm, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(fvm, annotationNode);
injectMethod(job.builderType, fvm);
// Generate $fillValuesFromInstanceIntoBuilder() method in the builder implementation class.
JCMethodDecl sfvm = generateStaticFillValuesMethod(job, annInstance.setterPrefix());
- recursiveSetGeneratedBy(sfvm, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(sfvm, annotationNode);
injectMethod(job.builderType, sfvm);
}
// Generate abstract self() and build() methods in the abstract builder.
JCMethodDecl asm = generateAbstractSelfMethod(job, superclassBuilderClass != null, builderGenericName);
- recursiveSetGeneratedBy(asm, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(asm, annotationNode);
injectMethod(job.builderType, asm);
JCMethodDecl abm = generateAbstractBuildMethod(job, superclassBuilderClass != null, classGenericName);
- recursiveSetGeneratedBy(abm, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(abm, annotationNode);
injectMethod(job.builderType, abm);
// Create the setter methods in the abstract builder.
@@ -355,13 +353,13 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
// Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder.
- JCMethodDecl toStringMethod = HandleToString.createToString(job.builderType, fieldNodes, true, superclassBuilderClass != null, FieldAccess.ALWAYS_FIELD, ast);
+ JCMethodDecl toStringMethod = HandleToString.createToString(job.builderType, fieldNodes, true, superclassBuilderClass != null, FieldAccess.ALWAYS_FIELD, annotationNode);
if (toStringMethod != null) injectMethod(job.builderType, toStringMethod);
// If clean methods are requested, add them now.
if (addCleaning) {
- JCMethodDecl md = generateCleanMethod(job.builderFields, job.builderType, ast);
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ JCMethodDecl md = generateCleanMethod(job.builderFields, job.builderType, annotationNode);
+ recursiveSetGeneratedBy(md, annotationNode);
injectMethod(job.builderType, md);
}
@@ -373,7 +371,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
job.builderImplType = findInnerClass(parent, job.builderImplClassName);
if (job.builderImplType == null) {
job.builderImplType = generateBuilderImplClass(job);
- recursiveSetGeneratedBy(job.builderImplType.get(), ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(job.builderImplType.get(), annotationNode);
} else {
JCClassDecl builderImplTypeDeclaration = (JCClassDecl) job.builderImplType.get();
if (!builderImplTypeDeclaration.getModifiers().getFlags().contains(Modifier.STATIC)
@@ -391,11 +389,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// Create the self() and build() methods in the BuilderImpl.
JCMethodDecl selfMethod = generateSelfMethod(job);
- recursiveSetGeneratedBy(selfMethod, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(selfMethod, annotationNode);
injectMethod(job.builderType, selfMethod);
if (methodExists(job.buildMethodName, job.builderType, -1) == MemberExistsResult.NOT_EXISTS) {
JCMethodDecl buildMethod = generateBuildMethod(job, buildMethodThrownExceptions);
- recursiveSetGeneratedBy(buildMethod, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(buildMethod, annotationNode);
injectMethod(job.builderType, buildMethod);
}
}
@@ -415,7 +413,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (generateBuilderMethod) {
JCMethodDecl builderMethod = generateBuilderMethod(job);
if (builderMethod != null) {
- recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(builderMethod, annotationNode);
injectMethod(job.parentType, builderMethod);
}
}
@@ -428,7 +426,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
case NOT_EXISTS:
JCMethodDecl md = generateToBuilderMethod(job);
if (md != null) {
- recursiveSetGeneratedBy(md, ast, annotationNode.getContext());
+ recursiveSetGeneratedBy(md, annotationNode);
injectMethod(job.parentType, md);
}
break;
@@ -462,7 +460,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
allTypeParams.add(maker.TypeParameter(job.toName(classGenericName), List.<JCExpression>of(annotatedClass)));
// 2. The return type for all setter methods, named "B", which extends this builder class.
Name builderClassName = job.toName(job.builderClassName);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
typeParamsForBuilder.add(maker.Ident(job.toName(classGenericName)));
typeParamsForBuilder.add(maker.Ident(job.toName(builderGenericName)));
JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, job.parentType, builderClassName, false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
@@ -472,7 +470,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (superclassBuilderClass != null) {
// If the annotated class extends another class, we want this builder to extend the builder of the superclass.
// 1. Add the type parameters of the superclass.
- typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker, job.sourceNode.getContext());
+ typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker, job.sourceNode);
// 2. Add the builder type params <C, B>.
typeParamsForBuilder.add(maker.Ident(job.toName(classGenericName)));
typeParamsForBuilder.add(maker.Ident(job.toName(builderGenericName)));
@@ -480,6 +478,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
JCClassDecl builder = maker.ClassDef(mods, builderClassName, allTypeParams.toList(), extending, List.<JCExpression>nil(), List.<JCTree>nil());
+ recursiveSetGeneratedBy(builder, job.sourceNode);
return injectType(job.parentType, builder);
}
@@ -501,12 +500,13 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// 2. The return type for all setter methods (named "B" in the abstract builder), which is this builder class.
JCExpression builderImplClassExpression = namePlusTypeParamsToTypeReference(maker, job.parentType, job.toName(job.builderImplClassName), false, job.typeParams);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
typeParamsForBuilder.add(annotatedClass);
typeParamsForBuilder.add(builderImplClassExpression);
extending = maker.TypeApply(extending, typeParamsForBuilder.toList());
JCClassDecl builder = maker.ClassDef(mods, job.toName(job.builderImplClassName), copyTypeParams(job.parentType, job.typeParams), extending, List.<JCExpression>nil(), List.<JCTree>nil());
+ recursiveSetGeneratedBy(builder, job.sourceNode);
return injectType(job.parentType, builder);
}
@@ -530,7 +530,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
for (BuilderFieldData bfd : job.builderFields) {
JCExpression rhs;
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, bfd.originalFieldNode, bfd.type, statements, bfd.builderFieldName, "b");
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, bfd.originalFieldNode, job.sourceNode, statements, bfd.builderFieldName, "b");
rhs = maker.Ident(bfd.singularData.getPluralName());
} else {
rhs = maker.Select(maker.Ident(builderVariableName), bfd.builderFieldName);
@@ -563,7 +563,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, job.getContext());
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
typeParamsForBuilderParameter.add(wildcard);
@@ -583,7 +583,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JCMethodDecl constr = recursiveSetGeneratedBy(maker.MethodDef(mods, job.toName("<init>"),
null, List.<JCTypeParameter>nil(), params.toList(), List.<JCExpression>nil(),
- maker.Block(0L, statements.toList()), null), job.source, job.getContext());
+ maker.Block(0L, statements.toList()), null), job.sourceNode);
injectMethod(job.parentType, constr, null, Javac.createVoidType(job.builderType.getSymbolTable(), CTC_VOID));
}
@@ -725,7 +725,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// 2nd parameter: "FoobarBuilder<?, ?> b" (plus generics on the annotated type)
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.getContext());
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(job.typeParams, maker, job.sourceNode);
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
typeParamsForBuilderParameter.add(wildcard);
@@ -872,7 +872,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return methodDef;
}
- private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
+ private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JavacNode source) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
@@ -887,7 +887,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName("$lombokClean"), maker.Type(Javac.createVoidType(type.getSymbolTable(), CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
- private void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
+ private void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JavacNode source) {
int len = builderFields.size();
java.util.List<JavacNode> existing = new ArrayList<JavacNode>();
for (JavacNode child : builderType.down()) {
@@ -899,7 +899,11 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
for (int i = len - 1; i >= 0; i--) {
BuilderFieldData bfd = builderFields.get(i);
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source));
+ java.util.List<JavacNode> fields = bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source);
+ for (JavacNode field : fields) {
+ generated.add((JCVariableDecl) field.get());
+ }
+ bfd.createdFields.addAll(fields);
} else {
JavacNode field = null, setFlag = null;
for (JavacNode exists : existing) {
@@ -910,7 +914,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
JavacTreeMaker maker = builderType.getTreeMaker();
if (field == null) {
JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
- JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, source, builderType.getContext()), null);
+ JCVariableDecl newField = maker.VarDef(mods, bfd.builderFieldName, cloneType(maker, bfd.type, source), null);
field = injectFieldAndMarkGenerated(builderType, newField);
generated.add(newField);
}
@@ -923,7 +927,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
bfd.createdFields.add(field);
}
}
- for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source, builderType.getContext());
+ for (JCVariableDecl gen : generated) recursiveSetGeneratedBy(gen, source);
}
private void generateSetterMethodsForBuilder(final SuperBuilderJob job, BuilderFieldData fieldNode, final String builderGenericName, String setterPrefix) {
@@ -941,7 +945,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
generateSimpleSetterMethodForBuilder(job, deprecate, fieldNode.createdFields.get(0), fieldNode.name, fieldNode.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), fieldNode.annotations, fieldNode.originalFieldNode, setterPrefix);
} else {
fieldNode.singularData.getSingularizer().generateMethods(job.checkerFramework, fieldNode.singularData, deprecate, job.builderType,
- job.source, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
+ job.sourceNode, true, returnTypeMaker, returnStatementMaker, AccessLevel.PUBLIC);
}
}
@@ -972,7 +976,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
List<JCAnnotation> annotations = newMethod.mods.annotations;
if (annotations == null) annotations = List.nil();
JCAnnotation anno = maker.Annotation(genTypeRef(job.builderType, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER), List.<JCExpression>nil());
- recursiveSetGeneratedBy(anno, job.source, job.getContext());
+ recursiveSetGeneratedBy(anno, job.sourceNode);
newMethod.mods.annotations = annotations.prepend(anno);
}
@@ -1082,7 +1086,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return null;
}
- private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker, Context context) {
+ private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker, JavacNode source) {
ListBuffer<JCExpression> typeParamsForBuilderParameter = new ListBuffer<JCExpression>();
for (JCTree typeParam : typeParams) {
if (typeParam instanceof JCTypeParameter) {
@@ -1092,7 +1096,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
} else if (typeParam instanceof JCFieldAccess) {
typeParamsForBuilderParameter.add(copySelect(maker, (JCFieldAccess) typeParam));
} else if (typeParam instanceof JCTypeApply) {
- typeParamsForBuilderParameter.add(cloneType(maker, (JCTypeApply)typeParam, typeParam, context));
+ typeParamsForBuilderParameter.add(cloneType(maker, (JCTypeApply)typeParam, source));
}
}
return typeParamsForBuilderParameter;
diff --git a/src/core/lombok/javac/handlers/HandleSynchronized.java b/src/core/lombok/javac/handlers/HandleSynchronized.java
index b6f1e47f..f7ac50e7 100644
--- a/src/core/lombok/javac/handlers/HandleSynchronized.java
+++ b/src/core/lombok/javac/handlers/HandleSynchronized.java
@@ -46,7 +46,6 @@ import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
/**
@@ -87,7 +86,6 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
}
JavacTreeMaker maker = methodNode.getTreeMaker().at(ast.pos);
- Context context = methodNode.getContext();
JavacNode typeNode = upToTypeNode(annotationNode);
@@ -120,7 +118,7 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
List.<JCExpression>of(maker.Literal(CTC_INT, 0)), null);
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (isStatic[0] ? Flags.STATIC : 0)),
- methodNode.toName(lockName), objectType, newObjectArray), ast, context);
+ methodNode.toName(lockName), objectType, newObjectArray), annotationNode);
injectFieldAndMarkGenerated(methodNode.up(), fieldDecl);
}
@@ -133,8 +131,8 @@ public class HandleSynchronized extends JavacAnnotationHandler<Synchronized> {
lockNode = maker.Select(maker.Ident(methodNode.toName("this")), methodNode.toName(lockName));
}
- recursiveSetGeneratedBy(lockNode, ast, context);
- method.body = setGeneratedBy(maker.Block(0, List.<JCStatement>of(setGeneratedBy(maker.Synchronized(lockNode, method.body), ast, context))), ast, context);
+ recursiveSetGeneratedBy(lockNode, annotationNode);
+ method.body = setGeneratedBy(maker.Block(0, List.<JCStatement>of(setGeneratedBy(maker.Synchronized(lockNode, method.body), annotationNode))), annotationNode);
methodNode.rebuild();
}
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java
index 0a950f7c..6bf38a84 100644
--- a/src/core/lombok/javac/handlers/HandleToString.java
+++ b/src/core/lombok/javac/handlers/HandleToString.java
@@ -42,7 +42,6 @@ import lombok.javac.JavacTreeMaker;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
@@ -141,7 +140,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
}
}
}
- JCMethodDecl method = createToString(typeNode, members, includeFieldNames, callSuper, fieldAccess, source.get());
+ JCMethodDecl method = createToString(typeNode, members, includeFieldNames, callSuper, fieldAccess, source);
injectMethod(typeNode, method);
break;
case EXISTS_BY_LOMBOK:
@@ -156,7 +155,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
}
static JCMethodDecl createToString(JavacNode typeNode, Collection<Included<JavacNode, ToString.Include>> members,
- boolean includeNames, boolean callSuper, FieldAccess fieldAccess, JCTree source) {
+ boolean includeNames, boolean callSuper, FieldAccess fieldAccess, JavacNode source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
@@ -256,7 +255,7 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
JCMethodDecl methodDef = maker.MethodDef(mods, typeNode.toName("toString"), returnType,
List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
createRelevantNonNullAnnotation(typeNode, methodDef);
- return recursiveSetGeneratedBy(methodDef, source, typeNode.getContext());
+ return recursiveSetGeneratedBy(methodDef, source);
}
public static String getTypeName(JavacNode typeNode) {
diff --git a/src/core/lombok/javac/handlers/HandleUtilityClass.java b/src/core/lombok/javac/handlers/HandleUtilityClass.java
index 5d651689..b400098b 100644
--- a/src/core/lombok/javac/handlers/HandleUtilityClass.java
+++ b/src/core/lombok/javac/handlers/HandleUtilityClass.java
@@ -146,7 +146,7 @@ public class HandleUtilityClass extends JavacAnnotationHandler<UtilityClass> {
Name name = typeNode.toName("<init>");
JCBlock block = maker.Block(0L, createThrowStatement(typeNode, maker));
JCMethodDecl methodDef = maker.MethodDef(mods, name, null, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), block, null);
- JCMethodDecl constructor = recursiveSetGeneratedBy(methodDef, typeNode.get(), typeNode.getContext());
+ JCMethodDecl constructor = recursiveSetGeneratedBy(methodDef, typeNode);
JavacHandlerUtil.injectMethod(typeNode, constructor, List.<Type>nil(), Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
}
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 23c27bc0..54645354 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -63,6 +63,7 @@ public class HandleVal extends JavacASTAdapter {
JCTree typeTree = local.vartype;
if (typeTree == null) return;
String typeTreeToString = typeTree.toString();
+ JavacNode typeNode = localNode.getNodeFor(typeTree);
if (!(eq(typeTreeToString, "val") || eq(typeTreeToString, "var"))) return;
boolean isVal = typeMatches(val.class, localNode, typeTree);
@@ -111,7 +112,7 @@ public class HandleVal extends JavacASTAdapter {
if (isVal) local.mods.flags |= Flags.FINAL;
if (!localNode.shouldDeleteLombokAnnotations()) {
- JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeTree, localNode.getContext());
+ JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeNode);
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
@@ -182,7 +183,7 @@ public class HandleVal extends JavacASTAdapter {
local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
throw e;
} finally {
- recursiveSetGeneratedBy(local.vartype, typeTree, localNode.getContext());
+ recursiveSetGeneratedBy(local.vartype, typeNode);
}
}
}
diff --git a/src/core/lombok/javac/handlers/HandleValue.java b/src/core/lombok/javac/handlers/HandleValue.java
index abc5a5ca..503792fa 100644
--- a/src/core/lombok/javac/handlers/HandleValue.java
+++ b/src/core/lombok/javac/handlers/HandleValue.java
@@ -72,7 +72,6 @@ public class HandleValue extends JavacAnnotationHandler<Value> {
JCModifiers jcm = ((JCClassDecl) typeNode.get()).mods;
if ((jcm.flags & Flags.FINAL) == 0) {
jcm.flags |= Flags.FINAL;
- typeNode.rebuild();
}
}
handleFieldDefaults.generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true);
diff --git a/src/core/lombok/javac/handlers/HandleWith.java b/src/core/lombok/javac/handlers/HandleWith.java
index 4e35a574..387f3ecd 100644
--- a/src/core/lombok/javac/handlers/HandleWith.java
+++ b/src/core/lombok/javac/handlers/HandleWith.java
@@ -215,6 +215,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym;
Type returnType = sym == null ? null : sym.type;
+ recursiveSetGeneratedBy(createdWith, source);
injectMethod(typeNode, createdWith, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
}
@@ -234,7 +235,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, field.getContext());
List<JCAnnotation> annsOnParam = copyAnnotations(onParam).appendList(copyableAnnotations);
- JCExpression pType = cloneType(maker, fieldDecl.vartype, source.get(), source.getContext());
+ JCExpression pType = cloneType(maker, fieldDecl.vartype, source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(flags, annsOnParam), fieldDecl.name, pType, null);
if (!makeAbstract) {
@@ -289,7 +290,7 @@ public class HandleWith extends JavacAnnotationHandler<With> {
if (makeAbstract) access = access | Flags.ABSTRACT;
JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType,
- methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
copyJavadoc(field, decl, CopyJavadoc.WITH);
return decl;
}
diff --git a/src/core/lombok/javac/handlers/HandleWithBy.java b/src/core/lombok/javac/handlers/HandleWithBy.java
index 19673172..dfbb6830 100644
--- a/src/core/lombok/javac/handlers/HandleWithBy.java
+++ b/src/core/lombok/javac/handlers/HandleWithBy.java
@@ -209,6 +209,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
ClassSymbol sym = ((JCClassDecl) fieldNode.up().get()).sym;
Type returnType = sym == null ? null : sym.type;
+ recursiveSetGeneratedBy(createdWithBy, source);
injectMethod(typeNode, createdWithBy, List.<Type>of(getMirrorForFieldType(fieldNode)), returnType);
}
@@ -265,7 +266,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
}
if (functionalInterfaceName == null) {
functionalInterfaceName = NAME_JUF_FUNCTION;
- parameterizer = cloneType(maker, fieldDecl.vartype, source.get(), field.getContext());
+ parameterizer = cloneType(maker, fieldDecl.vartype, source);
}
if (functionalInterfaceName == NAME_JUF_INTOP) applyMethodName = "applyAsInt";
if (functionalInterfaceName == NAME_JUF_LONGOP) applyMethodName = "applyAsLong";
@@ -274,7 +275,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
JCExpression varType = chainDots(field, functionalInterfaceName);
if (parameterizer != null && superExtendsStyle) {
JCExpression parameterizer1 = parameterizer;
- JCExpression parameterizer2 = cloneType(maker, parameterizer, source.get(), field.getContext());
+ JCExpression parameterizer2 = cloneType(maker, parameterizer, source);
// TODO: Apply copyable annotations to 'parameterizer' and 'parameterizer2'.
JCExpression arg1 = maker.Wildcard(maker.TypeBoundKind(BoundKind.SUPER), parameterizer1);
JCExpression arg2 = maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), parameterizer2);
@@ -334,7 +335,7 @@ public class HandleWithBy extends JavacAnnotationHandler<WithBy> {
if (makeAbstract) access = access | Flags.ABSTRACT;
createRelevantNonNullAnnotation(source, param);
JCMethodDecl decl = recursiveSetGeneratedBy(maker.MethodDef(maker.Modifiers(access, annsOnMethod), methodName, returnType,
- methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source.get(), field.getContext());
+ methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
copyJavadoc(field, decl, CopyJavadoc.WITH_BY);
createRelevantNonNullAnnotation(source, decl);
return decl;
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index c33d3c78..5cbe08da 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -116,17 +116,15 @@ public class JavacHandlerUtil {
}
private static class MarkingScanner extends TreeScanner {
- private final JCTree source;
- private final Context context;
+ private final JavacNode source;
- MarkingScanner(JCTree source, Context context) {
+ MarkingScanner(JavacNode source) {
this.source = source;
- this.context = context;
}
@Override public void scan(JCTree tree) {
if (tree == null) return;
- setGeneratedBy(tree, source, context);
+ setGeneratedBy(tree, source);
super.scan(tree);
}
}
@@ -158,20 +156,31 @@ public class JavacHandlerUtil {
return getGeneratedBy(node) != null;
}
- public static <T extends JCTree> T recursiveSetGeneratedBy(T node, JCTree source, Context context) {
+ public static <T extends JCTree> T recursiveSetGeneratedBy(T node, JavacNode source) {
if (node == null) return null;
- setGeneratedBy(node, source, context);
- node.accept(new MarkingScanner(source, context));
+ setGeneratedBy(node, source);
+ node.accept(new MarkingScanner(source));
return node;
}
- public static <T extends JCTree> T setGeneratedBy(T node, JCTree source, Context context) {
+ public static <T extends JCTree> T setGeneratedBy(T node, JavacNode sourceNode) {
if (node == null) return null;
- if (source == null) JCTree_generatedNode.clear(node);
- else JCTree_generatedNode.set(node, source);
- if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos;
+ if (sourceNode == null) {
+ JCTree_generatedNode.clear(node);
+ return node;
+ }
+ JCTree_generatedNode.set(node, sourceNode.get());
+
+ if (!inNetbeansEditor(sourceNode.getContext()) || isParameter(node)) {
+ node.pos = sourceNode.getStartPos();
+ storeEnd(node, sourceNode.getEndPosition(), (JCCompilationUnit) sourceNode.top().get());
+ }
return node;
}
+
+ public static boolean isParameter(JCTree node) {
+ return node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0;
+ }
public static boolean hasAnnotation(String type, JavacNode node) {
return hasAnnotation(type, node, false);
@@ -1035,8 +1044,8 @@ public class JavacHandlerUtil {
JCClassDecl type = (JCClassDecl) typeNode.get();
if (addGenerated) {
- addSuppressWarningsAll(field.mods, typeNode, field.pos, getGeneratedBy(field), typeNode.getContext());
- addGenerated(field.mods, typeNode, field.pos, getGeneratedBy(field), typeNode.getContext());
+ addSuppressWarningsAll(field.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(field)), typeNode.getContext());
+ addGenerated(field.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(field)), typeNode.getContext());
}
List<JCTree> insertAfter = null;
@@ -1229,8 +1238,8 @@ public class JavacHandlerUtil {
}
}
- addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
- addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
+ addSuppressWarningsAll(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
+ addGenerated(method.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(method)), typeNode.getContext());
type.defs = type.defs.append(method);
List<Symbol.VarSymbol> params = null;
@@ -1268,7 +1277,7 @@ public class JavacHandlerUtil {
typeNode.add(method, Kind.METHOD);
}
-
+
private static void fixMethodMirror(Context context, Element typeMirror, long access, Name methodName, List<Type> paramTypes, List<Symbol.VarSymbol> params, Type returnType) {
if (typeMirror == null || paramTypes == null || returnType == null) return;
ClassSymbol cs = (ClassSymbol) typeMirror;
@@ -1291,8 +1300,8 @@ 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());
+ addSuppressWarningsAll(type.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(type)), typeNode.getContext());
+ addGenerated(type.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(type)), typeNode.getContext());
typeDecl.defs = typeDecl.defs.append(type);
return typeNode.add(type, Kind.TYPE);
}
@@ -1331,7 +1340,7 @@ public class JavacHandlerUtil {
}
}
- public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
+ public static void addSuppressWarningsAll(JCModifiers mods, JavacNode node, JavacNode source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateSuppressWarnings()) return;
boolean addJLSuppress = !Boolean.FALSE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_SUPPRESSWARNINGS_ANNOTATIONS));
@@ -1347,27 +1356,27 @@ public class JavacHandlerUtil {
}
}
}
- if (addJLSuppress) addAnnotation(mods, node, pos, source, context, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));
+ if (addJLSuppress) addAnnotation(mods, node, source, "java.lang.SuppressWarnings", node.getTreeMaker().Literal("all"));
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_FINDBUGS_SUPPRESSWARNINGS_ANNOTATIONS))) {
JavacTreeMaker maker = node.getTreeMaker();
JCExpression arg = maker.Assign(maker.Ident(node.toName("justification")), maker.Literal("generated code"));
- addAnnotation(mods, node, pos, source, context, "edu.umd.cs.findbugs.annotations.SuppressFBWarnings", arg);
+ addAnnotation(mods, node, source, "edu.umd.cs.findbugs.annotations.SuppressFBWarnings", arg);
}
}
- public static void addGenerated(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context) {
+ public static void addGenerated(JCModifiers mods, JavacNode node, JavacNode source, Context context) {
if (!LombokOptionsFactory.getDelombokOptions(context).getFormatPreferences().generateGenerated()) return;
if (HandlerUtil.shouldAddGenerated(node)) {
- addAnnotation(mods, node, pos, source, context, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
+ addAnnotation(mods, node, source, "javax.annotation.Generated", node.getTreeMaker().Literal("lombok"));
}
if (Boolean.TRUE.equals(node.getAst().readConfiguration(ConfigurationKeys.ADD_LOMBOK_GENERATED_ANNOTATIONS))) {
- addAnnotation(mods, node, pos, source, context, "lombok.Generated", null);
+ addAnnotation(mods, node, source, "lombok.Generated", null);
}
}
- public static void addAnnotation(JCModifiers mods, JavacNode node, int pos, JCTree source, Context context, String annotationTypeFqn, JCExpression arg) {
+ public static void addAnnotation(JCModifiers mods, JavacNode node, JavacNode source, String annotationTypeFqn, JCExpression arg) {
boolean isJavaLangBased;
String simpleName; {
int idx = annotationTypeFqn.lastIndexOf('.');
@@ -1390,17 +1399,8 @@ public class JavacHandlerUtil {
JavacTreeMaker maker = node.getTreeMaker();
JCExpression annType = isJavaLangBased ? genJavaLangTypeRef(node, simpleName) : chainDotsString(node, annotationTypeFqn);
- annType.pos = pos;
- if (arg != null) {
- arg.pos = pos;
- if (arg instanceof JCAssign) {
- ((JCAssign) arg).lhs.pos = pos;
- ((JCAssign) arg).rhs.pos = pos;
- }
- }
List<JCExpression> argList = arg != null ? List.of(arg) : List.<JCExpression>nil();
- JCAnnotation annotation = recursiveSetGeneratedBy(maker.Annotation(annType, argList), source, context);
- annotation.pos = pos;
+ JCAnnotation annotation = recursiveSetGeneratedBy(maker.Annotation(annType, argList), source);
mods.annotations = mods.annotations.append(annotation);
}
@@ -1820,13 +1820,12 @@ public class JavacHandlerUtil {
if (params == null || params.isEmpty()) return params;
ListBuffer<JCTypeParameter> out = new ListBuffer<JCTypeParameter>();
JavacTreeMaker maker = source.getTreeMaker();
- Context context = source.getContext();
for (JCTypeParameter tp : params) {
List<JCExpression> bounds = tp.bounds;
if (bounds != null && !bounds.isEmpty()) {
ListBuffer<JCExpression> boundsCopy = new ListBuffer<JCExpression>();
for (JCExpression expr : tp.bounds) {
- boundsCopy.append(cloneType(maker, expr, source.get(), context));
+ boundsCopy.append(cloneType(maker, expr, source));
}
bounds = boundsCopy.toList();
}
@@ -1949,11 +1948,11 @@ public class JavacHandlerUtil {
return node;
}
- public static List<JCExpression> cloneTypes(JavacTreeMaker maker, List<JCExpression> in, JCTree source, Context context) {
+ public static List<JCExpression> cloneTypes(JavacTreeMaker maker, List<JCExpression> in, JavacNode source) {
if (in.isEmpty()) return List.nil();
- if (in.size() == 1) return List.of(cloneType(maker, in.get(0), source, context));
+ if (in.size() == 1) return List.of(cloneType(maker, in.get(0), source));
ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>();
- for (JCExpression expr : in) lb.append(cloneType(maker, expr, source, context));
+ for (JCExpression expr : in) lb.append(cloneType(maker, expr, source));
return lb.toList();
}
@@ -1967,9 +1966,9 @@ public class JavacHandlerUtil {
* the class's own parameter, but as its a static method, the static method's notion of {@code T} is different from the class notion of {@code T}. If you're duplicating
* a type used in the class context, you need to use this method.
*/
- public static JCExpression cloneType(JavacTreeMaker maker, JCExpression in, JCTree source, Context context) {
+ public static JCExpression cloneType(JavacTreeMaker maker, JCExpression in, JavacNode source) {
JCExpression out = cloneType0(maker, in);
- if (out != null) recursiveSetGeneratedBy(out, source, context);
+ if (out != null) recursiveSetGeneratedBy(out, source);
return out;
}
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 35a4dbb0..1af4f673 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -43,7 +43,6 @@ import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.JCTree.JCWildcard;
-import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -236,7 +235,7 @@ public class JavacSingularsRecipes {
return Arrays.asList(p, s);
}
- public abstract java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source);
+ public abstract java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source);
/**
* Generates the singular, plural, and clear methods for the given {@link SingularData}.
@@ -246,7 +245,7 @@ public class JavacSingularsRecipes {
*/
public void generateMethods(final BuilderJob job, SingularData data, boolean deprecate) {
//job.checkerFramework, job.builderType, job.source, job.oldFluent, job.oldChain, job.accessInners
- //CheckerFrameworkVersion cfv, final JavacNode builderType, JCTree source, boolean fluent, final boolean chain, AccessLevel access) {
+ //CheckerFrameworkVersion cfv, final JavacNode builderType, JavacNode source, boolean fluent, final boolean chain, AccessLevel access) {
final JavacTreeMaker maker = job.builderType.getTreeMaker();
ExpressionMaker returnTypeMaker = new ExpressionMaker() { @Override public JCExpression make() {
@@ -259,23 +258,23 @@ public class JavacSingularsRecipes {
return job.oldChain ? maker.Return(maker.Ident(job.builderType.toName("this"))) : null;
}};
- generateMethods(job.checkerFramework, data, deprecate, job.builderType, job.source, job.oldFluent, returnTypeMaker, returnStatementMaker, job.accessInners);
+ generateMethods(job.checkerFramework, data, deprecate, job.builderType, job.sourceNode, job.oldFluent, returnTypeMaker, returnStatementMaker, job.accessInners);
}
/**
* Generates the singular, plural, and clear methods for the given {@link SingularData}.
* Uses the given {@code returnTypeMaker} and {@code returnStatementMaker} for the generated methods.
*/
- public abstract void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
+ public abstract void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access);
- protected void doGenerateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ protected void doGenerateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
JavacTreeMaker maker = builderType.getTreeMaker();
generateSingularMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
generatePluralMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, fluent, access);
generateClearMethod(cfv, deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source, access);
}
- private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, List<JCAnnotation> methodAnnotations, AccessLevel access, Boolean ignoreNullCollections) {
+ private void finishAndInjectMethod(CheckerFrameworkVersion cfv, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JavacNode source, boolean deprecate, ListBuffer<JCStatement> statements, Name methodName, List<JCVariableDecl> jcVariableDecls, List<JCAnnotation> methodAnnotations, AccessLevel access, Boolean ignoreNullCollections) {
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
JCModifiers mods = makeMods(maker, cfv, builderType, deprecate, access, methodAnnotations);
@@ -291,12 +290,12 @@ public class JavacSingularsRecipes {
}
JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, jcVariableDecls, thrown, body, null);
- recursiveSetGeneratedBy(method, source, builderType.getContext());
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, method);
+ recursiveSetGeneratedBy(method, source);
injectMethod(builderType, method);
}
- private void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, AccessLevel access) {
+ private void generateClearMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JavacNode source, AccessLevel access) {
JCStatement clearStatement = generateClearStatements(maker, data, builderType);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.add(clearStatement);
@@ -307,7 +306,7 @@ public class JavacSingularsRecipes {
protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType);
- private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
+ private void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JavacNode source, boolean fluent, AccessLevel access) {
ListBuffer<JCStatement> statements = generateSingularMethodStatements(maker, data, builderType, source);
List<JCVariableDecl> params = generateSingularMethodParameters(maker, data, builderType, source);
Name name = data.getSingularName();
@@ -320,7 +319,7 @@ public class JavacSingularsRecipes {
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, params, methodAnnotations, access, null);
}
- protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, Name name) {
+ protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source, Name name) {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
JCExpression type = cloneParamType(typeIndex, maker, data.getTypeArgs(), builderType, source);
List<JCAnnotation> typeUseAnns = getTypeUseAnnotations(type);
@@ -335,11 +334,11 @@ public class JavacSingularsRecipes {
return maker.Exec(invokeAdd);
}
- protected abstract ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- protected abstract List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, AccessLevel access) {
+ private void generatePluralMethod(CheckerFrameworkVersion cfv, boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JavacNode source, boolean fluent, AccessLevel access) {
ListBuffer<JCStatement> statements = generatePluralMethodStatements(maker, data, builderType, source);
Name name = data.getPluralName();
@@ -368,7 +367,7 @@ public class JavacSingularsRecipes {
finishAndInjectMethod(cfv, maker, returnType, returnStatement, data, builderType, source, deprecate, statements, name, List.of(param), methodAnnotations, access, ignoreNullCollections);
}
- protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All");
@@ -380,9 +379,9 @@ public class JavacSingularsRecipes {
protected abstract JCExpression getPluralMethodParamType(JavacNode builderType);
- protected abstract JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source);
+ protected abstract JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source);
- public abstract void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable);
+ public abstract void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable);
public boolean shadowedDuringBuild() {
return true;
@@ -396,7 +395,7 @@ public class JavacSingularsRecipes {
}
}
- public void appendCleaningCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements) {
+ public void appendCleaningCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements) {
}
// -- Utility methods --
@@ -412,16 +411,15 @@ public class JavacSingularsRecipes {
* @param typeArgs the list of type args to clone.
* @param source The source annotation that is the root cause of this code generation.
*/
- protected JCExpression addTypeArgs(int count, boolean addExtends, JavacNode node, JCExpression type, List<JCExpression> typeArgs, JCTree source) {
+ protected JCExpression addTypeArgs(int count, boolean addExtends, JavacNode node, JCExpression type, List<JCExpression> typeArgs, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
List<JCExpression> clonedAndFixedTypeArgs = createTypeArgs(count, addExtends, node, typeArgs, source);
return maker.TypeApply(type, clonedAndFixedTypeArgs);
}
- protected List<JCExpression> createTypeArgs(int count, boolean addExtends, JavacNode node, List<JCExpression> typeArgs, JCTree source) {
+ protected List<JCExpression> createTypeArgs(int count, boolean addExtends, JavacNode node, List<JCExpression> typeArgs, JavacNode source) {
JavacTreeMaker maker = node.getTreeMaker();
- Context context = node.getContext();
if (count < 0) throw new IllegalArgumentException("count is negative");
if (count == 0) return List.nil();
@@ -438,17 +436,17 @@ public class JavacSingularsRecipes {
} catch (Exception e) {
inner = genJavaLangTypeRef(node, "Object");
}
- arguments.append(cloneType(maker, inner, source, context));
+ arguments.append(cloneType(maker, inner, source));
} else {
- arguments.append(cloneType(maker, orig, source, context));
+ arguments.append(cloneType(maker, orig, source));
}
} else {
if (orig.getKind() == Kind.UNBOUNDED_WILDCARD || orig.getKind() == Kind.SUPER_WILDCARD) {
arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null));
} else if (orig.getKind() == Kind.EXTENDS_WILDCARD) {
- arguments.append(cloneType(maker, orig, source, context));
+ arguments.append(cloneType(maker, orig, source));
} else {
- arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), cloneType(maker, orig, source, context)));
+ arguments.append(maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), cloneType(maker, orig, source)));
}
}
if (--count == 0) break;
@@ -479,7 +477,7 @@ public class JavacSingularsRecipes {
return sizeInvoke;
}
- protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JCTree source) {
+ protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JavacNode source) {
if (typeArgs == null || typeArgs.size() <= index) {
return genJavaLangTypeRef(builderType, "Object");
} else {
@@ -488,12 +486,12 @@ public class JavacSingularsRecipes {
return genJavaLangTypeRef(builderType, "Object");
} else if (originalType.getKind() == Kind.EXTENDS_WILDCARD) {
try {
- return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source, builderType.getContext());
+ return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source);
} catch (Exception e) {
return genJavaLangTypeRef(builderType, "Object");
}
} else {
- return cloneType(maker, originalType, source, builderType.getContext());
+ return cloneType(maker, originalType, source);
}
}
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index dadf881d..ce5aad5e 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -39,7 +39,6 @@ import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -62,7 +61,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return "builder";
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
String simpleTypeName = getSimpleTargetTypeName(data);
JCExpression type = JavacHandlerUtil.chainDots(builderType, "com", "google", "common", "collect", simpleTypeName, "Builder");
@@ -72,7 +71,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -83,7 +82,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name[] names = generateSingularMethodParameterNames(data, builderType);
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
for (int i = 0; i < names.length; i++) {
@@ -93,7 +92,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name[] names = generateSingularMethodParameterNames(data, builderType);
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName());
@@ -124,7 +123,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
return genTypeRef(builderType, getAddAllTypeName());
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
List<JCExpression> jceBlank = List.nil();
@@ -156,7 +155,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName());
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 634a086d..dfc8c7b0 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -37,7 +37,6 @@ import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -58,7 +57,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return super.listMethodsToBeGenerated(data, builderType);
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
JCExpression type = JavacHandlerUtil.chainDots(builderType, "java", "util", "ArrayList");
type = addTypeArgs(1, false, builderType, type, data.getTypeArgs(), source);
@@ -67,7 +66,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -84,13 +83,13 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return new ListBuffer<JCStatement>()
.append(generateSingularMethodAddStatement(maker, builderType, data.getSingularName(), data.getPluralName().toString()));
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
JCVariableDecl param = generateSingularMethodParameter(0, maker, data, builderType, source, data.getSingularName());
return List.of(param);
}
@@ -101,7 +100,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return createConstructBuilderVarIfNeeded(maker, data, builderType, false, source);
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
index 1f8bbbe9..56a162e3 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSingularizer.java
@@ -32,7 +32,6 @@ import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCase;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -50,7 +49,7 @@ public class JavacJavaUtilListSingularizer extends JavacJavaUtilListSetSingulari
return "java.util.Collections.emptyList";
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
@@ -94,7 +93,7 @@ public class JavacJavaUtilListSingularizer extends JavacJavaUtilListSetSingulari
statements.append(switchStat);
}
- private List<JCStatement> createListCopy(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, String builderVariable) {
+ private List<JCStatement> createListCopy(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
Name thisName = builderType.toName(builderVariable);
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 8dc7ecff..22f569f4 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -40,7 +40,6 @@ import lombok.javac.handlers.JavacSingularsRecipes.StatementMaker;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -74,7 +73,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return super.listMethodsToBeGenerated(data, builderType);
}
- @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JCTree source) {
+ @Override public java.util.List<JavacNode> generateFields(SingularData data, JavacNode builderType, JavacNode source) {
JavacTreeMaker maker = builderType.getTreeMaker();
JCVariableDecl buildKeyField; {
@@ -98,7 +97,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return Arrays.asList(keyFieldNode, valueFieldNode);
}
- @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JCTree source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
+ @Override public void generateMethods(CheckerFrameworkVersion cfv, SingularData data, boolean deprecate, JavacNode builderType, JavacNode source, boolean fluent, ExpressionMaker returnTypeMaker, StatementMaker returnStatementMaker, AccessLevel access) {
doGenerateMethods(cfv, data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker, access);
}
@@ -117,7 +116,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name keyName = builderType.toName(data.getSingularName().toString() + "Key");
Name valueName = builderType.toName(data.getSingularName().toString() + "Value");
@@ -130,7 +129,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected List<JCVariableDecl> generateSingularMethodParameters(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
Name keyName = builderType.toName(data.getSingularName().toString() + "Key");
Name valueName = builderType.toName(data.getSingularName().toString() + "Value");
JCVariableDecl paramKey = generateSingularMethodParameter(0, maker, data, builderType, source, keyName);
@@ -139,7 +138,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected ListBuffer<JCStatement> generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
long baseFlags = JavacHandlerUtil.addFinalIfNeeded(0, builderType.getContext());
@@ -164,11 +163,11 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
}
@Override
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JavacNode source) {
return createConstructBuilderVarIfNeeded(maker, data, builderType, true, source);
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
if (data.getTargetFqn().equals("java.util.Map")) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
index 7c870c0a..5a0638d8 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSetSingularizer.java
@@ -29,7 +29,6 @@ import lombok.javac.JavacTreeMaker;
import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -46,7 +45,7 @@ public class JavacJavaUtilSetSingularizer extends JavacJavaUtilListSetSingulariz
return "java.util.Collections.emptySet";
}
- @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
+ @Override public void appendBuildCode(SingularData data, JavacNode builderType, JavacNode source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
JavacTreeMaker maker = builderType.getTreeMaker();
if (data.getTargetFqn().equals("java.util.Set")) {
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
index 5670b5e6..cf8fea9f 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilSingularizer.java
@@ -24,7 +24,6 @@ package lombok.javac.handlers.singulars;
import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCase;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCStatement;
@@ -38,7 +37,7 @@ import lombok.javac.handlers.JavacSingularsRecipes.JavacSingularizer;
import lombok.javac.handlers.JavacSingularsRecipes.SingularData;
abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
- protected List<JCStatement> createJavaUtilSetMapInitialCapacitySwitchStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType, JCTree source, String builderVariable) {
+ protected List<JCStatement> createJavaUtilSetMapInitialCapacitySwitchStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, String emptyCollectionMethod, String singletonCollectionMethod, String targetType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
@@ -88,7 +87,7 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
return List.of(varDefStat, switchStat);
}
- protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, JCTree source) {
+ protected JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, JavacNode source) {
List<JCExpression> jceBlank = List.nil();
Name v1Name = mapMode ? builderType.toName(data.getPluralName() + "$key") : data.getPluralName();
@@ -117,7 +116,7 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
return maker.If(cond, thenPart, null);
}
- protected List<JCStatement> createJavaUtilSimpleCreationAndFillStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, boolean defineVar, boolean addInitialCapacityArg, boolean nullGuard, String targetType, JCTree source, String builderVariable) {
+ protected List<JCStatement> createJavaUtilSimpleCreationAndFillStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, boolean mapMode, boolean defineVar, boolean addInitialCapacityArg, boolean nullGuard, String targetType, JavacNode source, String builderVariable) {
List<JCExpression> jceBlank = List.nil();
Name thisName = builderType.toName(builderVariable);