From 60e3c8eecd9e600f02e4ba4e92b2a3bc2e474896 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 22 Nov 2016 17:40:52 +0300 Subject: [PATCH] Make breakpoints work in local functions in secondary constructors --- .../debugger/DebuggerClassNameProvider.kt | 3 ++- .../stopInLocalFunInSecondaryConstructor.out | 8 ++++++ ...neCallInLocalFunInSecondaryConstructor.out | 8 ++++++ .../stopInLocalFunInSecondaryConstructor.kt | 19 ++++++++++++++ ...ineCallInLocalFunInSecondaryConstructor.kt | 25 +++++++++++++++++++ .../debugger/KotlinSteppingTestGenerated.java | 12 +++++++++ 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 idea/testData/debugger/tinyApp/outs/stopInLocalFunInSecondaryConstructor.out create mode 100644 idea/testData/debugger/tinyApp/outs/stopInlineCallInLocalFunInSecondaryConstructor.out create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt create mode 100644 idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt index cff44ea3622..0adfd446246 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt @@ -216,7 +216,8 @@ class DebuggerClassNameProvider(val myDebugProcess: DebugProcess, val scopes: Li KtNamedFunction::class.java, KtPropertyAccessor::class.java, KtProperty::class.java, - KtClassInitializer::class.java) + KtClassInitializer::class.java, + KtSecondaryConstructor::class.java) private fun getElementToCalculateClassName(notPositionedElement: PsiElement?): KtElement? { if (notPositionedElement?.javaClass as Class<*> in TYPES_TO_CALCULATE_CLASSNAME) return notPositionedElement as KtElement diff --git a/idea/testData/debugger/tinyApp/outs/stopInLocalFunInSecondaryConstructor.out b/idea/testData/debugger/tinyApp/outs/stopInLocalFunInSecondaryConstructor.out new file mode 100644 index 00000000000..609b9f0c286 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/stopInLocalFunInSecondaryConstructor.out @@ -0,0 +1,8 @@ +LineBreakpoint created at stopInLocalFunInSecondaryConstructor.kt:7 +!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 +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +stopInLocalFunInSecondaryConstructor.kt:7 +stopInLocalFunInSecondaryConstructor.kt:8 +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/outs/stopInlineCallInLocalFunInSecondaryConstructor.out b/idea/testData/debugger/tinyApp/outs/stopInlineCallInLocalFunInSecondaryConstructor.out new file mode 100644 index 00000000000..0afad327afd --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/stopInlineCallInLocalFunInSecondaryConstructor.out @@ -0,0 +1,8 @@ +LineBreakpoint created at stopInlineCallInLocalFunInSecondaryConstructor.kt:8 +!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 +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +stopInlineCallInLocalFunInSecondaryConstructor.kt:8 +stopInlineCallInLocalFunInSecondaryConstructor.kt:9 +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt new file mode 100644 index 00000000000..95f974baa0a --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt @@ -0,0 +1,19 @@ +package stopInLocalFunInSecondaryConstructor + +class Foo(bar: Any) { + constructor() : this(12) { + fun some() { + //Breakpoint! + nop() + nop() + } + + some() + } + + fun nop() {} +} + +fun main(args: Array) { + Foo() +} diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt new file mode 100644 index 00000000000..ddac18cc111 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt @@ -0,0 +1,25 @@ +package stopInlineCallInLocalFunInSecondaryConstructor + +class Foo(bar: Any) { + constructor() : this(12) { + fun test() { + inlineFun { + //Breakpoint! + nop() + nop() + } + } + + test() + } + + fun nop() {} +} + +fun main(args: Array) { + Foo() +} + +inline fun inlineFun(f: () -> Any) { + f() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java index 3b32c17a20f..b98d24a06ff 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinSteppingTestGenerated.java @@ -752,6 +752,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { doStepOverTest(fileName); } + @TestMetadata("stopInLocalFunInSecondaryConstructor.kt") + public void testStopInLocalFunInSecondaryConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInSecondaryConstructor.kt"); + doStepOverTest(fileName); + } + @TestMetadata("stopInLocalFunInlineCallLambda.kt") public void testStopInLocalFunInlineCallLambda() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInLocalFunInlineCallLambda.kt"); @@ -781,6 +787,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInObjectLiteralInInlineCallWithClosure.kt"); doStepOverTest(fileName); } + + @TestMetadata("stopInlineCallInLocalFunInSecondaryConstructor.kt") + public void testStopInlineCallInLocalFunInSecondaryConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt"); + doStepOverTest(fileName); + } } @TestMetadata("idea/testData/debugger/tinyApp/src/stepping/filters")