aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-09-10 10:20:12 +0200
committerRawi01 <Rawi01@users.noreply.github.com>2020-09-10 10:32:14 +0200
commit0064c534273d9fb877f7e570f7a430060c88a5fb (patch)
treeee7089c1fbe948127aaea4c3317dd7dc18b0ee39 /src/delombok
parent9148294f78a8e646ee131ca182a9b692bc028fdb (diff)
downloadlombok-0064c534273d9fb877f7e570f7a430060c88a5fb.tar.gz
lombok-0064c534273d9fb877f7e570f7a430060c88a5fb.tar.bz2
lombok-0064c534273d9fb877f7e570f7a430060c88a5fb.zip
Add record support
Diffstat (limited to 'src/delombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyPrinter.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/delombok/lombok/delombok/PrettyPrinter.java b/src/delombok/lombok/delombok/PrettyPrinter.java
index 54fa4ebf..6682b5a3 100644
--- a/src/delombok/lombok/delombok/PrettyPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyPrinter.java
@@ -97,6 +97,7 @@ import lombok.javac.PackageName;
import lombok.permit.Permit;
import lombok.javac.CommentInfo.EndConnection;
import lombok.javac.CommentInfo.StartConnection;
+import lombok.javac.Java14Flags;
import lombok.javac.JavacTreeMaker.TreeTag;
import lombok.javac.JavacTreeMaker.TypeTag;
@@ -516,10 +517,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 & Java14Flags.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);
@@ -542,6 +545,10 @@ public class PrettyPrinter extends JCTree.Visitor {
print(tree.implementing, ", ");
}
+ if (isRecord) {
+ printRecordConstructor(tree.defs);
+ }
+
println(" {");
indent++;
printClassMembers(tree.defs, isEnum, isInterface);
@@ -551,6 +558,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 & Java14Flags.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.
@@ -580,6 +604,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 & Java14Flags.GENERATED_MEMBER) != 0) continue;
if (prefType != null && prefType != JCVariableDecl.class) println();
if (isInterface) flagMod = -1L & ~(PUBLIC | STATIC | FINAL);
print(member);