First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ElseIf.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java
new file mode 100644 (file)
index 0000000..d2fac29
--- /dev/null
@@ -0,0 +1,34 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * @author Matthieu Casanova
+ */
+public class ElseIf extends Statement {
+
+  public Expression condition;
+
+  public Statement[] statements;
+
+  public ElseIf(Expression condition, Statement[] statements, int sourceStart, int sourceEnd) {
+    super(sourceStart, sourceEnd);
+    this.condition = condition;
+    this.statements = statements;
+  }
+
+  /**
+   * 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("elseif (");
+    buff.append(condition.toStringExpression());
+    buff.append(") \n");
+    for (int i = 0; i < statements.length; i++) {
+      Statement statement = statements[i];
+      buff.append(statement.toString(tab+1)).append('\n');
+    }
+    return buff.toString();
+  }
+}