void (@NotNull ActionContext context, @NotNull PsiJavaModule javaModule, @NotNull ModPsiUpdater updater) { final List<T> statementsToMerge = getStatementsToMerge(javaModule); LOG.assertTrue(!statementsToMerge.isEmpty()); final String text = getReplacementText(statementsToMerge); final PsiStatement replacement = JavaPsiFacade.getElementFactory(context.project()).createModuleStatementFromText(text, null); final T firstStatement = statementsToMerge.get(0); final CommentTracker commentTracker = new CommentTracker(); final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(context.project()); final PsiElement resultingStatement = codeStyleManager.reformat(commentTracker.replace(firstStatement, replacement)); for (int i = 1; i < statementsToMerge.size(); i++) { T statement = statementsToMerge.get(i); commentTracker.delete(statement); } commentTracker.insertCommentsBefore(resultingStatement); updater.moveTo(resultingStatement.getTextRange().getEndOffset()); }