aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorEmil Lundberg <emil@emlun.se>2019-01-10 05:26:24 +0100
committerEmil Lundberg <emil@emlun.se>2019-01-13 02:27:32 +0100
commitfe11913fa6ecbf3cec06263dcb0fef08a2eb8cce (patch)
treea543574822f0b3fcf2bca58aac5fee2604a677e3 /src/core/lombok/javac
parente0b6dae52106f399ac9020f590119a1ec11a3636 (diff)
downloadlombok-fe11913fa6ecbf3cec06263dcb0fef08a2eb8cce.tar.gz
lombok-fe11913fa6ecbf3cec06263dcb0fef08a2eb8cce.tar.bz2
lombok-fe11913fa6ecbf3cec06263dcb0fef08a2eb8cce.zip
Extract overloaded method createConstructBuilderVarIfNeeded
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java8
-rw-r--r--src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java8
2 files changed, 12 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
index 9b8e32d1..2ae4b32b 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilListSetSingularizer.java
@@ -99,7 +99,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
@Override
protected ListBuffer<JCStatement> generateSingularMethodStatements(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source));
+ statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
statements.append(generateSingularMethodAddStatement(maker, builderType, data.getSingularName(), data.getPluralName().toString()));
return statements;
}
@@ -113,7 +113,7 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
@Override
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, false, source));
+ statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
JCExpression thisDotFieldDotAdd = chainDots(builderType, "this", data.getPluralName().toString(), getAddMethodName() + "All");
JCExpression invokeAdd = maker.Apply(List.<JCExpression>nil(), thisDotFieldDotAdd, List.<JCExpression>of(maker.Ident(data.getPluralName())));
statements.append(maker.Exec(invokeAdd));
@@ -133,6 +133,10 @@ abstract class JavacJavaUtilListSetSingularizer extends JavacJavaUtilSingularize
return chainDots(builderType, "java", "util", "Collection");
}
+ private JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ return createConstructBuilderVarIfNeeded(maker, data, builderType, false, source);
+ }
+
@Override
protected String getAddMethodName() {
return "add";
diff --git a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
index 8270bae7..d92923c1 100644
--- a/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
+++ b/src/core/lombok/javac/handlers/singulars/JavacJavaUtilMapSingularizer.java
@@ -129,7 +129,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
Name keyName = builderType.toName(data.getSingularName().toString() + "Key");
Name valueName = builderType.toName(data.getSingularName().toString() + "Value");
- statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, true, source));
+ statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
/* Generates: this.pluralname$key.add(singularnameKey); */
statements.append(generateSingularMethodAddStatement(maker, builderType, keyName, data.getPluralName() + "$key"));
/* Generates: this.pluralname$value.add(singularnameValue); */
@@ -150,7 +150,7 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
protected void generatePluralMethod(boolean deprecate, JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source, boolean fluent) {
List<JCExpression> jceBlank = List.nil();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
- statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, true, source));
+ statements.append(createConstructBuilderVarIfNeeded(maker, data, builderType, source));
long baseFlags = JavacHandlerUtil.addFinalIfNeeded(0, builderType.getContext());
Name entryName = builderType.toName("$lombokEntry");
@@ -180,6 +180,10 @@ public class JavacJavaUtilMapSingularizer extends JavacJavaUtilSingularizer {
return chainDots(builderType, "java", "util", "Map");
}
+ private JCStatement createConstructBuilderVarIfNeeded(JavacTreeMaker maker, SingularData data, JavacNode builderType, JCTree source) {
+ return createConstructBuilderVarIfNeeded(maker, data, builderType, true, source);
+ }
+
@Override public void appendBuildCode(SingularData data, JavacNode builderType, JCTree source, ListBuffer<JCStatement> statements, Name targetVariableName, String builderVariable) {
if (useGuavaInstead(builderType)) {
guavaMapSingularizer.appendBuildCode(data, builderType, source, statements, targetVariableName, builderVariable);