Skip to content

Commit 2959469

Browse files
authored
Collect all necessary system paths for import other modules (#1567)
1 parent 44bc8cd commit 2959469

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/language/python/PythonDialogProcessor.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,20 @@ fun getDirectoriesForSysPath(
271271
if (ancestor != null && !sources.contains(ancestor))
272272
sources.add(ancestor)
273273

274+
// Collect sys.path directories with imported modules
275+
file.importTargets.forEach { importTarget ->
276+
importTarget.multiResolve().forEach {
277+
val element = it.element
278+
if (element != null) {
279+
val directory = element.parent
280+
if (directory is PsiDirectory) {
281+
sources.add(directory.virtualFile)
282+
}
283+
}
284+
285+
}
286+
}
287+
274288
var importPath = ancestor?.let { VfsUtil.getParentDir(VfsUtilCore.getRelativeLocation(file.virtualFile, it)) } ?: ""
275289
if (importPath != "")
276290
importPath += "."

0 commit comments

Comments
 (0)