First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / DoStatement.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java
new file mode 100644 (file)
index 0000000..1a80333
--- /dev/null
@@ -0,0 +1,40 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * @author Matthieu Casanova
+ */
+public class DoStatement extends Statement {
+
+
+  /** The condition expression. */
+  public Expression condition;
+  /** The action of the while. (it could be a block) */
+  public Statement action;
+
+  public DoStatement(Expression condition,
+                     Statement action,
+                     int sourceStart,
+                     int sourceEnd) {
+    super(sourceStart, sourceEnd);
+    this.condition = condition;
+    this.action = action;
+  }
+
+  /**
+   * Return the object into String.
+   * @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("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(s).append(" while (");
+    buff.append(condition.toStringExpression()).append(")");   //$NON-NLS-1$
+    return buff.toString();
+  }
+}