1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * an array initializer.
7 * array('a','b','c') or array('a' => 2,'b' = '3');
8 * @author Matthieu Casanova
10 public final class ArrayInitializer extends Expression {
12 /** the key and values. */
13 private final ArrayVariableDeclaration[] vars;
16 * Create a new array initializer.
17 * @param vars the keys and values of the array
18 * @param sourceStart the starting offset
19 * @param sourceEnd the ending offset
21 public ArrayInitializer(final ArrayVariableDeclaration[] vars,
22 final int sourceStart,
23 final int sourceEnd) {
24 super(sourceStart, sourceEnd);
29 * Return the expression as String.
30 * @return the expression
32 public String toStringExpression() {
33 final StringBuffer buff = new StringBuffer("array(");
34 for (int i = 0; i < vars.length; i++) {
38 if (vars[i] != null) {
39 buff.append(vars[i].toStringExpression());
43 return buff.toString();
47 * Get the variables from outside (parameters, globals ...)
48 * @param list the list where we will put variables
50 public void getOutsideVariable(final List list) {}
53 * get the modified variables.
54 * @param list the list where we will put variables
56 public void getModifiedVariable(final List list) {
57 for (int i = 0; i < vars.length; i++) {
58 if (vars[i] != null) {
59 vars[i].getModifiedVariable(list);
65 * Get the variables used.
66 * @param list the list where we will put variables
68 public void getUsedVariable(final List list) {
69 for (int i = 0; i < vars.length; i++) {
70 if (vars[i] != null) {
71 vars[i].getUsedVariable(list);