diff options
author | Emil Lundberg <emil@emlun.se> | 2019-01-10 04:21:54 +0100 |
---|---|---|
committer | Emil Lundberg <emil@emlun.se> | 2019-01-13 02:25:26 +0100 |
commit | 0c20da8e0e19e6db37c4c9d0de05d784e472c258 (patch) | |
tree | 8289909628fb25d0162a76632761a7adc07c63b7 /src/core | |
parent | fd7301117deeaa94f4ecb4316a3ef68c1a13a660 (diff) | |
download | lombok-0c20da8e0e19e6db37c4c9d0de05d784e472c258.tar.gz lombok-0c20da8e0e19e6db37c4c9d0de05d784e472c258.tar.bz2 lombok-0c20da8e0e19e6db37c4c9d0de05d784e472c258.zip |
Move single-use variable declarations to just before use
Diffstat (limited to 'src/core')
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<JCStatement> statements = new ListBuffer<JCStatement>(); 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<JCStatement> statements = new ListBuffer<JCStatement>(); 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<JCVariableDecl> 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<JCStatement> statements = new ListBuffer<JCStatement>(); 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<JCVariableDecl> params = List.of(paramKey, paramValue); + JCModifiers mods = makeMods(maker, builderType, deprecate); finishAndInjectSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent, mods, statements, params, "put"); } |