diff options
author | Jan Rieke <rieke@subshell.com> | 2018-09-24 16:46:00 +0200 |
---|---|---|
committer | Jan Rieke <rieke@subshell.com> | 2018-09-24 16:46:00 +0200 |
commit | b5648976b6501bdf755814d8d8a096c33f6997ec (patch) | |
tree | aafe939cdc6fdda41719deb42f03c77934cb5209 /src/core/lombok/eclipse/handlers/singulars | |
parent | fd4c9d4bff6e75b30a3ee247edafaabc6888a691 (diff) | |
parent | aee4e76d864e01b5d453409e703ad54852fa57bb (diff) | |
download | lombok-b5648976b6501bdf755814d8d8a096c33f6997ec.tar.gz lombok-b5648976b6501bdf755814d8d8a096c33f6997ec.tar.bz2 lombok-b5648976b6501bdf755814d8d8a096c33f6997ec.zip |
Merge remote-tracking branch 'upstream/master' into superToBuilder
Diffstat (limited to 'src/core/lombok/eclipse/handlers/singulars')
3 files changed, 27 insertions, 10 deletions
diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java index f1687c9c..17fc5e09 100644 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseGuavaSingularizer.java @@ -32,6 +32,7 @@ import lombok.core.GuavaTypeMap; import lombok.core.LombokImmutableList; import lombok.core.handlers.HandlerUtil; import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.HandleNonNull; import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer; import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData; import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker; @@ -150,14 +151,17 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer { md.arguments = new Argument[suffixes.size()]; for (int i = 0; i < suffixes.size(); i++) { TypeReference tr = cloneParamType(i, data.getTypeArgs(), builderType); - md.arguments[i] = new Argument(names[i], 0, tr, 0); + Annotation[] typeUseAnns = getTypeUseAnnotations(tr); + removeTypeUseAnnotations(tr); + md.arguments[i] = new Argument(names[i], 0, tr, ClassFileConstants.AccFinal); + md.arguments[i].annotations = typeUseAnns; } md.returnType = returnType; md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName(getAddMethodName(), new String(data.getSingularName())).toCharArray(); md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null; data.setGeneratedByRecursive(md); - injectMethod(builderType, md); + HandleNonNull.INSTANCE.fix(injectMethod(builderType, md)); } void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { @@ -182,7 +186,7 @@ abstract class EclipseGuavaSingularizer extends EclipseSingularizer { TypeReference paramType; paramType = new QualifiedTypeReference(fromQualifiedName(getAddAllTypeName()), NULL_POSS); paramType = addTypeArgs(getTypeArgumentsCount(), true, builderType, paramType, data.getTypeArgs()); - Argument param = new Argument(data.getPluralName(), 0, paramType, 0); + Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName(getAddMethodName() + "All", new String(data.getPluralName())).toCharArray(); diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java index 5f86a4dc..c7315790 100644 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilListSetSingularizer.java @@ -30,6 +30,7 @@ import java.util.List; import lombok.core.handlers.HandlerUtil; import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.HandleNonNull; import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData; import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker; import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker; @@ -138,14 +139,18 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula md.statements = statements.toArray(new Statement[statements.size()]); TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType); - Argument param = new Argument(data.getSingularName(), 0, paramType, 0); + Annotation[] typeUseAnns = getTypeUseAnnotations(paramType); + removeTypeUseAnnotations(paramType); + Argument param = new Argument(data.getSingularName(), 0, paramType, ClassFileConstants.AccFinal); + param.annotations = typeUseAnns; md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray(); md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null; data.setGeneratedByRecursive(md); - injectMethod(builderType, md); + + HandleNonNull.INSTANCE.fix(injectMethod(builderType, md)); } void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { @@ -169,7 +174,7 @@ abstract class EclipseJavaUtilListSetSingularizer extends EclipseJavaUtilSingula TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS); paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs()); - Argument param = new Argument(data.getPluralName(), 0, paramType, 0); + Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray(); diff --git a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java index 69c2186a..174cd5fc 100644 --- a/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java +++ b/src/core/lombok/eclipse/handlers/singulars/EclipseJavaUtilMapSingularizer.java @@ -59,6 +59,7 @@ import lombok.eclipse.handlers.EclipseSingularsRecipes.EclipseSingularizer; import lombok.eclipse.handlers.EclipseSingularsRecipes.SingularData; import lombok.eclipse.handlers.EclipseSingularsRecipes.StatementMaker; import lombok.eclipse.handlers.EclipseSingularsRecipes.TypeReferenceMaker; +import lombok.eclipse.handlers.HandleNonNull; @ProviderFor(EclipseSingularizer.class) public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer { @@ -214,16 +215,23 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer md.statements = statements.toArray(new Statement[statements.size()]); TypeReference keyParamType = cloneParamType(0, data.getTypeArgs(), builderType); - Argument keyParam = new Argument(keyParamName, 0, keyParamType, 0); TypeReference valueParamType = cloneParamType(1, data.getTypeArgs(), builderType); - Argument valueParam = new Argument(valueParamName, 0, valueParamType, 0); + Annotation[] typeUseAnnsKey = getTypeUseAnnotations(keyParamType); + Annotation[] typeUseAnnsValue = getTypeUseAnnotations(valueParamType); + + removeTypeUseAnnotations(keyParamType); + removeTypeUseAnnotations(valueParamType); + Argument keyParam = new Argument(keyParamName, 0, keyParamType, ClassFileConstants.AccFinal); + Argument valueParam = new Argument(valueParamName, 0, valueParamType, ClassFileConstants.AccFinal); + keyParam.annotations = typeUseAnnsKey; + valueParam.annotations = typeUseAnnsValue; md.arguments = new Argument[] {keyParam, valueParam}; md.returnType = returnType; md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("put", new String(data.getSingularName())).toCharArray(); md.annotations = deprecate ? new Annotation[] { generateDeprecatedAnnotation(data.getSource()) } : null; data.setGeneratedByRecursive(md); - injectMethod(builderType, md); + HandleNonNull.INSTANCE.fix(injectMethod(builderType, md)); } private void generatePluralMethod(boolean deprecate, TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { @@ -280,7 +288,7 @@ public class EclipseJavaUtilMapSingularizer extends EclipseJavaUtilSingularizer TypeReference paramType = new QualifiedTypeReference(JAVA_UTIL_MAP, NULL_POSS); paramType = addTypeArgs(2, true, builderType, paramType, data.getTypeArgs()); - Argument param = new Argument(data.getPluralName(), 0, paramType, 0); + Argument param = new Argument(data.getPluralName(), 0, paramType, ClassFileConstants.AccFinal); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("putAll", new String(data.getPluralName())).toCharArray(); |