1 package net.sourceforge.phpdt.internal.compiler.ast;
8 * @author Matthieu Casanova
10 public final class DoStatement extends Statement {
13 /** The condition expression. */
14 private final Expression condition;
15 /** The action of the while. (it could be a block) */
16 private final 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.
30 * @param tab how many tabs (not used here
33 public String toString(final int tab) {
34 final String conditionString = condition.toStringExpression();
35 final StringBuffer buff;
37 buff = new StringBuffer(17 + tab + conditionString.length());
38 buff.append("do ");//$NON-NLS-1$
39 buff.append(" {} ;"); //$NON-NLS-1$
41 final String actionString = action.toString(tab + 1);
42 buff = new StringBuffer(13 + conditionString.length() + actionString.length());
43 buff.append("do ");//$NON-NLS-1$
44 buff.append("\n");//$NON-NLS-1$
45 buff.append(actionString);
47 buff.append(tabString(tab));
48 buff.append(" while (");//$NON-NLS-1$
49 buff.append(conditionString);
50 buff.append(")");//$NON-NLS-1$
51 return buff.toString();
55 * Get the variables from outside (parameters, globals ...)
57 * @param list the list where we will put variables
59 public void getOutsideVariable(final List list) {
60 condition.getOutsideVariable(list); // todo: check if unuseful
61 action.getOutsideVariable(list);
65 * get the modified variables.
67 * @param list the list where we will put variables
69 public void getModifiedVariable(final List list) {
70 condition.getModifiedVariable(list);
71 action.getModifiedVariable(list);
75 * Get the variables used.
77 * @param list the list where we will put variables
79 public void getUsedVariable(final List list) {
80 condition.getUsedVariable(list);
81 action.getUsedVariable(list);