1 10 11 package com.sun.source.util; 12 13 import com.sun.source.tree.*; 14 15 26 public class TreePathScanner<R, P> extends TreeScanner<R, P> { 27 28 31 public R scan(TreePath path, P p) { 32 this.path = path; 33 try { 34 return path.getLeaf().accept(this, p); 35 } finally { 36 this.path = null; 37 } 38 } 39 40 44 @Override 45 public R scan(Tree tree, P p) { 46 if (tree == null) 47 return null; 48 49 TreePath prev = path; 50 path = new TreePath(path, tree); 51 try { 52 return tree.accept(this, p); 53 } finally { 54 path = prev; 55 } 56 } 57 58 62 public TreePath getCurrentPath() { 63 return path; 64 } 65 66 private TreePath path; 67 } 68 | Popular Tags |