From ffaee73f12f9583723d708a180cc89721bdb9135 Mon Sep 17 00:00:00 2001 From: Alexey Katsman Date: Tue, 21 Oct 2025 16:19:42 +0200 Subject: [PATCH] [python] PY-83881 Remove unused API in sdk configuration GitOrigin-RevId: 5a38b57db1c90279cea4dfbafb682b8227511138 --- .../PyProjectSdkConfigurationExtension.kt | 22 +++++-------------- .../inspections/PyInterpreterInspection.java | 3 ++- .../inspections/PyInterpreterInspectionEx.kt | 18 +++++++++++++++ 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt diff --git a/python/python-sdk/src/com/jetbrains/python/sdk/configuration/PyProjectSdkConfigurationExtension.kt b/python/python-sdk/src/com/jetbrains/python/sdk/configuration/PyProjectSdkConfigurationExtension.kt index f2622f55ca24..ae7294a08960 100644 --- a/python/python-sdk/src/com/jetbrains/python/sdk/configuration/PyProjectSdkConfigurationExtension.kt +++ b/python/python-sdk/src/com/jetbrains/python/sdk/configuration/PyProjectSdkConfigurationExtension.kt @@ -3,8 +3,6 @@ package com.jetbrains.python.sdk.configuration import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.module.Module -import com.intellij.openapi.progress.runBlockingMaybeCancellable -import com.intellij.util.concurrency.annotations.RequiresBackgroundThread import com.jetbrains.python.PyToolUIInfo import org.jetbrains.annotations.ApiStatus import org.jetbrains.annotations.CheckReturnValue @@ -22,22 +20,12 @@ interface PyProjectSdkConfigurationExtension { @JvmStatic val EP_NAME: ExtensionPointName = ExtensionPointName.create("Pythonid.projectSdkConfigurationExtension") - @JvmStatic - @RequiresBackgroundThread - fun findForModule(module: Module): CreateSdkInfo? = runBlockingMaybeCancellable { - EP_NAME.extensionsIfPointIsRegistered.firstNotNullOfOrNull { ext -> ext.checkEnvironmentAndPrepareSdkCreator(module) } - } - - @JvmStatic - @RequiresBackgroundThread - /** - * We return all configurators in a sorted order. The order is determined by extensions order, but existing environments have a - * higher priority. That means we first have all existing envs, and only after SDK creators that extensions can manage. - */ - fun findAllSortedForModule(module: Module): List = runBlockingMaybeCancellable { - EP_NAME.extensionsIfPointIsRegistered + /** + * We return all configurators in a sorted order. The order is determined by extensions order, but existing environments have a + * higher priority. That means we first have all existing envs, and only after SDK creators that extensions can manage. + */ + suspend fun findAllSortedForModule(module: Module): List = EP_NAME.extensionsIfPointIsRegistered .mapNotNull { e -> e.checkEnvironmentAndPrepareSdkCreator(module) }.sorted() - } } val toolInfo: PyToolUIInfo diff --git a/python/src/com/jetbrains/python/inspections/PyInterpreterInspection.java b/python/src/com/jetbrains/python/inspections/PyInterpreterInspection.java index 4ca3003a4db3..b0766eaaf1b5 100644 --- a/python/src/com/jetbrains/python/inspections/PyInterpreterInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyInterpreterInspection.java @@ -59,6 +59,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static com.intellij.python.sdkConfigurator.common.PublicApiKt.detectSdkForModulesIn; +import static com.jetbrains.python.inspections.PyInterpreterInspectionExKt.findAllSortedForModuleForJvm; public final class PyInterpreterInspection extends PyInspection { @@ -130,7 +131,7 @@ public final class PyInterpreterInspection extends PyInspection { final UserDataHolderBase context = new UserDataHolderBase(); - final List createSdkInfos = PyProjectSdkConfigurationExtension.findAllSortedForModule(module); + final List createSdkInfos = findAllSortedForModuleForJvm(module); if (!createSdkInfos.isEmpty()) { return new UseProvidedInterpreterFix(module, createSdkInfos.getFirst()); } diff --git a/python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt b/python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt new file mode 100644 index 000000000000..5c7b1ab208b9 --- /dev/null +++ b/python/src/com/jetbrains/python/inspections/PyInterpreterInspectionEx.kt @@ -0,0 +1,18 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.jetbrains.python.inspections + +import com.intellij.openapi.module.Module +import com.intellij.openapi.progress.runBlockingMaybeCancellable +import com.intellij.util.concurrency.annotations.RequiresBackgroundThread +import com.jetbrains.python.sdk.configuration.CreateSdkInfo +import com.jetbrains.python.sdk.configuration.PyProjectSdkConfigurationExtension +import org.jetbrains.annotations.ApiStatus + +/** + * To be used by [PyInterpreterInspection] only + */ +@ApiStatus.Internal +@RequiresBackgroundThread +internal fun findAllSortedForModuleForJvm(module: Module): List = runBlockingMaybeCancellable { + PyProjectSdkConfigurationExtension.findAllSortedForModule(module) +}