mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-87683 Refactor and extend trace contexts in Python plugin
Rename bundle keys from tracecontext.* to trace.context.*, consolidate tool-specific detection contexts into a parameterized key, and add new trace contexts for ToolDetectionService and PyCondaEnvProvider. GitOrigin-RevId: 8c3933c324366db13934a818b3463a28f4494ae6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0da93d7322
commit
12f18602e6
@@ -1744,23 +1744,18 @@ python.source.root.detection.confirm.notification.action.revert=Revert
|
||||
python.source.root.detection.confirm.notification.action.mute=Don't show again
|
||||
|
||||
read.only.python.sdk.system.wide.read.only.message=System Python packages are read-only. Select a different interpreter to modify packages.
|
||||
tracecontext.detecting.poetry.executable=Detecting Poetry Executable
|
||||
tracecontext.detecting.pip.executable=Detecting Pip Executable
|
||||
tracecontext.detecting.uv.executable=Detecting uv Executable
|
||||
tracecontext.detecting.hatch.executable=Detecting Hatch Executable
|
||||
tracecontext.detecting.hatch.environments=Detecting Hatch Environments
|
||||
tracecontext.detecting.executable=Detecting {0} Executable
|
||||
tracecontext.detecting.venv=Detecting venv folder
|
||||
tracecontext.generating.git=Generating git
|
||||
tracecontext.packaging.tool.window=Packaging Tool Window
|
||||
tracecontext.packages.sdk.controller=Packages SDK Controller
|
||||
tracecontext.add.local.python.sdk.dialog=Add Local Python SDK Dialog
|
||||
tracecontext.add.remote.python.sdk.dialog=Add {0} Python SDK Dialog
|
||||
tracecontext.new.project.wizard=New Project Wizard
|
||||
tracecontext.loading.interpreter.list=Loading Interpreter List
|
||||
tracecontext.detecting.conda.executable.and.environments=Detecting Conda Executable and environments
|
||||
tracecontext.packaging.tool.window.delete=Deleting Python Package
|
||||
tracecontext.packaging.tool.window.install=Installing Python Package
|
||||
trace.context.detecting.executable=Detecting {0} Executable
|
||||
trace.context.generating.git=Generating git
|
||||
trace.context.packaging.tool.window=Packaging Tool Window
|
||||
trace.context.packages.sdk.controller=Packages SDK Controller
|
||||
trace.context.add.local.python.sdk.dialog=Add Local Python SDK Dialog
|
||||
trace.context.add.remote.python.sdk.dialog=Add {0} Python SDK Dialog
|
||||
trace.context.new.project.wizard=New Project Wizard
|
||||
trace.context.loading.interpreter.list=Loading Interpreter List
|
||||
trace.context.packaging.tool.window.delete=Deleting Python Package
|
||||
trace.context.packaging.tool.window.install=Installing Python Package
|
||||
trace.context.python.tool.detection.service.detect.tools.for.module=Detect Tools for {0}
|
||||
trace.context.py.conda.env.provider.cache.update=Conda Environments Cache Update
|
||||
|
||||
evolution.uv.executable.is.not.found=uv executable is not found
|
||||
evolution.pyproject.toml.file.is.required.for.poetry=pyproject.toml file is required for Poetry
|
||||
|
||||
@@ -27,7 +27,7 @@ class PyV3BaseProjectSettings(var createGitRepository: Boolean = false) {
|
||||
suspend fun generateAndGetSdk(module: Module, baseDir: VirtualFile, supportsNotEmptyModuleStructure: Boolean = false): PyResult<Pair<Sdk, InterpreterStatisticsInfo>> = coroutineScope {
|
||||
val project = module.project
|
||||
if (createGitRepository) {
|
||||
launch(TraceContext(PyBundle.message("tracecontext.generating.git")) + Dispatchers.IO) {
|
||||
launch(TraceContext(PyBundle.message("trace.context.generating.git")) + Dispatchers.IO) {
|
||||
withBackgroundProgress(project, PyBundle.message("new.project.git")) {
|
||||
GitRepositoryInitializer.getInstance()?.initRepository(project, baseDir, true) ?: error("No git service available")
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class PyPackagingToolWindowPanel(private val project: Project) : SimpleToolWindo
|
||||
private val moduleController = PyPackagesSdkController(project)
|
||||
private val descriptionController = PyPackageInfoPanel(project)
|
||||
private val packagingScope = PyPackageCoroutine.getScope(project)
|
||||
.childScope("Packaging tool window", TraceContext(message("tracecontext.packaging.tool.window"), null)).also {
|
||||
.childScope("Packaging tool window", TraceContext(message("trace.context.packaging.tool.window"), null)).also {
|
||||
Disposer.register(this, it.asDisposable())
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -234,7 +234,7 @@ class PyPackagingToolWindowService(val project: Project, val serviceScope: Corou
|
||||
val context = sdkContext ?: return
|
||||
val managerUI = context.managerUI
|
||||
|
||||
withContext(TraceContext(message("tracecontext.packaging.tool.window.install"))) {
|
||||
withContext(TraceContext(message("trace.context.packaging.tool.window.install"))) {
|
||||
PythonPackagesToolwindowStatisticsCollector.installPackageEvent.log(project)
|
||||
managerUI.installPackagesRequestBackground(installRequest, options)?.let {
|
||||
handleActionCompleted(
|
||||
@@ -248,7 +248,7 @@ class PyPackagingToolWindowService(val project: Project, val serviceScope: Corou
|
||||
|
||||
suspend fun installPackage(pkg: PythonPackage, options: List<String> = emptyList()) {
|
||||
val context = sdkContext ?: return
|
||||
withContext(TraceContext(message("tracecontext.packaging.tool.window.install"))) {
|
||||
withContext(TraceContext(message("trace.context.packaging.tool.window.install"))) {
|
||||
val installRequest = context.manager.findPackageSpecification(pkg.name, pkg.version)?.toInstallRequest() ?: return@withContext
|
||||
PythonPackagesToolwindowStatisticsCollector.installPackageEvent.log(project)
|
||||
context.managerUI.installPackagesRequestBackground(installRequest, options)?.let {
|
||||
@@ -265,7 +265,7 @@ class PyPackagingToolWindowService(val project: Project, val serviceScope: Corou
|
||||
val context = sdkContext ?: return
|
||||
val managerUI = context.managerUI
|
||||
|
||||
withContext(TraceContext(message("tracecontext.packaging.tool.window.delete"))) {
|
||||
withContext(TraceContext(message("trace.context.packaging.tool.window.delete"))) {
|
||||
PythonPackagesToolwindowStatisticsCollector.uninstallPackageEvent.log(project)
|
||||
managerUI.uninstallPackagesBackground(selectedPackages.map { it.instance.name }) ?: return@withContext
|
||||
handleActionCompleted(
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import javax.swing.event.ListSelectionListener
|
||||
internal class PyPackagesSdkController(private val project: Project) : Disposable.Default {
|
||||
|
||||
private val packagingScope: CoroutineScope = PyPackageCoroutine.getScope(project)
|
||||
.childScope("Packages SDK Controller", TraceContext(PyBundle.message("tracecontext.packages.sdk.controller"), null)).also {
|
||||
.childScope("Packages SDK Controller", TraceContext(PyBundle.message("trace.context.packages.sdk.controller"), null)).also {
|
||||
Disposer.register(this, it.asDisposable())
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.util.ParameterizedCachedValue
|
||||
import com.intellij.python.pyproject.model.api.ModuleCreateInfo
|
||||
import com.intellij.python.pyproject.model.api.getModuleInfo
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.TraceContext
|
||||
import com.jetbrains.python.run.PythonInterpreterTargetEnvironmentFactory
|
||||
import com.jetbrains.python.run.allowCreationTargetOfThisType
|
||||
import com.jetbrains.python.sdk.ModuleOrProject.ModuleAndProject
|
||||
@@ -48,6 +49,7 @@ import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.util.function.Consumer
|
||||
@@ -201,7 +203,9 @@ private class ToolDetectionService(project: Project, val coroutineScope: Corouti
|
||||
|
||||
private fun detectBestToolAsync(module: Module): CachedValueProvider.Result<Deferred<CreateSdkInfoWithTool?>> {
|
||||
val result = coroutineScope.async {
|
||||
detectBestToolForModule(module)
|
||||
withContext(TraceContext(PyBundle.message("trace.context.python.tool.detection.service.detect.tools.for.module", module.name))) {
|
||||
detectBestToolForModule(module)
|
||||
}
|
||||
}
|
||||
result.invokeOnCompletion { getOrCreateModificationTracker(module).incModificationCount() }
|
||||
return CachedValueProvider.Result.create(result, getOrCreateModificationTracker(module))
|
||||
|
||||
@@ -67,7 +67,7 @@ internal class PythonAddLocalInterpreterDialog(private val dialogPresenter: Pyth
|
||||
mainPanel.setupUI(this, WHEN_PROPERTY_CHANGED(AtomicProperty(basePath)))
|
||||
}
|
||||
|
||||
rootPanel.launchOnShow("PythonAddLocalInterpreterDialog launchOnShow", TraceContext(PyBundle.message("tracecontext.add.local.python.sdk.dialog"), null)) {
|
||||
rootPanel.launchOnShow("PythonAddLocalInterpreterDialog launchOnShow", TraceContext(PyBundle.message("trace.context.add.local.python.sdk.dialog"), null)) {
|
||||
supervisorScope {
|
||||
model.initialize(this@supervisorScope)
|
||||
mainPanel.onShown(this@supervisorScope)
|
||||
|
||||
@@ -158,7 +158,7 @@ internal class PythonSdkPanelBuilderAndSdkCreator(
|
||||
}
|
||||
|
||||
override fun onShownInitialization(scopingComponent: Component) {
|
||||
scopingComponent.launchOnShow("${this::class.java} onShown initialization", TraceContext(message("tracecontext.new.project.wizard"), null)) {
|
||||
scopingComponent.launchOnShow("${this::class.java} onShown initialization", TraceContext(message("trace.context.new.project.wizard"), null)) {
|
||||
initMutex.withLock {
|
||||
supervisorScope {
|
||||
initialize(this@supervisorScope)
|
||||
|
||||
@@ -74,7 +74,7 @@ class ToolValidator<P : PathHolder>(
|
||||
}
|
||||
|
||||
private fun autodetectExecutableJob(): Deferred<Unit> {
|
||||
return scope.async(TraceContext(PyBundle.message("tracecontext.detecting.executable", toolVersionPrefix), scope)) {
|
||||
return scope.async(TraceContext(PyBundle.message("trace.context.detecting.executable", toolVersionPrefix), scope)) {
|
||||
withContext(Dispatchers.EDT) { isDirtyValue.set(true) }
|
||||
val validatedPath = fileSystem.autodetectWithVersionProbe(toolVersionPrefix, defaultPathSupplier)
|
||||
withContext(Dispatchers.EDT) { backProperty.set(validatedPath) }
|
||||
|
||||
@@ -104,7 +104,7 @@ abstract class PythonAddInterpreterModel<P : PathHolder>(
|
||||
modificationCounter.updateAndGet { it + 1 }
|
||||
}.launchIn(scope + Dispatchers.EDT)
|
||||
|
||||
scope.launch(TraceContext(message("tracecontext.loading.interpreter.list"), scope) + Dispatchers.EDT) {
|
||||
scope.launch(TraceContext(message("trace.context.loading.interpreter.list"), scope) + Dispatchers.EDT) {
|
||||
installable = fileSystem.getInstallableInterpreters()
|
||||
val projectPathPrefix = projectPathFlows.projectPathWithDefault.first()
|
||||
val existingSelectableInterpreters = fileSystem.getExistingSelectableInterpreters(projectPathPrefix)
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.intellij.python.community.execService.BinOnEel
|
||||
import com.intellij.python.community.execService.BinOnTarget
|
||||
import com.intellij.python.community.execService.BinaryToExec
|
||||
import com.intellij.python.community.execService.ExecService
|
||||
import com.jetbrains.python.PyBundle
|
||||
import com.jetbrains.python.TraceContext
|
||||
import com.jetbrains.python.errorProcessing.PyResult
|
||||
import com.jetbrains.python.isFailure
|
||||
import com.jetbrains.python.isSuccess
|
||||
@@ -16,6 +18,7 @@ import com.jetbrains.python.sdk.conda.execution.CondaExecutor
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.asExecutor
|
||||
import kotlinx.coroutines.future.asDeferred
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.nio.file.Path
|
||||
import java.util.Locale
|
||||
@@ -38,7 +41,9 @@ class PyCondaEnvProvider(
|
||||
.expireAfterWrite(ttlAfterWrite.toJavaDuration())
|
||||
.buildAsync { binaryToExec ->
|
||||
runBlockingMaybeCancellable {
|
||||
getEnvsInternal(binaryToExec)
|
||||
withContext(TraceContext(PyBundle.message("trace.context.py.conda.env.provider.cache.update"))) {
|
||||
getEnvsInternal(binaryToExec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class PythonLanguageRuntimeUI(
|
||||
dialogPanel.launchOnShow(
|
||||
debugName = "PythonLanguageRuntimeUI launchOnShow",
|
||||
context = TraceContext(
|
||||
title = message("tracecontext.add.remote.python.sdk.dialog", targetEnvironmentConfiguration.getTargetType().displayName),
|
||||
title = message("trace.context.add.remote.python.sdk.dialog", targetEnvironmentConfiguration.getTargetType().displayName),
|
||||
parentTraceContext = null
|
||||
)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user