void (@NotNull PsiElement element) { final PsiJavaToken token = (PsiJavaToken)element; final PsiIfStatement parentStatement = (PsiIfStatement)token.getParent(); if (parentStatement == null) { return; } final PsiStatement elseBranch = parentStatement.getElseBranch(); if (elseBranch == null) { return; } Project project = element.getProject(); PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{}", elseBranch); blockStatement.getCodeBlock().add(elseBranch); CodeStyleManager.getInstance(project).reformat(elseBranch.replace(blockStatement)); }