1 package net.sourceforge.phpdt.internal.compiler.ast;
5 * for(initializations;condition;increments) action
6 * @author Matthieu Casanova
8 public class ForStatement extends Statement {
10 /** the initializations. */
11 public Expression[] initializations;
14 public Expression condition;
15 /** the increments. */
16 public Expression[] increments;
18 public Statement action;
20 public ForStatement(Expression[] initializations,
22 Expression[] increments,
26 super(sourceStart, sourceEnd);
27 this.initializations = initializations;
28 this.condition = condition;
29 this.increments = increments;
33 public String toString(int tab) {
34 final StringBuffer buff = new StringBuffer(tabString(tab));
35 buff.append("for ("); //$NON-NLS-1$
37 if (initializations != null) {
38 for (int i = 0; i < initializations.length; i++) {
39 buff.append(initializations[i].toStringExpression());
40 if (i != (initializations.length - 1))
41 buff.append(" , "); //$NON-NLS-1$
44 buff.append( "; "); //$NON-NLS-1$
46 if (condition != null) {
47 buff.append(condition.toStringExpression());
49 buff.append( "; "); //$NON-NLS-1$
51 if (increments != null) {
52 for (int i = 0; i < increments.length; i++) {
53 //nice only with expressions
54 buff.append(increments[i].toStringExpression());
55 if (i != (increments.length - 1))
56 buff.append(" , "); //$NON-NLS-1$
59 buff.append(") "); //$NON-NLS-1$
62 buff.append("{}"); //$NON-NLS-1$
64 buff.append(action.toString(tab + 1)); //$NON-NLS-1$
65 return buff.toString();