void (@NotNull PsiStatement statement) { CommentTracker commentTracker = new CommentTracker(); PsiSwitchBlock switchBlock = generateEnhancedSwitch(statement, myNewBranches, commentTracker, true); if (switchBlock == null) return; if (myReturnToDelete != null) { CommentTracker ct = new CommentTracker(); commentTracker.markUnchanged(myReturnToDelete.getReturnValue()); ct.delete(myReturnToDelete); } if (myThrowStatementToDelete != null) { CommentTracker ct = new CommentTracker(); commentTracker.markUnchanged(myThrowStatementToDelete.getException()); ct.delete(myThrowStatementToDelete); } for (PsiStatement toDelete : myStatementsToDelete) { commentTracker.delete(toDelete); } PsiElementFactory factory = JavaPsiFacade.getElementFactory(statement.getProject()); PsiStatement returnStatement = factory.createStatementFromText("return " + switchBlock.getText() + ";", switchBlock); commentTracker.replaceAndRestoreComments(statement, returnStatement); }