Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Else.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * an else statement.
7  * it's else
8  * @author Matthieu Casanova
9  */
10 public class Else extends Statement {
11
12   /** the statements. */
13   public Statement[] statements;
14
15   /**
16    * An else statement bad version ( : endif).
17    * @param statements the statements
18    * @param sourceStart the starting offset
19    * @param sourceEnd the ending offset
20    */
21   public Else(final Statement[] statements,
22               final int sourceStart,
23               final int sourceEnd) {
24     super(sourceStart, sourceEnd);
25     this.statements = statements;
26   }
27
28   /**
29    * An else statement good version
30    * @param statement the statement (it could be a block)
31    * @param sourceStart the starting offset
32    * @param sourceEnd the ending offset
33    */
34   public Else(final Statement statement,
35               final int sourceStart,
36               final int sourceEnd) {
37     super(sourceStart, sourceEnd);
38     this.statements = new Statement[1];
39     this.statements[0] = statement;
40   }
41
42   /**
43    * Return the object into String.
44    * @param tab how many tabs (not used here
45    * @return a String
46    */
47   public String toString(final int tab) {
48     final StringBuffer buff = new StringBuffer(tabString(tab));
49     buff.append("else \n");//$NON-NLS-1$
50     Statement statement;
51     for (int i = 0; i < statements.length; i++) {
52       statement = statements[i];
53       buff.append(statement.toString(tab + 1)).append("\n");//$NON-NLS-1$
54     }
55     return buff.toString();
56   }
57
58   /**
59    * Get the variables from outside (parameters, globals ...)
60    */
61   public void getOutsideVariable(final List list) {
62     for (int i = 0; i < statements.length; i++) {
63       statements[i].getOutsideVariable(list);
64     }
65   }
66
67   /**
68    * get the modified variables.
69    */
70   public void getModifiedVariable(final List list) {
71     for (int i = 0; i < statements.length; i++) {
72       statements[i].getModifiedVariable(list);
73     }
74   }
75
76   /**
77    * Get the variables used.
78    */
79   public void getUsedVariable(final List list) {
80     for (int i = 0; i < statements.length; i++) {
81       statements[i].getUsedVariable(list);
82     }
83   }
84 }