Hide '$delegate' variables in Kotlin variables mode
This commit is contained in:
+18
-14
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -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)
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package delegatedPropertyInClassKotlinVariables
|
||||
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
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
|
||||
+15
@@ -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
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user