/** * Visitor method: enter all classes in given tree, catching any completion failure exceptions. * Return the tree's type. * * @param tree The tree to be visited. * @param env The environment visitor argument. */ Type classEnter(JCTree tree, Env<AttrContext> env) { Env<AttrContext> prevEnv = this.env; try { this.env = env; tree.accept(this); return result; } catch (CompletionFailure ex) { return chk.completionError(tree.pos(), ex); } finally { this.env = prevEnv; } }
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) { List<ClassSymbol> classes = List.nil(); for (JCCompilationUnit unit : units) { for (JCTree node : unit.defs) { if (node.getTag() == JCTree.CLASSDEF) { ClassSymbol sym = ((JCClassDecl) node).sym; Assert.checkNonNull(sym); classes = classes.prepend(sym); } } } return classes.reverse(); }
public JCTree visitOther(Tree node, P p) { JCTree tree = (JCTree) node; switch (tree.getTag()) { case JCTree.LETEXPR: { LetExpr t = (LetExpr) node; List<JCVariableDecl> defs = copy(t.defs, p); JCTree expr = copy(t.expr, p); return M.at(t.pos).LetExpr(defs, expr); } default: throw new AssertionError("unknown tree tag: " + tree.getTag()); } }
// prints the brackets of a nested array in reverse order // tree is either JCArrayTypeTree or JCAnnotatedTypeTree private void printBrackets(JCTree tree) throws IOException { JCTree elem = tree; while (true) { if (elem.hasTag(ANNOTATED_TYPE)) { JCAnnotatedType atype = (JCAnnotatedType) elem; elem = atype.underlyingType; if (elem.hasTag(TYPEARRAY)) { print(' '); printTypeAnnotations(atype.annotations); } } if (elem.hasTag(TYPEARRAY)) { print("[]"); elem = ((JCArrayTypeTree) elem).elemtype; } else { break; } } }
/** * Visitor method: print expression tree. * * @param prec The current precedence level. */ public void printExpr(JCTree tree, int prec) throws IOException { int prevPrec = this.prec; try { this.prec = prec; if (tree == null) print("/*missing*/"); else { tree.accept(this); } } catch (UncheckedIOException ex) { IOException e = new IOException(ex.getMessage()); e.initCause(ex); throw e; } finally { this.prec = prevPrec; } }
public void scan(JCTree tree) { if (tree != null && !result) tree.accept(this); }
/** Is the given tree an enumerator definition? */ boolean isEnumerator(JCTree t) { return t.getTag() == JCTree.VARDEF && (((JCVariableDecl) t).mods.flags & ENUM) != 0; }
public void scan(JCTree node) { super.scan(node); if (node != null) node.type = null; }
/** Visitor method: Scan a single node. */ public void scan(JCTree tree) { if (tree != null) tree.accept(this); }
/** Is the given tree an enumerator definition? */ boolean isEnumerator(JCTree t) { return t.hasTag(VARDEF) && (((JCVariableDecl) t).mods.flags & ENUM) != 0; }