First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / IfStatement.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java
new file mode 100644 (file)
index 0000000..aa61a55
--- /dev/null
@@ -0,0 +1,43 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * @author Matthieu Casanova
+ */
+public class IfStatement extends Statement {
+
+  public Expression condition;
+  public ElseIf[] elseifs;
+  public Else els;
+
+  public IfStatement(Expression condition,
+                     ElseIf[] elseifs,
+                     Else els,
+                     int sourceStart,
+                     int sourceEnd) {
+    super(sourceStart, sourceEnd);
+    this.condition = condition;
+    this.elseifs = elseifs;
+    this.els = els;
+  }
+
+  /**
+   * Return the object into String.
+   * @param tab how many tabs (not used here
+   * @return a String
+   */
+  public String toString(int tab) {
+    final StringBuffer buff = new StringBuffer(tabString(tab));
+    buff.append("if (");
+    buff.append(condition.toStringExpression()).append(") ");
+    for (int i = 0; i < elseifs.length; i++) {
+      ElseIf elseif = elseifs[i];
+      buff.append(elseif.toString(tab+1));
+      buff.append('\n');
+    }
+    if (els != null) {
+      buff.append(els.toString(tab+1));
+      buff.append('\n');
+    }
+    return buff.toString();
+  }
+}