1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import java.util.ArrayList;
9 * @author Matthieu Casanova
11 public class Else extends Statement {
13 /** the statements. */
14 public Statement[] statements;
17 * An else statement bad version ( : endif).
18 * @param statements the statements
19 * @param sourceStart the starting offset
20 * @param sourceEnd the ending offset
22 public Else(final Statement[] statements,
23 final int sourceStart,
24 final int sourceEnd) {
25 super(sourceStart, sourceEnd);
26 this.statements = statements;
30 * An else statement good version
31 * @param statement the statement (it could be a block)
32 * @param sourceStart the starting offset
33 * @param sourceEnd the ending offset
35 public Else(final Statement statement,
36 final int sourceStart,
37 final int sourceEnd) {
38 super(sourceStart, sourceEnd);
39 this.statements = new Statement[1];
40 this.statements[0] = statement;
44 * Return the object into String.
45 * @param tab how many tabs (not used here
48 public String toString(final int tab) {
49 final StringBuffer buff = new StringBuffer(tabString(tab));
50 buff.append("else \n");//$NON-NLS-1$
52 for (int i = 0; i < statements.length; i++) {
53 statement = statements[i];
54 buff.append(statement.toString(tab + 1)).append("\n");//$NON-NLS-1$
56 return buff.toString();
60 * Get the variables from outside (parameters, globals ...)
61 * @return the variables from outside
63 public List getOutsideVariable() {
64 final ArrayList list = new ArrayList();
65 for (int i = 0; i < statements.length; i++) {
66 list.addAll(statements[i].getOutsideVariable());
72 * get the modified variables.
73 * @return the variables from outside
75 public List getModifiedVariable() {
76 final ArrayList list = new ArrayList();
77 for (int i = 0; i < statements.length; i++) {
78 list.addAll(statements[i].getModifiedVariable());
84 * Get the variables used.
85 * @return the variables from outside
87 public List getUsedVariable() {
88 final ArrayList list = new ArrayList();
89 for (int i = 0; i < statements.length; i++) {
90 list.addAll(statements[i].getUsedVariable());