aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 02:34:20 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:13:55 +0100
commitbb7b5cce75988b0d774152a6f4d7b56ac1ab3953 (patch)
tree2fe63c12ce22f5f38444be0a6a65fabb51047db4 /src
parent3c9324e801b6192717c1e9b78e4d762c9e4ef57f (diff)
downloadlombok-bb7b5cce75988b0d774152a6f4d7b56ac1ab3953.tar.gz
lombok-bb7b5cce75988b0d774152a6f4d7b56ac1ab3953.tar.bz2
lombok-bb7b5cce75988b0d774152a6f4d7b56ac1ab3953.zip
Move one-use variable declarations to just before use
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/javac/handlers/JavacSingularsRecipes.java4
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java9
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java8
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java6
4 files changed, 13 insertions, 14 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
index 602e926c..6391c66c 100644
--- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
+++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java
@@ -250,8 +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<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
List<JCVariableDecl> params = List.nil();
JCStatement clearStatement = generateClearStatements(maker, data, builderType);
@@ -259,6 +257,8 @@ public class JavacSingularsRecipes {
JCBlock body = maker.Block(0, statements);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, methodName, params);
}
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index de5585b3..9141482f 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -83,9 +83,6 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
@Override
protected void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
-
LombokImmutableList<String> suffixes = getArgumentSuffixes();
Name[] names = new Name[suffixes.size()];
for (int i = 0; i < suffixes.size(); i++) {
@@ -120,13 +117,13 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
params.append(p);
}
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, methodName, params.toList());
}
@Override
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
@@ -147,6 +144,8 @@ 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);
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, 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 e90198c0..ba73d392 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -100,8 +100,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) {
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source));
@@ -118,13 +116,13 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
paramType = removeTypeUseAnnotations(paramType);
JCModifiers paramMods = typeUseAnns.isEmpty() ? maker.Modifiers(paramFlags) : maker.Modifiers(paramFlags, typeUseAnns);
JCVariableDecl param = maker.VarDef(paramMods, data.getSingularName(), paramType, null);
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, name, List.of(param));
}
@Override
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source));
@@ -139,6 +137,8 @@ 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);
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, 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 9a6a8f89..fe0db83e 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -127,8 +127,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) {
- List<JCTypeParameter> typeParams = List.nil();
- List<JCExpression> thrown = List.nil();
JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
@@ -161,12 +159,13 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
JCModifiers paramModsValue = typeUseAnnsValue.isEmpty() ? maker.Modifiers(paramFlags) : maker.Modifiers(paramFlags, typeUseAnnsValue);
JCVariableDecl paramKey = maker.VarDef(paramModsKey, keyName, paramTypeKey, null);
JCVariableDecl paramValue = maker.VarDef(paramModsValue, valueName, paramTypeValue, null);
+ List<JCTypeParameter> typeParams = List.nil();
+ List<JCExpression> thrown = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, name, List.of(paramKey, paramValue));
}
@Override
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
- List<JCTypeParameter> typeParams = List.nil();
List<JCExpression> jceBlank = List.nil();
JCModifiers mods = makeMods(maker, builderType, deprecate);
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
@@ -193,6 +192,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);
+ List<JCTypeParameter> typeParams = List.nil();
finishAndInjectMethod(maker, returnType, builderType, source, typeParams, jceBlank, mods, body, name, List.of(param));
}