aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJan Rieke <rieke@subshell.com>2018-05-30 11:52:42 +0200
committerJan Rieke <rieke@subshell.com>2018-05-30 11:52:42 +0200
commit61f0689f6bfb8de28c90eb786cd9e9e06a776287 (patch)
tree03f27d45eb634fb034a2d9f8b4365fff45c8b3b8 /src/core
parent9ee2491427f1522a7689d1c28a816294bcff315b (diff)
downloadlombok-61f0689f6bfb8de28c90eb786cd9e9e06a776287.tar.gz
lombok-61f0689f6bfb8de28c90eb786cd9e9e06a776287.tar.bz2
lombok-61f0689f6bfb8de28c90eb786cd9e9e06a776287.zip
ecj: copy type parameters to builder class
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 5586bc6b..40c84a3e 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -681,6 +681,16 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
}
return null;
}
+
+ private TypeReference[] appendBuilderTypeReferences(TypeParameter[] typeParams, String classGenericName, String builderGenericName) {
+ TypeReference[] typerefs = new TypeReference[typeParams.length + 2];
+ for (int i = 0; i < typeParams.length; i++) {
+ typerefs[i] = new SingleTypeReference(typeParams[i].name, 0);
+ }
+ typerefs[typerefs.length - 2] = new SingleTypeReference(classGenericName.toCharArray(), 0);
+ typerefs[typerefs.length - 1] = new SingleTypeReference(builderGenericName.toCharArray(), 0);
+ return typerefs;
+ }
private EclipseNode makeBuilderAbstractClass(EclipseNode tdParent, String builderClass,
TypeReference superclassBuilderClass, TypeParameter[] typeParams,
@@ -703,10 +713,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
// 2. The return type for all setter methods, named "B", which extends this builder class.
o = new TypeParameter();
o.name = builderGenericName.toCharArray();
- TypeReference[] typerefs = new TypeReference[] {
- new SingleTypeReference(classGenericName.toCharArray(), 0),
- new SingleTypeReference(builderGenericName.toCharArray(), 0)
- };
+ TypeReference[] typerefs = appendBuilderTypeReferences(typeParams, classGenericName, builderGenericName);
o.type = new ParameterizedSingleTypeReference(builderClass.toCharArray(), typerefs, 0, 0);
builder.typeParameters[builder.typeParameters.length - 1] = o;
@@ -722,12 +729,26 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
builder.bits |= Eclipse.ECLIPSE_DO_NOT_TOUCH_FLAG;
builder.modifiers |= ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal;
builder.name = builderImplClass.toCharArray();
+ builder.typeParameters = copyTypeParams(typeParams, source);
if (builderAbstractClass != null) {
// Extend the abstract builder.
- // TODO: 1. Add any type params of the annotated class.
+ // 1. Add any type params of the annotated class.
+ TypeReference[] typeArgs = new TypeReference[typeParams.length + 2];
+ for (int i = 0; i < typeParams.length; i++) {
+ typeArgs[i] = new SingleTypeReference(typeParams[i].name, 0);
+ }
// 2. The return type for the build() method (named "C" in the abstract builder), which is the annotated class.
// 3. The return type for all setter methods (named "B" in the abstract builder), which is this builder class.
- TypeReference[] typeArgs = new TypeReference[] {cloneSelfType(tdParent, source), new SingleTypeReference(builderImplClass.toCharArray(), 0)};
+ typeArgs[typeArgs.length - 2] = cloneSelfType(tdParent, source);
+ if (typeParams.length > 0) {
+ TypeReference[] typerefs = new TypeReference[typeParams.length];
+ for (int i = 0; i < typeParams.length; i++) {
+ typerefs[i] = new SingleTypeReference(typeParams[i].name, 0);
+ }
+ typeArgs[typeArgs.length - 1] = new ParameterizedSingleTypeReference(builderImplClass.toCharArray(), typerefs, 0, 0);
+ } else {
+ typeArgs[typeArgs.length - 1] = new SingleTypeReference(builderImplClass.toCharArray(), 0);
+ }
builder.superclass = new ParameterizedSingleTypeReference(builderAbstractClass.toCharArray(), typeArgs, 0, 0);
}
builder.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);