Basic mutual highlighting for Litho components

Summary: Shows basic relationship between the AX and nonAX tree litho nodes. When a litho component is selected from the nonAX tree, it's corresponding hostView or lithoView (root of the component tree) is highlighted in the AX tree giving priority to the hostView if it exists. If a hostView is selected in the AX tree, it's corresponding component is selected in the non-AX tree. If a lithoView is selected from the AX tree, it's corresponding lithoView is highlighted in the non-AX tree. This means that each hostView has a one-to-one highlighting between the two trees but lithoViews will have many nodes in the main tree that map to one node in the AX tree (which is accurate to litho components rendering but we may need to change in the future if it is not clear).

Reviewed By: jknoxville

Differential Revision: D8972205

fbshipit-source-id: d136f5b594d0ac1b66a82b35dc7b085186829fc4
This commit is contained in:
Sara Valderrama
2018-07-25 10:12:01 -07:00
committed by Facebook Github Bot
parent c57e6e4396
commit 41f4478a74
4 changed files with 70 additions and 10 deletions

View File

@@ -541,9 +541,12 @@ public class InspectorSonarPlugin implements SonarPlugin {
}
}.run();
String name = descriptor.getAXName(obj);
name = name.substring(name.lastIndexOf('.') + 1);
return new SonarObject.Builder()
.put("id", descriptor.getId(obj))
.put("name", descriptor.getAXName(obj))
.put("name", name)
.put("data", data)
.put("children", children)
.put("attributes", attributes)

View File

@@ -558,6 +558,29 @@ public class DebugComponentDescriptor extends NodeDescriptor<DebugComponent> {
return attributes;
}
@Override
public SonarObject getExtraInfo(DebugComponent node) {
SonarObject.Builder extraInfo = new SonarObject.Builder();
final NodeDescriptor descriptor = descriptorForClass(View.class);
final View hostView = node.getComponentHost();
final View lithoView = node.getLithoView();
if (hostView != null) {
try {
extraInfo.put("linkedAXNode", descriptor.getId(hostView));
} catch (Exception ignored) {
// doesn't have linked node descriptor
}
} else if (lithoView != null) {
try {
extraInfo.put("linkedAXNode", descriptor.getId(lithoView));
} catch (Exception ignored) {
// doesn't add linked node descriptor
}
}
return extraInfo.build();
}
@Override
public void setHighlighted(DebugComponent node, boolean selected) {
final LithoView lithoView = node.getLithoView();