From 8059a4e383b2c2ebbb8b811d8bb45e5fac2e2d4c Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 05:42:58 +0100 Subject: Merge finishAndInjectPluralMethod into generatePluralMethod --- .../javac/handlers/JavacSingularsRecipes.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 96694fa4..058fa38a 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -296,19 +296,6 @@ public class JavacSingularsRecipes { void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) { ListBuffer statements = generatePluralMethodStatements(maker, data, builderType, source); - finishAndInjectPluralMethod(deprecate, maker, returnType, returnStatement, data, builderType, source, fluent, statements); - } - - protected ListBuffer generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) { - ListBuffer statements = new ListBuffer(); - statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source)); - JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All"); - JCExpression invokeAdd = maker.Apply(List.nil(), thisDotFieldDotAdd, List.of(maker.Ident(data.getPluralName()))); - statements.append(maker.Exec(invokeAdd)); - return statements; - } - - void finishAndInjectPluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent, ListBuffer statements) { if (returnStatement != null) statements.append(returnStatement); JCBlock body = maker.Block(0, statements.toList()); Name name = data.getPluralName(); @@ -320,6 +307,15 @@ public class JavacSingularsRecipes { finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param)); } + protected ListBuffer generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) { + ListBuffer statements = new ListBuffer(); + statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source)); + JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All"); + JCExpression invokeAdd = maker.Apply(List.nil(), thisDotFieldDotAdd, List.of(maker.Ident(data.getPluralName()))); + statements.append(maker.Exec(invokeAdd)); + return statements; + } + protected abstract JCExpression getPluralMethodParamType(JavacNode builderType); protected abstract JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source); -- cgit