diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java index af0841a48..71f8d0936 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java @@ -187,6 +187,11 @@ public interface ReactShadowNode { boolean isDescendantOf(T ancestorNode); + /** + * @return a {@link String} representation of the Yoga hierarchy of this {@link ReactShadowNode} + */ + String getHierarchyInfo(); + /* * In some cases we need a way to specify some environmental data to shadow node * to improve layout (or do something similar), so {@code localData} serves these needs. @@ -197,7 +202,7 @@ public interface ReactShadowNode { * Use {@link UIManagerModule#setViewLocalData} to set this property * (to provide local/environmental data for a shadow node) from the main thread. */ - public void setLocalData(Object data); + void setLocalData(Object data); /** * Returns the offset within the native children owned by all layout-only nodes in the subtree diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java index 73ed6bc48..fe807cfc2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java @@ -9,7 +9,6 @@ package com.facebook.react.uimanager; import static java.lang.System.arraycopy; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.annotations.ReactPropertyHolder; import com.facebook.yoga.YogaAlign; import com.facebook.yoga.YogaBaselineFunction; @@ -235,9 +234,9 @@ public class ReactShadowNodeImpl implements ReactShadowNode throw new RuntimeException( "Cannot add a child that doesn't have a YogaNode to a parent without a measure " + "function! (Trying to add a '" - + child.getClass().getSimpleName() + + child.toString() + "' to a '" - + getClass().getSimpleName() + + toString() + "')"); } mYogaNode.addChildAt(childYogaNode, i); @@ -570,6 +569,11 @@ public class ReactShadowNodeImpl implements ReactShadowNode return isDescendant; } + @Override + public String toString() { + return mViewClassName; + } + /* * In some cases we need a way to specify some environmental data to shadow node * to improve layout (or do something similar), so {@code localData} serves these needs. @@ -962,13 +966,13 @@ public class ReactShadowNodeImpl implements ReactShadowNode } @Override - public String toString() { + public String getHierarchyInfo() { StringBuilder sb = new StringBuilder(); - toStringWithIndentation(sb, 0); + getHierarchyInfoWithIndentation(sb, 0); return sb.toString(); } - private void toStringWithIndentation(StringBuilder result, int level) { + private void getHierarchyInfoWithIndentation(StringBuilder result, int level) { // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. for (int i = 0; i < level; ++i) { result.append("__"); @@ -987,7 +991,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode } for (int i = 0; i < getChildCount(); i++) { - getChildAt(i).toStringWithIndentation(result, level + 1); + getChildAt(i).getHierarchyInfoWithIndentation(result, level + 1); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactRawTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactRawTextShadowNode.java index a37fab61a..87f6d5369 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactRawTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactRawTextShadowNode.java @@ -49,5 +49,8 @@ public class ReactRawTextShadowNode extends ReactShadowNodeImpl { return true; } - + @Override + public String toString() { + return getViewClass() + " [text: " + mText + "]"; + } }