mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-35921 Pick the content root containing *.iml as the base directory of the module
A module may have many content roots. We used to pick the first mentioned in its settings. It didn't match the expectations. If you have a content root that contains the *.iml file of the module, it is likely the one you want to use. If there are no content roots that contain your *.iml, then we still use the first content root. GitOrigin-RevId: 7670730eab25d0ff1e269cfec79f4d85a186f62e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
26bc53e571
commit
fedf5828ff
@@ -2,13 +2,18 @@ package com.jetbrains.python.sdk
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
val Module.rootManager: ModuleRootManager
|
||||
get() = ModuleRootManager.getInstance(this)
|
||||
|
||||
val Module.baseDir: VirtualFile?
|
||||
get() = rootManager.contentRoots.firstOrNull()
|
||||
get() {
|
||||
val moduleFile = moduleFile ?: return null
|
||||
val roots = rootManager.contentRoots
|
||||
return roots.firstOrNull { VfsUtil.isAncestor(it, moduleFile, true) } ?: roots.firstOrNull()
|
||||
}
|
||||
|
||||
val Module.basePath: String?
|
||||
get() = baseDir?.path
|
||||
Reference in New Issue
Block a user