TextRange (Editor editor, PsiExpression expr, CodeStyleManager codeStyleManager, PsiElement toReplace, PsiSwitchBlock switchBlock) { switchBlock = (PsiSwitchBlock)codeStyleManager.reformat(switchBlock); PsiExpression selectorExpression = switchBlock.getExpression(); if (selectorExpression != null) { selectorExpression.replace(expr); } switchBlock = (PsiSwitchBlock)toReplace.replace(switchBlock); PsiCodeBlock body = switchBlock.getBody(); if (body != null) { body = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(body); if (body != null) { TextRange range = body.getStatements()[0].getTextRange(); editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset()); return TextRange.from(range.getStartOffset(), 0); } } return TextRange.from(editor.getCaretModel().getOffset(), 0); }