Skip to content

Commit 066f41c

Browse files
committed
refactor(model-server): rename method parameters and add comments in ContentExplorer
1 parent 768513e commit 066f41c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

model-server/src/main/kotlin/org/modelix/model/server/handlers/ContentExplorer.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,20 @@ class ContentExplorer(private val client: IModelClient, private val repoManager:
129129
}
130130
}
131131

132-
private fun collectExpandableChildNodes(node: PNodeAdapter, expandedNodeIds: Set<String>): Set<String> {
133-
if (expandedNodeIds.contains(node.nodeId.toString())) {
134-
val newIds = mutableSetOf<String>()
135-
for (child in node.allChildren) {
136-
newIds.addAll(collectExpandableChildNodes(child as PNodeAdapter, expandedNodeIds))
132+
// The method traverses the expanded tree based on the alreadyExpandedNodeIds and
133+
// collects the expandable (not empty) nodes which are not expanded yet
134+
private fun collectExpandableChildNodes(under: PNodeAdapter, alreadyExpandedNodeIds: Set<String>): Set<String> {
135+
if (alreadyExpandedNodeIds.contains(under.nodeId.toString())) {
136+
val expandableIds = mutableSetOf<String>()
137+
for (child in under.allChildren) {
138+
expandableIds.addAll(collectExpandableChildNodes(child as PNodeAdapter, alreadyExpandedNodeIds))
137139
}
138-
return newIds
140+
return expandableIds
139141
}
140-
if (node.allChildren.toList().isNotEmpty()) {
141-
return setOf(node.nodeId.toString())
142+
143+
if (under.allChildren.toList().isNotEmpty()) {
144+
// Node is collected if it is expandable
145+
return setOf(under.nodeId.toString())
142146
}
143147
return emptySet()
144148
}

0 commit comments

Comments
 (0)