void (@NotNull final Editor editor, @NotNull final PsiElement scope, @NotNull final Project project, @NotNull final PsiElement addedElement, int size) { final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project); final Document document = editor.getDocument(); if (!(scope instanceof PsiFile)) { int line1 = editor.offsetToLogicalPosition(scope.getTextRange().getStartOffset()).line; int line2 = editor.offsetToLogicalPosition(scope.getTextRange().getEndOffset()).line; codeStyleManager.adjustLineIndent(scope.getContainingFile(), new TextRange(document.getLineStartOffset(line1), document.getLineEndOffset(line2))); } else { int line1 = editor.offsetToLogicalPosition(addedElement.getTextRange().getStartOffset()).line; PsiElement end = addedElement; while (size > 0) { PsiElement tmp = end.getNextSibling(); if (tmp == null) break; size -= 1; end = tmp; } int endOffset = end.getTextRange().getEndOffset(); int line2 = editor.offsetToLogicalPosition(endOffset).line; codeStyleManager.adjustLineIndent(scope.getContainingFile(), new TextRange(document.getLineStartOffset(line1), document.getLineEndOffset(line2))); } }