# HG changeset patch # User Andreas Woess # Date 1405008509 -7200 # Node ID 456abab80eb553242a6cd300a2d0ddf840e18fb5 # Parent 76081918079d0e1e41f457cfed11066557751a45 Truffle: remove obsolete NodeUtil.findNodeInstancesInFunction (functionally equivalent to findAllNodeInstances) diff -r 76081918079d -r 456abab80eb5 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Thu Jul 10 18:08:29 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Thu Jul 10 18:08:29 2014 +0200 @@ -542,15 +542,12 @@ return null; } - public static List findAllNodeInstances(final Node root, final Class clazz) { + public static List findAllNodeInstances(final Node root, final Class clazz) { final List nodeList = new ArrayList<>(); root.accept(new NodeVisitor() { - - @SuppressWarnings("unchecked") - @Override public boolean visit(Node node) { if (clazz.isInstance(node)) { - nodeList.add((T) node); + nodeList.add(clazz.cast(node)); } return true; } @@ -558,53 +555,15 @@ return nodeList; } - // Don't visit found node instances. - public static List findNodeInstancesShallow(final Node root, final Class clazz) { - final List nodeList = new ArrayList<>(); - root.accept(new NodeVisitor() { - - @SuppressWarnings("unchecked") - @Override - public boolean visit(Node node) { - if (clazz.isInstance(node)) { - nodeList.add((T) node); - return false; - } - return true; - } - }); - return nodeList; - } - - /** Find node instances within current function only (not in nested functions). */ - public static List findNodeInstancesInFunction(final Node root, final Class clazz) { + /** + * Like {@link #findAllNodeInstances(Node, Class)} but do not visit children of found nodes. + */ + public static List findNodeInstancesShallow(final Node root, final Class clazz) { final List nodeList = new ArrayList<>(); root.accept(new NodeVisitor() { - - @SuppressWarnings("unchecked") - @Override public boolean visit(Node node) { if (clazz.isInstance(node)) { - nodeList.add((T) node); - } else if (node instanceof RootNode && node != root) { - return false; - } - return true; - } - }); - return nodeList; - } - - public static List findNodeInstancesInFunctionInterface(final Node root, final Class clazz) { - final List nodeList = new ArrayList<>(); - root.accept(new NodeVisitor() { - - @SuppressWarnings("unchecked") - @Override - public boolean visit(Node node) { - if (clazz.isInstance(node)) { - nodeList.add((I) node); - } else if (node instanceof RootNode && node != root) { + nodeList.add(clazz.cast(node)); return false; } return true;