Stepping for inline function: filter out inline function body lines from step over
#KT-9665 Fixed
This commit is contained in:
+15
-1
@@ -24,6 +24,7 @@ import com.intellij.debugger.impl.DebuggerContextImpl
|
||||
import com.intellij.debugger.impl.JvmSteppingCommandProvider
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.xdebugger.impl.XSourcePositionImpl
|
||||
import com.sun.jdi.AbsentInformationException
|
||||
import com.sun.jdi.Location
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
@@ -291,10 +292,23 @@ fun getStepOutPosition(
|
||||
): XSourcePositionImpl? {
|
||||
val computedReferenceType = location.declaringType() ?: return null
|
||||
|
||||
fun isLocationSuitable(nextLocation: Location): Boolean {
|
||||
if (nextLocation.method() != location.method() || nextLocation.lineNumber() !in range) {
|
||||
return false
|
||||
}
|
||||
|
||||
return try {
|
||||
nextLocation.sourceName("Kotlin") == file.name
|
||||
}
|
||||
catch(e: AbsentInformationException) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val locations = computedReferenceType.allLineLocations()
|
||||
.dropWhile { it != location }
|
||||
.drop(1)
|
||||
.filter { it.method() == location.method() && it.lineNumber() in range }
|
||||
.filter { isLocationSuitable(it) }
|
||||
.dropWhile { it.lineNumber() == location.lineNumber() }
|
||||
|
||||
for (locationAtLine in locations) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at inlineFunctionSameLines.kt:12
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! inlineFunctionSameLines.InlineFunctionSameLinesKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
inlineFunctionSameLines.kt:12
|
||||
inlineFunctionSameLines.kt:13
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package inlineFunctionSameLines
|
||||
|
||||
inline fun <reified T> myFun(t: T): Int {
|
||||
val a = 1
|
||||
val b = 2
|
||||
val c = 3
|
||||
val d = 4
|
||||
return 1
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package inlineFunctionSameLines
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (1 > 2) {
|
||||
val a = 1
|
||||
}
|
||||
else {
|
||||
val b = 2
|
||||
}
|
||||
|
||||
//Breakpoint!
|
||||
myFun(1)
|
||||
val a = 1
|
||||
}
|
||||
@@ -343,6 +343,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
||||
doStepOverTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionSameLines.kt")
|
||||
public void testInlineFunctionSameLines() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/inlineFunctionSameLines.kt");
|
||||
doStepOverTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("stepOverIfWithInline.kt")
|
||||
public void testStepOverIfWithInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stepOverIfWithInline.kt");
|
||||
|
||||
Reference in New Issue
Block a user