Skip to content

Commit 3d3cb64

Browse files
committed
Only display hierarchial variables as trees
1 parent 0bbd49f commit 3d3cb64

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

adapter/src/main/kotlin/org/javacs/ktda/adapter/DAPConverter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class DAPConverter(
8888
name = variableTree.name
8989
value = variableTree.value
9090
type = variableTree.type
91-
variablesReference = variablesPool.store(Unit, variableTree)
91+
variablesReference = variableTree.childs?.takeIf { it.isNotEmpty() }?.let { variablesPool.store(Unit, variableTree) } ?: 0
9292
}
9393

9494
fun toDAPThread(internalThread: DebuggeeThread) = DAPThread().apply {

adapter/src/main/kotlin/org/javacs/ktda/adapter/KotlinDebugAdapter.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ class KotlinDebugAdapter(
330330
.let(converter::toVariableTree)
331331
?: throw KotlinDAException("Could not find variablesReference with ID ${args.variablesReference}"))
332332
.childs
333-
.map(converter::toDAPVariable)
334-
.toTypedArray()
333+
?.map(converter::toDAPVariable)
334+
?.toTypedArray()
335+
?: emptyArray()
335336
}
336337
)
337338

adapter/src/main/kotlin/org/javacs/ktda/core/scope/VariableTreeNode.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ interface VariableTreeNode {
1010
get() = null
1111
val type: String?
1212
get() = null
13-
val childs: List<VariableTreeNode>
14-
get() = emptyList()
13+
val childs: List<VariableTreeNode>?
14+
get() = null
1515

1616
// TODO: Setters for values?
1717
}

adapter/src/main/kotlin/org/javacs/ktda/jdi/scope/JDIVariable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class JDIVariable(
1616
) : VariableTreeNode {
1717
override val value: String = jdiValue?.toString() ?: "null" // TODO: Better string representation
1818
override val type: String = (jdiType?.name() ?: jdiValue?.type()?.name()) ?: "Unknown type"
19-
override val childs: List<VariableTreeNode> by lazy { jdiValue?.let(::childrenOf) ?: emptyList() }
19+
override val childs: List<VariableTreeNode>? by lazy { jdiValue?.let(::childrenOf) }
2020

2121
private fun childrenOf(jdiValue: Value): List<VariableTreeNode> {
2222
val jdiType = jdiValue.type()

adapter/src/main/kotlin/org/javacs/ktda/util/ObjectPool.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private data class ObjectMapping<O, V> (
1010
val value: V
1111
)
1212

13-
private var currentID = 0L
13+
private var currentID = 1L
1414

1515
/**
1616
* Maps objects of owners to multiple owned values.

0 commit comments

Comments
 (0)