aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/HandleSuperBuilder.java
diff options
context:
space:
mode:
authorLekanich <lekan1992@gmail.com>2019-10-27 15:09:56 +0200
committerLekanich <lekan1992@gmail.com>2019-10-27 15:09:56 +0200
commitda9cc7b6b27de2a233b1ed92333ff4e280f21f40 (patch)
tree72fcd72f55058f67c26e9d5a3b92565c291937ae /src/core/lombok/javac/handlers/HandleSuperBuilder.java
parenta81df33c10f69d49425bdd0606052178a172a66f (diff)
downloadlombok-da9cc7b6b27de2a233b1ed92333ff4e280f21f40.tar.gz
lombok-da9cc7b6b27de2a233b1ed92333ff4e280f21f40.tar.bz2
lombok-da9cc7b6b27de2a233b1ed92333ff4e280f21f40.zip
Issue2262.
Added ability to process JCField as type parameter for HandleSuperBuilder. javac.
Diffstat (limited to 'src/core/lombok/javac/handlers/HandleSuperBuilder.java')
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 0f809571..83dc23d1 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -26,6 +26,7 @@ import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
import java.util.ArrayList;
+import java.util.Collections;
import javax.lang.model.element.Modifier;
@@ -1007,8 +1008,35 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
typeParamsForBuilderParameter.add(maker.Ident(((JCTypeParameter)typeParam).getName()));
} else if (typeParam instanceof JCIdent) {
typeParamsForBuilderParameter.add(maker.Ident(((JCIdent)typeParam).getName()));
+ } else if (typeParam instanceof JCFieldAccess) {
+ typeParamsForBuilderParameter.add(copySelect(maker, (JCFieldAccess) typeParam));
}
}
return typeParamsForBuilderParameter;
}
+
+ private JCExpression copySelect(JavacTreeMaker maker, JCFieldAccess typeParam) {
+ java.util.List<Name> chainNames = new ArrayList<Name>();
+ JCExpression expression = typeParam;
+ while (expression != null) {
+ if (expression instanceof JCFieldAccess) {
+ chainNames.add(((JCFieldAccess) expression).getIdentifier());
+ expression = ((JCFieldAccess) expression).getExpression();
+ } else if (expression instanceof JCIdent) {
+ chainNames.add(((JCIdent) expression).getName());
+ expression = null;
+ }
+ }
+
+ Collections.reverse(chainNames);
+ JCExpression typeParameter = null;
+ for (Name name : chainNames) {
+ if (typeParameter == null) {
+ typeParameter = maker.Ident(name);
+ } else {
+ typeParameter = maker.Select(typeParameter, name);
+ }
+ }
+ return typeParameter;
+ }
}