1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
7 * @author Matthieu Casanova
9 public class ForeachStatement extends Statement {
11 public Expression expression;
12 public Expression variable;
13 public Statement statement;
15 public ForeachStatement(final Expression expression,
16 final Expression variable,
17 final Statement statement,
18 final int sourceStart,
19 final int sourceEnd) {
20 super(sourceStart, sourceEnd);
21 this.expression = expression;
22 this.variable = variable;
23 this.statement = statement;
27 * Return the object into String.
28 * @param tab how many tabs (not used here
31 public String toString(final int tab) {
32 final StringBuffer buff = new StringBuffer(tabString(tab));
33 buff.append("foreach (");
34 buff.append(expression.toStringExpression());
36 buff.append(variable.toStringExpression());
38 buff.append(statement.toString(tab+1));
40 return buff.toString();
44 * Get the variables from outside (parameters, globals ...)
45 * @return the variables from outside
47 public List getOutsideVariable() {
48 final ArrayList list = new ArrayList();
49 list.addAll(expression.getOutsideVariable());
50 list.addAll(variable.getOutsideVariable());
51 list.addAll(statement.getOutsideVariable());
56 * get the modified variables.
57 * @return the variables from we change value
59 public List getModifiedVariable() {
60 final ArrayList list = new ArrayList();
61 list.addAll(expression.getModifiedVariable());
62 list.addAll(variable.getModifiedVariable());
63 list.addAll(statement.getModifiedVariable());
68 * Get the variables used.
69 * @return the variables used
71 public List getUsedVariable() {
72 final ArrayList list = new ArrayList();
73 list.addAll(expression.getUsedVariable());
74 list.addAll(statement.getUsedVariable());