[delombok] [prettyprinter] add support for the compact record constructor

This commit is contained in:
Reinier Zwitserloot
2021-03-23 04:58:20 +01:00
parent 5e2a90836d
commit 2eabd8485d
+23 -13
View File
@@ -812,22 +812,32 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.name);
}
boolean argsLessConstructor = false;
if (isConstructor && (tree.mods.flags & COMPACT_RECORD_CONSTRUCTOR) != 0) {
argsLessConstructor = true;
for (JCVariableDecl param : tree.params) {
if ((param.mods.flags & GENERATED_MEMBER) == 0) argsLessConstructor = false;
}
}
boolean first = true;
print("(");
JCVariableDecl recvparam = readObject(tree, "recvparam", null);
if (recvparam != null) {
printVarDefInline(recvparam);
first = false;
if (!argsLessConstructor) {
print("(");
JCVariableDecl recvparam = readObject(tree, "recvparam", null);
if (recvparam != null) {
printVarDefInline(recvparam);
first = false;
}
for (JCVariableDecl param : tree.params) {
if (!first) print(", ");
first = false;
printVarDefInline(param);
}
print(")");
}
for (JCVariableDecl param : tree.params) {
if (!first) print(", ");
first = false;
printVarDefInline(param);
}
print(")");
if (tree.thrown.nonEmpty()) {
print(" throws ");
print(tree.thrown, ", ");