Make step over for single thread work in Ultimate
(cherry picked from commit a220e64)
This commit is contained in:
committed by
Nikolay Krasko
parent
7992df7b93
commit
40d810ce60
@@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.util.EventDispatcher
|
import com.intellij.util.EventDispatcher
|
||||||
import com.sun.jdi.request.EventRequest
|
import com.sun.jdi.request.EventRequest
|
||||||
import com.sun.jdi.request.StepRequest
|
import com.sun.jdi.request.StepRequest
|
||||||
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
// Mass-copy-paste code for commands behaviour from com.intellij.debugger.engine.DebugProcessImpl
|
// Mass-copy-paste code for commands behaviour from com.intellij.debugger.engine.DebugProcessImpl
|
||||||
@SuppressWarnings("UnnecessaryFinalOnLocalVariableOrParameter")
|
@SuppressWarnings("UnnecessaryFinalOnLocalVariableOrParameter")
|
||||||
@@ -46,25 +47,23 @@ class KotlinStepActionFactory(private val debuggerProcess: DebugProcessImpl) {
|
|||||||
private val session: DebuggerSession get() = debuggerProcess.session
|
private val session: DebuggerSession get() = debuggerProcess.session
|
||||||
|
|
||||||
// TODO: ask for better API
|
// TODO: ask for better API
|
||||||
private val debugProcessDispatcher: EventDispatcher<DebugProcessListener>
|
// Should be safe to use reflection as field is protected and not obfuscated
|
||||||
// Should be safe to use reflection as field is protected and not obfuscated
|
private val debugProcessDispatcher: EventDispatcher<DebugProcessListener> = getFromField("myDebugProcessDispatcher")
|
||||||
get() = getFromField("myDebugProcessDispatcher")
|
|
||||||
|
|
||||||
// TODO: ask for better API
|
// TODO: ask for better API
|
||||||
private val threadBlockedMonitor: ThreadBlockedMonitor
|
// Get field by type as it private and obfuscated in Ultimate
|
||||||
// FIXME: obfuscated in ULTIMATE. Absent in old AS
|
private val threadBlockedMonitor: ThreadBlockedMonitor = getFromField(ThreadBlockedMonitor::class.java)
|
||||||
get() = getFromField("myThreadBlockedMonitor")
|
|
||||||
|
|
||||||
private fun showStatusText(message: String) {
|
private fun showStatusText(message: String) {
|
||||||
debuggerProcess.showStatusText(message)
|
debuggerProcess.showStatusText(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ask for better API
|
// TODO: ask for better API
|
||||||
|
// Should be safe to use reflection as method is protected and not obfuscated
|
||||||
private fun doStep(
|
private fun doStep(
|
||||||
suspendContext: SuspendContextImpl,
|
suspendContext: SuspendContextImpl,
|
||||||
stepThread: ThreadReferenceProxyImpl,
|
stepThread: ThreadReferenceProxyImpl,
|
||||||
size: Int, depth: Int, hint: RequestHint) {
|
size: Int, depth: Int, hint: RequestHint) {
|
||||||
// Should be safe to use reflection as field is protected and not obfuscated
|
|
||||||
val doStepMethod = DebugProcessImpl::class.java.getDeclaredMethod(
|
val doStepMethod = DebugProcessImpl::class.java.getDeclaredMethod(
|
||||||
"doStep",
|
"doStep",
|
||||||
SuspendContextImpl::class.java, ThreadReferenceProxyImpl::class.java,
|
SuspendContextImpl::class.java, ThreadReferenceProxyImpl::class.java,
|
||||||
@@ -75,9 +74,16 @@ class KotlinStepActionFactory(private val debuggerProcess: DebugProcessImpl) {
|
|||||||
doStepMethod.invoke(debuggerProcess, suspendContext, stepThread, size, depth, hint)
|
doStepMethod.invoke(debuggerProcess, suspendContext, stepThread, size, depth, hint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun <T> getFromField(fieldType: Class<T>): T {
|
||||||
|
return getFromField(DebugProcessImpl::class.java.declaredFields.single { it.type == fieldType })
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T> getFromField(fieldName: String): T {
|
private fun <T> getFromField(fieldName: String): T {
|
||||||
val field = DebugProcessImpl::class.java.getDeclaredField(fieldName)
|
return getFromField(DebugProcessImpl::class.java.getDeclaredField(fieldName))
|
||||||
field.isAccessible = true
|
}
|
||||||
|
|
||||||
|
private fun <T> getFromField(field: Field?): T {
|
||||||
|
field!!.isAccessible = true
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return field.get(debuggerProcess) as T
|
return field.get(debuggerProcess) as T
|
||||||
@@ -144,7 +150,6 @@ class KotlinStepActionFactory(private val debuggerProcess: DebugProcessImpl) {
|
|||||||
resumeAction(suspendContext, stepThread)
|
resumeAction(suspendContext, stepThread)
|
||||||
debugProcessDispatcher.multicaster.resumed(suspendContext)
|
debugProcessDispatcher.multicaster.resumed(suspendContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Reference in New Issue
Block a user