GotoData (@NotNull Editor editor, int offset, PsiElement source) { final PsiElement[] targets = findTargets(editor, offset, source); if (targets == null) { //canceled search GotoData data = new GotoData(source, PsiElement.EMPTY_ARRAY, Collections.emptyList()); data.isCanceled = true; return data; } final PsiReference reference = TargetElementUtil.findReference(editor, offset); GotoData gotoData = new GotoData(source, targets, Collections.emptyList()); gotoData.listUpdaterTask = new ImplementationsUpdaterTask(gotoData, editor, offset, reference) { @Override public void onSuccess() { super.onSuccess(); @Nullable ItemWithPresentation oneElement = getTheOnlyOneElement(); if (oneElement != null && oneElement.getItem() instanceof SmartPsiElementPointer<?> && navigateToElement(((SmartPsiElementPointer<?>)oneElement.getItem()).getElement())) { myPopup.cancel(); } } }; return gotoData; }