First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ConditionalExpression.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java
new file mode 100644 (file)
index 0000000..d85c89c
--- /dev/null
@@ -0,0 +1,29 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * A ConditionalExpression is like that : booleanExpression ? trueValue : falseValue;
+ * @author Matthieu Casanova
+ */
+public class ConditionalExpression extends OperatorExpression {
+
+  public Expression condition, valueIfTrue, valueIfFalse;
+
+  public ConditionalExpression(Expression condition,
+                               Expression valueIfTrue,
+                               Expression valueIfFalse) {
+    super(-1, condition.sourceStart, valueIfFalse.sourceEnd);
+    this.condition = condition;
+    this.valueIfTrue = valueIfTrue;
+    this.valueIfFalse = valueIfFalse;
+  }
+
+  public String toStringExpressionNoParenthesis() {
+    final StringBuffer buff = new StringBuffer("(");
+    buff.append(condition.toStringExpression());
+    buff.append(") ? ");
+    buff.append(valueIfTrue.toStringExpression());
+    buff.append(" : ");
+    buff.append(valueIfFalse.toStringExpression());
+    return buff.toString();
+  }
+}