aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-01-31 15:58:19 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-01-31 15:58:19 +0100
commit3f0fec18726fb9c9f4dce614dbcfa650c1c04bf7 (patch)
treed03abb38a198bbe5417e3aa1e1f7c55b03f32e63 /src/core/lombok/eclipse
parentc42bfbae39990b365a5f05eb23895da6203023bc (diff)
downloadlombok-3f0fec18726fb9c9f4dce614dbcfa650c1c04bf7.tar.gz
lombok-3f0fec18726fb9c9f4dce614dbcfa650c1c04bf7.tar.bz2
lombok-3f0fec18726fb9c9f4dce614dbcfa650c1c04bf7.zip
[issue #788] Add more nullity annotations where relevant
(chainable setters, static constructors, builder stuff)
Diffstat (limited to 'src/core/lombok/eclipse')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java3
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java1
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java2
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleSuperBuilder.java5
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java4
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java3
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java3
7 files changed, 19 insertions, 2 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 19388eda..20bec50e 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -650,6 +650,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
}
+ createRelevantNonNullAnnotation(type, out);
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -796,6 +797,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE)};
}
out.arguments = generateBuildArgs(cfv, type, builderFields, source);
+ if (staticName == null) createRelevantNonNullAnnotation(type, out);
out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return out;
}
@@ -864,6 +866,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
} else if (sefAnn != null) {
out.annotations = new Annotation[] {sefAnn};
}
+ createRelevantNonNullAnnotation(type, out);
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index f69a2d1c..129fa7c0 100755
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -562,6 +562,7 @@ public class HandleConstructor {
constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[0]);
constructor.statements = new Statement[] { new ReturnStatement(statement, (int) (p >> 32), (int)p) };
+ createRelevantNonNullAnnotation(type, constructor);
constructor.traverse(new SetGeneratedByVisitor(source), typeDecl.scope);
return constructor;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index 8ee54d0f..cb2ca3bf 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -260,6 +260,8 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
method.statements = statements.toArray(new Statement[0]);
param.annotations = copyAnnotations(source, copyableAnnotations, onParam.toArray(new Annotation[0]));
+ if (returnType != null && returnStatement != null) createRelevantNonNullAnnotation(sourceNode, method);
+
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 0a5acd56..306c6439 100755
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -599,6 +599,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ createRelevantNonNullAnnotation(type, out);
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -633,6 +634,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if (cfv.generateUnique()) out.annotations = new Annotation[] {generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__UNIQUE)};
+ createRelevantNonNullAnnotation(type, out);
out.traverse(new SetGeneratedByVisitor(source), ((TypeDeclaration) type.get()).scope);
return out;
}
@@ -850,8 +852,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
allocationStatement.arguments = new Expression[] {new ThisReference(0, 0)};
statements.add(new ReturnStatement(allocationStatement, 0, 0));
out.statements = statements.isEmpty() ? null : statements.toArray(new Statement[0]);
- out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
out.arguments = HandleBuilder.generateBuildArgs(cfv, builderType, builderFields, source);
+ createRelevantNonNullAnnotation(builderType, out);
+ out.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
return out;
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index 5d656c91..392418ff 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -132,6 +132,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
injectMethod(builderType, md);
}
@@ -176,6 +177,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
@@ -207,13 +209,13 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.statements = statements.toArray(new Statement[0]);
-
md.arguments = new Argument[] {param};
md.returnType = returnType;
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
index 024f5880..375f4e2c 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
@@ -122,6 +122,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
data.setGeneratedByRecursive(md);
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
injectMethod(builderType, md);
}
@@ -154,6 +155,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
@@ -189,6 +191,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index 843fd073..cb7d9ed6 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -191,6 +191,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.returnType = returnType;
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}
@@ -253,6 +254,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.selector = setterName.toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
HandleNonNull.INSTANCE.fix(injectMethod(builderType, md));
}
@@ -326,6 +328,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.selector = setterName.toCharArray();
md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
injectMethod(builderType, md);
}