aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
Diffstat (limited to 'src/delombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyCommentsPrinter.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
index f57b74a2..ca44670d 100644
--- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
@@ -1518,6 +1518,11 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
public void visitTypeParameter(JCTypeParameter tree) {
try {
+ List<JCExpression> annotations = readExpressionListOrNil(tree, "annotations");
+ if (!annotations.isEmpty()) {
+ printExprs(annotations);
+ print(" ");
+ }
print(tree.name);
if (tree.bounds.nonEmpty()) {
print(" extends ");
@@ -1614,6 +1619,8 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
} else if ("JCMemberReference".equals(simpleName)) {
visitReference0(tree);
return;
+ } else if ("JCAnnotatedType".equals(simpleName)) {
+ visitAnnotatedType0(tree);
} else {
print("(UNKNOWN[" + tree.getClass().getSimpleName() + "]: " + tree + ")");
println();
@@ -1662,13 +1669,31 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
printExprs(typeArgs);
print(">");
}
- ;
print(readObject(tree, "mode").toString().equals("INVOKE") ? readObject(tree, "name") : "new");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
+ public void visitAnnotatedType0(JCTree tree) {
+ try {
+ JCTree underlyingType = readTree(tree, "underlyingType");
+ if (underlyingType instanceof JCFieldAccess) {
+ printExpr(((JCFieldAccess) underlyingType).selected);
+ print(".");
+ printExprs(readExpressionList(tree, "annotations"));
+ print(" ");
+ print(((JCFieldAccess) underlyingType).name);
+ } else {
+ printExprs(readExpressionList(tree, "annotations"));
+ print(" ");
+ printExpr(underlyingType);
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
private JCTree readTree(JCTree tree, String fieldName) {
try {
return (JCTree) readObject0(tree, fieldName);
@@ -1695,6 +1720,15 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
}
}
+ @SuppressWarnings("unchecked")
+ private List<JCExpression> readExpressionListOrNil(JCTree tree, String fieldName) throws IOException {
+ try {
+ return (List<JCExpression>) readObject0(tree, fieldName, List.nil());
+ } catch (Exception e) {
+ return List.nil();
+ }
+ }
+
private Object readObject(JCTree tree, String fieldName) {
try {
return readObject0(tree, fieldName);
@@ -1712,4 +1746,13 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
throw e;
}
}
+
+ @SuppressWarnings("unchecked")
+ private Object readObject0(JCTree tree, String fieldName, Object defaultValue) throws Exception {
+ try {
+ return tree.getClass().getDeclaredField(fieldName).get(tree);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
}