void (Editor editor, @Nullable PsiFile file, boolean requestFocus, @Nullable Runnable closeCallback, boolean onAutoUpdate) { myEditor = editor; Project project = getProject(file); PsiDocumentManager.getInstance(project).commitAllDocuments(); if (file != null && !file.isValid()) { file = null; // commit could invalidate the file } PsiFile finalFile = file; PsiElement originalElement = getContextElement(editor, file); int offset = editor.getCaretModel().getOffset(); CancellablePromise<PsiElement> elementPromise = ReadAction.nonBlocking( () -> findTargetElementFromContext(editor, offset, finalFile) ).coalesceBy(this).submit(AppExecutorUtil.getAppExecutorService()); CompletableFuture<PsiElement> elementFuture = Promises.asCompletableFuture(elementPromise); PopupUpdateProcessor updateProcessor = new PopupUpdateProcessor(project) { @Override public void updatePopup(Object lookupItemObject) { if (lookupItemObject == null) { doShowJavaDocInfo(elementFuture, false, this, originalElement, closeCallback, CodeInsightBundle.message("no.documentation.found"), true, onAutoUpdate); return; } PsiElement psiElement = PSIPresentationBgRendererWrapper.toPsi(lookupItemObject); if (psiElement != null) { doShowJavaDocInfo(psiElement, false, this, originalElement, closeCallback, null, true, onAutoUpdate); return; } DocumentationProvider documentationProvider = getProviderFromElement(finalFile); PsiElement element = documentationProvider.getDocumentationElementForLookupItem( PsiManager.getInstance(myProject), lookupItemObject, originalElement ); if (element == null) { doShowJavaDocInfo(elementFuture, false, this, originalElement, closeCallback, CodeInsightBundle.message("no.documentation.found"), true, onAutoUpdate); return; } if (myEditor != null) { PsiFile file = element.getContainingFile(); if (file != null) { Editor editor = myEditor; showJavaDocInfo(myEditor, file, false); myEditor = editor; } } else { doShowJavaDocInfo(element, false, this, originalElement, closeCallback, null, true, onAutoUpdate); } } }; doShowJavaDocInfo(elementFuture, requestFocus, updateProcessor, originalElement, closeCallback, null, true, onAutoUpdate); }