1 19 20 package org.netbeans.modules.java.source.engine; 21 22 import com.sun.source.tree.*; 23 import com.sun.source.util.TreeScanner; 24 25 28 public class TreeFinder extends TreeScanner<Boolean ,Object > { 29 protected Tree target; 30 protected boolean found = false; 31 32 37 public TreeFinder(Tree target) { 38 this.target = target; 39 } 40 41 47 public Boolean scan(Tree tree, Object o) { 48 found = found || tree == target; 49 if (!found && tree != null) 50 tree.accept(this, o); 51 return found; 52 } 53 54 60 public Boolean scan(Iterable <? extends Tree> trees, Object o) { 61 if (!found && trees != null) 62 for (Tree tree : trees) 63 if (scan(tree, o)) 64 return true; 65 return found; 66 } 67 } 68 | Popular Tags |