Skip to content

Commit

Permalink
8320200: Use Elements predicates for record constructors to improve p…
Browse files Browse the repository at this point in the history
…rint output

Reviewed-by: vromero
  • Loading branch information
jddarcy committed Dec 12, 2023
1 parent 4fb5c12 commit ac07355
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,25 @@ public NestingKind visitType(TypeElement e, Void p) {
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;
Expand Down

0 comments on commit ac07355

Please sign in to comment.