*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DoStatement.java
index 1a80333..f3ee853 100644 (file)
@@ -1,6 +1,10 @@
 package net.sourceforge.phpdt.internal.compiler.ast;
 
+import java.util.List;
+import java.util.ArrayList;
+
 /**
+ * A do statement.
  * @author Matthieu Casanova
  */
 public class DoStatement extends Statement {
@@ -11,10 +15,10 @@ public class DoStatement extends Statement {
   /** The action of the while. (it could be a block) */
   public Statement action;
 
-  public DoStatement(Expression condition,
-                     Statement action,
-                     int sourceStart,
-                     int sourceEnd) {
+  public DoStatement(final Expression condition,
+                     final Statement action,
+                     final int sourceStart,
+                     final int sourceEnd) {
     super(sourceStart, sourceEnd);
     this.condition = condition;
     this.action = action;
@@ -25,16 +29,49 @@ public class DoStatement extends Statement {
    * @param tab how many tabs (not used here
    * @return a String
    */
-  public String toString(int tab) {
+  public String toString(final int tab) {
     final String s = tabString(tab);
-    final StringBuffer buff = new StringBuffer("do "); //$NON-NLS-1$
+    final StringBuffer buff = new StringBuffer("do ");//$NON-NLS-1$
     if (action == null) {
       buff.append(" {} ;"); //$NON-NLS-1$
     } else {
-      buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$
+      buff.append("\n").append(action.toString(tab + 1));//$NON-NLS-1$
     }
-    buff.append(s).append(" while (");
-    buff.append(condition.toStringExpression()).append(")");   //$NON-NLS-1$
+    buff.append(s).append(" while (");//$NON-NLS-1$
+    buff.append(condition.toStringExpression()).append(")");//$NON-NLS-1$
     return buff.toString();
   }
+
+  /**
+   * Get the variables from outside (parameters, globals ...)
+   * @return the variables from outside
+   */
+  public List getOutsideVariable() {
+    final ArrayList list = new ArrayList();
+    list.addAll(condition.getOutsideVariable()); // todo: check if unuseful
+    list.addAll(action.getOutsideVariable());
+    return list;
+  }
+
+  /**
+   * get the modified variables.
+   * @return the variables from we change value
+   */
+  public List getModifiedVariable() {
+    final ArrayList list = new ArrayList();
+    list.addAll(condition.getModifiedVariable());
+    list.addAll(action.getModifiedVariable());
+    return list;
+  }
+
+  /**
+   * Get the variables used.
+   * @return the variables used
+   */
+  public List getUsedVariable() {
+    final ArrayList list = new ArrayList();
+    list.addAll(condition.getUsedVariable());
+    list.addAll(action.getUsedVariable());
+    return list;
+  }
 }