Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DoStatement.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * A do statement.
7  * @author Matthieu Casanova
8  */
9 public class DoStatement extends Statement {
10
11
12   /** The condition expression. */
13   public Expression condition;
14   /** The action of the while. (it could be a block) */
15   public Statement action;
16
17   public DoStatement(final Expression condition,
18                      final Statement action,
19                      final int sourceStart,
20                      final int sourceEnd) {
21     super(sourceStart, sourceEnd);
22     this.condition = condition;
23     this.action = action;
24   }
25
26   /**
27    * Return the object into String.
28    * @param tab how many tabs (not used here
29    * @return a String
30    */
31   public String toString(final int tab) {
32     final String s = tabString(tab);
33     final StringBuffer buff = new StringBuffer("do ");//$NON-NLS-1$
34     if (action == null) {
35       buff.append(" {} ;"); //$NON-NLS-1$
36     } else {
37       buff.append("\n").append(action.toString(tab + 1));//$NON-NLS-1$
38     }
39     buff.append(s).append(" while (");//$NON-NLS-1$
40     buff.append(condition.toStringExpression()).append(")");//$NON-NLS-1$
41     return buff.toString();
42   }
43
44   /**
45    * Get the variables from outside (parameters, globals ...)
46    */
47   public void getOutsideVariable(final List list) {
48     condition.getOutsideVariable(list); // todo: check if unuseful
49     action.getOutsideVariable(list);
50   }
51
52   /**
53    * get the modified variables.
54    */
55   public void getModifiedVariable(final List list) {
56     condition.getModifiedVariable(list);
57     action.getModifiedVariable(list);
58   }
59
60   /**
61    * Get the variables used.
62    */
63   public void getUsedVariable(final List list) {
64     condition.getUsedVariable(list);
65     action.getUsedVariable(list);
66   }
67 }