(CoroutineDebugger) Fixed CombinedContext information, default group renamed to empty dispatcher

This commit is contained in:
Vladimir Ilmov
2020-04-19 11:41:42 +02:00
parent 677ca2b9ae
commit 276cf36d6b
5 changed files with 11 additions and 6 deletions
@@ -19,7 +19,7 @@ coroutine.dump.creation.trace=Coroutine creation stack trace
coroutine.dump.threads.loading=Loading…
coroutine.view.title=Coroutines
coroutine.view.default.group=Default group
coroutine.view.dispatcher.empty=Empty dispatcher
coroutine.view.fetching.error=An error occurred on fetching information
coroutine.view.fetching.not_found=No coroutine information found
to.enable.information.breakpoint.suspend.policy.should.be.set.to.all.threads=To enable information breakpoint suspend policy should be set to 'All' threads.
@@ -49,6 +49,10 @@ data class CoroutineInfoData(
}
data class CoroutineNameIdState(val name: String, val id: String, val state: State, val dispatcher: String?) {
fun formatName() =
"$name:$id"
companion object {
fun instance(mirror: MirrorOfCoroutineInfo): CoroutineNameIdState =
CoroutineNameIdState(
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.idea.debugger.evaluate.DefaultExecutionContext
import java.lang.StackTraceElement
class CoroutineContext(context: DefaultExecutionContext) :
BaseMirror<MirrorOfCoroutineContext>("kotlin.coroutines.CoroutineContext", context) {
BaseMirror<MirrorOfCoroutineContext>("kotlin.coroutines.CombinedContext", context) {
val coroutineNameRef = CoroutineName(context)
val coroutineIdRef = CoroutineId(context)
val jobRef = Job(context)
@@ -27,7 +27,8 @@ class CoroutineContext(context: DefaultExecutionContext) :
}
fun <T> getElementValue(value: ObjectReference, context: DefaultExecutionContext, keyProvider: ContextKey<T>): T? {
val elementValue = objectValue(value, getContextElement, context, keyProvider.key() ?: return null) ?: return null
val key = keyProvider.key() ?: return null
val elementValue = objectValue(value, getContextElement, context, key) ?: return null
return keyProvider.mirror(elementValue, context)
}
}
@@ -117,7 +117,7 @@ class SimpleColoredTextIconPresentationRenderer {
val hasChildren = infoData.stackTrace.isNotEmpty() || infoData.creationStackTrace.isNotEmpty()
val label = SimpleColoredTextIcon(icon, hasChildren)
label.append("\"")
label.appendValue(infoData.key.name)
label.appendValue(infoData.key.formatName())
label.append("\": ${infoData.key.state}")
if (name.isNotEmpty()) {
label.append(" on thread \"")
@@ -154,13 +154,13 @@ class XCoroutineView(val project: Project, val session: XDebugSession) :
managerThreadExecutor.on(suspendContext).schedule {
val debugProbesProxy = CoroutineDebugProbesProxy(suspendContext)
val defaultGroupName = KotlinDebuggerCoroutinesBundle.message("coroutine.view.default.group")
val emptyDispatcherName = KotlinDebuggerCoroutinesBundle.message("coroutine.view.dispatcher.empty")
var coroutineCache = debugProbesProxy.dumpCoroutines()
if (coroutineCache.isOk()) {
val children = XValueChildrenList()
var groups = coroutineCache.cache.groupBy { it.key.dispatcher }
for (dispatcher in groups.keys) {
children.add(CoroutineContainer(suspendContext, dispatcher ?: defaultGroupName, groups[dispatcher]))
children.add(CoroutineContainer(suspendContext, dispatcher ?: emptyDispatcherName, groups[dispatcher]))
}
if (children.size() > 0)
node.addChildren(children, true)