1 package net.sourceforge.phpdt.internal.compiler.ast;
7 * @author Matthieu Casanova
9 public final class WhileStatement extends Statement {
11 /** The condition expression. */
12 private final Expression condition;
13 /** The action of the while. (it could be a block) */
14 private final 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 * @param list the list where we will put variables
54 public void getOutsideVariable(final List list) {
55 condition.getOutsideVariable(list); // todo: check if unuseful
57 action.getOutsideVariable(list);
62 * get the modified variables.
64 * @param list the list where we will put variables
66 public void getModifiedVariable(final List list) {
67 condition.getModifiedVariable(list);
69 action.getModifiedVariable(list);
74 * Get the variables used.
76 * @param list the list where we will put variables
78 public void getUsedVariable(final List list) {
79 condition.getUsedVariable(list);
81 action.getUsedVariable(list);