x.getSourceInfo(), x.getType(), JBinaryOperator.OR, condExpr,
elseExpr);
ctx.replaceMe(binOp);
} else {
// e.g. (cond ? false : else) -> !cond && else
JPrefixOperation notCondExpr = new JPrefixOperation(program,
condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
JBinaryOperation binOp = new JBinaryOperation(program,
x.getSourceInfo(), x.getType(), JBinaryOperator.AND, notCondExpr,
elseExpr);
ctx.replaceMe(binOp);
}
} else if (elseExpr instanceof JBooleanLiteral) {
if (((JBooleanLiteral) elseExpr).getValue()) {
// e.g. (cond ? then : true) -> !cond || then
JPrefixOperation notCondExpr = new JPrefixOperation(program,
condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
JBinaryOperation binOp = new JBinaryOperation(program,
x.getSourceInfo(), x.getType(), JBinaryOperator.OR, notCondExpr,
thenExpr);
ctx.replaceMe(binOp);