Python: findPathInHelpers must not be nullable.

Unless user breaks installation, helpers are always there

GitOrigin-RevId: 080832690128e72128eef661f0a887ce4a85798d
This commit is contained in:
Ilya.Kazakevich
2025-06-06 17:26:36 +02:00
committed by intellij-monorepo-bot
parent 770520e473
commit 19c3576535
5 changed files with 24 additions and 15 deletions

View File

@@ -68,14 +68,18 @@ interface PythonHelpersLocator {
*/
@JvmStatic
@RequiresBackgroundThread
fun findPathInHelpers(resourceName: String): Path? {
fun findPathInHelpers(resourceName: String): Path {
return findPathInHelpersPossibleNull(resourceName) ?: error("File $resourceName does not exist in helpers root. Installation broken?")
}
@JvmStatic
@RequiresBackgroundThread
fun findPathInHelpersPossibleNull(resourceName: String): Path? {
for (helperRoot in getHelpersRoots()) {
val path = Path.of(helperRoot.pathString, resourceName)
if (path.exists())
return path
}
LOG.info("File $resourceName does not exist in helpers root")
return null
}
@@ -101,7 +105,7 @@ interface PythonHelpersLocator {
@Internal
@JvmStatic
@RequiresBackgroundThread
fun findPathStringInHelpers(@NonNls resourceName: String): String = findPathInHelpers(resourceName)?.absolutePathString() ?: ""
fun findPathStringInHelpers(@NonNls resourceName: String): String = findPathInHelpers(resourceName).absolutePathString()
@Deprecated("Use {@link PythonHelpersLocator#findPathInHelpers}.", ReplaceWith("findPathInHelpers(resourceName)"), DeprecationLevel.ERROR)
@JvmStatic