diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index b5ff0e37e8e..b3dece55ca2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -34,9 +34,12 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils +import org.jetbrains.kotlin.idea.core.refactoring.getLineEndOffset +import org.jetbrains.kotlin.idea.core.refactoring.getLineStartOffset import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.utils.addToStdlib.check import java.util.* public class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider { @@ -61,8 +64,7 @@ private fun findAdditionalExpressions(position: SourcePosition): Set 0 } ?: return emptySet() val elem = file.findElementAt(offset) val containingElement = getContainingElement(elem!!) ?: elem ?: return emptySet() @@ -79,8 +81,8 @@ private fun findAdditionalExpressions(position: SourcePosition): Set= endOffset) return emptySet() diff --git a/idea/testData/debugger/tinyApp/outs/evFunctionDeclaration.out b/idea/testData/debugger/tinyApp/outs/evFunctionDeclaration.out new file mode 100644 index 00000000000..a182a4f63b8 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/evFunctionDeclaration.out @@ -0,0 +1,24 @@ +LineBreakpoint created at evFunctionDeclaration.kt:5 +!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! evFunctionDeclaration.EvFunctionDeclarationKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +evFunctionDeclaration.kt:5 +package evFunctionDeclaration + +class A(val a: Int) { + //Breakpoint! + fun foo() = a +} + +fun main(args: Array) { + A(1).foo() +} + +// PRINT_FRAME +Compile bytecode for a + frame = foo():5, A {evFunctionDeclaration} + this = this = {evFunctionDeclaration.A@uniqueID} + field = a: int = 1 (sp = evFunctionDeclaration.kt, 3) + extra = a +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/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt new file mode 100644 index 00000000000..221942f10ee --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt @@ -0,0 +1,12 @@ +package evFunctionDeclaration + +class A(val a: Int) { + //Breakpoint! + fun foo() = a +} + +fun main(args: Array) { + A(1).foo() +} + +// PRINT_FRAME \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index 41a2b78745b..1a69f749b76 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -390,6 +390,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat doSingleBreakpointTest(fileName); } + @TestMetadata("evFunctionDeclaration.kt") + public void testEvFunctionDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evFunctionDeclaration.kt"); + doSingleBreakpointTest(fileName); + } + @TestMetadata("evLineRange.kt") public void testEvLineRange() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evLineRange.kt");