From a303c8a2f6c0c9913bbb5f201872fc1db755680a Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Mon, 5 Oct 2015 17:16:45 +0300 Subject: [PATCH] Debugger, stepping: first check that source position is in kotlin file --- .../stepping/KotlinSteppingCommandProvider.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index 382b90d7fb9..268ce130c27 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -51,13 +51,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { ): DebugProcessImpl.ResumeCommand? { if (suspendContext == null || suspendContext.isResumed) return null - val location = computeInManagerThread(suspendContext) { - it.safeFrameProxy?.location() - } ?: return null - - val sourcePosition = suspendContext.debugProcess.positionManager.getSourcePosition(location) ?: return null - val computedReferenceType = location.declaringType() ?: return null - + val sourcePosition = suspendContext.debugProcess.debuggerContext.sourcePosition ?: return null val file = sourcePosition.file as? JetFile ?: return null val inlineFunctionCalls = getInlineFunctionCallsIfAny(sourcePosition) @@ -69,6 +63,12 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { return null } + val location = computeInManagerThread(suspendContext) { + it.safeFrameProxy?.location() + } ?: return null + + val computedReferenceType = location.declaringType() ?: return null + val additionalElementsToSkip = sourcePosition.elementAt.getAdditionalElementsToSkip() val containingFunction = sourcePosition.elementAt.getParentOfType(false) @@ -184,26 +184,30 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() { override fun getStepOutCommand(suspendContext: SuspendContextImpl?, stepSize: Int): DebugProcessImpl.ResumeCommand? { if (suspendContext == null || suspendContext.isResumed) return null + val sourcePosition = suspendContext.debugProcess.debuggerContext.sourcePosition ?: return null + val file = sourcePosition.file as? JetFile ?: return null + + val lineStartOffset = file.getLineStartOffset(sourcePosition.line) ?: return null + + val inlineFunctions = getInlineFunctionsIfAny(file, lineStartOffset) + val inlinedArgument = getInlineArgumentIfAny(file, lineStartOffset) + + if (inlineFunctions.isEmpty() && inlinedArgument == null) return null + val location = computeInManagerThread(suspendContext) { it.safeFrameProxy?.location() } ?: return null - val sourcePosition = suspendContext.debugProcess.positionManager.getSourcePosition(location) ?: return null val computedReferenceType = location.declaringType() ?: return null val locations = computedReferenceType.allLineLocations() - - val file = sourcePosition.file as? JetFile ?: return null - val lineStartOffset = file.getLineStartOffset(sourcePosition.line) ?: return null val nextLineLocations = locations.dropWhile { it.lineNumber() != location.lineNumber() }.filter { it.method() == location.method() } - val inlineFunction = getInlineFunctionsIfAny(file, lineStartOffset) - if (inlineFunction.isNotEmpty()) { - val xPosition = suspendContext.getXPositionForStepOutFromInlineFunction(nextLineLocations, inlineFunction) ?: return null + if (inlineFunctions.isNotEmpty()) { + val xPosition = suspendContext.getXPositionForStepOutFromInlineFunction(nextLineLocations, inlineFunctions) ?: return null return suspendContext.debugProcess.createRunToCursorCommand(suspendContext, xPosition, true) } - val inlinedArgument = getInlineArgumentIfAny(file, lineStartOffset) if (inlinedArgument != null) { val xPosition = suspendContext.getXPositionForStepOutFromInlinedArgument(nextLineLocations, inlinedArgument) ?: return null return suspendContext.debugProcess.createRunToCursorCommand(suspendContext, xPosition, true)