Skip to content

Commit 60e3c8e

Browse files
committed
Make breakpoints work in local functions in secondary constructors
1 parent 1889f4f commit 60e3c8e

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ class DebuggerClassNameProvider(val myDebugProcess: DebugProcess, val scopes: Li
216216
KtNamedFunction::class.java,
217217
KtPropertyAccessor::class.java,
218218
KtProperty::class.java,
219-
KtClassInitializer::class.java)
219+
KtClassInitializer::class.java,
220+
KtSecondaryConstructor::class.java)
220221

221222
private fun getElementToCalculateClassName(notPositionedElement: PsiElement?): KtElement? {
222223
if (notPositionedElement?.javaClass as Class<*> in TYPES_TO_CALCULATE_CLASSNAME) return notPositionedElement as KtElement
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LineBreakpoint created at stopInLocalFunInSecondaryConstructor.kt:7
2+
!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! stopInLocalFunInSecondaryConstructor.StopInLocalFunInSecondaryConstructorKt
3+
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
4+
stopInLocalFunInSecondaryConstructor.kt:7
5+
stopInLocalFunInSecondaryConstructor.kt:8
6+
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
7+
8+
Process finished with exit code 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LineBreakpoint created at stopInlineCallInLocalFunInSecondaryConstructor.kt:8
2+
!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! stopInlineCallInLocalFunInSecondaryConstructor.StopInlineCallInLocalFunInSecondaryConstructorKt
3+
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
4+
stopInlineCallInLocalFunInSecondaryConstructor.kt:8
5+
stopInlineCallInLocalFunInSecondaryConstructor.kt:9
6+
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
7+
8+
Process finished with exit code 0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package stopInLocalFunInSecondaryConstructor
2+
3+
class Foo(bar: Any) {
4+
constructor() : this(12) {
5+
fun some() {
6+
//Breakpoint!
7+
nop()
8+
nop()
9+
}
10+
11+
some()
12+
}
13+
14+
fun nop() {}
15+
}
16+
17+
fun main(args: Array<String>) {
18+
Foo()
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package stopInlineCallInLocalFunInSecondaryConstructor
2+
3+
class Foo(bar: Any) {
4+
constructor() : this(12) {
5+
fun test() {
6+
inlineFun {
7+
//Breakpoint!
8+
nop()
9+
nop()
10+
}
11+
}
12+
13+
test()
14+
}
15+
16+
fun nop() {}
17+
}
18+
19+
fun main(args: Array<String>) {
20+
Foo()
21+
}
22+
23+
inline fun inlineFun(f: () -> Any) {
24+
f()
25+
}

idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,12 @@ public void testStopInLambdaInlineCallLambda() throws Exception {
752752
doStepOverTest(fileName);
753753
}
754754

755+
@TestMetadata("stopInLocalFunInSecondaryConstructor.kt")
756+
public void testStopInLocalFunInSecondaryConstructor() throws Exception {
757+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt");
758+
doStepOverTest(fileName);
759+
}
760+
755761
@TestMetadata("stopInLocalFunInlineCallLambda.kt")
756762
public void testStopInLocalFunInlineCallLambda() throws Exception {
757763
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInlineCallLambda.kt");
@@ -781,6 +787,12 @@ public void testStopInObjectLiteralInInlineCallWithClosure() throws Exception {
781787
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosure.kt");
782788
doStepOverTest(fileName);
783789
}
790+
791+
@TestMetadata("stopInlineCallInLocalFunInSecondaryConstructor.kt")
792+
public void testStopInlineCallInLocalFunInSecondaryConstructor() throws Exception {
793+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt");
794+
doStepOverTest(fileName);
795+
}
784796
}
785797

786798
@TestMetadata("idea/testData/debugger/tinyApp/src/stepping/filters")

0 commit comments

Comments
 (0)