aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 05:00:59 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:26:56 +0100
commit36653329e51cd478199a2d74da6ec5ee471d9cac (patch)
treef809c2f3d43516edce166eee2a47e9582c2fc25a /src/core
parent1eaa6da81602ddfd7d2d170974c064b8c0b117cf (diff)
downloadlombok-36653329e51cd478199a2d74da6ec5ee471d9cac.tar.gz
lombok-36653329e51cd478199a2d74da6ec5ee471d9cac.tar.bz2
lombok-36653329e51cd478199a2d74da6ec5ee471d9cac.zip
Move single-use variable declarations to just before use
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java4
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java2
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java2
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index db03c77a..a32a64be 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -250,7 +250,6 @@ public class JavacSingularsRecipes {
}
protected void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) {
- JCModifiers mods = makeMods(maker, builderType, deprecate);
List<JCVariableDecl> params = List.nil();
@@ -259,6 +258,7 @@ public class JavacSingularsRecipes {
JCBlock body = maker.Block(0, statements);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
+ JCModifiers mods = makeMods(maker, builderType, deprecate);
finishAndInjectMethod(maker, returnType, builderType, source, mods, body, methodName, params);
}
@@ -267,12 +267,12 @@ public class JavacSingularsRecipes {
void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
ListBuffer<JCStatement> statements = generateSingularMethodStatements(maker, data, builderType, source);
List<JCVariableDecl> params = generateSingularMethodParameters(maker, data, builderType, source);
- JCModifiers mods = makeMods(maker, builderType, deprecate);
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()));
+ JCModifiers mods = makeMods(maker, builderType, deprecate);
finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, params);
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index b192564c..c493e08f 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -120,7 +120,6 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
@Override
protected void generatePluralMethod(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, source));
JCExpression thisDotFieldDotAddAll = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All");
@@ -140,6 +139,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
}
paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs(), source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
+ JCModifiers mods = makeMods(maker, builderType, deprecate);
finishAndInjectMethod(maker, returnType, builderType, source, mods, body, methodName, List.of(param));
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 2f9bd0b7..0d88e662 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -112,7 +112,6 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
@Override
protected void generatePluralMethod(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));
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), "addAll");
@@ -126,6 +125,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
JCExpression paramType = chainDots(builderType, "java", "util", "Collection");
paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs(), source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
+ JCModifiers mods = makeMods(maker, builderType, deprecate);
finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(param));
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 4bd771a4..f849203e 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -149,7 +149,6 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
@Override
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
List<JCExpression> jceBlank = List.nil();
- JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, true, source));
long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
@@ -174,6 +173,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
JCExpression paramType = chainDots(builderType, "java", "util", "Map");
paramType = addTypeArgs(2, true, builderType, paramType, data.getTypeArgs(), source);
JCVariableDecl param = maker.VarDef(maker.Modifiers(paramFlags), data.getPluralName(), paramType, null);
+ JCModifiers mods = makeMods(maker, builderType, deprecate);
finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(param));
}