diff options
author | Emil Lundberg <emil@emlun.se> | 2019-01-10 03:29:55 +0100 |
---|---|---|
committer | Emil Lundberg <emil@emlun.se> | 2019-01-13 02:20:02 +0100 |
commit | a367f7815dcf7a818e3494929e3d005e06c2efb1 (patch) | |
tree | 141644618ead14f27815af781476c44afe374855 /src/core/lombok/javac | |
parent | b09f4ca38dd1a7f819b9294382db0c7a43ebe809 (diff) | |
download | lombok-a367f7815dcf7a818e3494929e3d005e06c2efb1.tar.gz lombok-a367f7815dcf7a818e3494929e3d005e06c2efb1.tar.bz2 lombok-a367f7815dcf7a818e3494929e3d005e06c2efb1.zip |
Move local variable declarations to just before use
Diffstat (limited to 'src/core/lombok/javac')
3 files changed, 5 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java index 50426a87..73b1a456 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java @@ -104,10 +104,10 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { if (returnStatement != null) statements.append(returnStatement); JCBlock body = maker.Block(0, statements.toList()); Name methodName = data.getSingularName(); - long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); if (!fluent) methodName = builderType.toName(HandlerUtil.buildAccessorName(getAddMethodName(), methodName.toString())); ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>(); for (int i = 0; i < suffixes.size(); i++) { + long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); params.append(generateSingularMethodParameter(i, maker, data, builderType, source, names[i], paramFlags)); } diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java index 665e22ea..d6c0a02d 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java @@ -107,9 +107,10 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize if (returnStatement != null) statements.append(returnStatement); JCBlock body = maker.Block(0, statements.toList()); Name name = data.getSingularName(); - long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("add", name.toString())); Name paramName = data.getSingularName(); + + long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); JCVariableDecl param = generateSingularMethodParameter(0, maker, data, builderType, source, paramName, paramFlags); 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 8b5f08eb..a936f117 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java @@ -144,11 +144,11 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { } if (returnStatement != null) statements.append(returnStatement); JCBlock body = maker.Block(0, statements.toList()); - long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); - + Name name = data.getSingularName(); if (!fluent) name = builderType.toName(HandlerUtil.buildAccessorName("put", name.toString())); + long paramFlags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, builderType.getContext()); JCVariableDecl paramKey = generateSingularMethodParameter(0, maker, data, builderType, source, keyName, paramFlags); JCVariableDecl paramValue = generateSingularMethodParameter(1, maker, data, builderType, source, valueName, paramFlags); finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(paramKey, paramValue)); |