From d08aa5a83d2302eaaf84c4323073dfe3edd43703 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Thu, 10 Jan 2019 01:51:47 +0100 Subject: Pull generateClearMethod up to JavacSingularizer --- src/core/lombok/javac/handlers/JavacSingularsRecipes.java | 10 ++++++++-- .../javac/handlers/singulars/JavacGuavaSingularizer.java | 12 ------------ .../singulars/JavacJavaUtilListSetSingularizer.java | 12 ------------ .../handlers/singulars/JavacJavaUtilMapSingularizer.java | 13 ------------- 4 files changed, 8 insertions(+), 39 deletions(-) (limited to 'src/core/lombok/javac/handlers') diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 1d4d5a8d..765d7e43 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -241,9 +241,15 @@ public class JavacSingularsRecipes { generateClearMethod(deprecate, maker, returnTypeMaker.make(), returnStatementMaker.make(), data, builderType, source); } - protected abstract void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source); + protected void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) { + JCModifiers mods = makeMods(maker, builderType, deprecate); + + List typeParams = List.nil(); + List thrown = List.nil(); + List params = List.nil(); + + List statements = generateClearStatements(maker, returnStatement, data, builderType); - protected void finishGenerateClearMethod(JavacTreeMaker maker, JCExpression returnType, SingularData data, JavacNode builderType, JCTree source, JCModifiers mods, List typeParams, List thrown, List params, List statements) { JCBlock body = maker.Block(0, statements); Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString())); JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, params, thrown, body, null); diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java index 13a48869..d6796d51 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java @@ -76,18 +76,6 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker); } - @Override - protected void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) { - JCModifiers mods = makeMods(maker, builderType, deprecate); - List typeParams = List.nil(); - List thrown = List.nil(); - List params = List.nil(); - - List statements = generateClearStatements(maker, returnStatement, data, builderType); - - finishGenerateClearMethod(maker, returnType, data, builderType, source, mods, typeParams, thrown, params, statements); - } - @Override protected List generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName()); diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java index f332aad1..9ecdbbaf 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java @@ -87,18 +87,6 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker); } - @Override - protected void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) { - JCModifiers mods = makeMods(maker, builderType, deprecate); - List typeParams = List.nil(); - List thrown = List.nil(); - List params = List.nil(); - - List statements = generateClearStatements(maker, returnStatement, data, builderType); - - finishGenerateClearMethod(maker, returnType, data, builderType, source, mods, typeParams, thrown, params, statements); - } - @Override protected List generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { List jceBlank = List.nil(); diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java index dab09eb3..ecd01aa3 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java @@ -112,19 +112,6 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { doGenerateMethods(data, deprecate, builderType, source, fluent, returnTypeMaker, returnStatementMaker); } - @Override - protected void generateClearMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) { - JCModifiers mods = makeMods(maker, builderType, deprecate); - - List typeParams = List.nil(); - List thrown = List.nil(); - List params = List.nil(); - - List statements = generateClearStatements(maker, returnStatement, data, builderType); - - finishGenerateClearMethod(maker, returnType, data, builderType, source, mods, typeParams, thrown, params, statements); - } - @Override protected List generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { List jceBlank = List.nil(); -- cgit