aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java60
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java11
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java11
-rw-r--r--src/core/lombok/eclipse/handlers/HandleNonNull.java21
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java18
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWither.java7
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java10
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java11
-rw-r--r--src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java16
11 files changed, 142 insertions, 44 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 1e29764a..5d582aad 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -48,6 +48,7 @@ import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
import lombok.core.TypeResolver;
import lombok.core.configuration.NullCheckExceptionType;
+import lombok.core.configuration.TypeName;
import lombok.core.debug.ProblemReporter;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.Eclipse;
@@ -448,6 +449,24 @@ public class EclipseHandlerUtil {
return out;
}
+ public static Annotation[] getTypeUseAnnotations(TypeReference from) {
+ Annotation[][] a;
+ try {
+ a = (Annotation[][]) reflect(TYPE_REFERENCE__ANNOTATIONS, from);
+ } catch (Exception e) {
+ return null;
+ }
+ if (a == null) return null;
+ Annotation[] b = a[a.length - 1];
+ return b.length == 0 ? null : b;
+ }
+
+ public static void removeTypeUseAnnotations(TypeReference from) {
+ try {
+ reflectSet(TYPE_REFERENCE__ANNOTATIONS, from, null);
+ } catch (Exception ignore) {}
+ }
+
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
if (params != null && params.length > 0) {
TypeReference[] refs = new TypeReference[params.length];
@@ -672,6 +691,47 @@ public class EclipseHandlerUtil {
}
}
+ public static boolean hasNonNullAnnotations(EclipseNode node) {
+ AbstractVariableDeclaration avd = (AbstractVariableDeclaration) node.get();
+ if (avd.annotations == null) return false;
+ for (Annotation annotation : avd.annotations) {
+ TypeReference typeRef = annotation.type;
+ if (typeRef != null && typeRef.getTypeName() != null) {
+ for (String bn : NONNULL_ANNOTATIONS) if (typeMatches(bn, node, typeRef)) return true;
+ }
+ }
+ return false;
+ }
+
+ private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0];
+
+ /**
+ * Searches the given field node for annotations and returns each one that is 'copyable' (either via configuration or from the base list).
+ */
+ public static Annotation[] findCopyableAnnotations(EclipseNode node) {
+ AbstractVariableDeclaration avd = (AbstractVariableDeclaration) node.get();
+ if (avd.annotations == null) return EMPTY_ANNOTATIONS_ARRAY;
+ List<Annotation> result = new ArrayList<Annotation>();
+ List<TypeName> configuredCopyable = node.getAst().readConfiguration(ConfigurationKeys.COPYABLE_ANNOTATIONS);
+
+ for (Annotation annotation : avd.annotations) {
+ TypeReference typeRef = annotation.type;
+ boolean match = false;
+ if (typeRef != null && typeRef.getTypeName() != null) {
+ for (TypeName cn : configuredCopyable) if (typeMatches(cn.toString(), node, typeRef)) {
+ result.add(annotation);
+ match = true;
+ break;
+ }
+ if (!match) for (String bn : BASE_COPYABLE_ANNOTATIONS) if (typeMatches(bn, node, typeRef)) {
+ result.add(annotation);
+ break;
+ }
+ }
+ }
+ return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
+ }
+
/**
* Checks if the provided annotation type is likely to be the intended type for the given annotation node.
*
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 3b10483d..f6e0a175 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -106,6 +106,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
public static class BuilderFieldData {
+ Annotation[] annotations;
TypeReference type;
char[] rawName;
char[] name;
@@ -199,9 +200,12 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode);
boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
+ Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
+
BuilderFieldData bfd = new BuilderFieldData();
bfd.rawName = fieldNode.getName().toCharArray();
bfd.name = removePrefixFromField(fieldNode);
+ bfd.annotations = copyAnnotations(fd, copyableAnnotations);
bfd.type = fd.type;
bfd.singularData = getSingularData(fieldNode, ast);
bfd.originalFieldNode = fieldNode;
@@ -374,8 +378,12 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
if (param.getKind() != Kind.ARGUMENT) continue;
BuilderFieldData bfd = new BuilderFieldData();
Argument arg = (Argument) param.get();
+
+ Annotation[] copyableAnnotations = findCopyableAnnotations(param);
+
bfd.rawName = arg.name;
bfd.name = arg.name;
+ bfd.annotations = copyAnnotations(arg, copyableAnnotations);
bfd.type = arg.type;
bfd.singularData = getSingularData(param, ast);
bfd.originalFieldNode = param;
@@ -744,13 +752,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
public void makeSetterMethodsForBuilder(EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- makeSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, sourceNode, fluent, chain);
+ makeSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations);
} else {
bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, fluent, chain);
}
}
- private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain) {
+ private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY;
@@ -767,7 +775,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName());
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, nameOfSetFlag, chain, ClassFileConstants.AccPublic,
- sourceNode, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
+ sourceNode, Collections.<Annotation>emptyList(), annotations != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annotations)) : Collections.<Annotation>emptyList());
injectMethod(builderType, setter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 6c7b4caf..cb07115a 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -139,7 +139,7 @@ public class HandleConstructor {
FieldDeclaration fieldDecl = (FieldDeclaration) child.get();
if (!filterField(fieldDecl)) continue;
boolean isFinal = (fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0;
- boolean isNonNull = nullMarked && findAnnotations(fieldDecl, NON_NULL_PATTERN).length != 0;
+ boolean isNonNull = nullMarked && hasNonNullAnnotations(child);
if ((isFinal || isNonNull) && fieldDecl.initialization == null) fields.add(child);
}
return fields;
@@ -403,13 +403,12 @@ public class HandleConstructor {
assigns.add(assignment);
long fieldPos = (((long) field.sourceStart) << 32) | field.sourceEnd;
Argument parameter = new Argument(fieldName, fieldPos, copyType(field.type, source), Modifier.FINAL);
- Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
- if (nonNulls.length != 0) {
+ Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
+ if (hasNonNullAnnotations(fieldNode)) {
Statement nullCheck = generateNullCheck(parameter, sourceNode);
if (nullCheck != null) nullChecks.add(nullCheck);
}
- parameter.annotations = copyAnnotations(source, nonNulls, nullables);
+ parameter.annotations = copyAnnotations(source, copyableAnnotations);
params.add(parameter);
}
@@ -546,7 +545,7 @@ public class HandleConstructor {
assigns.add(nameRef);
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
- parameter.annotations = copyAnnotations(source, findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN));
+ parameter.annotations = copyAnnotations(source, findCopyableAnnotations(fieldNode));
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index d0c2cc23..7d3fe62f 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -236,8 +236,6 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
}
public MethodDeclaration createGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy, List<Annotation> onMethod) {
- FieldDeclaration field = (FieldDeclaration) fieldNode.get();
-
// Remember the type; lazy will change it;
TypeReference returnType = copyType(((FieldDeclaration) fieldNode.get()).type, source);
@@ -271,11 +269,10 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
}
method.annotations = copyAnnotations(source,
- onMethod.toArray(new Annotation[0]),
- findAnnotations(field, NON_NULL_PATTERN),
- findAnnotations(field, NULLABLE_PATTERN),
- findDelegatesAndMarkAsHandled(fieldNode),
- deprecated);
+ onMethod.toArray(new Annotation[0]),
+ findCopyableAnnotations(fieldNode),
+ findDelegatesAndMarkAsHandled(fieldNode),
+ deprecated);
}
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java
index d09993ed..ebc62909 100644
--- a/src/core/lombok/eclipse/handlers/HandleNonNull.java
+++ b/src/core/lombok/eclipse/handlers/HandleNonNull.java
@@ -58,7 +58,26 @@ import org.mangosdk.spi.ProviderFor;
@ProviderFor(EclipseAnnotationHandler.class)
@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first.
public class HandleNonNull extends EclipseAnnotationHandler<NonNull> {
+ public static final HandleNonNull INSTANCE = new HandleNonNull();
+
+ public void fix(EclipseNode method) {
+ for (EclipseNode m : method.down()) {
+ if (m.getKind() != Kind.ARGUMENT) continue;
+ for (EclipseNode c : m.down()) {
+ if (c.getKind() == Kind.ANNOTATION) {
+ if (annotationTypeMatches(NonNull.class, c)) {
+ handle0((Annotation) c.get(), c, true);
+ }
+ }
+ }
+ }
+ }
+
@Override public void handle(AnnotationValues<NonNull> annotation, Annotation ast, EclipseNode annotationNode) {
+ handle0(ast, annotationNode, false);
+ }
+
+ private void handle0(Annotation ast, EclipseNode annotationNode, boolean force) {
handleFlagUsage(annotationNode, ConfigurationKeys.NON_NULL_FLAG_USAGE, "@NonNull");
if (annotationNode.up().getKind() == Kind.FIELD) {
@@ -88,7 +107,7 @@ public class HandleNonNull extends EclipseAnnotationHandler<NonNull> {
return;
}
- if (isGenerated(declaration)) return;
+ if (!force && isGenerated(declaration)) return;
if (declaration.isAbstract()) {
// This used to be a warning, but as @NonNull also has a documentary purpose, better to not warn about this. Since 1.16.7
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index d4df0deb..529a7d19 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -236,10 +236,9 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
- Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
+ Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
List<Statement> statements = new ArrayList<Statement>(5);
- if (nonNulls.length == 0) {
+ if (!hasNonNullAnnotations(fieldNode)) {
statements.add(assignment);
} else {
Statement nullCheck = generateNullCheck(field, sourceNode);
@@ -255,7 +254,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
statements.add(returnStatement);
}
method.statements = statements.toArray(new Statement[0]);
- param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
+ param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0]));
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 8f353cce..97e38904 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -156,9 +156,12 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode);
boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
+ Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
+
BuilderFieldData bfd = new BuilderFieldData();
bfd.rawName = fieldNode.getName().toCharArray();
bfd.name = removePrefixFromField(fieldNode);
+ bfd.annotations = copyAnnotations(fd, copyableAnnotations);
bfd.type = fd.type;
bfd.singularData = getSingularData(fieldNode, ast);
bfd.originalFieldNode = fieldNode;
@@ -516,12 +519,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
statements.add(assignment);
}
- Annotation[] nonNulls = findAnnotations((FieldDeclaration)fieldNode.originalFieldNode.get(), NON_NULL_PATTERN);
- if (nonNulls.length != 0) {
- Statement nullCheck = generateNullCheck((FieldDeclaration)fieldNode.originalFieldNode.get(), sourceNode);
- if (nullCheck != null) {
- statements.add(nullCheck);
- }
+ if (hasNonNullAnnotations(fieldNode.originalFieldNode)) {
+ Statement nullCheck = generateNullCheck((FieldDeclaration) fieldNode.originalFieldNode.get(), sourceNode);
+ if (nullCheck != null) statements.add(nullCheck);
}
}
@@ -851,13 +851,13 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
};
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- generateSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode);
+ generateSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, returnTypeMaker.make(), returnStatementMaker.make(), sourceNode, bfd.annotations);
} else {
bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, true, returnTypeMaker, returnStatementMaker);
}
}
- private void generateSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode) {
+ private void generateSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, TypeReference returnType, Statement returnStatement, EclipseNode sourceNode, Annotation[] annosOnParam) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY_METHODS;
@@ -874,7 +874,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
String setterName = fieldNode.getName();
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, nameOfSetFlag, returnType, returnStatement, ClassFileConstants.AccPublic,
- sourceNode, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
+ sourceNode, Collections.<Annotation>emptyList(), annosOnParam != null ? Arrays.asList(copyAnnotations(sourceNode.get(), annosOnParam)) : Collections.<Annotation>emptyList());
injectMethod(builderType, setter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java
index c035fc26..a99789a6 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWither.java
@@ -240,8 +240,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.typeParameters = null;
method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
- Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
+ Annotation[] copyableAnnotations = findCopyableAnnotations(fieldNode);
if (!makeAbstract) {
List<Expression> args = new ArrayList<Expression>();
@@ -277,7 +276,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
List<Statement> statements = new ArrayList<Statement>(5);
- if (nonNulls.length > 0) {
+ if (hasNonNullAnnotations(fieldNode)) {
Statement nullCheck = generateNullCheck(field, sourceNode);
if (nullCheck != null) statements.add(nullCheck);
}
@@ -285,7 +284,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.statements = statements.toArray(new Statement[0]);
}
- param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
+ param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0]));
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index f1687c9c..17fc5e09 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -32,6 +32,7 @@ import lombok.core.GuavaTypeMap;
import lombok.core.LombokImmutableList;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseNode;
+import lombok.eclipse.handlers.HandleNonNull;
import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker;
@@ -150,14 +151,17 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.arguments = new Argument[suffixes.size()];
for (int i = 0; i < suffixes.size(); i++) {
TypeReference tr = cloneParamType(i, data.getTypeArgs(), builderType);
- md.arguments[i] = new Argument(names[i], 0, tr, 0);
+ Annotation[] typeUseAnns = getTypeUseAnnotations(tr);
+ removeTypeUseAnnotations(tr);
+ md.arguments[i] = new Argument(names[i], 0, tr, ClassFileConstants.AccFinal);
+ md.arguments[i].annotations = typeUseAnns;
}
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray();
md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
data.setGeneratedByRecursive(md);
- injectMethod(builderType, md);
+ HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
@@ -182,7 +186,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
TypeReference paramType;
paramType = new QualifiedTypeReference(fromQualifiedName(getAddAllTypeName()), NULL_POSS);
paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs());
- Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
+ Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal);
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName(getAddMethodName() + "All", new String(data.getPluralName())).toCharArray();
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
index 5f86a4dc..c7315790 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
@@ -30,6 +30,7 @@ import java.util.List;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseNode;
+import lombok.eclipse.handlers.HandleNonNull;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker;
import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker;
@@ -138,14 +139,18 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.statements = statements.toArray(new Statement[statements.size()]);
TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType);
- Argument param = new Argument(data.getSingularName(), 0, paramType, 0);
+ Annotation[] typeUseAnns = getTypeUseAnnotations(paramType);
+ removeTypeUseAnnotations(paramType);
+ Argument param = new Argument(data.getSingularName(), 0, paramType, ClassFileConstants.AccFinal);
+ param.annotations = typeUseAnns;
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
data.setGeneratedByRecursive(md);
- injectMethod(builderType, md);
+
+ HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
@@ -169,7 +174,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS);
paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs());
- Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
+ Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal);
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index 69c2186a..174cd5fc 100644
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -59,6 +59,7 @@ import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer;
import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData;
import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker;
import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker;
+import lombok.eclipse.handlers.HandleNonNull;
@ProviderFor(EclipseSingularizer.class)
public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer {
@@ -214,16 +215,23 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.statements = statements.toArray(new Statement[statements.size()]);
TypeReference keyParamType = cloneParamType(0, data.getTypeArgs(), builderType);
- Argument keyParam = new Argument(keyParamName, 0, keyParamType, 0);
TypeReference valueParamType = cloneParamType(1, data.getTypeArgs(), builderType);
- Argument valueParam = new Argument(valueParamName, 0, valueParamType, 0);
+ Annotation[] typeUseAnnsKey = getTypeUseAnnotations(keyParamType);
+ Annotation[] typeUseAnnsValue = getTypeUseAnnotations(valueParamType);
+
+ removeTypeUseAnnotations(keyParamType);
+ removeTypeUseAnnotations(valueParamType);
+ Argument keyParam = new Argument(keyParamName, 0, keyParamType, ClassFileConstants.AccFinal);
+ Argument valueParam = new Argument(valueParamName, 0, valueParamType, ClassFileConstants.AccFinal);
+ keyParam.annotations = typeUseAnnsKey;
+ valueParam.annotations = typeUseAnnsValue;
md.arguments = new Argument[] {keyParam, valueParam};
md.returnType = returnType;
md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("put", new String(data.getSingularName())).toCharArray();
md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null;
data.setGeneratedByRecursive(md);
- injectMethod(builderType, md);
+ HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
private void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) {
@@ -280,7 +288,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
TypeReference paramType = new QualifiedTypeReference(JAVA_UTIL_MAP, NULL_POSS);
paramType = addTypeArgs(2, true, builderType, paramType, data.getTypeArgs());
- Argument param = new Argument(data.getPluralName(), 0, paramType, 0);
+ Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal);
md.arguments = new Argument[] {param};
md.returnType = returnType;
md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("putAll", new String(data.getPluralName())).toCharArray();