1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
8 * @author Matthieu Casanova
10 public class WhileStatement extends Statement {
12 /** The condition expression. */
13 public Expression condition;
14 /** The action of the while. (it could be a block) */
15 public Statement action;
18 * Create a While statement.
19 * @param condition the condition
20 * @param action the action
21 * @param sourceStart the starting offset
22 * @param sourceEnd the ending offset
24 public WhileStatement(final Expression condition,
25 final Statement action,
26 final int sourceStart,
27 final int sourceEnd) {
28 super(sourceStart, sourceEnd);
29 this.condition = condition;
34 * Return the object into String.
35 * @param tab how many tabs (not used here
38 public String toString(final int tab) {
39 final String s = tabString(tab);
40 final StringBuffer buff = new StringBuffer(s).append("while ("); //$NON-NLS-1$
41 buff.append(condition.toStringExpression()).append(")"); //$NON-NLS-1$
43 buff.append(" {} ;"); //$NON-NLS-1$
45 buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$
47 return buff.toString();
51 * Get the variables from outside (parameters, globals ...)
53 public void getOutsideVariable(final List list) {
54 condition.getOutsideVariable(list); // todo: check if unuseful
56 action.getOutsideVariable(list);
61 * get the modified variables.
63 public void getModifiedVariable(final List list) {
64 condition.getModifiedVariable(list);
66 action.getModifiedVariable(list);
71 * Get the variables used.
73 public void getUsedVariable(final List list) {
74 condition.getUsedVariable(list);
76 action.getUsedVariable(list);