boolean (@NotNull Project project, @NotNull ModUpdateFileText upd) { VirtualFile file = upd.file(); Document document = FileDocumentManager.getInstance().getDocument(file); if (document == null) return false; String oldText = upd.oldText(); if (!document.getText().equals(oldText)) return false; List<@NotNull Fragment> ranges = calculateRanges(upd); return WriteAction.compute(() -> { applyRanges(document, ranges, upd.newText()); PsiDocumentManager.getInstance(project).commitDocument(document); return true; }); }