8285610: TreeInfo.pathFor and its uses appear to be dead code

Reviewed-by: vromero
This commit is contained in:
Jonathan Gibbons 2022-04-29 00:35:24 +00:00
parent 21b62fef33
commit 80cf59ff0b
2 changed files with 0 additions and 42 deletions

View File

@ -489,10 +489,6 @@ public class JavacTaskImpl extends BasicJavacTask {
return results;
}
public Iterable<? extends Tree> pathFor(CompilationUnitTree unit, Tree node) {
return TreeInfo.pathFor((JCTree) node, (JCTree.JCCompilationUnit) unit).reverse();
}
public void ensureEntered() {
args.allowEmpty();
enter(null);

View File

@ -793,44 +793,6 @@ public class TreeInfo {
return s.result;
}
public static Env<AttrContext> scopeFor(JCTree node, JCCompilationUnit unit) {
return scopeFor(pathFor(node, unit));
}
public static Env<AttrContext> scopeFor(List<JCTree> path) {
// TODO: not implemented yet
throw new UnsupportedOperationException("not implemented yet");
}
public static List<JCTree> pathFor(final JCTree node, final JCCompilationUnit unit) {
class Result extends Error {
static final long serialVersionUID = -5942088234594905625L;
@SuppressWarnings("serial") // List not statically Serilizable
List<JCTree> path;
Result(List<JCTree> path) {
this.path = path;
}
}
class PathFinder extends TreeScanner {
List<JCTree> path = List.nil();
public void scan(JCTree tree) {
if (tree != null) {
path = path.prepend(tree);
if (tree == node)
throw new Result(path);
super.scan(tree);
path = path.tail;
}
}
}
try {
new PathFinder().scan(unit);
} catch (Result result) {
return result.path;
}
return List.nil();
}
/** Return the statement referenced by a label.
* If the label refers to a loop or switch, return that switch
* otherwise return the labelled statement itself