1 package net.sourceforge.phpdt.internal.compiler.ast;
4 * @author Matthieu Casanova
6 public class ForStatement extends Statement {
8 public Statement[] initializations;
9 public Expression condition;
10 public Statement[] increments;
11 public Statement action;
13 public ForStatement(Statement[] initializations,
15 Statement[] increments,
19 super(sourceStart, sourceEnd);
20 this.initializations = initializations;
21 this.condition = condition;
22 this.increments = increments;
26 public String toString(int tab) {
27 final StringBuffer buff = new StringBuffer(tabString(tab));
28 buff.append("for ("); //$NON-NLS-1$
30 if (initializations != null) {
31 for (int i = 0; i < initializations.length; i++) {
32 //nice only with expressions
33 buff.append(initializations[i].toString());
34 if (i != (initializations.length - 1))
35 buff.append(" , "); //$NON-NLS-1$
38 buff.append( "; "); //$NON-NLS-1$
40 if (condition != null) {
41 buff.append(condition.toStringExpression());
43 buff.append( "; "); //$NON-NLS-1$
45 if (increments != null) {
46 for (int i = 0; i < increments.length; i++) {
47 //nice only with expressions
48 buff.append(increments[i].toString());
49 if (i != (increments.length - 1))
50 buff.append(" , "); //$NON-NLS-1$
53 buff.append(") "); //$NON-NLS-1$
56 buff.append("{}"); //$NON-NLS-1$
58 buff.append( "\n").append(action.toString(tab + 1)); //$NON-NLS-1$
59 return buff.toString();