diff --git a/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTree.kt b/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTree.kt index e2cac54f0b..b5a0802597 100644 --- a/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTree.kt +++ b/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTree.kt @@ -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))) } } diff --git a/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTreeNode.kt b/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTreeNode.kt index 9e5a51b5b4..9461ec2c3a 100644 --- a/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTreeNode.kt +++ b/litho-rendercore/src/main/java/com/facebook/rendercore/RenderTreeNode.kt @@ -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 }