if (thenExpression == null || elseExpression == null) {
// empty returns are not supported.
return null;
}
JConditional conditional =
new JConditional(sourceInfo, currentMethod.getType(), condExpr, thenExpression,
elseExpression);
JReturnStatement returnStatement = new JReturnStatement(sourceInfo, conditional);
return returnStatement;
}
if (elseStmt != null) {
// if () { } else { } -> ... ? ... : ... ;
JExpression thenExpression = extractExpression(thenStmt);
JExpression elseExpression = extractExpression(elseStmt);
if (thenExpression != null && elseExpression != null) {
JConditional conditional =
new JConditional(sourceInfo, JPrimitiveType.VOID, condExpr, thenExpression,
elseExpression);
return conditional.makeStatement();
}
} else {
// if () { } -> ... && ...;
JExpression thenExpression = extractExpression(thenStmt);