*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ArrayInitializer.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
4
5 import java.util.List;
6 import java.util.ArrayList;
7
8 /**
9  * @author Matthieu Casanova
10  */
11 public class ArrayInitializer extends Expression {
12
13   public ArrayVariableDeclaration[] vars;
14
15   public ArrayInitializer(final ArrayVariableDeclaration[] vars,
16                           final int sourceStart,
17                           final int sourceEnd) {
18     super(sourceStart, sourceEnd);
19     this.vars = vars;
20   }
21
22   /**
23    * Return the expression as String.
24    * @return the expression
25    */
26   public String toStringExpression() {
27     final StringBuffer buff = new StringBuffer("array(");
28     for (int i = 0; i < vars.length; i++) {
29       final ArrayVariableDeclaration var = vars[i];
30       if (i != 0) {
31         buff.append(",");
32       }
33       buff.append(var.toStringExpression());
34     }
35     buff.append(")");
36     return buff.toString();
37   }
38
39              /**
40    * Get the variables from outside (parameters, globals ...)
41    * @return the variables from outside
42    */
43   public List getOutsideVariable() {
44     return new ArrayList();
45   }
46
47   /**
48    * get the modified variables.
49    * @return the variables from we change value
50    */
51   public List getModifiedVariable() {
52     final ArrayList list = new ArrayList();
53     for (int i = 0; i < vars.length; i++) {
54       list.addAll(vars[i].getModifiedVariable());
55     }
56     return list;
57   }
58
59   /**
60    * Get the variables used.
61    * @return the variables used
62    */
63   public List getUsedVariable() {
64     final ArrayList list = new ArrayList();
65     for (int i = 0; i < vars.length; i++) {
66       list.addAll(vars[i].getUsedVariable());
67     }
68     return list;
69   }
70 }