First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / WhileStatement.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 /**
4  * A While statement.
5  * @author Matthieu Casanova
6  */
7 public class WhileStatement extends Statement {
8
9   /** The condition expression. */
10   public Expression condition;
11   /** The action of the while. (it could be a block) */
12   public Statement action;
13
14   /**
15    * Create a While statement.
16    * @param condition the condition
17    * @param action the action
18    * @param sourceStart the starting offset
19    * @param sourceEnd the ending offset
20    */
21   public WhileStatement(Expression condition,
22                         Statement action,
23                         int sourceStart,
24                         int sourceEnd) {
25     super(sourceStart, sourceEnd);
26     this.condition = condition;
27     this.action = action;
28   }
29
30   /**
31    * Return the object into String.
32    * @param tab how many tabs (not used here
33    * @return a String
34    */
35   public String toString(int tab) {
36                 final String s = tabString(tab);
37     final StringBuffer buff = new StringBuffer("while ("); //$NON-NLS-1$
38                 buff.append(condition.toStringExpression()).append(")");        //$NON-NLS-1$
39                 if (action == null) {
40                         buff.append(" {} ;"); //$NON-NLS-1$
41     } else {
42                         buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$
43     }
44                 return buff.toString();
45   }
46 }