Skip to content

Commit

Permalink
Add indents for all nodes in RenderTree.generateDebugString
Browse files Browse the repository at this point in the history
Summary: When ``DuplicateRenderUnitException`` is thrown it is easier to debug when all nodes converted to strings have indents.

Reviewed By: pentiumao

Differential Revision: D65472834

fbshipit-source-id: c7a554ef6e40fa0f538c3917608e2f950171ffee
  • Loading branch information
Radoslaw Kaczmarczyk authored and facebook-github-bot committed Nov 5, 2024
1 parent bc0cb49 commit 88cf5b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class RenderTree(
append("RenderTree details:\n")
append(String.format(l, "Full child list (size = %d):\n", renderTree.flatList.size))
for (node in renderTree.flatList) {
append(" ".repeat(node.getHierarchyDepth())) // indent
append(String.format(l, "%s\n", node.generateDebugString(renderTree)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ class RenderTreeNode(
parentId)
}

fun getHierarchyDepth(): Int {
var depth = 0
var node: RenderTreeNode? = parent
while (node != null) {
depth++
node = node.parent
}
return depth
}

companion object {
private const val DEFAULT_SIZE = 4
}
Expand Down

0 comments on commit 88cf5b8

Please sign in to comment.