aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 05:37:26 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:27:33 +0100
commit0ef178137759f0a780e3e3f6ea141ee073d96826 (patch)
treeb5439eba5955e4d34a0d49f62b57ff3c60ca348f /src
parentb227bcb487471631fffb6e33999986d4fa1013b2 (diff)
downloadlombok-0ef178137759f0a780e3e3f6ea141ee073d96826.tar.gz
lombok-0ef178137759f0a780e3e3f6ea141ee073d96826.tar.bz2
lombok-0ef178137759f0a780e3e3f6ea141ee073d96826.zip
Extract method finishAndInjectPluralMethod
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java6
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java12
2 files changed, 7 insertions, 11 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 13b2bb67..62513bc1 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -241,7 +241,7 @@ public class JavacSingularsRecipes {
generateClearMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source);
}
- protected void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, boolean deprecate, JCBlock body, Name methodName, List<JCVariableDecl> jcVariableDecls) {
+ void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, boolean deprecate, JCBlock body, Name methodName, List<JCVariableDecl> jcVariableDecls) {
JCModifiers mods = makeMods(maker, builderType, deprecate);
List<JCTypeParameter> typeParams = List.nil();
List<JCExpression> thrown = List.nil();
@@ -301,6 +301,10 @@ public class JavacSingularsRecipes {
JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, List.<JCExpression>of(maker.Ident(data.getPluralName())));
statements.append(maker.Exec(invokeAdd));
+ finishAndInjectPluralMethod(deprecate, maker, returnType, returnStatement, data, builderType, source, fluent, statements);
+ }
+
+ protected void finishAndInjectPluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, ListBuffer<JCStatement> statements) {
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
Name name = data.getPluralName();
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 6792f94e..d37dd445 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -164,16 +164,8 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
JCExpression entrySetInvocation = maker.Apply(jceBlank, maker.Select(maker.Ident(data.getPluralName()), builderType.toName("entrySet")), jceBlank);
JCStatement forEach = maker.ForeachLoop(maker.VarDef(maker.Modifiers(baseFlags), entryName, forEachType, null), entrySetInvocation, forEachBody);
statements.append(forEach);
-
- if (returnStatement != null) statements.append(returnStatement);
- JCBlock body = maker.Block(0, statements.toList());
- Name name = data.getPluralName();
- if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", name.toString()));
- JCExpression paramType = getPluralMethodParamType(builderType);
- paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs(), source);
- long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
- JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
- finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param));
+
+ finishAndInjectPluralMethod(deprecate, maker, returnType, returnStatement, data, builderType, source, fluent, statements);
}
@Override