1 package net.sourceforge.phpdt.internal.compiler.ast;
7 * @author Matthieu Casanova
9 public class WhileStatement extends Statement {
11 /** The condition expression. */
12 public Expression condition;
13 /** The action of the while. (it could be a block) */
14 public Statement action;
17 * Create a While statement.
18 * @param condition the condition
19 * @param action the action
20 * @param sourceStart the starting offset
21 * @param sourceEnd the ending offset
23 public WhileStatement(final Expression condition,
24 final Statement action,
25 final int sourceStart,
26 final int sourceEnd) {
27 super(sourceStart, sourceEnd);
28 this.condition = condition;
33 * Return the object into String.
34 * @param tab how many tabs (not used here
37 public String toString(final int tab) {
38 final String s = tabString(tab);
39 final StringBuffer buff = new StringBuffer(s).append("while ("); //$NON-NLS-1$
40 buff.append(condition.toStringExpression()).append(")"); //$NON-NLS-1$
42 buff.append(" {} ;"); //$NON-NLS-1$
44 buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$
46 return buff.toString();
50 * Get the variables from outside (parameters, globals ...)
52 public void getOutsideVariable(final List list) {
53 condition.getOutsideVariable(list); // todo: check if unuseful
55 action.getOutsideVariable(list);
60 * get the modified variables.
62 public void getModifiedVariable(final List list) {
63 condition.getModifiedVariable(list);
65 action.getModifiedVariable(list);
70 * Get the variables used.
72 public void getUsedVariable(final List list) {
73 condition.getUsedVariable(list);
75 action.getUsedVariable(list);