(CoroutineDebugger) Local variables should have precedence over restored.

This commit is contained in:
Vladimir Ilmov
2020-05-12 11:12:00 +02:00
parent f19f49711c
commit 5a5c1c3420
3 changed files with 19 additions and 27 deletions
@@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.debugger.coroutine.data
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.engine.JVMStackFrameInfoProvider
import com.intellij.debugger.impl.DebuggerContextImpl
import com.intellij.debugger.jdi.LocalVariableProxyImpl
import com.intellij.debugger.jdi.StackFrameProxyImpl
import com.intellij.debugger.memory.utils.StackFrameItem
@@ -33,18 +34,16 @@ class CoroutinePreflightStackFrame(
private val firstFrameVariables: List<XNamedValue> = coroutineInfoData.topFrameVariables()
) : KotlinStackFrame(stackFrameDescriptorImpl), JVMStackFrameInfoProvider {
override fun computeChildren(node: XCompositeNode) {
val childrenList = XValueChildrenList()
firstFrameVariables.forEach {
childrenList.add(it)
override fun buildVariablesThreadAction(debuggerContext: DebuggerContextImpl?, children: XValueChildrenList?, node: XCompositeNode?) {
super.buildVariablesThreadAction(debuggerContext, children, node)
// add vars from first restored frame if no local vars found
children?.let {
val varNames = (0 until children.size()).map { children.getName(it) }.toSet()
firstFrameVariables.forEach {
if (!varNames.contains(it.name))
children.add(it)
}
}
node.addChildren(childrenList, false)
super.computeChildren(node)
}
override fun getVisibleVariables(): List<LocalVariableProxyImpl> {
// skip restored variables
return super.getVisibleVariables().filter { v -> !firstFrameVariables.any { it.name == v.name() } }
}
override fun isInLibraryContent() = false
@@ -133,7 +133,13 @@ class CoroutineFrameBuilder {
val continuationHolder = ContinuationHolder.instance(context)
val coroutineInfo = continuationHolder.extractCoroutineInfoData(continuation) ?: return null
return preflight(frame, theFollowingFrames, coroutineInfo, mode)
val descriptor = StackFrameDescriptorImpl(frame, MethodsTracker())
return CoroutinePreflightStackFrame(
coroutineInfo,
descriptor,
theFollowingFrames,
mode
)
}
return null
}
@@ -148,21 +154,6 @@ class CoroutineFrameBuilder {
return null
}
private fun preflight(
frame: StackFrameProxyImpl,
framesLeft: List<StackFrameProxyImpl>,
coroutineInfoData: CoroutineInfoData,
mode: SuspendExitMode
): CoroutinePreflightStackFrame? {
val descriptor = StackFrameDescriptorImpl(frame, MethodsTracker())
return CoroutinePreflightStackFrame(
coroutineInfoData,
descriptor,
framesLeft,
mode
)
}
private fun getLVTContinuation(frame: StackFrameProxyImpl?) =
frame?.continuationVariableValue()
@@ -31,6 +31,7 @@ import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree
import com.intellij.xdebugger.impl.ui.tree.nodes.*
import org.jetbrains.kotlin.idea.debugger.KotlinFrameExtraVariablesProvider
import org.jetbrains.kotlin.idea.debugger.coroutine.data.ContinuationValueDescriptorImpl
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory
import org.jetbrains.kotlin.idea.debugger.invokeInManagerThread
import org.jetbrains.kotlin.idea.debugger.test.KOTLIN_LIBRARY_NAME
@@ -274,6 +275,7 @@ private class Printer(private val delegate: FramePrinterDelegate, private val co
is ThisDescriptorImpl -> "this"
is FieldDescriptor -> "field"
is ArrayElementDescriptor -> "element"
is ContinuationValueDescriptorImpl -> "cont"
is MessageDescriptor -> ""
else -> "unknown"
}