+++ /dev/null
-package net.sourceforge.phpdt.internal.compiler.ast;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Matthieu Casanova
- */
-public class SwitchStatement extends Statement {
-
- public Expression variable;
- public AbstractCase[] cases;
-
- public SwitchStatement(final Expression variable,
- final AbstractCase[] cases,
- final int sourceStart,
- final int sourceEnd) {
- super(sourceStart, sourceEnd);
- this.variable = variable;
- this.cases = cases;
- }
-
- /**
- * Return the object into String.
- * @param tab how many tabs (not used here
- * @return a String
- */
- public String toString(final int tab) {
- final StringBuffer buff = new StringBuffer(tabString(tab));
- buff.append("switch (").append(variable.toStringExpression()).append(") {\n");
- for (int i = 0; i < cases.length; i++) {
- final AbstractCase cas = cases[i];
- buff.append(cas.toString(tab + 1));
- buff.append('\n');
- }
- buff.append('}');
- return buff.toString();
- }
-
- /**
- * Get the variables from outside (parameters, globals ...)
- * @return the variables from outside
- */
- public List getOutsideVariable() {
- final ArrayList list = new ArrayList();
- for (int i = 0; i < cases.length; i++) {
- list.addAll(cases[i].getOutsideVariable());
- }
- return list;
- }
-
- /**
- * get the modified variables.
- * @return the variables modified
- */
- public List getModifiedVariable() {
- final ArrayList list = new ArrayList();
- for (int i = 0; i < cases.length; i++) {
- list.addAll(cases[i].getModifiedVariable());
- }
- list.addAll(variable.getModifiedVariable());
- return list;
- }
-
- /**
- * Get the variables used.
- * @return the variables used
- */
- public List getUsedVariable() {
- final ArrayList list = new ArrayList();
- for (int i = 0; i < cases.length; i++) {
- list.addAll(cases[i].getUsedVariable());
- }
- list.addAll(variable.getUsedVariable());
- return list;
- }
-}