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 ...)
52 * @return the variables from outside
54 public List getOutsideVariable() {
55 final ArrayList list = new ArrayList();
56 list.addAll(condition.getOutsideVariable()); // todo: check if unuseful
58 list.addAll(action.getOutsideVariable());
64 * get the modified variables.
65 * @return the variables from we change value
67 public List getModifiedVariable() {
68 final ArrayList list = new ArrayList();
69 list.addAll(condition.getModifiedVariable());
71 list.addAll(action.getModifiedVariable());
77 * Get the variables used.
78 * @return the variables used
80 public List getUsedVariable() {
81 final ArrayList list = new ArrayList();
82 list.addAll(condition.getUsedVariable());
84 list.addAll(action.getUsedVariable());