aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-08-26 21:41:10 +0200
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-08-27 00:15:47 +0200
commitc11edbf032ce27e448faa00d37245665942095af (patch)
tree78a08bd85b134c6846389cae2abdd7de0950db77 /src/core/lombok/eclipse
parent7bf70ed638fac701c60e2fb29217af7c38056a8c (diff)
downloadlombok-c11edbf032ce27e448faa00d37245665942095af.tar.gz
lombok-c11edbf032ce27e448faa00d37245665942095af.tar.bz2
lombok-c11edbf032ce27e448faa00d37245665942095af.zip
[With] renaming lombok.experimental.Wither to lombok.experimental.With
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java16
-rw-r--r--src/core/lombok/eclipse/handlers/HandleWith.java (renamed from src/core/lombok/eclipse/handlers/HandleWither.java)72
2 files changed, 44 insertions, 44 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 6a6d4cca..0955dba6 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1417,20 +1417,20 @@ public class EclipseHandlerUtil {
}
/**
- * Translates the given field into all possible wither names.
- * Convenient wrapper around {@link TransformationsUtil#toAllWitherNames(lombok.core.AnnotationValues, CharSequence, boolean)}.
+ * Translates the given field into all possible with names.
+ * Convenient wrapper around {@link TransformationsUtil#toAllWithNames(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
- public static java.util.List<String> toAllWitherNames(EclipseNode field, boolean isBoolean) {
- return HandlerUtil.toAllWitherNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
+ public static java.util.List<String> toAllWithNames(EclipseNode field, boolean isBoolean) {
+ return HandlerUtil.toAllWithNames(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
- * @return the likely wither name for the stated field. (e.g. private boolean foo; to withFoo).
+ * @return the likely with name for the stated field. (e.g. private boolean foo; to withFoo).
*
- * Convenient wrapper around {@link TransformationsUtil#toWitherName(lombok.core.AnnotationValues, CharSequence, boolean)}.
+ * Convenient wrapper around {@link TransformationsUtil#toWithName(lombok.core.AnnotationValues, CharSequence, boolean)}.
*/
- public static String toWitherName(EclipseNode field, boolean isBoolean) {
- return HandlerUtil.toWitherName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
+ public static String toWithName(EclipseNode field, boolean isBoolean) {
+ return HandlerUtil.toWithName(field.getAst(), getAccessorsForField(field), field.getName(), isBoolean);
}
/**
diff --git a/src/core/lombok/eclipse/handlers/HandleWither.java b/src/core/lombok/eclipse/handlers/HandleWith.java
index 8be08cfe..8c8c3712 100644
--- a/src/core/lombok/eclipse/handlers/HandleWither.java
+++ b/src/core/lombok/eclipse/handlers/HandleWith.java
@@ -32,12 +32,12 @@ import java.util.List;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
+import lombok.With;
import lombok.core.AST.Kind;
import lombok.core.configuration.CheckerFrameworkVersion;
import lombok.core.AnnotationValues;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
-import lombok.experimental.Wither;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
@@ -60,10 +60,10 @@ import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.mangosdk.spi.ProviderFor;
@ProviderFor(EclipseAnnotationHandler.class)
-public class HandleWither extends EclipseAnnotationHandler<Wither> {
- public boolean generateWitherForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWither) {
- if (checkForTypeLevelWither) {
- if (hasAnnotation(Wither.class, typeNode)) {
+public class HandleWith extends EclipseAnnotationHandler<With> {
+ public boolean generateWithForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWith) {
+ if (checkForTypeLevelWith) {
+ if (hasAnnotation(With.class, typeNode)) {
//The annotation will make it happen, so we can skip it.
return true;
}
@@ -76,7 +76,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
(ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0;
if (typeDecl == null || notAClass) {
- pos.addError("@Wither is only supported on a class or a field.");
+ pos.addError("@With is only supported on a class or a field.");
return false;
}
@@ -88,28 +88,28 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
//Skip final fields.
if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0 && fieldDecl.initialization != null) continue;
- generateWitherForField(field, pos, level);
+ generateWithForField(field, pos, level);
}
return true;
}
/**
- * Generates a wither on the stated field.
+ * Generates a with on the stated field.
*
* Used by {@link HandleValue}.
*
* The difference between this call and the handle method is as follows:
*
- * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the
+ * If there is a {@code lombok.With} annotation on the field, it is used and the
* same rules apply (e.g. warning if the method already exists, stated access level applies).
- * If not, the wither is still generated if it isn't already there, though there will not
+ * If not, the with method is still generated if it isn't already there, though there will not
* be a warning if its already there. The default access level is used.
*/
- public void generateWitherForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) {
+ public void generateWithForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) {
for (EclipseNode child : fieldNode.down()) {
if (child.getKind() == Kind.ANNOTATION) {
- if (annotationTypeMatches(Wither.class, child)) {
+ if (annotationTypeMatches(With.class, child)) {
//The annotation will make it happen, so we can skip it.
return;
}
@@ -117,49 +117,49 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
}
List<Annotation> empty = Collections.emptyList();
- createWitherForField(level, fieldNode, sourceNode, false, empty, empty);
+ createWithForField(level, fieldNode, sourceNode, false, empty, empty);
}
- @Override public void handle(AnnotationValues<Wither> annotation, Annotation ast, EclipseNode annotationNode) {
- handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
+ @Override public void handle(AnnotationValues<With> annotation, Annotation ast, EclipseNode annotationNode) {
+ handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITH_FLAG_USAGE, "@With");
EclipseNode node = annotationNode.up();
AccessLevel level = annotation.getInstance().value();
if (level == AccessLevel.NONE || node == null) return;
- List<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod", annotationNode);
- List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam", annotationNode);
+ List<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@With(onMethod", annotationNode);
+ List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@With(onParam", annotationNode);
switch (node.getKind()) {
case FIELD:
- createWitherForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam);
+ createWithForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam);
break;
case TYPE:
if (!onMethod.isEmpty()) {
- annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
+ annotationNode.addError("'onMethod' is not supported for @With on a type.");
}
if (!onParam.isEmpty()) {
- annotationNode.addError("'onParam' is not supported for @Wither on a type.");
+ annotationNode.addError("'onParam' is not supported for @With on a type.");
}
- generateWitherForType(node, annotationNode, level, false);
+ generateWithForType(node, annotationNode, level, false);
break;
}
}
- public void createWitherForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) {
+ public void createWithForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode sourceNode, boolean whineIfExists, List<Annotation> onMethod, List<Annotation> onParam) {
for (EclipseNode fieldNode : fieldNodes) {
- createWitherForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam);
+ createWithForField(level, fieldNode, sourceNode, whineIfExists, onMethod, onParam);
}
}
- public void createWitherForField(
+ public void createWithForField(
AccessLevel level, EclipseNode fieldNode, EclipseNode sourceNode,
boolean whineIfExists, List<Annotation> onMethod,
List<Annotation> onParam) {
ASTNode source = sourceNode.get();
if (fieldNode.getKind() != Kind.FIELD) {
- sourceNode.addError("@Wither is only supported on a class or a field.");
+ sourceNode.addError("@With is only supported on a class or a field.");
return;
}
@@ -169,38 +169,38 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
TypeReference fieldType = copyType(field.type, source);
boolean isBoolean = isBoolean(fieldType);
- String witherName = toWitherName(fieldNode, isBoolean);
+ String withName = toWithName(fieldNode, isBoolean);
- if (witherName == null) {
- fieldNode.addWarning("Not generating wither for this field: It does not fit your @Accessors prefix list.");
+ if (withName == null) {
+ fieldNode.addWarning("Not generating a with method for this field: It does not fit your @Accessors prefix list.");
return;
}
if ((field.modifiers & ClassFileConstants.AccStatic) != 0) {
- fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for static fields.");
+ fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for static fields.");
return;
}
if ((field.modifiers & ClassFileConstants.AccFinal) != 0 && field.initialization != null) {
- fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for final, initialized fields.");
+ fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for final, initialized fields.");
return;
}
if (field.name != null && field.name.length > 0 && field.name[0] == '$') {
- fieldNode.addWarning("Not generating wither for this field: Withers cannot be generated for fields starting with $.");
+ fieldNode.addWarning("Not generating " + withName + " for this field: With methods cannot be generated for fields starting with $.");
return;
}
- for (String altName : toAllWitherNames(fieldNode, isBoolean)) {
+ for (String altName : toAllWithNames(fieldNode, isBoolean)) {
switch (methodExists(altName, fieldNode, false, 1)) {
case EXISTS_BY_LOMBOK:
return;
case EXISTS_BY_USER:
if (whineIfExists) {
String altNameExpl = "";
- if (!altName.equals(witherName)) altNameExpl = String.format(" (%s)", altName);
+ if (!altName.equals(withName)) altNameExpl = String.format(" (%s)", altName);
fieldNode.addWarning(
- String.format("Not generating %s(): A method with that name already exists%s", witherName, altNameExpl));
+ String.format("Not generating %s(): A method with that name already exists%s", withName, altNameExpl));
}
return;
default:
@@ -211,11 +211,11 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
int modifier = toEclipseModifier(level);
- MethodDeclaration method = createWither((TypeDeclaration) fieldNode.up().get(), fieldNode, witherName, modifier, sourceNode, onMethod, onParam, makeAbstract);
+ MethodDeclaration method = createWith((TypeDeclaration) fieldNode.up().get(), fieldNode, withName, modifier, sourceNode, onMethod, onParam, makeAbstract);
injectMethod(fieldNode.up(), method);
}
- public MethodDeclaration createWither(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam, boolean makeAbstract ) {
+ public MethodDeclaration createWith(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, EclipseNode sourceNode, List<Annotation> onMethod, List<Annotation> onParam, boolean makeAbstract ) {
ASTNode source = sourceNode.get();
if (name == null) return null;
FieldDeclaration field = (FieldDeclaration) fieldNode.get();