mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-15503 Numpy: unresolved reference: false positive for testing package referenced with numpy import only
fixed resolve for the relative from imports
This commit is contained in:
@@ -106,6 +106,10 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
if (!inSameFile(location, myModule)) {
|
||||
importElements.addAll(myModule.getImportTargets());
|
||||
}
|
||||
final List<PyFromImportStatement> imports = myModule.getFromImports();
|
||||
for (PyFromImportStatement anImport : imports) {
|
||||
Collections.addAll(importElements, anImport.getImportElements());
|
||||
}
|
||||
}
|
||||
final List<? extends RatedResolveResult> implicitMembers = resolveImplicitPackageMember(name, importElements);
|
||||
if (implicitMembers != null) {
|
||||
@@ -185,6 +189,18 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
importedQNames.add(implicitSubModuleQName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<PsiElement> elements = ResolveImportUtil.resolveFromImportStatementSource(fromImportStatement, element.getImportedQName());
|
||||
for (PsiElement psiElement : elements) {
|
||||
if (psiElement instanceof PsiFile) {
|
||||
final VirtualFile virtualFile = ((PsiFile)psiElement).getVirtualFile();
|
||||
final QualifiedName qName = QualifiedNameFinder.findShortestImportableQName(element, virtualFile);
|
||||
if (qName != null) {
|
||||
importedQNames.add(qName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (stmt instanceof PyImportStatement) {
|
||||
final QualifiedName importedQName = element.getImportedQName();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import x
|
||||
|
||||
print(x.z)
|
||||
# <ref>
|
||||
@@ -0,0 +1,5 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
from . import z as qq
|
||||
|
||||
print(z)
|
||||
@@ -0,0 +1,4 @@
|
||||
__author__ = 'ktisha'
|
||||
|
||||
def foo():
|
||||
return 1
|
||||
@@ -402,4 +402,9 @@ public class PyMultiFileResolveTest extends PyMultiFileResolveTestCase {
|
||||
}
|
||||
assertResolveResult(element, PyClass.class, "A");
|
||||
}
|
||||
|
||||
public void testRelativeImport() {
|
||||
assertResolvesTo(PyFile.class, "z.py");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user