return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0); } else if (parent instanceof JCUnary) { return TreeInfo.opPrec(parent.getTag()); } else if (parent instanceof JCBinary) { JCBinary binary = (JCBinary) parent; return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0); } else if (parent instanceof JCTypeCast) { JCTypeCast typeCast = (JCTypeCast) parent;
.map( ctx -> ctx.tree.getTag() == Tag.CLASSDEF ? ((ClassSymbol) ASTHelpers.getSymbol(ctx.tree)).members().getSymbols() : ctx.info.getLocalElements())
/** Is tree a constructor declaration? */ public static boolean isConstructor(JCTree tree) { if (tree.getTag() == JCTree.METHODDEF) { Name name = ((JCMethodDecl) tree).name; return name == name.table.init; } else { return false; } }
public static boolean isEnumInit(JCTree tree) { switch (tree.getTag()) { case VARDEF: return (((JCVariableDecl)tree).mods.flags & ENUM) != 0; default: return false; } }
public static List<JCExpression> args(JCTree t) { switch (t.getTag()) { case APPLY: return ((JCMethodInvocation)t).args; case NEWCLASS: return ((JCNewClass)t).args; default: return null; } }
public static boolean isEnumInit(JCTree tree) { switch (tree.getTag()) { case VARDEF: return (((JCVariableDecl)tree).mods.flags & ENUM) != 0; default: return false; } }
boolean trackTree(JCTree tree) { switch (tree.getTag()) { // of course a method closes the alive range of a local variable. case METHODDEF: // for while loops we want only the body case WHILELOOP: return false; } return true; }
/** Return closest enclosing environment which points to a tree with given tag. */ public Env<A> enclosing(int tag) { Env<A> env1 = this; while (env1 != null && env1.tree.getTag() != tag) env1 = env1.next; return env1; }
/** Skip parens and return the enclosed expression */ public static JCTree skipParens(JCTree tree) { if (tree.getTag() == JCTree.PARENS) return skipParens((JCParens)tree); else return tree; }
public List<JCTree> getTypeDecls() { List<JCTree> typeDefs; for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) if (typeDefs.head.getTag() != IMPORT) break; return typeDefs; } @Override
private boolean isCanonical(JCTree tree) { while (tree.getTag() == JCTree.SELECT) { JCFieldAccess s = (JCFieldAccess) tree; if (s.sym.owner != TreeInfo.symbol(s.selected)) return false; tree = s.selected; } return true; }
public static boolean isDeclaration(JCTree node) { node = skipParens(node); switch (node.getTag()) { case CLASSDEF: case METHODDEF: case VARDEF: return true; default: return false; } }
/** If tree is either a simple name or of the form this.name or * C.this.name, and tree represents a trackable variable, * record an initialization of the variable. */ void letInit(JCTree tree) { tree = TreeInfo.skipParens(tree); if (tree.getTag() == JCTree.IDENT || tree.getTag() == JCTree.SELECT) { Symbol sym = TreeInfo.symbol(tree); letInit(tree.pos(), (VarSymbol)sym); } }
/** Add any variables defined in stats to the switch scope. */ private static void addVars(List<JCStatement> stats, Scope switchScope) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; if (stat.getTag() == JCTree.VARDEF) switchScope.enter(((JCVariableDecl) stat).sym); } } // where
return null; switch (tree.getTag()) { case APPLY: return new MethodInvocationElementSupport((JCMethodInvocation) tree);
public Name fullName(JCTree tree) { switch (tree.getTag()) { case IDENT: return ((JCIdent) tree).name; case SELECT: JCFieldAccess sel = (JCFieldAccess)tree; Name sname = fullName(sel.selected); return sname != null && sname.getByteLength() > 0 ? sname.append('.', sel.name) : sel.name; default: return null; } }
public List<JCImport> getImports() { ListBuffer<JCImport> imports = new ListBuffer<JCImport>(); for (JCTree tree : defs) { if (tree.getTag() == IMPORT) imports.append((JCImport)tree); else break; } return imports.toList(); } public JCExpression getPackageName() { return pid; }
/** Analyze a definition. */ void scanDef(JCTree tree) { scanStat(tree); if (tree != null && tree.getTag() == JCTree.BLOCK && !alive) { log.error(tree.pos(), "initializer.must.be.able.to.complete.normally"); } }
/** Analyze a statement. Check that statement is reachable. */ void scanStat(JCTree tree) { if (!alive && tree != null) { log.error(tree.pos(), "unreachable.stmt"); if (tree.getTag() != JCTree.SKIP) alive = true; } scan(tree); }
/** Add any variables defined in stats to inits and uninits. */ private static void addVars(List<JCStatement> stats, Bits inits, Bits uninits) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; if (stat.getTag() == JCTree.VARDEF) { int adr = ((JCVariableDecl) stat).sym.adr; inits.excl(adr); uninits.incl(adr); } } }