aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleSetter.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-22 08:03:42 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-22 08:03:42 +0100
commitbcd05a01b14705678dfd280989fa5071b627a234 (patch)
tree55f5af9b2b158c37f9d04b7ec27aad048d4e1ffd /src/core/lombok/javac/handlers/HandleSetter.java
parentade900b82b8205bb439ac9d6d99dff0c3af6e10f (diff)
parentfa0b5249cf5fee28d9be13ecdf0225f651f686aa (diff)
downloadlombok-bcd05a01b14705678dfd280989fa5071b627a234.tar.gz
lombok-bcd05a01b14705678dfd280989fa5071b627a234.tar.bz2
lombok-bcd05a01b14705678dfd280989fa5071b627a234.zip
Merge branch 'records'
# Conflicts: # src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java # src/core/lombok/eclipse/handlers/HandleBuilder.java # src/core/lombok/eclipse/handlers/HandleData.java # src/core/lombok/eclipse/handlers/HandleNonNull.java # src/core/lombok/eclipse/handlers/HandleSuperBuilder.java # src/core/lombok/javac/handlers/HandleBuilder.java # src/core/lombok/javac/handlers/HandleNonNull.java # src/core/lombok/javac/handlers/HandleSuperBuilder.java # test/core/src/lombok/RunTestsViaEcj.java
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleSetter.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index a4fb1b71..5c34f9f5 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -61,6 +61,8 @@ import com.sun.tools.javac.util.Name;
*/
@Provides
public class HandleSetter extends JavacAnnotationHandler<Setter> {
+ private static final String SETTER_NODE_NOT_SUPPORTED_ERR = "@Setter is only supported on a class or a field.";
+
public void generateSetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelSetter, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
if (checkForTypeLevelSetter) {
if (hasAnnotation(Setter.class, typeNode)) {
@@ -69,13 +71,8 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
}
}
- JCClassDecl typeDecl = null;
- if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
- long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
- boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0;
-
- if (typeDecl == null || notAClass) {
- errorNode.addError("@Setter is only supported on a class or a field.");
+ if (!isClass(typeNode)) {
+ errorNode.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return;
}
@@ -149,7 +146,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
public void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode sourceNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
if (fieldNode.getKind() != Kind.FIELD) {
- fieldNode.addError("@Setter is only supported on a class or a field.");
+ fieldNode.addError(SETTER_NODE_NOT_SUPPORTED_ERR);
return;
}