Make ReactShadowNode's toString useful
Reviewed By: AaaChiuuu Differential Revision: D5054307 fbshipit-source-id: af548077e9efabcdd9d86c3c06f6408a022762b8
This commit is contained in:
parent
06993fb780
commit
4a225f79a3
|
@ -777,11 +777,37 @@ public class ReactShadowNode {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (mYogaNode != null) {
|
||||
return mYogaNode.toString();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
toStringWithIndentation(sb, 0);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void toStringWithIndentation(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("__");
|
||||
}
|
||||
|
||||
return getClass().getSimpleName() + " (virtual node)";
|
||||
result
|
||||
.append(getClass().getSimpleName())
|
||||
.append(" ");
|
||||
if (mYogaNode != null) {
|
||||
result
|
||||
.append(getLayoutWidth())
|
||||
.append(",")
|
||||
.append(getLayoutHeight());
|
||||
} else {
|
||||
result.append("(virtual node)");
|
||||
}
|
||||
result.append("\n");
|
||||
|
||||
if (getChildCount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
getChildAt(i).toStringWithIndentation(result, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
|
Loading…
Reference in New Issue