1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * @author Matthieu Casanova
8 public final class ForeachStatement extends Statement {
10 private final Expression expression;
11 private final Expression variable;
12 private final Statement statement;
14 public ForeachStatement(final Expression expression,
15 final Expression variable,
16 final Statement statement,
17 final int sourceStart,
18 final int sourceEnd) {
19 super(sourceStart, sourceEnd);
20 this.expression = expression;
21 this.variable = variable;
22 this.statement = statement;
26 * Return the object into String.
28 * @param tab how many tabs (not used here
31 public String toString(final int tab) {
32 final String expressionString = expression.toStringExpression();
33 final String variableString = variable.toStringExpression();
34 final String statementString = statement.toString(tab + 1);
35 final StringBuffer buff = new StringBuffer(tab +
36 expressionString.length() +
37 variableString.length() +
38 statementString.length() + 18);
39 buff.append(tabString(tab));
40 buff.append("foreach (");
41 buff.append(expressionString);
43 buff.append(variableString);
45 buff.append(statementString);
47 return buff.toString();
51 * Get the variables from outside (parameters, globals ...)
53 * @param list the list where we will put variables
55 public void getOutsideVariable(final List list) {
56 expression.getOutsideVariable(list);
57 variable.getOutsideVariable(list);
58 statement.getOutsideVariable(list);
62 * get the modified variables.
64 * @param list the list where we will put variables
66 public void getModifiedVariable(final List list) {
67 expression.getModifiedVariable(list);
68 variable.getUsedVariable(list);
69 statement.getModifiedVariable(list);
73 * Get the variables used.
75 * @param list the list where we will put variables
77 public void getUsedVariable(final List list) {
78 expression.getUsedVariable(list);
79 statement.getUsedVariable(list);