Debugger: ability to set breakpoint to lambda in return statement (KT-14615)
#KT-14615 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
730e561177
commit
01d4ec4187
@@ -142,13 +142,14 @@ fun getLambdasAtLineIfAny(file: KtFile, line: Int): List<KtFunction> {
|
||||
val start = topMostElement.startOffset
|
||||
val end = topMostElement.endOffset
|
||||
|
||||
val allInlineFunctionCalls = CodeInsightUtils.
|
||||
val allLiterals = CodeInsightUtils.
|
||||
findElementsOfClassInRange(file, start, end, KtFunction::class.java)
|
||||
.filter { KtPsiUtil.getParentCallIfPresent(it as KtExpression) != null }
|
||||
.filterIsInstance<KtFunction>()
|
||||
// filter function literals and functional expressions
|
||||
.filter { it is KtFunctionLiteral || it.name == null }
|
||||
.toSet()
|
||||
|
||||
return allInlineFunctionCalls.filter {
|
||||
return allLiterals.filter {
|
||||
val statement = (it.bodyExpression as? KtBlockExpression)?.statements?.firstOrNull() ?: it
|
||||
statement.getLineNumber() == line && statement.getLineNumber(false) == line
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ class A {
|
||||
fun foo() {
|
||||
val a = {
|
||||
fun innerFoo() {
|
||||
val b = {} // A\$foo\$a\$1\$1
|
||||
val b = 1 // A\$foo\$a\$1\$1
|
||||
}
|
||||
innerFoo()
|
||||
}()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at lambdaOnReturn.kt:14 lambdaOrdinal = 1
|
||||
!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! lambdaOnReturn.LambdaOnReturnKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
lambdaOnReturn.kt:14
|
||||
Compile bytecode for y
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package lambdaOnReturn
|
||||
|
||||
// KT-14615
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val f1 = MyClass()
|
||||
f1(1)
|
||||
}
|
||||
|
||||
fun MyClass(): (Int) -> String {
|
||||
// EXPRESSION: y
|
||||
// RESULT: 1: I
|
||||
//Breakpoint! (lambdaOrdinal = 1)
|
||||
return { y: Int -> y.toString() }
|
||||
}
|
||||
+6
@@ -814,6 +814,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaOnReturn.kt")
|
||||
public void testLambdaOnReturn() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/lambdaOnReturn.kt");
|
||||
doSingleBreakpointTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaOnSecondLine.kt")
|
||||
public void testLambdaOnSecondLine() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/lambdaOnSecondLine.kt");
|
||||
|
||||
Reference in New Issue
Block a user