PsiReference (int offset) { // copy/paste from SharedPsiElementImplUtil PsiElement element = findElementAt(offset); if (element == null || element instanceof OuterLanguageElement) return null; offset = getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset(); List<PsiReference> referencesList = new ArrayList<>(); final PsiFile file = element.getContainingFile(); final var context = file != null ? TypeEvalContext.codeAnalysis(file.getProject(), file) : TypeEvalContext.codeInsightFallback(element.getProject()); final PyResolveContext resolveContext = PyResolveContext.implicitContext(context); while (element != null) { addReferences(offset, element, referencesList, resolveContext); offset = element.getStartOffsetInParent() + offset; if (element instanceof PsiFile) break; element = element.getParent(); } if (referencesList.isEmpty()) return null; if (referencesList.size() == 1) return referencesList.get(0); return new PsiMultiReference(referencesList.toArray(PsiReference.EMPTY_ARRAY), referencesList.get(referencesList.size() - 1).getElement()); }