void ( @NotNull String fqn, @NotNull PsiElement element, @NotNull Editor editor, @NotNull QualifiedNameProvider provider ) { final Project project = editor.getProject(); if (project == null) return; final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); documentManager.commitDocument(editor.getDocument()); final PsiFile file = documentManager.getPsiFile(editor.getDocument()); if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { Document document = editor.getDocument(); documentManager.doPostponedOperationsAndUnblockDocument(document); documentManager.commitDocument(document); EditorModificationUtil.deleteSelectedText(editor); provider.insertQualifiedName(fqn, element, editor, project); }), IdeBundle.message("command.pasting.reference"), null); }