diff options
author | Emil Lundberg <emil@emlun.se> | 2019-01-10 02:04:15 +0100 |
---|---|---|
committer | Emil Lundberg <emil@emlun.se> | 2019-01-13 02:13:54 +0100 |
commit | 62bb81311e58f6ec1108e94bc4f61bbf93eb411a (patch) | |
tree | 0f27660892fddc8bbed1586f953c18f5694b961d /src/core | |
parent | d08aa5a83d2302eaaf84c4323073dfe3edd43703 (diff) | |
download | lombok-62bb81311e58f6ec1108e94bc4f61bbf93eb411a.tar.gz lombok-62bb81311e58f6ec1108e94bc4f61bbf93eb411a.tar.bz2 lombok-62bb81311e58f6ec1108e94bc4f61bbf93eb411a.zip |
Pull return statement wrapping up into generateClearMethod
Diffstat (limited to 'src/core')
4 files changed, 9 insertions, 12 deletions
diff --git a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java index 765d7e43..eed21af4 100644 --- a/src/core/lombok/javac/handlers/JavacSingularsRecipes.java +++ b/src/core/lombok/javac/handlers/JavacSingularsRecipes.java @@ -248,7 +248,8 @@ public class JavacSingularsRecipes { List<JCExpression> thrown = List.nil(); List<JCVariableDecl> params = List.nil(); - List<JCStatement> statements = generateClearStatements(maker, returnStatement, data, builderType); + JCStatement clearStatement = generateClearStatements(maker, data, builderType); + List<JCStatement> statements = returnStatement != null ? List.of(clearStatement, returnStatement) : List.of(clearStatement); JCBlock body = maker.Block(0, statements); Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString())); @@ -257,7 +258,7 @@ public class JavacSingularsRecipes { injectMethod(builderType, method); } - protected abstract List<JCStatement> generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType); + protected abstract JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType); protected abstract void generateSingularMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent); diff --git a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java index d6796d51..6c60798d 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacGuavaSingularizer.java @@ -77,11 +77,9 @@ abstract class JavacGuavaSingularizer extends JavacSingularizer { } @Override - protected List<JCStatement> generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { + protected JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType) { JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName()); - - JCStatement clearField = maker.Exec(maker.Assign(thisDotField, maker.Literal(CTC_BOT, null))); - return returnStatement != null ? List.of(clearField, returnStatement) : List.of(clearField); + return maker.Exec(maker.Assign(thisDotField, maker.Literal(CTC_BOT, null))); } @Override diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java index 9ecdbbaf..d07355c9 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java @@ -88,7 +88,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize } @Override - protected List<JCStatement> generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { + protected JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType) { List<JCExpression> jceBlank = List.nil(); JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName()); JCExpression thisDotFieldDotClear = maker.Select(maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName()), builderType.toName("clear")); @@ -96,8 +96,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize JCStatement clearCall = maker.Exec(maker.Apply(jceBlank, thisDotFieldDotClear, jceBlank)); JCExpression cond = maker.Binary(CTC_NOT_EQUAL, thisDotField, maker.Literal(CTC_BOT, null)); - JCStatement ifSetCallClear = maker.If(cond, clearCall, null); - return returnStatement != null ? List.of(ifSetCallClear, returnStatement) : List.of(ifSetCallClear); + return maker.If(cond, clearCall, null); } @Override diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java index ecd01aa3..fce0ccb9 100644 --- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java +++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java @@ -113,7 +113,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { } @Override - protected List<JCStatement> generateClearStatements(JavacTreeMaker maker, JCStatement returnStatement, SingularData data, JavacNode builderType) { + protected JCStatement generateClearStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType) { List<JCExpression> jceBlank = List.nil(); JCExpression thisDotKeyField = chainDots(builderType, "this", data.getPluralName() + "$key"); @@ -123,8 +123,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer { JCStatement clearValueCall = maker.Exec(maker.Apply(jceBlank, thisDotValueFieldDotClear, jceBlank)); JCExpression cond = maker.Binary(CTC_NOT_EQUAL, thisDotKeyField, maker.Literal(CTC_BOT, null)); JCBlock clearCalls = maker.Block(0, List.of(clearKeyCall, clearValueCall)); - JCStatement ifSetCallClear = maker.If(cond, clearCalls, null); - return returnStatement != null ? List.of(ifSetCallClear, returnStatement) : List.of(ifSetCallClear); + return maker.If(cond, clearCalls, null); } @Override |