Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ConditionalExpression.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * A ConditionalExpression is like that : booleanExpression ? trueValue : falseValue;
7  * @author Matthieu Casanova
8  */
9 public class ConditionalExpression extends OperatorExpression {
10
11   public Expression condition, valueIfTrue, valueIfFalse;
12
13   public ConditionalExpression(final Expression condition,
14                                final Expression valueIfTrue,
15                                final Expression valueIfFalse) {
16     super(-1, condition.sourceStart, valueIfFalse.sourceEnd);
17     this.condition = condition;
18     this.valueIfTrue = valueIfTrue;
19     this.valueIfFalse = valueIfFalse;
20   }
21
22   public String toStringExpression() {
23     final StringBuffer buff = new StringBuffer("(");
24     buff.append(condition.toStringExpression());
25     buff.append(") ? ");
26     buff.append(valueIfTrue.toStringExpression());
27     buff.append(" : ");
28     buff.append(valueIfFalse.toStringExpression());
29     return buff.toString();
30   }
31
32   /**
33    * Get the variables from outside (parameters, globals ...)
34    */
35   public void getOutsideVariable(final List list) {
36   }
37
38   /**
39    * get the modified variables.
40    */
41   public void getModifiedVariable(final List list) {
42     condition.getModifiedVariable(list);
43     valueIfTrue.getModifiedVariable(list);
44     valueIfFalse.getModifiedVariable(list);
45   }
46
47   /**
48    * Get the variables used.
49    */
50   public void getUsedVariable(final List list) {
51     condition.getUsedVariable(list);
52     valueIfTrue.getUsedVariable(list);
53     valueIfFalse.getUsedVariable(list);
54   }
55 }