protected int diffForeachLoop(JCEnhancedForLoop oldT, JCEnhancedForLoop newT, int[] bounds) { int localPointer = bounds[0]; // variable int[] varBounds = getBounds(oldT.var); copyTo(localPointer, varBounds[0]); localPointer = diffTree(oldT.var, newT.var, varBounds); // expression int[] exprBounds = getBounds(oldT.expr); copyTo(localPointer, exprBounds[0]); localPointer = diffTree(oldT.expr, newT.expr, exprBounds); // body int[] bodyBounds = new int[] { localPointer, endPos(oldT.body) }; int oldIndent = newT.body.hasTag(Tag.BLOCK) ? -1 : printer.indent(); localPointer = diffTree(oldT.body, newT.body, bodyBounds, oldT.getKind()); if (!newT.body.hasTag(Tag.BLOCK)) printer.undent(oldIndent); copyTo(localPointer, bounds[1]); return bounds[1]; }
@Override public void visitForeachLoop(JCEnhancedForLoop tree) { aPrint("for ("); printVarDefInline(tree.var); print(" : "); print(tree.expr); print(") "); print(tree.body); }
public void visitForeachLoop(JCEnhancedForLoop that) { try { print("JCEnhancedForLoop:"); } catch (Exception e) { } super.visitForeachLoop(that); }
public void visitForeachLoop(JCEnhancedForLoop tree) { try { print("for ("); printExpr(tree.var); print(" : "); printExpr(tree.expr); print(") "); printStat(tree.body); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException { return inliner.maker().ForeachLoop( getVariable().inline(inliner), getExpression().inline(inliner), getStatement().inline(inliner)); }
@Override public void visitForeachLoop(JCEnhancedForLoop tree) { printNode(tree); child("var", tree.var); child("expr", tree.expr); child("body", tree.body); indent--; }
@Override public void visitForeachLoop(JCEnhancedForLoop node) { ForEach fe = new ForEach(); fe.rawIterable(toTree(node.getExpression())); fe.rawStatement(toTree(node.getStatement())); fe.rawVariable(toTree(node.getVariable(), FlagKey.VARDEF_IS_DEFINITION)); set(node, fe); }
@Override public JCEnhancedForLoop inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .ForeachLoop( getVariable().inline(inliner), getExpression().inline(inliner), getStatement().inline(inliner)); }
@Override public Choice<State<JCEnhancedForLoop>> visitEnhancedForLoop( final EnhancedForLoopTree node, State<?> state) { return chooseSubtrees( state, s -> unifyExpression(node.getExpression(), s), s -> unifyStatement(node.getStatement(), s), (expr, stmt) -> maker().ForeachLoop((JCVariableDecl) node.getVariable(), expr, stmt)); }
public void visitForeachLoop(JCEnhancedForLoop tree) { Env<AttrContext> loopEnv = env.dup(env.tree, env.info.dup(env.info.scope.dup())); attribStat(tree.var, loopEnv); Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv)); chk.checkNonVoid(tree.pos(), exprType); Type elemtype = types.elemtype(exprType); // perhaps expr is an array? if (elemtype == null) { // or perhaps expr implements Iterable<T>? Type base = types.asSuper(exprType, syms.iterableType.tsym); if (base == null) { log.error(tree.expr.pos(), "foreach.not.applicable.to.type", exprType, diags.fragment("type.req.array.or.iterable")); elemtype = types.createErrorType(exprType); } else { List<Type> iterableParams = base.allparams(); elemtype = iterableParams.isEmpty() ? syms.objectType : types.upperBound(iterableParams.head); } } chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type); loopEnv.tree = tree; // before, we were not in loop! attribStat(tree.body, loopEnv); loopEnv.info.scope.leave(); result = null; }
private boolean matchForeachLoop(JCEnhancedForLoop t1, JCEnhancedForLoop t2) { return treesMatch(t1.var, t2.var) && treesMatch(t1.expr, t2.expr) && treesMatch(t1.body, t2.body); }
@Override public void visitForeachLoop(JCEnhancedForLoop tree) { //skip body (to prevents same statements to be analyzed twice) scan(tree.getExpression()); }
@Override public void visitForeachLoop(JCEnhancedForLoop tree) { scan(tree.getExpression()); }
public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { return invoke(ForeachLoop, var, expr, body); }
public AJCEnhancedForLoop(JCEnhancedForLoop ltree) { super(ltree.var, ltree.expr, ltree.body); }
public AJCEnhancedForLoop(JCEnhancedForLoop ltree, String lcomment) { this(ltree); setComment(lcomment); }