diff options
author | Caleb Brinkman <cbrinkman@sonatype.com> | 2019-09-11 09:17:02 -0500 |
---|---|---|
committer | Caleb Brinkman <cbrinkman@sonatype.com> | 2019-09-11 09:17:02 -0500 |
commit | dc56309dada0ae0fba2c939d3fc300d6abac145c (patch) | |
tree | f79b31cb086a368aa467f359b84923bca1ecaa6b /src/core/lombok/eclipse/handlers/HandleSetter.java | |
parent | 4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7 (diff) | |
parent | 8c32769f18361ed626ebd06962d924c288950d26 (diff) | |
download | lombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.tar.gz lombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.tar.bz2 lombok-dc56309dada0ae0fba2c939d3fc300d6abac145c.zip |
Merge branch 'master' of github.com:rzwitserloot/lombok into feature/builder-setter-prefixes
Diffstat (limited to 'src/core/lombok/eclipse/handlers/HandleSetter.java')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleSetter.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java index bb704ead..8180c3fa 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.java @@ -36,6 +36,7 @@ import lombok.AccessLevel; import lombok.ConfigurationKeys; import lombok.Setter; import lombok.core.AST.Kind; +import lombok.core.configuration.CheckerFrameworkVersion; import lombok.core.AnnotationValues; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; @@ -200,7 +201,11 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { returnThis = new ReturnStatement(thisRef, pS, pE); } - return createSetter(parent, deprecate, fieldNode, name, paramName, booleanFieldToSet, returnType, returnThis, modifier, sourceNode, onMethod, onParam); + MethodDeclaration d = createSetter(parent, deprecate, fieldNode, name, paramName, booleanFieldToSet, returnType, returnThis, modifier, sourceNode, onMethod, onParam); + if (shouldReturnThis && getCheckerFrameworkVersion(sourceNode).generateReturnsReceiver()) { + d.annotations = copyAnnotations(source, d.annotations, new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__RETURNS_RECEIVER) }); + } + return d; } static MethodDeclaration createSetter(TypeDeclaration parent, boolean deprecate, EclipseNode fieldNode, String name, char[] paramName, char[] booleanFieldToSet, TypeReference returnType, Statement returnStatement, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam) { @@ -221,7 +226,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { if (isFieldDeprecated(fieldNode) || deprecate) { deprecated = new Annotation[] { generateDeprecatedAnnotation(source) }; } - method.annotations = mergeAnnotations(copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated), findCopyableToSetterAnnotations(fieldNode)); + method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated, findCopyableToSetterAnnotations(fieldNode)); Argument param = new Argument(paramName, p, copyType(field.type, source), Modifier.FINAL); param.sourceStart = pS; param.sourceEnd = pE; method.arguments = new Argument[] { param }; |