@@ -1026,6 +1026,85 @@ public open class ReactViewGroup public constructor(context: Context?) :
10261026 accessibilityStateChangeListener = null
10271027 }
10281028
1029+ // #region debug helper
1030+ public fun describeViewAncestry (start : View ): String {
1031+ val sb = StringBuilder ()
1032+ var v: View ? = start
1033+ var depth = 0
1034+ while (v != null ) {
1035+ val nativeId = v.getTag(R .id.view_tag_native_id)
1036+ val testId = v.getTag(R .id.react_test_id)
1037+ val uiType = getUIManagerType(v).toString()
1038+ val cd = v.contentDescription
1039+ sb.append(" #" ).append(depth)
1040+ .append(" class=" ).append(v::class .java.name)
1041+ .append(" tag=" ).append(v.id)
1042+ .append(" ui=" ).append(uiType)
1043+ if (nativeId != null ) sb.append(" nativeID=" ).append(nativeId)
1044+ if (testId != null ) sb.append(" testID=" ).append(testId)
1045+ if (cd != null ) sb.append(" contentDesc=" ).append(cd)
1046+ sb.append(' \n ' )
1047+ val p = v.parent
1048+ v = if (p is View ) p else null
1049+ depth++
1050+ }
1051+ return sb.toString()
1052+ }
1053+
1054+ public fun describeChildren (): String {
1055+ val sb = StringBuilder ()
1056+
1057+ sb.append(" Attached children: " )
1058+ val childCount = childCount
1059+ if (childCount == 0 ) {
1060+ sb.append(" (none)\n " )
1061+ } else {
1062+ for (i in 0 until childCount) {
1063+ try {
1064+ val child = getChildAt(i)
1065+ if (child == null ) {
1066+ sb.append(" [$i ] NULL CHILD!\n " )
1067+ } else {
1068+ val childNativeId = child.getTag(R .id.view_tag_native_id)
1069+ val childTestId = child.getTag(R .id.react_test_id)
1070+ sb.append(" [$i ] " )
1071+ .append(child::class .java.simpleName)
1072+ .append(" id=" ).append(child.id)
1073+ if (childNativeId != null ) sb.append(" nativeID=" ).append(childNativeId)
1074+ if (childTestId != null ) sb.append(" testID=" ).append(childTestId)
1075+ sb.append(" parent=" ).append(if (child.parent != null ) " attached" else " DETACHED" )
1076+ sb.append(' \n ' )
1077+ }
1078+ } catch (e: Exception ) {
1079+ sb.append(" [$i ] ERROR: " ).append(e.message).append(' \n ' )
1080+ }
1081+ }
1082+ }
1083+
1084+ try {
1085+ // If removeClippedSubviews is enabled, show clipped children too
1086+ if (removeClippedSubviews && allChildren != null && allChildrenCount > childCount) {
1087+ sb.append(" Clipped children:\n " )
1088+ for (i in 0 until allChildrenCount) {
1089+ val child = allChildren!! [i]
1090+ if (child != null && child.parent == null ) {
1091+ val childNativeId = child.getTag(R .id.view_tag_native_id)
1092+ sb.append(" [$i ] " )
1093+ .append(child::class .java.simpleName)
1094+ .append(" id=" ).append(child.id)
1095+ if (childNativeId != null ) sb.append(" nativeID=" ).append(childNativeId)
1096+ sb.append(" (CLIPPED)\n " )
1097+ }
1098+ }
1099+ }
1100+ } catch (e: Exception ) {
1101+ sb.append(" Error describing clipped children: " ).append(e.message).append(' \n ' )
1102+ }
1103+
1104+ return sb.toString()
1105+ }
1106+ // #endregion
1107+
10291108 private companion object {
10301109 private const val ARRAY_CAPACITY_INCREMENT = 12
10311110 private val defaultLayoutParam = LayoutParams (0 , 0 )
0 commit comments