1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
8 * @author Matthieu Casanova
10 public class DoStatement extends Statement {
13 /** The condition expression. */
14 public Expression condition;
15 /** The action of the while. (it could be a block) */
16 public Statement action;
18 public DoStatement(final Expression condition,
19 final Statement action,
20 final int sourceStart,
21 final int sourceEnd) {
22 super(sourceStart, sourceEnd);
23 this.condition = condition;
28 * Return the object into String.
29 * @param tab how many tabs (not used here
32 public String toString(final int tab) {
33 final String s = tabString(tab);
34 final StringBuffer buff = new StringBuffer("do ");//$NON-NLS-1$
36 buff.append(" {} ;"); //$NON-NLS-1$
38 buff.append("\n").append(action.toString(tab + 1));//$NON-NLS-1$
40 buff.append(s).append(" while (");//$NON-NLS-1$
41 buff.append(condition.toStringExpression()).append(")");//$NON-NLS-1$
42 return buff.toString();
46 * Get the variables from outside (parameters, globals ...)
47 * @return the variables from outside
49 public List getOutsideVariable() {
50 final ArrayList list = new ArrayList();
51 list.addAll(condition.getOutsideVariable()); // todo: check if unuseful
52 list.addAll(action.getOutsideVariable());
57 * get the modified variables.
58 * @return the variables from we change value
60 public List getModifiedVariable() {
61 final ArrayList list = new ArrayList();
62 list.addAll(condition.getModifiedVariable());
63 list.addAll(action.getModifiedVariable());
68 * Get the variables used.
69 * @return the variables used
71 public List getUsedVariable() {
72 final ArrayList list = new ArrayList();
73 list.addAll(condition.getUsedVariable());
74 list.addAll(action.getUsedVariable());