List<RatedResolveResult> () { final ResolveResultList overriddenResult = resolveByOverridingReferenceResolveProviders(); if (!overriddenResult.isEmpty()) { return overriddenResult; } final String referencedName = myElement.getReferencedName(); if (referencedName == null) return Collections.emptyList(); if (myElement instanceof PyTargetExpression && PsiTreeUtil.getParentOfType(myElement, PyComprehensionElement.class) != null) { return ResolveResultList.to(myElement); } // Use real context here to enable correct completion and resolve in case of PyExpressionCodeFragment final PsiElement realContext = PyPsiUtils.getRealContext(myElement); if (!myContext.getTypeEvalContext().maySwitchToAST(realContext) && realContext instanceof PyFile) { return ((PyFile)realContext).multiResolveName(referencedName); } // here we have an unqualified expr. it may be defined: // ...in current file final PyResolveProcessor processor = new PyResolveProcessor(referencedName); final PsiElement roof = findResolveRoof(referencedName, realContext); PyResolveUtil.scopeCrawlUp(processor, myElement, referencedName, roof); return getResultsFromProcessor(referencedName, processor, realContext, roof); }