aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-22 08:03:42 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-22 08:03:42 +0100
commitbcd05a01b14705678dfd280989fa5071b627a234 (patch)
tree55f5af9b2b158c37f9d04b7ec27aad048d4e1ffd /src/delombok
parentade900b82b8205bb439ac9d6d99dff0c3af6e10f (diff)
parentfa0b5249cf5fee28d9be13ecdf0225f651f686aa (diff)
downloadlombok-bcd05a01b14705678dfd280989fa5071b627a234.tar.gz
lombok-bcd05a01b14705678dfd280989fa5071b627a234.tar.bz2
lombok-bcd05a01b14705678dfd280989fa5071b627a234.zip
Merge branch 'records'
# Conflicts: # src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java # src/core/lombok/eclipse/handlers/HandleBuilder.java # src/core/lombok/eclipse/handlers/HandleData.java # src/core/lombok/eclipse/handlers/HandleNonNull.java # src/core/lombok/eclipse/handlers/HandleSuperBuilder.java # src/core/lombok/javac/handlers/HandleBuilder.java # src/core/lombok/javac/handlers/HandleNonNull.java # src/core/lombok/javac/handlers/HandleSuperBuilder.java # test/core/src/lombok/RunTestsViaEcj.java
Diffstat (limited to 'src/delombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index 7531b0b1..05904815 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 The Project Lombok Authors.
+ * Copyright (C) 2016-2021 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -514,10 +514,12 @@ public class PrettyPrinter extends JCTree.Visitor {
boolean isInterface = (tree.mods.flags & INTERFACE) != 0;
boolean isAnnotationInterface = isInterface && (tree.mods.flags & ANNOTATION) != 0;
boolean isEnum = (tree.mods.flags & ENUM) != 0;
+ boolean isRecord = (tree.mods.flags & RECORD) != 0;
if (isAnnotationInterface) print("@interface ");
else if (isInterface) print("interface ");
else if (isEnum) print("enum ");
+ else if (isRecord) print("record ");
else print("class ");
print(tree.name);
@@ -540,6 +542,8 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.implementing, ", ");
}
+ if (isRecord) printRecordConstructor(tree.defs);
+
println(" {");
indent++;
printClassMembers(tree.defs, isEnum, isInterface);
@@ -549,6 +553,23 @@ public class PrettyPrinter extends JCTree.Visitor {
currentTypeName = prevTypeName;
}
+ private void printRecordConstructor(List<JCTree> members) {
+ boolean first = true;
+ print("(");
+ for (JCTree member : members) {
+ if (member instanceof JCVariableDecl) {
+ JCVariableDecl variableDecl = (JCVariableDecl) member;
+ if ((variableDecl.mods.flags & GENERATED_MEMBER) != 0) {
+ if (!first) print(", ");
+ first = false;
+ printAnnotations(variableDecl.mods.annotations, false);
+ printVarDef0(variableDecl);
+ }
+ }
+ }
+ print(")");
+ }
+
private void printClassMembers(List<JCTree> members, boolean isEnum, boolean isInterface) {
Class<?> prefType = null;
int typeOfPrevEnumMember = isEnum ? 3 : 0; // 1 = normal, 2 = with body, 3 = no enum field yet.
@@ -578,6 +599,7 @@ public class PrettyPrinter extends JCTree.Visitor {
JCTree init = ((JCVariableDecl) member).init;
typeOfPrevEnumMember = init instanceof JCNewClass && ((JCNewClass) init).def != null ? 2 : 1;
} else if (member instanceof JCVariableDecl) {
+ if ((((JCVariableDecl) member).mods.flags & GENERATED_MEMBER) != 0) continue;
if (prefType != null && prefType != JCVariableDecl.class) println();
if (isInterface) flagMod = -1L & ~(PUBLIC | STATIC | FINAL);
print(member);