PsiStatement (final PsiStatement statement, final PsiElement container, final PsiElement[] statements) { if (container instanceof PsiSwitchLabeledRuleStatement && !(statement instanceof PsiBlockStatement)) { Project project = container.getProject(); PsiManager manager = PsiManager.getInstance(project); PsiElementFactory factory = JavaPsiFacade.getElementFactory(manager.getProject()); CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project); PsiBlockStatement blockStatement = (PsiBlockStatement)factory.createStatementFromText("{\n}", null); blockStatement = (PsiBlockStatement)codeStyleManager.reformat(blockStatement); blockStatement = (PsiBlockStatement)container.addAfter(blockStatement, statements[statements.length - 1]); return (PsiStatement)blockStatement.getCodeBlock().add(statement); } return (PsiStatement)container.addAfter(statement, statements[statements.length - 1]); }