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