diff --git a/python/pluginCore/resources/META-INF/plugin.xml b/python/pluginCore/resources/META-INF/plugin.xml index e0730510546f..36f2f99ff645 100644 --- a/python/pluginCore/resources/META-INF/plugin.xml +++ b/python/pluginCore/resources/META-INF/plugin.xml @@ -548,8 +548,6 @@ The Python plug-in provides smart editing for Python scripts. The feature set of - - () } -/** - * Used for CoroutineScope in com.jetbrains.python.sdk - */ -@Service(Service.Level.PROJECT) -internal class PythonSdkRunCommandService(val cs: CoroutineScope) - /** * Runs a command line operation in a background thread. * diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkCoroutineService.kt b/python/src/com/jetbrains/python/sdk/PythonSdkCoroutineService.kt new file mode 100644 index 000000000000..498f2d2c0150 --- /dev/null +++ b/python/src/com/jetbrains/python/sdk/PythonSdkCoroutineService.kt @@ -0,0 +1,11 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.jetbrains.python.sdk + +import com.intellij.openapi.components.Service +import kotlinx.coroutines.CoroutineScope + +/** + * Used for CoroutineScope in com.jetbrains.python.sdk + */ +@Service(Service.Level.APP) +internal class PythonSdkCoroutineService(val cs: CoroutineScope) \ No newline at end of file diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt index e09cb44a56c0..7a6703156d27 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PoetryCommandExecutor.kt @@ -145,7 +145,7 @@ private fun runCommand(projectPath: Path, command: String, vararg args: String): } internal fun runPoetryInBackground(module: Module, args: List, @NlsSafe description: String) { - module.project.service().cs.launch { + service().cs.launch { withBackgroundProgress(module.project, "$description...", true) { val sdk = module.pythonSdk ?: return@withBackgroundProgress try { diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigLoader.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigLoader.kt deleted file mode 100644 index afa34e708b9a..000000000000 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigLoader.kt +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.python.sdk.poetry - - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.smartReadAction -import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.ProjectActivity -import com.jetbrains.python.statistics.sdks - - -class PoetryConfigLoader : ProjectActivity { - override suspend fun execute(project: Project) { - if (ApplicationManager.getApplication().isUnitTestMode) return - if (project.isDisposed) return - smartReadAction(project) { - project.sdks - .filterNot { it.isPoetry } - .filter { PoetryConfigService.getInstance(project).poetryVirtualenvPaths.contains(it.homePath) } - .forEach { it.isPoetry = true } - } - } -} diff --git a/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigService.kt b/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigService.kt deleted file mode 100644 index b6175af50532..000000000000 --- a/python/src/com/jetbrains/python/sdk/poetry/PoetryConfigService.kt +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.jetbrains.python.sdk.poetry - -import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.Service -import com.intellij.openapi.components.State -import com.intellij.openapi.components.Storage -import com.intellij.openapi.project.Project -import com.intellij.util.xmlb.XmlSerializerUtil - -/** - * This source code is edited by @koxudaxi Koudai Aono - */ - -@Service(Service.Level.PROJECT) -@State(name = "PoetryConfigService", storages = [Storage("poetry.xml")]) -class PoetryConfigService : PersistentStateComponent { - var poetryVirtualenvPaths = mutableSetOf() - - override fun getState(): PoetryConfigService { - return this - } - - override fun loadState(config: PoetryConfigService) { - XmlSerializerUtil.copyBean(config, this) - } - - companion object { - fun getInstance(project: Project): PoetryConfigService { - return project.getService(PoetryConfigService::class.java) - } - } - -} \ No newline at end of file diff --git a/python/src/com/jetbrains/python/sdk/poetry/PyProjectTomlUtils.kt b/python/src/com/jetbrains/python/sdk/poetry/PyProjectTomlUtils.kt index dd66b02eac9a..74d44cd839a0 100644 --- a/python/src/com/jetbrains/python/sdk/poetry/PyProjectTomlUtils.kt +++ b/python/src/com/jetbrains/python/sdk/poetry/PyProjectTomlUtils.kt @@ -35,7 +35,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiElementFilter import com.intellij.psi.util.PsiTreeUtil import com.jetbrains.python.psi.LanguageLevel -import com.jetbrains.python.sdk.PythonSdkRunCommandService +import com.jetbrains.python.sdk.PythonSdkCoroutineService import com.jetbrains.python.sdk.PythonSdkUpdater import com.jetbrains.python.sdk.add.v2.PythonSelectableInterpreter import com.jetbrains.python.sdk.poetry.VersionType.Companion.getVersionType @@ -210,7 +210,7 @@ private class PyProjectTomlPostStartupActivity : ProjectActivity { readAction { tomlFile.findDocument()?.addDocumentListener(object : DocumentListener { override fun documentChanged(event: DocumentEvent) { - project.service().cs.launch { + service().cs.launch { val newVersion = findPythonVersion(tomlFile, project) ?: return@launch val oldVersion = PyProjectTomlPythonVersionsService.instance.getVersionString(module) if (oldVersion != newVersion) {