PsiImplementationViewSession (@NotNull DataContext dataContext, @NotNull Project project, boolean searchDeep, boolean alwaysIncludeSelf) { PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); Editor editor = getEditor(dataContext); Pair<PsiElement, PsiReference> pair = getElementAndReference(dataContext, project, file, editor); if (pair == null) return null; PsiElement element = pair.first; PsiReference ref = pair.second; String text = ""; PsiElement[] impls = PsiElement.EMPTY_ARRAY; if (element != null) { impls = getSelfAndImplementations(editor, element, createImplementationsSearcher(searchDeep)); text = SymbolPresentationUtil.getSymbolPresentableText(element); } if (impls.length == 0 && ref instanceof PsiPolyVariantReference polyReference) { PsiElement refElement = polyReference.getElement(); TextRange rangeInElement = polyReference.getRangeInElement(); String refElementText = refElement.getText(); LOG.assertTrue(rangeInElement.getEndOffset() <= refElementText.length(), "Ref:" + polyReference + "; refElement: " + refElement + "; refText:" + refElementText); text = rangeInElement.substring(refElementText); final ResolveResult[] results = polyReference.multiResolve(false); final List<PsiElement> implsList = new ArrayList<>(results.length); for (ResolveResult result : results) { final PsiElement resolvedElement = result.getElement(); if (resolvedElement != null && resolvedElement.isPhysical()) { implsList.add(resolvedElement); } } if (!implsList.isEmpty()) { impls = implsList.toArray(PsiElement.EMPTY_ARRAY); } } return new PsiImplementationViewSession(project, element, impls, text, editor, file != null ? file.getVirtualFile() : null, searchDeep, alwaysIncludeSelf); }