aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 05:09:04 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:26:56 +0100
commitf4b77187afede3f30b4b82939b806b88772c3990 (patch)
tree6e119f912eff0baac8cc4e1c8d6c67263b9e5708 /src/core/lombok/javac
parentfe143bfd69f70749f4e745c5be6644c37840083f (diff)
downloadlombok-f4b77187afede3f30b4b82939b806b88772c3990.tar.gz
lombok-f4b77187afede3f30b4b82939b806b88772c3990.tar.bz2
lombok-f4b77187afede3f30b4b82939b806b88772c3990.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/singulars/JavacGuavaSingularizer.java2
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java3
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java2
3 files changed, 4 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
index 53b5e416..fe5a6765 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java
@@ -128,7 +128,6 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
Name methodName = data.getPluralName();
- long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
if (!fluent) methodName = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName() + "All", methodName.toString()));
JCExpression paramType;
String aaTypeName = getAddAllTypeName();
@@ -138,6 +137,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer {
paramType = chainDotsString(builderType, aaTypeName);
}
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);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, 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 51aaf3f7..95b29faf 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -117,13 +117,14 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), "addAll");
JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, List.<JCExpression>of(maker.Ident(data.getPluralName())));
statements.append(maker.Exec(invokeAdd));
+
if (returnStatement != null) statements.append(returnStatement);
JCBlock body = maker.Block(0, statements.toList());
Name name = data.getPluralName();
- long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("addAll", name.toString()));
JCExpression paramType = chainDots(builderType, "java", "util", "Collection");
paramType = addTypeArgs(1, 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);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, 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 cbf61225..610f041d 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -151,7 +151,6 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, true, source));
- long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext());
long baseFlags = JavacHandlerUtil.addFinalIfNeeded(0, builderType.getContext());
Name entryName = builderType.toName("$lombokEntry");
@@ -172,6 +171,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("putAll", name.toString()));
JCExpression paramType = chainDots(builderType, "java", "util", "Map");
paramType = addTypeArgs(2, 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);
finishAndInjectMethod(maker, returnType, builderType, source, deprecate, body, name, List.of(param));
}