aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorWerner Dietl <wdietl@gmail.com>2018-08-27 18:36:13 -0400
committerReinier Zwitserloot <reinier@zwitserloot.com>2018-09-11 01:59:19 +0200
commit79bfcc4f7ae4bcd61f7f942bfefb940c77927b71 (patch)
tree382b77e1806bd3513dc8f49b009e1aa23cc4dd2d /src/core/lombok/eclipse
parent7a575e1e5d1c78fa5be1deca7fc308bd9eb390dd (diff)
downloadlombok-79bfcc4f7ae4bcd61f7f942bfefb940c77927b71.tar.gz
lombok-79bfcc4f7ae4bcd61f7f942bfefb940c77927b71.tar.bz2
lombok-79bfcc4f7ae4bcd61f7f942bfefb940c77927b71.zip
Add configuration key, handle whereever NULLABLE is handled, support Eclipse.
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java12
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java3
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java1
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java3
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWither.java3
5 files changed, 16 insertions, 6 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 4d20f052..77c29634 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -106,6 +106,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
private static class BuilderFieldData {
+ Annotation[] annotations;
TypeReference type;
char[] rawName;
char[] name;
@@ -199,9 +200,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode);
boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode));
+ Annotation[] nonNulls = findAnnotations(fd, NON_NULL_PATTERN);
+ Annotation[] nullables = findAnnotations(fd, NULLABLE_PATTERN);
+ Annotation[] copyAnnotations = findExactAnnotations(fd, copyAnnotationNames(fieldNode.getAst()));
+
BuilderFieldData bfd = new BuilderFieldData();
bfd.rawName = fieldNode.getName().toCharArray();
bfd.name = removePrefixFromField(fieldNode);
+ bfd.annotations = copyAnnotations(fd, nonNulls, nullables, copyAnnotations);
bfd.type = fd.type;
bfd.singularData = getSingularData(fieldNode, ast);
bfd.originalFieldNode = fieldNode;
@@ -744,13 +750,13 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
public void makeSetterMethodsForBuilder(EclipseNode builderType, BuilderFieldData bfd, EclipseNode sourceNode, boolean fluent, boolean chain) {
boolean deprecate = isFieldDeprecated(bfd.originalFieldNode);
if (bfd.singularData == null || bfd.singularData.getSingularizer() == null) {
- makeSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, sourceNode, fluent, chain);
+ makeSimpleSetterMethodForBuilder(builderType, deprecate, bfd.createdFields.get(0), bfd.nameOfSetFlag, sourceNode, fluent, chain, bfd.annotations);
} else {
bfd.singularData.getSingularizer().generateMethods(bfd.singularData, deprecate, builderType, fluent, chain);
}
}
- private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain) {
+ private void makeSimpleSetterMethodForBuilder(EclipseNode builderType, boolean deprecate, EclipseNode fieldNode, char[] nameOfSetFlag, EclipseNode sourceNode, boolean fluent, boolean chain, Annotation[] annotations) {
TypeDeclaration td = (TypeDeclaration) builderType.get();
AbstractMethodDeclaration[] existing = td.methods;
if (existing == null) existing = EMPTY;
@@ -767,7 +773,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName());
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, nameOfSetFlag, chain, ClassFileConstants.AccPublic,
- sourceNode, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
+ sourceNode, Collections.<Annotation>emptyList(), Arrays.asList(annotations));
injectMethod(builderType, setter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 6c7b4caf..cb9c2b4b 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -405,11 +405,12 @@ public class HandleConstructor {
Argument parameter = new Argument(fieldName, fieldPos, copyType(field.type, source), Modifier.FINAL);
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
+ Annotation[] copyAnnotations = findExactAnnotations(field, copyAnnotationNames(fieldNode.getAst()));
if (nonNulls.length != 0) {
Statement nullCheck = generateNullCheck(parameter, sourceNode);
if (nullCheck != null) nullChecks.add(nullCheck);
}
- parameter.annotations = copyAnnotations(source, nonNulls, nullables);
+ parameter.annotations = copyAnnotations(source, nonNulls, nullables, copyAnnotations);
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index d0c2cc23..45ddb2cc 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -274,6 +274,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
onMethod.toArray(new Annotation[0]),
findAnnotations(field, NON_NULL_PATTERN),
findAnnotations(field, NULLABLE_PATTERN),
+ findExactAnnotations(field, copyAnnotationNames(fieldNode.getAst())),
findDelegatesAndMarkAsHandled(fieldNode),
deprecated);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index d4df0deb..bd34b313 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -238,6 +238,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
+ Annotation[] copyAnnotations = findExactAnnotations(field, copyAnnotationNames(fieldNode.getAst()));
List<Statement> statements = new ArrayList<Statement>(5);
if (nonNulls.length == 0) {
statements.add(assignment);
@@ -255,7 +256,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
statements.add(returnStatement);
}
method.statements = statements.toArray(new Statement[0]);
- param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
+ param.annotations = copyAnnotations(source, nonNulls, nullables, copyAnnotations, onParam.toArray(new Annotation[0]));
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java
index c035fc26..e9831ce1 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWither.java
@@ -242,6 +242,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
+ Annotation[] copyAnnotations = findExactAnnotations(field, copyAnnotationNames(fieldNode.getAst()));
if (!makeAbstract) {
List<Expression> args = new ArrayList<Expression>();
@@ -285,7 +286,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.statements = statements.toArray(new Statement[0]);
}
- param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
+ param.annotations = copyAnnotations(source, nonNulls, nullables, copyAnnotations, onParam.toArray(new Annotation[0]));
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;