First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / IfStatement.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 /**
4  * @author Matthieu Casanova
5  */
6 public class IfStatement extends Statement {
7
8   public Expression condition;
9   public ElseIf[] elseifs;
10   public Else els;
11
12   public IfStatement(Expression condition,
13                      ElseIf[] elseifs,
14                      Else els,
15                      int sourceStart,
16                      int sourceEnd) {
17     super(sourceStart, sourceEnd);
18     this.condition = condition;
19     this.elseifs = elseifs;
20     this.els = els;
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(int tab) {
29     final StringBuffer buff = new StringBuffer(tabString(tab));
30     buff.append("if (");
31     buff.append(condition.toStringExpression()).append(") ");
32     for (int i = 0; i < elseifs.length; i++) {
33       ElseIf elseif = elseifs[i];
34       buff.append(elseif.toString(tab+1));
35       buff.append('\n');
36     }
37     if (els != null) {
38       buff.append(els.toString(tab+1));
39       buff.append('\n');
40     }
41     return buff.toString();
42   }
43 }