aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java36
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java3
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java9
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java5
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java5
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWither.java5
6 files changed, 30 insertions, 33 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 5e322c90..80c90b65 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -22,7 +22,7 @@
package lombok.eclipse.handlers;
import static lombok.eclipse.Eclipse.*;
-import static lombok.core.TransformationsUtil.*;
+import static lombok.core.handlers.HandlerUtil.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -38,14 +38,15 @@ import java.util.Map;
import java.util.WeakHashMap;
import lombok.AccessLevel;
+import lombok.ConfigurationKeys;
import lombok.Data;
import lombok.Getter;
import lombok.Lombok;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
-import lombok.core.TransformationsUtil;
import lombok.core.TypeResolver;
+import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Accessors;
@@ -1043,7 +1044,7 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toAllGetterNames(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static List<String> toAllGetterNames(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toAllGetterNames(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toAllGetterNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
@@ -1052,7 +1053,7 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toGetterName(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static String toGetterName(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toGetterName(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toGetterName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
@@ -1060,7 +1061,7 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toAllSetterNames(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static java.util.List<String> toAllSetterNames(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toAllSetterNames(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toAllSetterNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
@@ -1069,7 +1070,7 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toSetterName(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static String toSetterName(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toSetterName(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toSetterName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
@@ -1077,7 +1078,7 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toAllWitherNames(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static java.util.List<String> toAllWitherNames(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toAllWitherNames(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
@@ -1086,19 +1087,17 @@ public class EclipseHandlerUtil {
* Convenient wrapper around {@link TransformationsUtil#toWitherName(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
public static String toWitherName(EclipseNode field, boolean isBoolean) {
- return TransformationsUtil.toWitherName(getAccessorsForField(field), field.getName(), isBoolean);
+ return HandlerUtil.toWitherName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
* When generating a setter, the setter either returns void (beanspec) or Self (fluent).
- * This method scans for the {@code Accessors} annotation to figure that out.
+ * This method scans for the {@code Accessors} annotation and associated config properties to figure that out.
*/
public static boolean shouldReturnThis(EclipseNode field) {
if ((((FieldDeclaration) field.get()).modifiers & ClassFileConstants.AccStatic) != 0) return false;
AnnotationValues<Accessors> accessors = EclipseHandlerUtil.getAccessorsForField(field);
- boolean forced = (accessors.getActualExpression("chain") != null);
- Accessors instance = accessors.getInstance();
- return instance.chain() || (instance.fluent() && !forced);
+ return shouldReturnThis0(accessors, field.getAst());
}
/**
@@ -1126,10 +1125,11 @@ public class EclipseHandlerUtil {
}
public static char[] removePrefixFromField(EclipseNode field) {
- String[] prefixes = null;
+ List<String> prefixes = null;
for (EclipseNode node : field.down()) {
if (annotationTypeMatches(Accessors.class, node)) {
- prefixes = createAnnotation(Accessors.class, node).getInstance().prefix();
+ AnnotationValues<Accessors> ann = createAnnotation(Accessors.class, node);
+ if (ann.isExplicit("prefix")) prefixes = Arrays.asList(ann.getInstance().prefix());
break;
}
}
@@ -1140,7 +1140,8 @@ public class EclipseHandlerUtil {
while (current != null) {
for (EclipseNode node : current.down()) {
if (annotationTypeMatches(Accessors.class, node)) {
- prefixes = createAnnotation(Accessors.class, node).getInstance().prefix();
+ AnnotationValues<Accessors> ann = createAnnotation(Accessors.class, node);
+ if (ann.isExplicit("prefix")) prefixes = Arrays.asList(ann.getInstance().prefix());
break outer;
}
}
@@ -1148,8 +1149,9 @@ public class EclipseHandlerUtil {
}
}
- if (prefixes != null && prefixes.length > 0) {
- CharSequence newName = TransformationsUtil.removePrefix(field.getName(), prefixes);
+ if (prefixes == null) prefixes = field.getAst().readConfiguration(ConfigurationKeys.ACCESSORS_PREFIX);
+ if (!prefixes.isEmpty()) {
+ CharSequence newName = removePrefix(field.getName(), prefixes);
if (newName != null) return newName.toString().toCharArray();
}
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 9cf3291f..fd7923b1 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -60,7 +60,6 @@ import lombok.ConfigurationKeys;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.HandlerPriority;
-import lombok.core.TransformationsUtil;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -350,7 +349,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
boolean isBoolean = isBoolean(fd.type);
- String setterName = fluent ? fieldNode.getName() : TransformationsUtil.toSetterName(null, fieldNode.getName(), isBoolean);
+ String setterName = fluent ? fieldNode.getName() : toSetterName(builderType.getAst(), null, fieldNode.getName(), isBoolean);
return HandleSetter.createSetter(td, fieldNode, setterName, chain, ClassFileConstants.AccPublic,
source, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList());
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 15c4d534..ec2bf5dc 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -38,7 +38,6 @@ import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.core.TransformationsUtil;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Builder;
@@ -114,7 +113,7 @@ public class HandleConstructor {
FieldDeclaration fieldDecl = (FieldDeclaration) child.get();
if (!filterField(fieldDecl)) continue;
boolean isFinal = (fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0;
- boolean isNonNull = findAnnotations(fieldDecl, TransformationsUtil.NON_NULL_PATTERN).length != 0;
+ boolean isNonNull = findAnnotations(fieldDecl, NON_NULL_PATTERN).length != 0;
if ((isFinal || isNonNull) && fieldDecl.initialization == null) fields.add(child);
}
return fields;
@@ -293,8 +292,8 @@ public class HandleConstructor {
assigns.add(assignment);
long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd;
Argument parameter = new Argument(fieldName, fieldPos, copyType(field.type, source), Modifier.FINAL);
- Annotation[] nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN);
+ Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
+ Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
if (nonNulls.length != 0) {
Statement nullCheck = generateNullCheck(field, source);
if (nullCheck != null) nullChecks.add(nullCheck);
@@ -363,7 +362,7 @@ public class HandleConstructor {
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
- Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN));
+ Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN));
if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
params.add(parameter);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index 331cf097..0ad20717 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -38,7 +38,6 @@ import lombok.Delegate;
import lombok.Getter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.core.TransformationsUtil;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.agent.PatchDelegate;
@@ -273,8 +272,8 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
Annotation[] copiedAnnotations = copyAnnotations(source,
onMethod.toArray(new Annotation[0]),
- findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN),
- findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN),
+ findAnnotations(field, NON_NULL_PATTERN),
+ findAnnotations(field, NULLABLE_PATTERN),
findDelegatesAndMarkAsHandled(fieldNode),
deprecated);
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index 42f0cd3f..01d1a7ac 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -36,7 +36,6 @@ import lombok.ConfigurationKeys;
import lombok.Setter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.core.TransformationsUtil;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess;
@@ -234,8 +233,8 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
- Annotation[] nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN);
+ Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
+ Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
List<Statement> statements = new ArrayList<Statement>(5);
if (nonNulls.length == 0) {
statements.add(assignment);
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWither.java
index 6149bb08..afe573b9 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWither.java
@@ -35,7 +35,6 @@ import lombok.AccessLevel;
import lombok.ConfigurationKeys;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
-import lombok.core.TransformationsUtil;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess;
@@ -270,8 +269,8 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.bodyStart = method.declarationSourceStart = method.sourceStart = source.sourceStart;
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = source.sourceEnd;
- Annotation[] nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN);
- Annotation[] nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN);
+ Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
+ Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
List<Statement> statements = new ArrayList<Statement>(5);
if (nonNulls.length > 0) {
Statement nullCheck = generateNullCheck(field, source);