if (onlyOneReturnStatement(siblings)) {
returnDeclaration = concatenateElements(siblings);
}
final String finalReturnDeclaration = returnDeclaration;
WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
document.deleteString(rightCurlyPosition, rightCurlyPosition + 1);
document.insertString(leftCurlyPosition + 1, "\n" + finalReturnDeclaration + "\n}");
}
};
writeCommandAction.execute();
flipCondition(document, condition);
GoSimpleStatement simpleStatement = stmt.getSimpleStatement();
if (simpleStatement != null) {
extractSimpleStatement(stmt, document, condition, simpleStatement);
}
} else {
WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
document.insertString(leftCurlyPosition, "{\n} else ");
}
};
writeCommandAction.execute();
flipCondition(document, condition);
}
reformatPositions(file, stmtRange);