Revert "Remove a wrong test for copyAnnotations returning empty array."

While Maaartinus' thoughts are obviously correct (far better to use an empty array to convey 'this list-like construct has 0 items in it right now', vs. a null pointer),
eclipse actually uses null-as-empty almost everywhere, and a lot of eclipse code will simply break if you don't do it right.

This reverts commit 842a475916.
This commit is contained in:
Reinier Zwitserloot committed 2014-06-01 09:50:18 +02:00
1 parent 6159508d40
commit fe25bb1533
4 files changed
+21 -12

No files matched your search

@@ -333,9 +333,8 @@ public class HandleConstructor {
Statement nullCheck = generateNullCheck(field, sourceNode);
if (nullCheck != null) nullChecks.add(nullCheck);
}
parameter.annotations = copyAnnotations(source, nonNulls, nullables);
Annotation[] copiedAnnotations = copyAnnotations(source, nonNulls, nullables);
if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
params.add(parameter);
}
@@ -349,9 +348,10 @@ public class HandleConstructor {
constructorProperties = createConstructorProperties(source, fields);
}
constructor.annotations = copyAnnotations(source,
Annotation[] copiedAnnotations = copyAnnotations(source,
onConstructor.toArray(new Annotation[0]),
constructorProperties);
if (copiedAnnotations.length != 0) constructor.annotations = copiedAnnotations;
}
constructor.traverse(new SetGeneratedByVisitor(source), typeDeclaration.scope);
@@ -397,7 +397,8 @@ public class HandleConstructor {
Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);
parameter.annotations = copyAnnotations(source, findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN));
Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN));
if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
params.add(parameter);
}
@@ -270,12 +270,14 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> {
deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
}
method.annotations = copyAnnotations(source,
Annotation[] copiedAnnotations = copyAnnotations(source,
onMethod.toArray(new Annotation[0]),
findAnnotations(field, NON_NULL_PATTERN),
findAnnotations(field, NULLABLE_PATTERN),
findDelegatesAndMarkAsHandled(fieldNode),
deprecated);
if (copiedAnnotations.length != 0) method.annotations = copiedAnnotations;
}
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
@@ -216,8 +216,10 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
if (isFieldDeprecated(fieldNode)) {
deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
}
method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
Annotation[] copiedAnnotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
if (copiedAnnotations.length != 0) {
method.annotations = copiedAnnotations;
}
Argument param = new Argument(field.name, p, copyType(field.type, source), Modifier.FINAL);
param.sourceStart = pS; param.sourceEnd = pE;
method.arguments = new Argument[] { param };
@@ -251,7 +253,8 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
}
method.statements = statements.toArray(new Statement[0]);
param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
Annotation[] copiedAnnotationsParam = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
if (copiedAnnotationsParam.length != 0) param.annotations = copiedAnnotationsParam;
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;
@@ -227,8 +227,10 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
if (isFieldDeprecated(fieldNode)) {
deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
}
method.annotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
Annotation[] copiedAnnotations = copyAnnotations(source, onMethod.toArray(new Annotation[0]), deprecated);
if (copiedAnnotations.length != 0) {
method.annotations = copiedAnnotations;
}
Argument param = new Argument(field.name, p, copyType(field.type, source), Modifier.FINAL);
param.sourceStart = pS; param.sourceEnd = pE;
method.arguments = new Argument[] { param };
@@ -281,7 +283,8 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
method.statements = statements.toArray(new Statement[0]);
param.annotations = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
Annotation[] copiedAnnotationsParam = copyAnnotations(source, nonNulls, nullables, onParam.toArray(new Annotation[0]));
if (copiedAnnotationsParam.length != 0) param.annotations = copiedAnnotationsParam;
method.traverse(new SetGeneratedByVisitor(source), parent.scope);
return method;