8320200: Use Elements predicates for record constructors to improve print output

Reviewed-by: vromero
This commit is contained in:
Joe Darcy 2023-12-12 21:00:50 +00:00
parent 4fb5c12813
commit ac07355f55

View File

@ -155,14 +155,25 @@ public class PrintingProcessor extends AbstractProcessor {
break;
}
writer.print("(");
printParameters(e);
writer.print(")");
AnnotationValue defaultValue = e.getDefaultValue();
if (defaultValue != null)
writer.print(" default " + defaultValue);
if (elementUtils.isCompactConstructor(e)) {
// A record's compact constructor by definition
// lacks source-explicit parameters and lacks a
// throws clause.
writer.print(" {} /* compact constructor */ ");
} else {
writer.print("(");
printParameters(e);
writer.print(")");
// Display any default values for an annotation
// interface element
AnnotationValue defaultValue = e.getDefaultValue();
if (defaultValue != null)
writer.print(" default " + defaultValue);
printThrows(e);
}
printThrows(e);
writer.println(";");
}
return this;