PsiElement[] (PsiElement element, Editor editor) { if (canShowPopupWithOneItem(element)) { return new PsiElement[]{element}; } PsiElementProcessor.FindElement<PsiElement> collectProcessor = new PsiElementProcessor.FindElement<>(); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { search(element, editor).forEach(new PsiElementProcessorAdapter<>(collectProcessor) { @Override public boolean processInReadAction(PsiElement element) { return !accept(element) || super.processInReadAction(element); } }); } }, getSearchingForImplementations(), true, element.getProject())) { return null; } PsiElement foundElement = collectProcessor.getFoundElement(); return foundElement != null ? new PsiElement[] {foundElement} : PsiElement.EMPTY_ARRAY; }