diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt index 582db2c2d78..dfdfed7c38a 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/render/KotlinClassWithDelegatedPropertyRenderer.kt @@ -32,6 +32,7 @@ import com.intellij.xdebugger.settings.XDebuggerSettingsManager import com.sun.jdi.* import com.sun.jdi.Type import org.jetbrains.kotlin.idea.debugger.KotlinDebuggerSettings +import org.jetbrains.kotlin.idea.debugger.ToggleKotlinVariablesState import org.jetbrains.kotlin.load.java.JvmAbi import java.util.* import com.sun.jdi.Type as JdiType @@ -54,17 +55,18 @@ class KotlinClassWithDelegatedPropertyRenderer(private val rendererSettings: Nod try { return jdiType.allFields().any { it.name().endsWith(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX) } - } - catch (notPrepared: ClassNotPreparedException) { + } catch (notPrepared: ClassNotPreparedException) { LOG.error(notPreparedClassMessage(jdiType), notPrepared) } return false } - override fun calcLabel(descriptor: ValueDescriptor, - evaluationContext: EvaluationContext, - listener: DescriptorLabelListener): String { + override fun calcLabel( + descriptor: ValueDescriptor, + evaluationContext: EvaluationContext, + listener: DescriptorLabelListener + ): String { val res = calcToStringLabel(descriptor, evaluationContext, listener) if (res != null) { return res @@ -73,8 +75,10 @@ class KotlinClassWithDelegatedPropertyRenderer(private val rendererSettings: Nod return super.calcLabel(descriptor, evaluationContext, listener) } - private fun calcToStringLabel(descriptor: ValueDescriptor, evaluationContext: EvaluationContext, - listener: DescriptorLabelListener): String? { + private fun calcToStringLabel( + descriptor: ValueDescriptor, evaluationContext: EvaluationContext, + listener: DescriptorLabelListener + ): String? { val toStringRenderer = rendererSettings.toStringRenderer if (toStringRenderer.isEnabled && DebuggerManagerEx.getInstanceEx(evaluationContext.project).context.isEvaluationPossible) { if (toStringRenderer.isApplicable(descriptor.type)) { @@ -108,18 +112,18 @@ class KotlinClassWithDelegatedPropertyRenderer(private val rendererSettings: Nod if (field.name().endsWith(JvmAbi.DELEGATED_PROPERTY_NAME_SUFFIX)) { val shouldRenderDelegatedProperty = KotlinDebuggerSettings.getInstance().DEBUG_RENDER_DELEGATED_PROPERTIES - if (shouldRenderDelegatedProperty) { + if (shouldRenderDelegatedProperty && !ToggleKotlinVariablesState.getService().kotlinVariableView) { children.add(nodeManager.createNode(fieldDescriptor, context)) } val delegatedPropertyDescriptor = DelegatedPropertyFieldDescriptor( - context.debugProcess.project!!, - value, - field, - shouldRenderDelegatedProperty) + context.debugProcess.project!!, + value, + field, + shouldRenderDelegatedProperty + ) children.add(nodeManager.createNode(delegatedPropertyDescriptor, context)) - } - else { + } else { children.add(nodeManager.createNode(fieldDescriptor, context)) } } diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evDelegatedProperty.out b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evDelegatedProperty.out index 6b17b0ddcee..a73f36cb175 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evDelegatedProperty.out +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/extraVariables/evDelegatedProperty.out @@ -2,6 +2,7 @@ LineBreakpoint created at evDelegatedProperty.kt:13 Run Java Connected to the target VM evDelegatedProperty.kt:13 +Compile bytecode for a.prop frame = main:13, EvDelegatedPropertyKt {evDelegatedProperty} local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDelegatedProperty.kt, 9) local = a: evDelegatedProperty.A = {evDelegatedProperty.A@uniqueID} (sp = evDelegatedProperty.kt, 10) diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.kt new file mode 100644 index 00000000000..b4076aeafe8 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.kt @@ -0,0 +1,28 @@ +package delegatedPropertyInClassKotlinVariables + +import kotlin.properties.Delegates +import kotlin.reflect.KProperty + +fun main(args: Array) { + val a = A() + //Breakpoint! + args.size +} + +class A { + val prop by MyDelegate() + val propEx by MyDelegateThrowsException() +} + +class MyDelegate { + operator fun getValue(t: Any?, p: KProperty<*>): Int = 1 +} + +class MyDelegateThrowsException { + operator fun getValue(t: Any?, p: KProperty<*>): Int = throw IllegalStateException() +} + +// SHOW_KOTLIN_VARIABLES +// PRINT_FRAME +// SKIP: suppressedExceptions +// SKIP: stackTrace diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.out b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.out new file mode 100644 index 00000000000..19a2537f35c --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.out @@ -0,0 +1,15 @@ +LineBreakpoint created at delegatedPropertyInClassKotlinVariables.kt:9 +Run Java +Connected to the target VM +delegatedPropertyInClassKotlinVariables.kt:9 +Compile bytecode for args.size + frame = main:9, DelegatedPropertyInClassKotlinVariablesKt {delegatedPropertyInClassKotlinVariables} + local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = delegatedPropertyInClassKotlinVariables.kt, 6) + local = a: delegatedPropertyInClassKotlinVariables.A = {delegatedPropertyInClassKotlinVariables.A@uniqueID} (sp = delegatedPropertyInClassKotlinVariables.kt, 7) + field = prop: int = 1 (sp = delegatedPropertyInClassKotlinVariables.kt, 13) + field = propEx: int = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = delegatedPropertyInClassKotlinVariables.kt, 14) + field = detailMessage: java.lang.String = null (sp = Throwable.!EXT!) + field = cause: java.lang.Throwable = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = Throwable.!EXT!) +Disconnected from the target VM + +Process finished with exit code 0 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 8691da5dc9b..b07a9f67794 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -660,6 +660,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt"); } + @TestMetadata("delegatedPropertyInClassKotlinVariables.kt") + public void testDelegatedPropertyInClassKotlinVariables() throws Exception { + runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassKotlinVariables.kt"); + } + @TestMetadata("delegatedPropertyInClassWithToString.kt") public void testDelegatedPropertyInClassWithToString() throws Exception { runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClassWithToString.kt");