@Override public void visit(final IfStmt n, final A arg) { visitComment(n.getComment(), arg); n.getCondition().accept(this, arg); n.getThenStmt().accept(this, arg); if (n.getElseStmt() != null) { n.getElseStmt().accept(this, arg); } }
public void visit(IfStmt n, Object arg) { printer.print("if ("); n.getCondition().accept(this, arg); printer.print(") "); n.getThenStmt().accept(this, arg); if (n.getElseStmt() != null) { printer.print(" else "); n.getElseStmt().accept(this, arg); } }
@Override public Boolean visit(final IfStmt n1, final Node arg) { final IfStmt n2 = (IfStmt) arg; if (!nodeEquals(n1.getCondition(), n2.getCondition())) { return Boolean.FALSE; } if (!nodeEquals(n1.getThenStmt(), n2.getThenStmt())) { return Boolean.FALSE; } if (!nodeEquals(n1.getElseStmt(), n2.getElseStmt())) { return Boolean.FALSE; } return Boolean.TRUE; }
@Override public R visit(final IfStmt n, final A arg) { { R result = n.getCondition().accept(this, arg); if (result != null) { return result; } } { R result = n.getThenStmt().accept(this, arg); if (result != null) { return result; } } if (n.getElseStmt() != null) { { R result = n.getElseStmt().accept(this, arg); if (result != null) { return result; } } } return null; }
@Override public Node visit(final IfStmt n, final A arg) { n.setCondition((Expression) n.getCondition().accept(this, arg)); n.setThenStmt((Statement) n.getThenStmt().accept(this, arg)); if (n.getElseStmt() != null) { n.setElseStmt((Statement) n.getElseStmt().accept(this, arg)); } return n; }
if (!thenBlock) printer.unindent(); if (n.getElseStmt() != null) { if (thenBlock) printer.print(" "); else printer.printLn(); final boolean elseIf = n.getElseStmt() instanceof IfStmt; final boolean elseBlock = n.getElseStmt() instanceof BlockStmt; if (elseIf || elseBlock) // put chained if and start of block statement on a same level printer.print("else "); printer.indent(); n.getElseStmt().accept(this, arg); if (!(elseIf || elseBlock)) printer.unindent();
@Override public Node visit(IfStmt _n, Object _arg) { Expression condition = cloneNodes(_n.getCondition(), _arg); Statement thenStmt = cloneNodes(_n.getThenStmt(), _arg); Statement elseStmt = cloneNodes(_n.getElseStmt(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); IfStmt r = new IfStmt( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), condition, thenStmt, elseStmt ); r.setComment(comment); return r; }