void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final PsiReturnStatement returnStatement = (PsiReturnStatement)element; final PsiExpression returnValue = returnStatement.getReturnValue(); if (returnValue == null || ErrorUtil.containsDeepError(returnValue)) { return; } CommentTracker tracker = new CommentTracker(); final String newStatementText = buildIf(returnValue, true, tracker, new StringBuilder()).toString(); final Project project = returnStatement.getProject(); final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory(); final PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{" + newStatementText + "}", returnStatement); final PsiElement parent = returnStatement.getParent(); if (parent instanceof PsiCodeBlock) { PsiStatement @NotNull [] statements = blockStatement.getCodeBlock().getStatements(); for (int i = 0; i < statements.length; i++) { PsiStatement st = statements[i]; PsiElement result = CodeStyleManager.getInstance(project).reformat(parent.addBefore(st, returnStatement)); if (i == 0) { updater.moveTo(result); } } PsiReplacementUtil.replaceStatement(returnStatement, "return false;", tracker); } else { blockStatement.getCodeBlock().add(elementFactory.createStatementFromText("return false;", returnStatement)); PsiBlockStatement result = (PsiBlockStatement)tracker.replaceAndRestoreComments(returnStatement, blockStatement); updater.moveTo(result.getCodeBlock().getStatements()[0]); } }