mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 16:17:34 +00:00
SuperBuilder now with generics on self() method
This commit is contained in:
1 parent
e23cf0bcbe
commit
ca2b8c281b
2 files changed
+6
-6
No files matched your search
@@ -337,7 +337,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
}
|
||||
|
||||
// Create the self() and build() methods in the BuilderImpl.
|
||||
injectMethod(builderImplType, generateSelfMethod(builderImplType));
|
||||
injectMethod(builderImplType, generateSelfMethod(builderImplType, typeParams, p));
|
||||
injectMethod(builderImplType, generateBuildMethod(tdParent, buildMethodName, returnType, ast));
|
||||
|
||||
// Add the builder() method to the annotated class.
|
||||
@@ -544,13 +544,13 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
|
||||
return out;
|
||||
}
|
||||
|
||||
private MethodDeclaration generateSelfMethod(EclipseNode builderImplType) {
|
||||
private MethodDeclaration generateSelfMethod(EclipseNode builderImplType, TypeParameter[] typeParams, long p) {
|
||||
MethodDeclaration out = new MethodDeclaration(((CompilationUnitDeclaration) builderImplType.top().get()).compilationResult);
|
||||
out.selector = SELF_METHOD_NAME;
|
||||
out.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
|
||||
out.modifiers = ClassFileConstants.AccProtected;
|
||||
out.annotations = new Annotation[] {makeMarkerAnnotation(TypeConstants.JAVA_LANG_OVERRIDE, builderImplType.get())};
|
||||
out.returnType = new SingleTypeReference(builderImplType.getName().toCharArray(), 0);
|
||||
out.returnType = namePlusTypeParamsToTypeReference(builderImplType.getName().toCharArray(), typeParams, p);
|
||||
out.statements = new Statement[] {new ReturnStatement(new ThisReference(0, 0), 0, 0)};
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
if (cd != null) injectMethod(builderImplType, cd);
|
||||
|
||||
// Create the self() and build() methods in the BuilderImpl.
|
||||
injectMethod(builderImplType, generateSelfMethod(builderImplType));
|
||||
injectMethod(builderImplType, generateSelfMethod(builderImplType, typeParams));
|
||||
injectMethod(builderImplType, generateBuildMethod(buildMethodName, returnType, builderImplType, thrownExceptions));
|
||||
|
||||
recursiveSetGeneratedBy(builderImplType.get(), ast, annotationNode.getContext());
|
||||
@@ -509,14 +509,14 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
|
||||
return maker.MethodDef(modifiers, name, returnType, List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null);
|
||||
}
|
||||
|
||||
private JCMethodDecl generateSelfMethod(JavacNode builderImplType) {
|
||||
private JCMethodDecl generateSelfMethod(JavacNode builderImplType, List<JCTypeParameter> typeParams) {
|
||||
JavacTreeMaker maker = builderImplType.getTreeMaker();
|
||||
|
||||
JCAnnotation overrideAnnotation = maker.Annotation(genJavaLangTypeRef(builderImplType, "Override"), List.<JCExpression>nil());
|
||||
JCModifiers modifiers = maker.Modifiers(Flags.PROTECTED, List.of(overrideAnnotation));
|
||||
Name name = builderImplType.toName(SELF_METHOD);
|
||||
JCExpression returnType = maker.Ident(builderImplType.toName(builderImplType.getName()));
|
||||
|
||||
JCExpression returnType = namePlusTypeParamsToTypeReference(maker, builderImplType.toName(builderImplType.getName()), typeParams);
|
||||
JCStatement statement = maker.Return(maker.Ident(builderImplType.toName("this")));
|
||||
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
|
||||
|
||||
|
||||
Reference in new issue
Block a user