Commit 1645e80c authored by Alexander Koshevoy's avatar Alexander Koshevoy Committed by intellij-monorepo-bot
Browse files

PY-56302 Prevent throwing UOE on starting Python run configuration when a...

PY-56302 Prevent throwing UOE on starting Python run configuration when a module library does not have associated Path

An example of a library without an associated Path is a jar library added to a Java module with configured Python facet.

(cherry picked from commit d246e362c85e9554a7956deadee8d5f5c0154897)

IJ-MR-95600

GitOrigin-RevId: d2a69c5c91e1b1373e4da2136bd2a6c41e2d84bd
parent 5b08c5a2
Branches unavailable Tags unavailable
No related merge requests found
Showing with 9 additions and 1 deletion
+9 -1
......@@ -178,7 +178,7 @@ private fun addLibrariesFromModule(module: Module,
// skip libraries from Python facet
continue
}
for (root in entry.getRootFiles(OrderRootType.CLASSES).map { it.toNioPath() }) {
for (root in entry.getRootFiles(OrderRootType.CLASSES).mapNotNull { it.toNioPathOrNull() }) {
val library = entry.library
if (!PlatformUtils.isPyCharm()) {
pythonPathList += getTargetEnvironmentValueForLocalPath(root)
......@@ -194,6 +194,14 @@ private fun addLibrariesFromModule(module: Module,
}
}
/**
* Returns a related [Path] for [this] virtual file where possible or `null` otherwise.
*
* Unlike [VirtualFile.toNioPath], this extension function does not throw [UnsupportedOperationException], but rather return `null` in the
* same cases.
*/
private fun VirtualFile.toNioPathOrNull(): Path? = fileSystem.getNioPath(this)
private fun addRootsFromModule(module: Module, pythonPathList: MutableCollection<TargetEnvironmentFunction<String>>) {
// for Jython
val extension = CompilerModuleExtension.getInstance(module)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment