aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-23 04:58:20 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-23 04:58:20 +0100
commit2eabd8485df6fb01e05cf7bcf797d922b9d4e012 (patch)
tree1909fac66b986072d15f37f037327fbbd66b1f59 /src
parent5e2a90836d0c332b75af15b8f42403cf799ec355 (diff)
downloadlombok-2eabd8485df6fb01e05cf7bcf797d922b9d4e012.tar.gz
lombok-2eabd8485df6fb01e05cf7bcf797d922b9d4e012.tar.bz2
lombok-2eabd8485df6fb01e05cf7bcf797d922b9d4e012.zip
[delombok] [prettyprinter] add support for the compact record constructor
Diffstat (limited to 'src')
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index 05904815..8ce38c33 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -812,21 +812,31 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.name);
}
- boolean first = true;
- print("(");
-
- JCVariableDecl recvparam = readObject(tree, "recvparam", null);
- if (recvparam != null) {
- printVarDefInline(recvparam);
- first = false;
+ 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;
+ }
}
- for (JCVariableDecl param : tree.params) {
- if (!first) print(", ");
- first = false;
- printVarDefInline(param);
+ boolean first = true;
+ 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(")");
}
- print(")");
if (tree.thrown.nonEmpty()) {
print(" throws ");