Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ElseIf.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * An elseif statement.
7  * @author Matthieu Casanova
8  */
9 public class ElseIf extends Statement {
10
11   /** The condition. */
12   public Expression condition;
13
14   /** The statements. */
15   public Statement[] statements;
16
17   public ElseIf(final Expression condition, final Statement[] statements, final int sourceStart, final int sourceEnd) {
18     super(sourceStart, sourceEnd);
19     this.condition = condition;
20     this.statements = statements;
21   }
22
23   /**
24    * Return the object into String.
25    * @param tab how many tabs (not used here
26    * @return a String
27    */
28   public String toString(final int tab) {
29     final StringBuffer buff = new StringBuffer(tabString(tab));
30     buff.append("elseif (");
31     buff.append(condition.toStringExpression());
32     buff.append(") \n");
33     for (int i = 0; i < statements.length; i++) {
34       final Statement statement = statements[i];
35       buff.append(statement.toString(tab + 1)).append('\n');
36     }
37     return buff.toString();
38   }
39
40   /**
41    * Get the variables from outside (parameters, globals ...)
42    */
43   public void getOutsideVariable(final List list) {
44     for (int i = 0; i < statements.length; i++) {
45       statements[i].getModifiedVariable(list);
46     }
47   }
48
49   /**
50    * get the modified variables.
51    */
52   public void getModifiedVariable(final List list) {
53     for (int i = 0; i < statements.length; i++) {
54       statements[i].getModifiedVariable(list);
55     }
56     condition.getModifiedVariable(list);
57   }
58
59   /**
60    * Get the variables used.
61    */
62   public void getUsedVariable(final List list) {
63     for (int i = 0; i < statements.length; i++) {
64       statements[i].getUsedVariable(list);
65     }
66     condition.getUsedVariable(list);
67   }
68 }