1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
6 import java.util.ArrayList;
9 * an array initializer.
10 * array('a','b','c') or array('a' => 2,'b' = '3');
11 * @author Matthieu Casanova
13 public class ArrayInitializer extends Expression {
15 public ArrayVariableDeclaration[] vars;
17 public ArrayInitializer(final ArrayVariableDeclaration[] vars,
18 final int sourceStart,
19 final int sourceEnd) {
20 super(sourceStart, sourceEnd);
25 * Return the expression as String.
26 * @return the expression
28 public String toStringExpression() {
29 final StringBuffer buff = new StringBuffer("array(");
30 for (int i = 0; i < vars.length; i++) {
31 final ArrayVariableDeclaration var = vars[i];
35 buff.append(var.toStringExpression());
38 return buff.toString();
42 * Get the variables from outside (parameters, globals ...)
43 * @return the variables from outside
45 public List getOutsideVariable() {
46 return new ArrayList(1);
50 * get the modified variables.
51 * @return the variables from we change value
53 public List getModifiedVariable() {
54 final ArrayList list = new ArrayList();
55 for (int i = 0; i < vars.length; i++) {
56 list.addAll(vars[i].getModifiedVariable());
62 * Get the variables used.
63 * @return the variables used
65 public List getUsedVariable() {
66 final ArrayList list = new ArrayList();
67 for (int i = 0; i < vars.length; i++) {
68 list.addAll(vars[i].getUsedVariable());