From 360c1d5a21273793ef5c96c21b979501bdebb5c3 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 02:35:30 +0100 Subject: Move invariant parameters inside finishAndInjectMethod --- src/core/lombok/javac/handlers/JavacSingularsRecipes.java | 8 ++++---- .../lombok/javac/handlers/singulars/JavacGuavaSingularizer.java | 8 ++------ .../handlers/singulars/JavacJavaUtilListSetSingularizer.java | 8 ++------ .../javac/handlers/singulars/JavacJavaUtilMapSingularizer.java | 7 ++----- 4 files changed, 10 insertions(+), 21 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 6391c66c..9921ba89 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -241,7 +241,9 @@ public class JavacSingularsRecipes { generateClearMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source); } - protected void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, List typeParams, List thrown, JCModifiers mods, JCBlock body, Name methodName, List jcVariableDecls) { + protected void finishAndInjectMethod(JavacTreeMaker maker, JCExpression returnType, JavacNode builderType, JCTree source, JCModifiers mods, JCBlock body, Name methodName, List jcVariableDecls) { + List typeParams = List.nil(); + List thrown = List.nil(); JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, jcVariableDecls, thrown, body, null); recursiveSetGeneratedBy(method, source, builderType.getContext()); injectMethod(builderType, method); @@ -257,9 +259,7 @@ public class JavacSingularsRecipes { JCBlock body = maker.Block(0, statements); Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString())); - List typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, methodName, params); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, methodName, params); } protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType); diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java index 9141482f..b514ebd5 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java @@ -117,9 +117,7 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { params.append(p); } - List typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, methodName, params.toList()); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, methodName, params.toList()); } @Override @@ -144,9 +142,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); - List typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, methodName, List.of(param)); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, methodName, List.of(param)); } @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer statements, Name targetVariableName, String builderVariable) { diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java index ba73d392..1b661bb2 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java @@ -116,9 +116,7 @@ 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 typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, name, List.of(param)); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(param)); } @Override @@ -137,8 +135,6 @@ 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 typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, name, List.of(param)); + 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 fe0db83e..c7483be6 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java @@ -159,9 +159,7 @@ 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 typeParams = List.nil(); - List thrown = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, thrown, mods, body, name, List.of(paramKey, paramValue)); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(paramKey, paramValue)); } @Override @@ -192,8 +190,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 typeParams = List.nil(); - finishAndInjectMethod(maker, returnType, builderType, source, typeParams, jceBlank, mods, body, name, List.of(param)); + finishAndInjectMethod(maker, returnType, builderType, source, mods, body, name, List.of(param)); } @Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer statements, Name targetVariableName, String builderVariable) { -- cgit