First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ArrayInitializer.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java
new file mode 100644 (file)
index 0000000..3d9cb87
--- /dev/null
@@ -0,0 +1,34 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * @author Matthieu Casanova
+ */
+public class ArrayInitializer extends Expression {
+
+  public ArrayVariableDeclaration[] vars;
+
+  public ArrayInitializer(ArrayVariableDeclaration[] vars,
+                          int sourceStart,
+                          int sourceEnd) {
+    super(sourceStart, sourceEnd);
+    this.vars = vars;
+  }
+
+  /**
+   * Return the expression as String.
+   * @return the expression
+   */
+  public String toStringExpression() {
+    final StringBuffer buff = new StringBuffer("array(");
+    for (int i = 0; i < vars.length; i++) {
+      ArrayVariableDeclaration var = vars[i];
+      if (var != null) {
+        buff.append(var.toStringExpression());
+      }
+      if (i != 0) {
+        buff.append(',');
+      }
+    }
+    return buff.toString();
+  }
+}