diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-05-01 21:42:38 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-05-01 21:42:38 +0200 |
commit | c7bfba873eb62a73668875cb1e9d94fb322bec1c (patch) | |
tree | 73de1bf40ab4769ec17a5caed2d5949424567266 /src/delombok | |
parent | 81ba6ee5f5668f4634253f7446de9c93190455b0 (diff) | |
download | lombok-c7bfba873eb62a73668875cb1e9d94fb322bec1c.tar.gz lombok-c7bfba873eb62a73668875cb1e9d94fb322bec1c.tar.bz2 lombok-c7bfba873eb62a73668875cb1e9d94fb322bec1c.zip |
[java8] Support in delombok for method references.
Diffstat (limited to 'src/delombok')
-rw-r--r-- | src/delombok/lombok/delombok/PrettyCommentsPrinter.java | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 36413332..79f22e58 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -1575,6 +1575,9 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } else if ("JCLambda".equals(simpleName)) { visitLambda0(tree); return; + } else if ("JCMemberReference".equals(simpleName)) { + visitReference0(tree); + return; } else { print("(UNKNOWN[" + tree.getClass().getSimpleName() + "]: " + tree + ")"); println(); @@ -1610,9 +1613,27 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } } + + public void visitReference0(JCTree tree) { + try { + printExpr(readTree(tree, "expr")); + print("::"); + List<JCExpression> typeArgs = readExpressionList(tree, "typeargs"); + if (typeArgs != null) { + print("<"); + printExprs(typeArgs); + print(">"); + } + ; + print(readObject(tree, "mode").toString().equals("INVOKE") ? readObject(tree, "name") : "new"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private JCTree readTree(JCTree tree, String fieldName) { try { - return (JCTree) readObject(tree, fieldName); + return (JCTree) readObject0(tree, fieldName); } catch (Exception e) { return null; } @@ -1621,7 +1642,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { @SuppressWarnings("unchecked") private List<? extends JCTree> readTreeList(JCTree tree, String fieldName) throws IOException { try { - return (List<? extends JCTree>) readObject(tree, fieldName); + return (List<? extends JCTree>) readObject0(tree, fieldName); } catch (Exception e) { return List.nil(); } @@ -1630,14 +1651,22 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { @SuppressWarnings("unchecked") private List<JCExpression> readExpressionList(JCTree tree, String fieldName) throws IOException { try { - return (List<JCExpression>) readObject(tree, fieldName); + return (List<JCExpression>) readObject0(tree, fieldName); } catch (Exception e) { return List.nil(); } } + private Object readObject(JCTree tree, String fieldName) { + try { + return readObject0(tree, fieldName); + } catch (Exception e) { + return null; + } + } + @SuppressWarnings("unchecked") - private Object readObject(JCTree tree, String fieldName) throws Exception { + private Object readObject0(JCTree tree, String fieldName) throws Exception { try { return tree.getClass().getDeclaredField(fieldName).get(tree); } catch (Exception e) { |