mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[python] add TraceContext as a trace tracker for coroutine inner calls
* will be used by the Process Tool Window to show the context of the executed command Merge-request: IJ-MR-176530 Merged-by: Vitaly Legchilkin <Vitaly.Legchilkin@jetbrains.com> GitOrigin-RevId: 70d41845943b5c19b0647ef4711b16f48c53b28c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4b9736eb78
commit
0999615909
@@ -1,3 +1,4 @@
|
||||
python.execution.error={0}\nThe following command finished with error: {1}\nOutput: {2}\nError: {3}\Exit code: {4}
|
||||
python.execution.cant.start.error={0}\nThe following command could not be started: {1}. Error {2} code: {3}
|
||||
python.execution.timeout={0}\nThe following command stopped due to timeout: {1}.
|
||||
tracecontext.non.interactive=Non Interactive
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.currentCoroutineContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import kotlin.coroutines.AbstractCoroutineContextElement
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
@ApiStatus.Internal
|
||||
class TraceContext(
|
||||
val title: @Nls String,
|
||||
val parentTraceContext: TraceContext?,
|
||||
) : AbstractCoroutineContextElement(TraceContext) {
|
||||
val timestamp: Long = System.currentTimeMillis()
|
||||
|
||||
constructor(title: @Nls String, coroutineScope: CoroutineScope): this(title, coroutineScope.coroutineContext[Key])
|
||||
|
||||
override fun toString(): String = "TraceContext($title, $timestamp)\n\t-> $parentTraceContext"
|
||||
|
||||
/**
|
||||
* Key for [TraceContext] instance in the coroutine context.
|
||||
*/
|
||||
companion object Key : CoroutineContext.Key<TraceContext> {
|
||||
suspend operator fun invoke(title: @Nls String): TraceContext {
|
||||
val parent = currentCoroutineContext()[Key]
|
||||
return TraceContext(title, parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
val NON_INTERACTIVE_ROOT_TRACE_CONTEXT: TraceContext = TraceContext(PyCommunityBundle.message("tracecontext.non.interactive"), null)
|
||||
Reference in New Issue
Block a user