protected Object visit()

in src/main/java/org/apache/commons/jexl3/internal/Debugger.java [878:919]


    protected Object visit(final ASTForeachStatement node, final Object data) {
        final int form = node.getLoopForm();
        builder.append("for (");
        final JexlNode body;
        if (form == 0) {
            // for( .. : ...)
            accept(node.jjtGetChild(0), data);
            builder.append(" : ");
            accept(node.jjtGetChild(1), data);
            builder.append(") ");
            body = node.jjtGetNumChildren() > 2? node.jjtGetChild(2) : null;
        } else {
            // for( .. ; ... ; ..)
            int nc = 0;
            // first child is var declaration(s)
            final JexlNode vars = (form & 1) != 0 ? node.jjtGetChild(nc++) : null;
            final JexlNode predicate = (form & 2) != 0 ? node.jjtGetChild(nc++) : null;
            // the loop step
            final JexlNode step = (form & 4) != 0 ? node.jjtGetChild(nc++) : null;
            // last child is body
            body = (form & 8) != 0 ? node.jjtGetChild(nc) : null;
            if (vars != null) {
                accept(vars, data);
            }
            builder.append("; ");
            if (predicate != null) {
                accept(predicate, data);
            }
            builder.append("; ");
            if (step != null) {
                accept(step, data);
            }
            builder.append(") ");
        }
        // the body
        if (body != null) {
            accept(body, data);
        } else {
            builder.append(';');
        }
        return data;
    }