mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix incorrect path calculation in auto-import
This commit is contained in:
@@ -112,7 +112,7 @@ public class PythonReferenceImporter implements ReferenceImporter {
|
||||
if (isTopLevel(symbol)) { // we only want top-level symbols
|
||||
PsiFileSystemItem srcfile = symbol instanceof PsiFileSystemItem ? ((PsiFileSystemItem)symbol).getParent() : symbol.getContainingFile();
|
||||
if (srcfile != null && srcfile != existing_import_file && srcfile != node.getContainingFile()) {
|
||||
PyQualifiedName import_path = ResolveImportUtil.findCanonicalImportPath(symbol, node);
|
||||
PyQualifiedName import_path = ResolveImportUtil.findCanonicalImportPath(srcfile, node);
|
||||
if (import_path != null && !seen_file_names.contains(import_path.toString())) {
|
||||
// a new, valid hit
|
||||
fix.addImport(symbol, srcfile, import_path, proposeAsName(node.getContainingFile(), ref_text, import_path));
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<warning descr="Unresolved reference 'baz'">baz</warning>.quux()
|
||||
@@ -0,0 +1,3 @@
|
||||
from importFromModule.foo import baz
|
||||
|
||||
baz.quux()
|
||||
@@ -0,0 +1 @@
|
||||
def quux(): pass
|
||||
@@ -31,6 +31,11 @@ public class PyQuickFixTest extends PyLightFixtureTestCase {
|
||||
doInspectionTest(new String[] { "AddImportDocComment.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
|
||||
}
|
||||
|
||||
public void testImportFromModule() {
|
||||
doInspectionTest(new String[] { "importFromModule/foo/bar.py", "importFromModule/foo/baz.py", "importFromModule/foo/__init__.py" },
|
||||
PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
|
||||
}
|
||||
|
||||
public void testQualifyByImport() {
|
||||
final PyCodeInsightSettings settings = PyCodeInsightSettings.getInstance();
|
||||
boolean oldPreferFrom = settings.PREFER_FROM_IMPORT;
|
||||
|
||||
Reference in New Issue
Block a user