void (PsiReference ref) { PsiElement element = ref.getElement(); PsiFile file = element.getContainingFile(); TextRange range = ref.getRangeInElement().shiftRight(element.getTextRange().getStartOffset()); Document document = file.getViewProvider().getDocument(); assert document != null; PsiDocumentManager.getInstance(file.getProject()).doPostponedOperationsAndUnblockDocument(document); document.deleteString(range.getStartOffset(), range.getEndOffset()); }