예제 #1
0
 @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);
 }
예제 #2
0
 @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);
 }
예제 #3
0
 @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);
 }
예제 #4
0
 @Override
 public void visitVarDef(JCVariableDecl node) {
   if (node.init != null) {
     changeNode =
         (lm, ne) -> {
           // 変数への代入式を置換
           if (node.init == lm) {
             node.init = ne;
           }
         };
   }
   super.visitVarDef(node);
 }
예제 #5
0
  @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);
  }
예제 #6
0
 @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);
 }
예제 #7
0
 @Override
 public void visitVarDef(JCVariableDecl tree) {
   visitDecl(tree, tree.sym);
   super.visitVarDef(tree);
 }
예제 #8
0
 @Override
 public void visitMethodDef(JCMethodDecl tree) {
   visitDecl(tree, tree.sym);
   super.visitMethodDef(tree);
 }
예제 #9
0
 @Override
 public void visitClassDef(JCClassDecl tree) {
   visitDecl(tree, tree.sym);
   super.visitClassDef(tree);
 }
예제 #10
0
 @Override
 public void scan(JCTree tree) {
   setGeneratedBy(tree, source);
   super.scan(tree);
 }