void (@NotNull Project project, @NotNull Editor editor, @NotNull RangeMarker bounds, int caretOffset, @NotNull Ref<? super Boolean> indented, @NotNull List<? extends ReferenceTransferableData> values) { if (DumbService.getInstance(project).isDumb()) { return; } Document document = editor.getDocument(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document); if (!(file instanceof PsiClassOwner)) { return; } PsiDocumentManager.getInstance(project).commitAllDocuments(); assert values.size() == 1; ReferenceData[] referenceData = values.get(0).getData(); TRef[] refs = findReferencesToRestore(file, bounds, referenceData); if (CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE == CodeInsightSettings.ASK) { askReferencesToRestore(project, refs, referenceData); } PsiDocumentManager.getInstance(project).commitAllDocuments(); ApplicationEx app = ApplicationManagerEx.getApplicationEx(); Consumer<ProgressIndicator> consumer = indicator -> { Set<String> imported = new TreeSet<>(); restoreReferences(referenceData, refs, imported); if (CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE == CodeInsightSettings.YES && !imported.isEmpty()) { String notificationText = JavaBundle.message("copy.paste.reference.notification", imported.size()); app.invokeLater( () -> showHint(editor, notificationText, e -> { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { reviewImports(project, file, imported); } }), ModalityState.nonModal(), __ -> editor.isDisposed()); } }; if (Registry.is("run.refactorings.under.progress")) { app.runWriteActionWithCancellableProgressInDispatchThread(JavaBundle.message("progress.title.restore.references"), project, null, consumer); } else { app.runWriteAction(() -> consumer.accept(null)); } }