aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2021-03-24 06:24:02 +0100
committerGitHub <noreply@github.com>2021-03-24 06:24:02 +0100
commit30a2921e6321d20f0f925694dfd6a32d9e1f1552 (patch)
treeeedf6a2cd9f2051cb926d64fad031c387f4916da /src/core
parent52a31bc4ae2806907194d32567a820c670670357 (diff)
parenta6257f27f0831ed2c9971285a3bb29f73fabbb02 (diff)
downloadlombok-30a2921e6321d20f0f925694dfd6a32d9e1f1552.tar.gz
lombok-30a2921e6321d20f0f925694dfd6a32d9e1f1552.tar.bz2
lombok-30a2921e6321d20f0f925694dfd6a32d9e1f1552.zip
Merge pull request #2687 from janrieke/superBuilderConfigBuilderClassName
SuperBuilder: consider lombok.builder.className for builder extends clause
Diffstat (limited to 'src/core')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java12
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java12
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java8
4 files changed, 29 insertions, 17 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index c2b73988..c002c4ca 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -183,14 +183,14 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
builderMethodName = ann.builderMethodName();
buildMethodName = ann.buildMethodName();
- setBuilderClassName(fixBuilderClassName(node, ann.builderClassName()));
+ setBuilderClassName(getBuilderClassNameTemplate(node, ann.builderClassName()));
toBuilder = ann.toBuilder();
if (builderMethodName == null) builderMethodName = "builder";
if (buildMethodName == null) buildMethodName = "build";
}
- static String fixBuilderClassName(EclipseNode node, String override) {
+ static String getBuilderClassNameTemplate(EclipseNode node, String override) {
if (override != null && !override.isEmpty()) return override;
override = node.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
if (override != null && !override.isEmpty()) return override;
@@ -202,8 +202,12 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
String replaceBuilderClassName(char[] name) {
- if (builderClassName.indexOf('*') == -1) return builderClassName;
- return builderClassName.replace("*", new String(name));
+ return replaceBuilderClassName(name, builderClassName);
+ }
+
+ String replaceBuilderClassName(char[] name, String template) {
+ if (template.indexOf('*') == -1) return template;
+ return template.replace("*", new String(name));
}
String replaceBuilderClassName(String name) {
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 4f4baecd..4d5d2448 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -124,7 +124,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if (builderMethodName == null) builderMethodName = "builder";
if (buildMethodName == null) buildMethodName = "build";
- builderClassName = fixBuilderClassName(node, "");
+ builderClassName = getBuilderClassNameTemplate(node, null);
}
EclipseNode builderAbstractType;
@@ -274,8 +274,9 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
};
if (extendsClause instanceof QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference)extendsClause;
- String superclassClassName = String.valueOf(qualifiedTypeReference.getLastToken());
- String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName);
+ char[] superclassClassName = qualifiedTypeReference.getLastToken();
+ String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null);
+ String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName, builderClassNameTemplate);
char[][] tokens = Arrays.copyOf(qualifiedTypeReference.tokens, qualifiedTypeReference.tokens.length + 1);
tokens[tokens.length-1] = superclassBuilderClassName.toCharArray();
@@ -291,10 +292,11 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
superclassBuilderClass = new ParameterizedQualifiedTypeReference(tokens, typeArgsForTokens, 0, poss);
} else if (extendsClause != null) {
- String superClass = String.valueOf(extendsClause.getTypeName()[0]);
- String superclassBuilderClassName = superClass + "Builder";
+ char[] superclassClassName = extendsClause.getTypeName()[0];
+ String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null);
+ String superclassBuilderClassName = job.replaceBuilderClassName(superclassClassName, builderClassNameTemplate);
- char[][] tokens = new char[][] {superClass.toCharArray(), superclassBuilderClassName.toCharArray()};
+ char[][] tokens = new char[][] {superclassClassName, superclassBuilderClassName.toCharArray()};
long[] poss = new long[tokens.length];
Arrays.fill(poss, job.getPos());
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index a25baeb0..c23dc14c 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -130,7 +130,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
builderMethodName = ann.builderMethodName();
buildMethodName = ann.buildMethodName();
- builderClassName = fixBuilderClassName(node, ann.builderClassName());
+ builderClassName = getBuilderClassNameTemplate(node, ann.builderClassName());
toBuilder = ann.toBuilder();
if (builderMethodName == null) builderMethodName = "builder";
@@ -138,7 +138,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
if (builderClassName == null) builderClassName = "";
}
- static String fixBuilderClassName(JavacNode node, String override) {
+ static String getBuilderClassNameTemplate(JavacNode node, String override) {
if (override != null && !override.isEmpty()) return override;
override = node.getAst().readConfiguration(ConfigurationKeys.BUILDER_CLASS_NAME);
if (override != null && !override.isEmpty()) return override;
@@ -146,8 +146,12 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
String replaceBuilderClassName(Name name) {
- if (builderClassName.indexOf('*') == -1) return builderClassName;
- return builderClassName.replace("*", name.toString());
+ return replaceBuilderClassName(name.toString(), builderClassName);
+ }
+
+ String replaceBuilderClassName(String name, String template) {
+ if (template.indexOf('*') == -1) return template;
+ return template.replace("*", name);
}
JCExpression createBuilderParentTypeReference() {
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 9185cedf..8974cd68 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -111,7 +111,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (builderMethodName == null) builderMethodName = "builder";
if (buildMethodName == null) buildMethodName = "build";
- builderClassName = fixBuilderClassName(node, "");
+ builderClassName = getBuilderClassNameTemplate(node, null);
}
void setBuilderToImpl() {
@@ -253,10 +253,12 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
}
if (extendsClause instanceof JCFieldAccess) {
Name superclassName = ((JCFieldAccess) extendsClause).getIdentifier();
- String superclassBuilderClassName = superclassName.toString() + "Builder";
+ String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null);
+ String superclassBuilderClassName = job.replaceBuilderClassName(superclassName.toString(), builderClassNameTemplate);
superclassBuilderClass = parent.getTreeMaker().Select((JCFieldAccess) extendsClause, parent.toName(superclassBuilderClassName));
} else if (extendsClause != null) {
- String superclassBuilderClassName = extendsClause.toString() + "Builder";
+ String builderClassNameTemplate = BuilderJob.getBuilderClassNameTemplate(annotationNode, null);
+ String superclassBuilderClassName = job.replaceBuilderClassName(extendsClause.toString(), builderClassNameTemplate);
superclassBuilderClass = chainDots(parent, extendsClause.toString(), superclassBuilderClassName);
}