From a367f7815dcf7a818e3494929e3d005e06c2efb1 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 03:29:55 +0100 Subject: Move local variable declarations to just before use --- src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java | 2 +- .../javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java | 3 ++- .../lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core/lombok/javac') 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 params = new ListBuffer(); 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)); -- cgit