From 0c20da8e0e19e6db37c4c9d0de05d784e472c258 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 04:21:54 +0100 Subject: Move single-use variable declarations to just before use --- src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java | 2 +- .../javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java | 2 +- .../lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java index e79f626c..97329f78 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java @@ -90,7 +90,6 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { names[i] = s.isEmpty() ? n : builderType.toName(s); } - JCModifiers mods = makeMods(maker, builderType, deprecate); ListBuffer statements = new ListBuffer(); statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source)); JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName()); @@ -108,6 +107,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { params.append(generateSingularMethodParameter(i, maker, data, builderType, source, names[i])); } + JCModifiers mods = makeMods(maker, builderType, deprecate); finishAndInjectSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent, mods, statements, params.toList(), getAddMethodName()); } diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java index 7cc7e30e..76c58678 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java @@ -98,7 +98,6 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize @Override protected void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) { - JCModifiers mods = makeMods(maker, builderType, deprecate); ListBuffer statements = new ListBuffer(); statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source)); statements.append(generateSingularMethodAddStatement(maker, builderType, data.getSingularName(), data.getPluralName().toString())); @@ -106,6 +105,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize JCVariableDecl param = generateSingularMethodParameter(0, maker, data, builderType, source, data.getSingularName()); List params = List.of(param); + JCModifiers mods = makeMods(maker, builderType, deprecate); finishAndInjectSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent, mods, statements, params, "add"); } diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java index 687cb1d1..6add2fcb 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java @@ -125,8 +125,6 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { @Override protected void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) { - JCModifiers mods = makeMods(maker, builderType, deprecate); - ListBuffer statements = new ListBuffer(); statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, true, source)); Name keyName = builderType.toName(data.getSingularName().toString() + "Key"); @@ -141,6 +139,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { JCVariableDecl paramValue = generateSingularMethodParameter(1, maker, data, builderType, source, valueName); List params = List.of(paramKey, paramValue); + JCModifiers mods = makeMods(maker, builderType, deprecate); finishAndInjectSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent, mods, statements, params, "put"); } -- cgit