From 691c855b8962ef78d38ebb6851f5a74b500beab4 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 05:58:08 +0100 Subject: Move invariant parameter inside finishAndInjectMethod --- src/core/lombok/javac/handlers/JavacSingularsRecipes.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 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 e169e2f9..5f6c4784 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -241,7 +241,8 @@ public class JavacSingularsRecipes { generateClearMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source); } - void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, boolean deprecate, JCBlock body, Name methodName, List jcVariableDecls) { + void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, boolean deprecate, ListBuffer statements, Name methodName, List jcVariableDecls) { + JCBlock body = maker.Block(0, statements.toList()); JCModifiers mods = makeMods(maker, builderType, deprecate); List typeParams = List.nil(); List thrown = List.nil(); @@ -257,8 +258,7 @@ public class JavacSingularsRecipes { if (returnStatement != null) statements.append(returnStatement); Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString())); - JCBlock body = maker.Block(0, statements.toList()); - finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, methodName, List.nil()); + finishAndInjectMethod(maker, returnType, builderType, source, deprecate, statements, methodName, List.nil()); } protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType); @@ -270,8 +270,7 @@ public class JavacSingularsRecipes { Name name = data.getSingularName(); if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName(), name.toString())); - JCBlock body = maker.Block(0, statements.toList()); - finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, params); + finishAndInjectMethod(maker, returnType, builderType, source, deprecate, statements, name, params); } protected JCVariableDecl generateSingularMethodParameter(int typeIndex, JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source, Name name) { @@ -302,8 +301,7 @@ public class JavacSingularsRecipes { 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); - JCBlock body = maker.Block(0, statements.toList()); - finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param)); + finishAndInjectMethod(maker, returnType, builderType, source, deprecate, statements, name, List.of(param)); } protected ListBuffer generatePluralMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) { -- cgit