Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / WhileStatement.java
index 01e956d..f98367c 100644 (file)
@@ -1,15 +1,17 @@
 package net.sourceforge.phpdt.internal.compiler.ast;
 
+import java.util.List;
+
 /**
  * A While statement.
  * @author Matthieu Casanova
  */
-public class WhileStatement extends Statement {
+public final class WhileStatement extends Statement {
 
   /** The condition expression. */
-  public Expression condition;
+  private final Expression condition;
   /** The action of the while. (it could be a block) */
-  public Statement action;
+  private final Statement action;
 
   /**
    * Create a While statement.
@@ -18,10 +20,10 @@ public class WhileStatement extends Statement {
    * @param sourceStart the starting offset
    * @param sourceEnd the ending offset
    */
-  public WhileStatement(Expression condition,
-                        Statement action,
-                        int sourceStart,
-                        int sourceEnd) {
+  public WhileStatement(final Expression condition,
+                        final Statement action,
+                        final int sourceStart,
+                        final int sourceEnd) {
     super(sourceStart, sourceEnd);
     this.condition = condition;
     this.action = action;
@@ -32,15 +34,51 @@ public class WhileStatement extends Statement {
    * @param tab how many tabs (not used here
    * @return a String
    */
-  public String toString(int tab) {
-               final String s = tabString(tab);
-    final StringBuffer buff = new StringBuffer("while ("); //$NON-NLS-1$
-               buff.append(condition.toStringExpression()).append(")");        //$NON-NLS-1$
-               if (action == null) {
-                       buff.append(" {} ;"); //$NON-NLS-1$
+  public String toString(final int tab) {
+    final String s = tabString(tab);
+    final StringBuffer buff = new StringBuffer(s).append("while ("); //$NON-NLS-1$
+    buff.append(condition.toStringExpression()).append(")");   //$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$
+    }
+    return buff.toString();
+  }
+
+  /**
+   * Get the variables from outside (parameters, globals ...)
+   *
+   * @param list the list where we will put variables
+   */
+  public void getOutsideVariable(final List list) {
+    condition.getOutsideVariable(list); // todo: check if unuseful
+    if (action != null) {
+      action.getOutsideVariable(list);
+    }
+  }
+
+  /**
+   * get the modified variables.
+   *
+   * @param list the list where we will put variables
+   */
+  public void getModifiedVariable(final List list) {
+    condition.getModifiedVariable(list);
+    if (action != null) {
+      action.getModifiedVariable(list);
+    }
+  }
+
+  /**
+   * Get the variables used.
+   *
+   * @param list the list where we will put variables
+   */
+  public void getUsedVariable(final List list) {
+    condition.getUsedVariable(list);
+    if (action != null) {
+      action.getUsedVariable(list);
     }
-               return buff.toString();
   }
 }