aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 05:53:41 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:38:09 +0100
commitad4cc0f1831136d1836335020582b0adf6d801a6 (patch)
tree0764db891e7bb52ddeb9a5455ff32ebd1414718c /src/core/lombok/javac
parente7face9bd6d7660cf37f1c04b9754a1d0352f02e (diff)
downloadlombok-ad4cc0f1831136d1836335020582b0adf6d801a6.tar.gz
lombok-ad4cc0f1831136d1836335020582b0adf6d801a6.tar.bz2
lombok-ad4cc0f1831136d1836335020582b0adf6d801a6.zip
Move single-use variable declarations to just before use
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 1eb80f29..0cfeaf4d 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -254,8 +254,8 @@ public class JavacSingularsRecipes {
JCStatement clearStatement = generateClearStatements(maker, data, builderType);
List<JCStatement> statements = returnStatement != null ? List.of(clearStatement, returnStatement) : List.of(clearStatement);
- JCBlock body = maker.Block(0, statements);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
+ JCBlock body = maker.Block(0, statements);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, methodName, List.<JCVariableDecl>nil());
}
@@ -265,10 +265,10 @@ public class JavacSingularsRecipes {
ListBuffer<JCStatement> statements = generateSingularMethodStatements(maker, data, builderType, source);
List<JCVariableDecl> params = generateSingularMethodParameters(maker, data, builderType, source);
if (returnStatement != null) statements.append(returnStatement);
- JCBlock body = maker.Block(0, statements.toList());
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);
}
@@ -294,13 +294,13 @@ public class JavacSingularsRecipes {
void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
ListBuffer<JCStatement> statements = generatePluralMethodStatements(maker, data, builderType, source);
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);
+ JCBlock body = maker.Block(0, statements.toList());
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param));
}