(CoroutineDebugger) Minor fixes, kotlinx.coroutines version fix

This commit is contained in:
Vladimir Ilmov
2020-04-20 16:32:29 +02:00
parent 0ce8ca7bcd
commit 73f5e48518
22 changed files with 197 additions and 179 deletions
@@ -7,7 +7,9 @@ package org.jetbrains.kotlin.idea.debugger
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.engine.DebuggerManagerThreadImpl
import com.intellij.debugger.engine.SuspendContextImpl
import com.intellij.debugger.engine.events.DebuggerCommandImpl
import com.intellij.debugger.engine.events.SuspendContextCommandImpl
import com.intellij.debugger.impl.DebuggerContextImpl
import com.intellij.psi.PsiElement
import com.sun.jdi.*
@@ -84,6 +86,24 @@ fun <T : Any> DebugProcessImpl.invokeInManagerThread(f: (DebuggerContextImpl) ->
return result
}
fun <T : Any> SuspendContextImpl.invokeInSuspendManagerThread(debugProcessImpl: DebugProcessImpl, f: (SuspendContextImpl) -> T?): T? {
var result: T? = null
val command: SuspendContextCommandImpl = object : SuspendContextCommandImpl(this) {
override fun contextAction() {
result = runReadAction { f(this@invokeInSuspendManagerThread) }
}
}
when {
DebuggerManagerThreadImpl.isManagerThread() ->
debugProcessImpl.managerThread.invoke(command)
else ->
debugProcessImpl.managerThread.invokeAndWait(command)
}
return result
}
private fun lambdaOrdinalByArgument(elementAt: KtFunction, context: BindingContext): Int {
val type = asmTypeForAnonymousClass(context, elementAt)
return type.className.substringAfterLast("$").toInt()