List<RatedResolveResult> (@Nullable PsiElement parent, @NotNull String referencedName, @Nullable PsiFile containingFile, boolean fileOnly, boolean checkForPackage, boolean withoutStubs, boolean withoutForeign) { final PsiElement parentDir = PyUtil.turnInitIntoDir(parent); if (parentDir instanceof PsiDirectory) { final List<RatedResolveResult> resolved = resolveInDirectory(referencedName, containingFile, (PsiDirectory)parentDir, fileOnly, checkForPackage, withoutStubs); if (!resolved.isEmpty()) { for (RatedResolveResult result : resolved) { if (result.getRate() > RatedResolveResult.RATE_LOW) { return resolved; } } } if (!withoutForeign && parent instanceof PsiFile) { final PsiElement foreign = resolveForeignImports((PsiFile)parent, referencedName); if (foreign != null) { final ResolveResultList results = new ResolveResultList(); results.addAll(resolved); results.poke(foreign, RatedResolveResult.RATE_NORMAL); return results; } } return resolved; } return Collections.emptyList(); }