List<QualifiedName> (@NotNull PyReferenceExpression expression) { // SUPPORTED CASES: // import six // six.with_metaclass(...) // from six import metaclass // with_metaclass(...) // from six import with_metaclass as w_m // w_m(...) final PyExpression qualifier = expression.getQualifier(); if (qualifier instanceof PyReferenceExpression) { final String name = expression.getName(); return name == null ? Collections.emptyList() : ContainerUtil.map(resolveImportedElementQNameLocally((PyReferenceExpression)qualifier), qn -> qn.append(name)); } else { List<QualifiedName> result = fullMultiResolveLocally(expression, new HashSet<>()) .select(PyImportElement.class) .map(PyResolveUtil::getImportedElementQName) .nonNull() .toList(); if (!result.isEmpty()) return result; if (expression.getName() == null) return result; PsiFile containingFile = expression.getContainingFile(); if (!(containingFile instanceof PyFile)) return result; List<PyFromImportStatement> fromImports = ((PyFile)containingFile).getFromImports(); return StreamEx.of(fromImports) .filter(it -> it.isStarImport()) .map(it -> it.getImportSourceQName()) .nonNull() .map(it -> it.append(expression.getName())) .toList(); } }