Delegate step into command to kotlin command provider first

This commit is contained in:
Nikolay Krasko
2017-03-23 18:52:55 +03:00
parent 2c4f702d50
commit dfd7b0f388
@@ -43,6 +43,7 @@ import com.intellij.psi.search.FilenameIndex
import com.intellij.xdebugger.XDebuggerManager import com.intellij.xdebugger.XDebuggerManager
import com.intellij.xdebugger.XDebuggerUtil import com.intellij.xdebugger.XDebuggerUtil
import com.intellij.xdebugger.breakpoints.* import com.intellij.xdebugger.breakpoints.*
import com.sun.jdi.request.StepRequest
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties
import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinFieldBreakpoint import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinFieldBreakpoint
@@ -70,6 +71,9 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
protected var _debuggerContext: DebuggerContextImpl? = null protected var _debuggerContext: DebuggerContextImpl? = null
protected val debuggerContext get() = _debuggerContext!! protected val debuggerContext get() = _debuggerContext!!
protected var _commandProvider: KotlinSteppingCommandProvider? = KotlinSteppingCommandProvider()
protected val commandProvider get() = _commandProvider!!
override fun initApplication() { override fun initApplication() {
super.initApplication() super.initApplication()
saveDefaultSettings() saveDefaultSettings()
@@ -82,6 +86,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
_evaluationContext = null _evaluationContext = null
_debuggerContext = null _debuggerContext = null
_commandProvider = null
} }
protected fun configureSettings(fileText: String) { protected fun configureSettings(fileText: String) {
@@ -148,17 +153,20 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
} }
protected fun SuspendContextImpl.doStepInto(ignoreFilters: Boolean, smartStepFilter: MethodFilter?) { protected fun SuspendContextImpl.doStepInto(ignoreFilters: Boolean, smartStepFilter: MethodFilter?) {
dp.managerThread!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, smartStepFilter)) val stepIntoCommand = runReadAction {
commandProvider.getStepIntoCommand(this, ignoreFilters, smartStepFilter, StepRequest.STEP_LINE)
} ?: dp.createStepIntoCommand(this, ignoreFilters, smartStepFilter)
dp.managerThread.schedule(stepIntoCommand)
} }
protected fun SuspendContextImpl.doStepOut() { protected fun SuspendContextImpl.doStepOut() {
val stepOutCommand = runReadAction { KotlinSteppingCommandProvider().getStepOutCommand(this, debuggerContext) } val stepOutCommand = runReadAction { commandProvider.getStepOutCommand(this, debuggerContext) }
?: dp.createStepOutCommand(this) ?: dp.createStepOutCommand(this)
dp.managerThread.schedule(stepOutCommand) dp.managerThread.schedule(stepOutCommand)
} }
protected fun SuspendContextImpl.doStepOver() { protected fun SuspendContextImpl.doStepOver() {
val stepOverCommand = runReadAction { KotlinSteppingCommandProvider().getStepOverCommand(this, false, debuggerContext) } val stepOverCommand = runReadAction { commandProvider.getStepOverCommand(this, false, debuggerContext) }
?: dp.createStepOverCommand(this, false) ?: dp.createStepOverCommand(this, false)
dp.managerThread.schedule(stepOverCommand) dp.managerThread.schedule(stepOverCommand)
} }
@@ -180,7 +188,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
when { when {
!line.startsWith("//") -> return !line.startsWith("//") -> return
line.startsWith("// STEP_INTO: ") -> repeat("// STEP_INTO: ") { stepInto(this) } line.startsWith("// STEP_INTO: ") -> repeat("// STEP_INTO: ") { doStepInto(false, null) }
line.startsWith("// STEP_OUT: ") -> repeat("// STEP_OUT: ") { doStepOut() } line.startsWith("// STEP_OUT: ") -> repeat("// STEP_OUT: ") { doStepOut() }
line.startsWith("// STEP_OVER: ") -> repeat("// STEP_OVER: ") { doStepOver() } line.startsWith("// STEP_OVER: ") -> repeat("// STEP_OVER: ") { doStepOver() }
line.startsWith("// SMART_STEP_INTO_BY_INDEX: ") -> doOnBreakpoint { doSmartStepInto(InTextDirectivesUtils.getPrefixedInt(line, "// SMART_STEP_INTO_BY_INDEX: ")!!) } line.startsWith("// SMART_STEP_INTO_BY_INDEX: ") -> doOnBreakpoint { doSmartStepInto(InTextDirectivesUtils.getPrefixedInt(line, "// SMART_STEP_INTO_BY_INDEX: ")!!) }