int (Editor editor, int tailOffset, int startOffset) { Project project = editor.getProject(); if (project != null) { PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile != null) { editor.getCaretModel().moveToOffset(tailOffset); CodeStyleManager.getInstance(project).reformatText(psiFile, startOffset, tailOffset); tailOffset = editor.getCaretModel().getOffset(); } } return tailOffset; }