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