aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers/HandleWither.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-08-13 15:04:43 +0200
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-08-22 22:42:48 +0200
commit15df143df6d35dd64459d717a451a039eb26d761 (patch)
tree70fc0be372fd02491f9c5e9d7d68ffe7901da6d8 /src/core/lombok/eclipse/handlers/HandleWither.java
parentff1c01d9e9e66d898c30939b497490b04fe6163c (diff)
downloadlombok-15df143df6d35dd64459d717a451a039eb26d761.tar.gz
lombok-15df143df6d35dd64459d717a451a039eb26d761.tar.bz2
lombok-15df143df6d35dd64459d717a451a039eb26d761.zip
[checkerframework]
A bit of a shadow feature because the checker framework folks need to do some work on their side. this update makes lombok generate a few checker framework annotations (if configured to do so) which let the checker framework add warnings and errors for example if you misuse builders, or ignore the return values of withers, etc.
Diffstat (limited to 'src/core/lombok/eclipse/handlers/HandleWither.java')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWither.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java
index a99789a6..8be08cfe 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWither.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 The Project Lombok Authors.
+ * Copyright (C) 2012-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -33,6 +33,7 @@ import java.util.List;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -226,11 +227,11 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.returnType = cloneSelfType(fieldNode, source);
if (method.returnType == null) return null;
- Annotation[] deprecated = null;
- if (isFieldDeprecated(fieldNode)) {
- deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
- }
- method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
+ Annotation[] deprecated = null, checkerFramework = null;
+ if (isFieldDeprecated(fieldNode)) deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
+ if (getCheckerFrameworkVersion(fieldNode).generateSideEffectFree()) checkerFramework = new Annotation[] { generateNamedAnnotation(source, CheckerFrameworkVersion.NAME__SIDE_EFFECT_FREE) };
+
+ method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), checkerFramework, deprecated);
Argument param = new Argument(field.name, p, copyType(field.type, source), ClassFileConstants.AccFinal);
param.sourceStart = pS; param.sourceEnd = pE;
method.arguments = new Argument[] { param };