diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 3e6f1921a0655..3e65e1e37e393 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -343,6 +343,7 @@
+
diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/render/KotlinObjectRenderer.kt b/idea/src/org/jetbrains/jet/plugin/debugger/render/KotlinObjectRenderer.kt
new file mode 100644
index 0000000000000..fc217efe79c1b
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/debugger/render/KotlinObjectRenderer.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.debugger.render
+
+import com.intellij.debugger.ui.tree.render.ClassRenderer
+import com.sun.jdi.Type
+import com.intellij.debugger.engine.evaluation.EvaluationContext
+import com.sun.jdi.ObjectReference
+import com.sun.jdi.Field
+import com.sun.jdi.ClassType
+import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl
+import com.intellij.debugger.ui.tree.NodeDescriptorFactory
+import com.intellij.debugger.ui.tree.FieldDescriptor
+import com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl
+import com.intellij.openapi.project.Project
+import com.intellij.debugger.impl.DebuggerContextImpl
+import org.jetbrains.jet.lang.resolve.java.JvmAbi
+import com.intellij.debugger.ui.tree.ValueDescriptor
+import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
+import com.intellij.debugger.settings.NodeRendererSettings
+
+public class KotlinObjectRenderer : ClassRenderer() {
+
+ override fun isApplicable(jdiType: Type?): Boolean {
+ if (!super.isApplicable(jdiType)) return false
+
+ return jdiType.isKotlinClass()
+ }
+
+ override fun createFieldDescriptor(
+ parentDescriptor: ValueDescriptorImpl?,
+ nodeDescriptorFactory: NodeDescriptorFactory?,
+ objRef: ObjectReference?,
+ field: Field?,
+ evaluationContext: EvaluationContext?
+ ): FieldDescriptor {
+ if (field?.declaringType().isKotlinClass()) {
+ return KotlinObjectFieldDescriptor(evaluationContext?.getProject(), objRef, field)
+ }
+ return super.createFieldDescriptor(parentDescriptor, nodeDescriptorFactory, objRef, field, evaluationContext)
+ }
+
+ override fun calcLabel(
+ descriptor: ValueDescriptor?,
+ evaluationContext: EvaluationContext?,
+ labelListener: DescriptorLabelListener?
+ ): String? {
+ val toStringRenderer = NodeRendererSettings.getInstance().getToStringRenderer()
+ if (toStringRenderer.isApplicable(descriptor?.getValue()?.type())) {
+ return toStringRenderer.calcLabel(descriptor, evaluationContext, labelListener)
+ }
+ return super.calcLabel(descriptor, evaluationContext, labelListener)
+ }
+
+ private fun Type?.isKotlinClass(): Boolean {
+ return this is ClassType && this.allInterfaces().any { it.name() == JvmAbi.K_OBJECT.asString() }
+ }
+}
+
+public class KotlinObjectFieldDescriptor(
+ project: Project?,
+ objRef: ObjectReference?,
+ field: Field?
+): FieldDescriptorImpl(project, objRef, field) {
+ override fun getSourcePosition(project: Project?, context: DebuggerContextImpl?) = null
+ override fun getSourcePosition(project: Project?, context: DebuggerContextImpl?, nearest: Boolean) = null
+}
+
diff --git a/idea/testData/debugger/tinyApp/outs/allFilesPresentInRenderer.out b/idea/testData/debugger/tinyApp/outs/allFilesPresentInRenderer.out
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/idea/testData/debugger/tinyApp/outs/toStringRenderer.out b/idea/testData/debugger/tinyApp/outs/toStringRenderer.out
new file mode 100644
index 0000000000000..b94b18df01d8c
--- /dev/null
+++ b/idea/testData/debugger/tinyApp/outs/toStringRenderer.out
@@ -0,0 +1,24 @@
+LineBreakpoint created at toStringRenderer.kt:6
+!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! toStringRenderer.ToStringRendererPackage
+Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
+toStringRenderer.kt:5
+package toStringRenderer
+
+fun main(args: Array) {
+ val a = A()
+ //Breakpoint!
+ args.size
+}
+
+class A {
+ override fun toString() = "myA"
+}
+
+// PRINT_FRAME
+ frame = main():6, ToStringRendererPackage$@packagePartHASH {toStringRenderer}
+ static = static = toStringRenderer.ToStringRendererPackage$@packagePartHASH
+ local = args: java.lang.String[] = {java.lang.String[0]@uniqueID}
+ local = a: toStringRenderer.A = {toStringRenderer.A@uniqueID}myA
+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/renderer/toStringRenderer.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/renderer/toStringRenderer.kt
new file mode 100644
index 0000000000000..b236a8c659133
--- /dev/null
+++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/renderer/toStringRenderer.kt
@@ -0,0 +1,13 @@
+package toStringRenderer
+
+fun main(args: Array) {
+ val a = A()
+ //Breakpoint!
+ args.size
+}
+
+class A {
+ override fun toString() = "myA"
+}
+
+// PRINT_FRAME
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java
index f7bb65e07dd3b..7ad28f7fed036 100644
--- a/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java
@@ -35,7 +35,7 @@
public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluateExpressionTest {
@TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint")
@TestDataPath("$PROJECT_ROOT")
- @InnerTestClasses({SingleBreakpoint.Frame.class, SingleBreakpoint.Lambdas.class})
+ @InnerTestClasses({SingleBreakpoint.Frame.class, SingleBreakpoint.Lambdas.class, SingleBreakpoint.Renderer.class})
@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
public static class SingleBreakpoint extends AbstractKotlinEvaluateExpressionTest {
@TestMetadata("abstractFunCall.kt")
@@ -338,6 +338,22 @@ public void testTwoLambdasOnOneLineSecond() throws Exception {
}
+ @TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/renderer")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
+ public static class Renderer extends AbstractKotlinEvaluateExpressionTest {
+ public void testAllFilesPresentInRenderer() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/renderer"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("toStringRenderer.kt")
+ public void testToStringRenderer() throws Exception {
+ String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/renderer/toStringRenderer.kt");
+ doSingleBreakpointTest(fileName);
+ }
+
+ }
+
}
@TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints")