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++) {
34 if (vars[i] != null) {
35 buff.append(vars[i].toStringExpression());
39 return buff.toString();
43 * Get the variables from outside (parameters, globals ...)
44 * @return the variables from outside
46 public List getOutsideVariable() {
47 return new ArrayList(1);
51 * get the modified variables.
52 * @return the variables from we change value
54 public List getModifiedVariable() {
55 final ArrayList list = new ArrayList();
56 for (int i = 0; i < vars.length; i++) {
57 if (vars[i] != null) {
58 list.addAll(vars[i].getModifiedVariable());
65 * Get the variables used.
66 * @return the variables used
68 public List getUsedVariable() {
69 final ArrayList list = new ArrayList();
70 for (int i = 0; i < vars.length; i++) {
71 if (vars[i] != null) {
72 list.addAll(vars[i].getUsedVariable());