Debugger: Rewrite step over action (KT-14296)

The main goal is to make behavior similar to what happens in Java. For instance, now we always skip lambdas.
Also, we can reliably use '$i$f' and '$i$a' synthetic local variables. There is no need in complicated hacks any more.
This commit is contained in:
Yan Zhulanow
2019-11-22 16:11:51 +09:00
parent b7449c2d6e
commit 8f29f8bc9d
26 changed files with 206 additions and 305 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.idea.debugger
import com.intellij.debugger.engine.DebugProcess.JAVA_STRATUM
import com.intellij.debugger.engine.evaluation.AbsentInformationEvaluateException
import com.intellij.debugger.engine.evaluation.EvaluateException
import com.intellij.debugger.engine.jdi.StackFrameProxy
@@ -12,6 +13,7 @@ import com.intellij.debugger.impl.DebuggerUtilsEx
import com.intellij.debugger.jdi.LocalVariableProxyImpl
import com.intellij.debugger.jdi.StackFrameProxyImpl
import com.sun.jdi.*
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
fun StackFrameProxyImpl.safeVisibleVariables(): List<LocalVariableProxyImpl> {
return wrapAbsentInformationException { visibleVariables() } ?: emptyList()
@@ -21,6 +23,10 @@ fun StackFrameProxyImpl.safeVisibleVariableByName(name: String): LocalVariablePr
return wrapAbsentInformationException { visibleVariableByName(name) }
}
fun StackFrame.safeVisibleVariables(): List<LocalVariable> {
return wrapAbsentInformationException { visibleVariables() } ?: emptyList()
}
fun Method.safeAllLineLocations(): List<Location> {
return DebuggerUtilsEx.allLineLocations(this) ?: emptyList()
}
@@ -61,6 +67,14 @@ fun StackFrameProxy.safeLocation(): Location? {
}
}
fun StackFrameProxy.safeStackFrame(): StackFrame? {
return try {
this.stackFrame
} catch (e: EvaluateException) {
null
}
}
fun Location.safeSourceName(): String? {
return wrapAbsentInformationException { this.sourceName() }
}
@@ -73,8 +87,23 @@ fun Location.safeLineNumber(): Int {
return DebuggerUtilsEx.getLineNumber(this, false)
}
fun Location.safeSourceLineNumber(): Int {
return DebuggerUtilsEx.getLineNumber(this, true)
fun Location.safeLineNumber(stratum: String): Int {
return try {
lineNumber(stratum)
} catch (e: InternalError) {
-1
} catch (e: IllegalArgumentException) {
-1
}
}
fun Location.safeKotlinPreferredLineNumber(): Int {
val kotlinLineNumber = safeLineNumber(KOTLIN_STRATA_NAME)
if (kotlinLineNumber > 0) {
return kotlinLineNumber
}
return safeLineNumber(JAVA_STRATUM)
}
fun Location.safeMethod(): Method? {