aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers/singulars
diff options
context:
space:
mode:
authorJan Rieke <rieke@subshell.com>2021-07-21 13:54:54 +0200
committerRoel Spilker <r.spilker@gmail.com>2022-01-09 01:36:22 +0100
commitae8ff327d2734e373df2839335ba9b1923c6eb67 (patch)
tree55c94c8d02fa0fc4d60f8faa29fc44d67e2cc9dd /src/core/lombok/eclipse/handlers/singulars
parent9be867ef03b77e0455a45d22e4a8cd7c5fa9af61 (diff)
downloadlombok-ae8ff327d2734e373df2839335ba9b1923c6eb67.tar.gz
lombok-ae8ff327d2734e373df2839335ba9b1923c6eb67.tar.bz2
lombok-ae8ff327d2734e373df2839335ba9b1923c6eb67.zip
[fixes #3081] make CheckerFramework's This a type annotation
Diffstat (limited to 'src/core/lombok/eclipse/handlers/singulars')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java11
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java9
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java9
3 files changed, 19 insertions, 10 deletions
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
index 59fccdab..47822ff3 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java
@@ -129,13 +129,14 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.selector = HandlerUtil.buildAccessorName(builderType, "clear", new String(data.getPluralName())).toCharArray();
md.statements = returnStatement != null ? new Statement[] {a, returnStatement} : new Statement[] {a};
md.returnType = returnType;
- md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
+ md.annotations = generateSelfReturnAnnotations(deprecate, data.getSource());
data.setGeneratedByRecursive(md);
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
injectMethod(builderType, md);
}
-
+
void generateSingularMethod(CheckerFrameworkVersion cfv, boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent, AccessLevel access) {
LombokImmutableList<String> suffixes = getArgumentSuffixes();
char[][] names = new char[suffixes.size()][];
@@ -173,9 +174,10 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.arguments[i].annotations = typeUseAnns;
}
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(builderType, new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray();
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName(builderType, "add", new String(data.getSingularName())).toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
@@ -213,9 +215,10 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer {
md.arguments = new Argument[] {param};
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(builderType, new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName(builderType, "addAll", new String(data.getPluralName())).toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
index 6f5e9add..fbde3021 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java
@@ -119,7 +119,8 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
- md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
+ md.annotations = generateSelfReturnAnnotations(deprecate, data.getSource());
data.setGeneratedByRecursive(md);
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
@@ -151,9 +152,10 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
param.annotations = typeUseAnns;
md.arguments = new Argument[] {param};
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
char[] prefixedSingularName = data.getSetterPrefix().length == 0 ? data.getSingularName() : HandlerUtil.buildAccessorName(builderType, new String(data.getSetterPrefix()), new String(data.getSingularName())).toCharArray();
md.selector = fluent ? prefixedSingularName : HandlerUtil.buildAccessorName(builderType, "add", new String(data.getSingularName())).toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
@@ -189,9 +191,10 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula
md.arguments = new Argument[] {param};
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
char[] prefixedSelector = data.getSetterPrefix().length == 0 ? data.getPluralName() : HandlerUtil.buildAccessorName(builderType, new String(data.getSetterPrefix()), new String(data.getPluralName())).toCharArray();
md.selector = fluent ? prefixedSelector : HandlerUtil.buildAccessorName(builderType, "addAll", new String(data.getPluralName())).toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
index c28ba59d..859cce94 100755
--- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
+++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java
@@ -189,7 +189,8 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsgs, 0, 0);
md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
md.returnType = returnType;
- md.annotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
+ md.annotations = generateSelfReturnAnnotations(deprecate, data.getSource());
if (returnStatement != null) createRelevantNonNullAnnotation(builderType, md);
data.setGeneratedByRecursive(md);
@@ -246,13 +247,14 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
valueParam.annotations = typeUseAnnsValue;
md.arguments = new Argument[] {keyParam, valueParam};
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
String name = new String(data.getSingularName());
String setterPrefix = data.getSetterPrefix().length > 0 ? new String(data.getSetterPrefix()) : fluent ? "" : "put";
String setterName = HandlerUtil.buildAccessorName(builderType, setterPrefix, name);
md.selector = setterName.toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToBuilderSingularSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);
@@ -322,13 +324,14 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer
md.arguments = new Argument[] {param};
md.returnType = returnType;
+ addCheckerFrameworkReturnsReceiver(md.returnType, data.getSource(), cfv);
String name = new String(data.getPluralName());
String setterPrefix = data.getSetterPrefix().length > 0 ? new String(data.getSetterPrefix()) : fluent ? "" : "put";
String setterName = HandlerUtil.buildAccessorName(builderType, setterPrefix, name);
md.selector = setterName.toCharArray();
- Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, cfv, data.getSource());
+ Annotation[] selfReturnAnnotations = generateSelfReturnAnnotations(deprecate, data.getSource());
Annotation[] copyToSetterAnnotations = copyAnnotations(md, findCopyableToSetterAnnotations(data.getAnnotation().up()));
md.annotations = concat(selfReturnAnnotations, copyToSetterAnnotations, Annotation.class);