mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[qodana] QD-9527 Enabled Poetry SDK creation for Poetry projects in headless mode
GitOrigin-RevId: edaab8de048359a95a197989fb2c53068dd21f3e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
29ca865bc6
commit
f65c970d2d
@@ -78,10 +78,12 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator {
|
||||
}
|
||||
|
||||
private fun findExtension(module: Module): PyProjectSdkConfigurationExtension? {
|
||||
return if (!module.project.isTrusted() || ApplicationManager.getApplication().let { it.isHeadlessEnvironment || it.isUnitTestMode }) {
|
||||
return if (!module.project.isTrusted() || ApplicationManager.getApplication().isUnitTestMode) {
|
||||
null
|
||||
}
|
||||
else PyProjectSdkConfigurationExtension.EP_NAME.findFirstSafe { it.getIntention(module) != null }
|
||||
else PyProjectSdkConfigurationExtension.EP_NAME.findFirstSafe {
|
||||
it.getIntention(module) != null && (!ApplicationManager.getApplication().isHeadlessEnvironment || it.supportsHeadlessModel())
|
||||
}
|
||||
}
|
||||
|
||||
fun configureSdk(
|
||||
|
||||
@@ -45,6 +45,8 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
|
||||
override fun createAndAddSdkForInspection(module: Module): Sdk? = createAndAddSDk(module, true)
|
||||
|
||||
override fun supportsHeadlessModel(): Boolean = true
|
||||
|
||||
private fun createAndAddSDk(module: Module, inspection: Boolean): Sdk? {
|
||||
val poetryEnvExecutable = askForEnvData(module, inspection) ?: return null
|
||||
PropertiesComponent.getInstance().poetryPath = poetryEnvExecutable.poetryPath.pathString
|
||||
@@ -53,10 +55,14 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
|
||||
private fun askForEnvData(module: Module, inspection: Boolean): PyAddNewPoetryFromFilePanel.Data? {
|
||||
val poetryExecutable = getPoetryExecutable()
|
||||
val isHeadlessEnv = ApplicationManager.getApplication().isHeadlessEnvironment
|
||||
|
||||
if (inspection && validatePoetryExecutable(poetryExecutable) == null) {
|
||||
if ((inspection || isHeadlessEnv) && validatePoetryExecutable(poetryExecutable) == null) {
|
||||
return PyAddNewPoetryFromFilePanel.Data(poetryExecutable!!)
|
||||
}
|
||||
else if (isHeadlessEnv) {
|
||||
return null
|
||||
}
|
||||
|
||||
var permitted = false
|
||||
var envData: PyAddNewPoetryFromFilePanel.Data? = null
|
||||
@@ -152,4 +158,4 @@ class PyPoetrySdkConfiguration : PyProjectSdkConfigurationExtension {
|
||||
|
||||
override fun doValidateAll(): List<ValidationInfo> = panel.validateAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* Used on directory opening with an attempt to configure suitable Python interpreter
|
||||
* (mentioned below as sdk configurator, ignored in headless mode).
|
||||
* (mentioned below as sdk configurator).
|
||||
*
|
||||
* Used with an attempt to suggest suitable Python interpreter if no interpreter is specified.
|
||||
* Used with an attempt to suggest suitable Python interpreter
|
||||
* or try setup and register it in case of headless mode if no interpreter is specified.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
interface PyProjectSdkConfigurationExtension {
|
||||
@@ -60,4 +61,10 @@ interface PyProjectSdkConfigurationExtension {
|
||||
*/
|
||||
@RequiresBackgroundThread
|
||||
fun createAndAddSdkForInspection(module: Module): Sdk?
|
||||
|
||||
/**
|
||||
* If headless supported implementation is responsible for interpreter setup and registration
|
||||
* for [createAndAddSdkForConfigurator] method in IDE without an additional user input.
|
||||
*/
|
||||
fun supportsHeadlessModel(): Boolean = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user