void (final TextRange signatureRange, final Document document, final String initialSignature, Project project) { WriteCommandAction.runWriteCommandAction(project, () -> { document.replaceString(signatureRange.getStartOffset(), signatureRange.getEndOffset(), initialSignature); PsiDocumentManager.getInstance(project).commitDocument(document); }); }