Debugger, minor: Move Action to its own file, rename to KotlinStepAction
This commit is contained in:
+2
-2
@@ -58,7 +58,7 @@ public class DebuggerSteppingHelper {
|
|||||||
try {
|
try {
|
||||||
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
||||||
if (frameProxy != null) {
|
if (frameProxy != null) {
|
||||||
Action action = KotlinSteppingCommandProviderKt
|
KotlinStepAction action = KotlinSteppingCommandProviderKt
|
||||||
.getStepOverAction(frameProxy.location(), kotlinSourcePosition, frameProxy);
|
.getStepOverAction(frameProxy.location(), kotlinSourcePosition, frameProxy);
|
||||||
|
|
||||||
createStepRequest(
|
createStepRequest(
|
||||||
@@ -112,7 +112,7 @@ public class DebuggerSteppingHelper {
|
|||||||
try {
|
try {
|
||||||
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
||||||
if (frameProxy != null) {
|
if (frameProxy != null) {
|
||||||
Action action = KotlinSteppingCommandProviderKt.getStepOutAction(
|
KotlinStepAction action = KotlinSteppingCommandProviderKt.getStepOutAction(
|
||||||
frameProxy.location(),
|
frameProxy.location(),
|
||||||
suspendContext,
|
suspendContext,
|
||||||
inlineFunctions,
|
inlineFunctions,
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.debugger.stepping
|
||||||
|
|
||||||
|
import com.intellij.debugger.engine.DebugProcessImpl
|
||||||
|
import com.intellij.debugger.engine.SuspendContextImpl
|
||||||
|
import com.intellij.xdebugger.impl.XSourcePositionImpl
|
||||||
|
import org.jetbrains.kotlin.idea.debugger.stepping.filter.KotlinStepOverInlineFilter
|
||||||
|
import org.jetbrains.kotlin.idea.debugger.stepping.filter.StepOverFilterData
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
|
|
||||||
|
sealed class KotlinStepAction(
|
||||||
|
val position: XSourcePositionImpl? = null,
|
||||||
|
val stepOverInlineData: StepOverFilterData? = null
|
||||||
|
) {
|
||||||
|
class StepOver : KotlinStepAction() {
|
||||||
|
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
|
||||||
|
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction(suspendContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
class StepOut : KotlinStepAction() {
|
||||||
|
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
|
||||||
|
debugProcess.createStepOutCommand(suspendContext).contextAction(suspendContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunToCursor(position: XSourcePositionImpl) : KotlinStepAction(position) {
|
||||||
|
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) {
|
||||||
|
return runReadAction {
|
||||||
|
debugProcess.createRunToCursorCommand(suspendContext, position!!, ignoreBreakpoints)
|
||||||
|
}.contextAction(suspendContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StepOverInlined(stepOverInlineData: StepOverFilterData) : KotlinStepAction(stepOverInlineData = stepOverInlineData) {
|
||||||
|
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) {
|
||||||
|
return KotlinStepActionFactory(debugProcess).createKotlinStepOverInlineAction(
|
||||||
|
KotlinStepOverInlineFilter(debugProcess.project, stepOverInlineData!!)
|
||||||
|
).contextAction(suspendContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean)
|
||||||
|
}
|
||||||
+11
-44
@@ -235,44 +235,11 @@ private fun findCallsOnPosition(sourcePosition: SourcePosition, filter: (KtCallE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Action(
|
|
||||||
val position: XSourcePositionImpl? = null,
|
|
||||||
val stepOverInlineData: StepOverFilterData? = null
|
|
||||||
) {
|
|
||||||
class StepOver : Action() {
|
|
||||||
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
|
|
||||||
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction(suspendContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
class StepOut : Action() {
|
|
||||||
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
|
|
||||||
debugProcess.createStepOutCommand(suspendContext).contextAction(suspendContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
class RunToCursor(position: XSourcePositionImpl) : Action(position) {
|
|
||||||
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) {
|
|
||||||
return runReadAction {
|
|
||||||
debugProcess.createRunToCursorCommand(suspendContext, position!!, ignoreBreakpoints)
|
|
||||||
}.contextAction(suspendContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StepOverInlined(stepOverInlineData: StepOverFilterData) : Action(stepOverInlineData = stepOverInlineData) {
|
|
||||||
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) {
|
|
||||||
return KotlinStepActionFactory(debugProcess).createKotlinStepOverInlineAction(
|
|
||||||
KotlinStepOverInlineFilter(debugProcess.project, stepOverInlineData!!)
|
|
||||||
).contextAction(suspendContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean)
|
|
||||||
}
|
|
||||||
|
|
||||||
interface KotlinMethodFilter : MethodFilter {
|
interface KotlinMethodFilter : MethodFilter {
|
||||||
fun locationMatches(context: SuspendContextImpl, location: Location): Boolean
|
fun locationMatches(context: SuspendContextImpl, location: Location): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStepOverAction(location: Location, kotlinSourcePosition: KotlinSourcePosition, frameProxy: StackFrameProxyImpl): Action {
|
fun getStepOverAction(location: Location, kotlinSourcePosition: KotlinSourcePosition, frameProxy: StackFrameProxyImpl): KotlinStepAction {
|
||||||
val inlineArgumentsToSkip = runReadAction {
|
val inlineArgumentsToSkip = runReadAction {
|
||||||
getInlineCallFunctionArgumentsIfAny(kotlinSourcePosition.sourcePosition)
|
getInlineCallFunctionArgumentsIfAny(kotlinSourcePosition.sourcePosition)
|
||||||
}
|
}
|
||||||
@@ -289,12 +256,12 @@ fun getStepOverAction(
|
|||||||
range: IntRange,
|
range: IntRange,
|
||||||
inlineFunctionArguments: List<KtElement>,
|
inlineFunctionArguments: List<KtElement>,
|
||||||
frameProxy: StackFrameProxyImpl
|
frameProxy: StackFrameProxyImpl
|
||||||
): Action {
|
): KotlinStepAction {
|
||||||
location.declaringType() ?: return Action.StepOver()
|
location.declaringType() ?: return KotlinStepAction.StepOver()
|
||||||
|
|
||||||
val methodLocations = location.method().safeAllLineLocations()
|
val methodLocations = location.method().safeAllLineLocations()
|
||||||
if (methodLocations.isEmpty()) {
|
if (methodLocations.isEmpty()) {
|
||||||
return Action.StepOver()
|
return KotlinStepAction.StepOver()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isThisMethodLocation(nextLocation: Location): Boolean {
|
fun isThisMethodLocation(nextLocation: Location): Boolean {
|
||||||
@@ -364,7 +331,7 @@ fun getStepOverAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stepOverLocations.isNotEmpty()) {
|
if (stepOverLocations.isNotEmpty()) {
|
||||||
return Action.StepOverInlined(
|
return KotlinStepAction.StepOverInlined(
|
||||||
StepOverFilterData(
|
StepOverFilterData(
|
||||||
patchedLineNumber,
|
patchedLineNumber,
|
||||||
stepOverLocations.map { it.lineNumber() }.toSet(),
|
stepOverLocations.map { it.lineNumber() }.toSet(),
|
||||||
@@ -373,7 +340,7 @@ fun getStepOverAction(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Action.StepOver()
|
return KotlinStepAction.StepOver()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStepOutAction(
|
fun getStepOutAction(
|
||||||
@@ -381,8 +348,8 @@ fun getStepOutAction(
|
|||||||
suspendContext: SuspendContextImpl,
|
suspendContext: SuspendContextImpl,
|
||||||
inlineFunctions: List<KtNamedFunction>,
|
inlineFunctions: List<KtNamedFunction>,
|
||||||
inlinedArgument: KtFunctionLiteral?
|
inlinedArgument: KtFunctionLiteral?
|
||||||
): Action {
|
): KotlinStepAction {
|
||||||
val computedReferenceType = location.declaringType() ?: return Action.StepOut()
|
val computedReferenceType = location.declaringType() ?: return KotlinStepAction.StepOut()
|
||||||
|
|
||||||
val locations = computedReferenceType.safeAllLineLocations()
|
val locations = computedReferenceType.safeAllLineLocations()
|
||||||
val nextLineLocations = locations
|
val nextLineLocations = locations
|
||||||
@@ -393,15 +360,15 @@ fun getStepOutAction(
|
|||||||
|
|
||||||
if (inlineFunctions.isNotEmpty()) {
|
if (inlineFunctions.isNotEmpty()) {
|
||||||
val position = suspendContext.getXPositionForStepOutFromInlineFunction(nextLineLocations, inlineFunctions)
|
val position = suspendContext.getXPositionForStepOutFromInlineFunction(nextLineLocations, inlineFunctions)
|
||||||
return position?.let { Action.RunToCursor(it) } ?: Action.StepOver()
|
return position?.let { KotlinStepAction.RunToCursor(it) } ?: KotlinStepAction.StepOver()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlinedArgument != null) {
|
if (inlinedArgument != null) {
|
||||||
val position = suspendContext.getXPositionForStepOutFromInlinedArgument(nextLineLocations, inlinedArgument)
|
val position = suspendContext.getXPositionForStepOutFromInlinedArgument(nextLineLocations, inlinedArgument)
|
||||||
return position?.let { Action.RunToCursor(it) } ?: Action.StepOver()
|
return position?.let { KotlinStepAction.RunToCursor(it) } ?: KotlinStepAction.StepOver()
|
||||||
}
|
}
|
||||||
|
|
||||||
return Action.StepOver()
|
return KotlinStepAction.StepOver()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SuspendContextImpl.getXPositionForStepOutFromInlineFunction(
|
private fun SuspendContextImpl.getXPositionForStepOutFromInlineFunction(
|
||||||
|
|||||||
Reference in New Issue
Block a user