1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * A ConditionalExpression is like that : booleanExpression ? trueValue : falseValue;.
7 * @author Matthieu Casanova
9 public final class ConditionalExpression extends OperatorExpression {
11 private final Expression condition;
12 private final Expression valueIfTrue;
13 private final Expression valueIfFalse;
15 public ConditionalExpression(final Expression condition,
16 final Expression valueIfTrue,
17 final Expression valueIfFalse) {
18 super(-1, condition.sourceStart, valueIfFalse.sourceEnd);
19 this.condition = condition;
20 this.valueIfTrue = valueIfTrue;
21 this.valueIfFalse = valueIfFalse;
24 public String toStringExpression() {
25 final String conditionString = condition.toStringExpression();
26 final String valueIfTrueString = valueIfTrue.toStringExpression();
27 final String valueIfFalse = this.valueIfFalse.toStringExpression();
28 final StringBuffer buff = new StringBuffer(8 +
29 conditionString.length() +
30 valueIfTrueString.length() +
31 valueIfFalse.length());
33 buff.append(conditionString);
35 buff.append(valueIfTrueString);
37 buff.append(valueIfFalse);
38 return buff.toString();
42 * Get the variables from outside (parameters, globals ...)
44 * @param list the list where we will put variables
46 public void getOutsideVariable(final List list) {}
49 * get the modified variables.
51 * @param list the list where we will put variables
53 public void getModifiedVariable(final List list) {
54 condition.getModifiedVariable(list);
55 valueIfTrue.getModifiedVariable(list);
56 valueIfFalse.getModifiedVariable(list);
60 * Get the variables used.
62 * @param list the list where we will put variables
64 public void getUsedVariable(final List list) {
65 condition.getUsedVariable(list);
66 valueIfTrue.getUsedVariable(list);
67 valueIfFalse.getUsedVariable(list);