1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
6 import java.util.ArrayList;
9 * @author Matthieu Casanova
11 public class SwitchStatement extends Statement {
13 public Expression variable;
14 public AbstractCase[] cases;
16 public SwitchStatement(final Expression variable,
17 final AbstractCase[] cases,
18 final int sourceStart,
19 final int sourceEnd) {
20 super(sourceStart, sourceEnd);
21 this.variable = variable;
26 * Return the object into String.
27 * @param tab how many tabs (not used here
30 public String toString(final int tab) {
31 final StringBuffer buff = new StringBuffer(tabString(tab));
32 buff.append("switch (").append(variable.toStringExpression()).append(") {\n");
33 for (int i = 0; i < cases.length; i++) {
34 final AbstractCase cas = cases[i];
35 buff.append(cas.toString(tab + 1));
39 return buff.toString();
43 * Get the variables from outside (parameters, globals ...)
44 * @return the variables from outside
46 public List getOutsideVariable() {
47 final ArrayList list = new ArrayList();
48 for (int i = 0; i < cases.length; i++) {
49 list.addAll(cases[i].getOutsideVariable());
55 * get the modified variables.
56 * @return the variables modified
58 public List getModifiedVariable() {
59 final ArrayList list = new ArrayList();
60 for (int i = 0; i < cases.length; i++) {
61 list.addAll(cases[i].getModifiedVariable());
63 list.addAll(variable.getModifiedVariable());
68 * Get the variables used.
69 * @return the variables used
71 public List getUsedVariable() {
72 final ArrayList list = new ArrayList();
73 for (int i = 0; i < cases.length; i++) {
74 list.addAll(cases[i].getUsedVariable());
76 list.addAll(variable.getUsedVariable());