} else if (thenIsEmpty && !elseIsEmpty) {
// Convert "if (a()) {} else {stuff}" => "if (!a()) {stuff}".
JsUnaryOperation negatedOperation = new JsPrefixOperation(
makeSourceInfo(x, "Simplified if with empty then statement"),
JsUnaryOperator.NOT, x.getIfExpr());
JsIf newIf = new JsIf(makeSourceInfo(x,
"Simplified if with empty then statement"), negatedOperation,
elseStmt, null);
ctx.replaceMe(accept(newIf));
} else if (elseIsEmpty && thenExpr != null) {
// Convert "if (a()) {b()}" => "a()&&b()".
JsBinaryOperation op = new JsBinaryOperation(makeSourceInfo(x,
"Replaced if statement with &&"), JsBinaryOperator.AND,
x.getIfExpr(), thenExpr);
ctx.replaceMe(accept(op.makeStmt()));
} else if (elseIsEmpty && elseStmt != null) {
// Convert "if (a()) {b()} else {}" => "if (a()) {b()}".
JsIf newIf = new JsIf(makeSourceInfo(x, "Pruned empty else statement"),
x.getIfExpr(), thenStmt, null);
ctx.replaceMe(accept(newIf));
}
}