@Override void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { TreeScanner ds = new DeclScanner() { public void visitDecl(JCTree tree, Symbol sym) { String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString(); dprinter.printSymbol(label, sym); dprinter.out.println(); } }; ds.scan(tree); }
@Override void handle( final String name, final JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { TreeScanner ds = new DeclScanner() { public void visitDecl(JCTree tree, Symbol sym) { DocTree dt = unit.docComments.getCommentTree(tree); if (dt != null) { String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString(); dprinter.printDocTree(label, dt); dprinter.out.println(); } } }; ds.scan(tree); }
@Override void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) { TreeScanner ts = new TreeScanner() { @Override public void scan(JCTree tree) { if (tree == null) { return; } if (tree.type != null) { String label = Pretty.toSimpleString(tree); dprinter.printType(label, tree.type); dprinter.out.println(); } super.scan(tree); } }; ts.scan(tree); }
@Override public void visitVarDef(JCVariableDecl node) { if (node.init != null) { changeNode = (lm, ne) -> { // 変数への代入式を置換 if (node.init == lm) { node.init = ne; } }; } super.visitVarDef(node); }
@Override public void visitLambda(JCLambda node) { builder .build(node) .ifPresent( expr -> { JCExpression ne = parseExpression(expr); fixPos(ne, node.pos); changeNode.accept(node, ne); }); super.visitLambda(node); }
@Override public void visitApply(JCMethodInvocation node) { if (node.args != null && node.args.size() > 0) { changeNode = (lm, ne) -> { // メソッドの引数を置換 if (node.args.contains(lm)) { Stream<JCExpression> newArgs = node.args.stream().map(a -> (a == lm) ? ne : a); node.args = com.sun.tools.javac.util.List.from(newArgs::iterator); } }; } super.visitApply(node); }
@Override public void visitVarDef(JCVariableDecl tree) { visitDecl(tree, tree.sym); super.visitVarDef(tree); }
@Override public void visitMethodDef(JCMethodDecl tree) { visitDecl(tree, tree.sym); super.visitMethodDef(tree); }
@Override public void visitClassDef(JCClassDecl tree) { visitDecl(tree, tree.sym); super.visitClassDef(tree); }
@Override public void scan(JCTree tree) { setGeneratedBy(tree, source); super.scan(tree); }