NodeInfo tree working (besides litho nodes)

Summary: The second tree has access to all AX NodeInfo properties (they are not in the sidebar yet). Infrastructure set up to customize displayed information bassed on what is most useful. Descriptors for views updated to include AX functionality and non-view descriptors AX functions defaulted to null/empty. Non-view nodes (like Fragments, Window, Appication) no longer included in AX tree. Corresponding nodes will be highlighted (although not expanded) on click in either tree.

Differential Revision: D8795800

fbshipit-source-id: cf2333f69bfecca3ff84aae62681c684dfa14bf3
This commit is contained in:
Sara Valderrama
2018-07-12 09:23:29 -07:00
committed by Facebook Github Bot
parent 9e673a07a8
commit 1c5ecce667
8 changed files with 284 additions and 8 deletions

View File

@@ -12,7 +12,9 @@ import com.facebook.sonar.core.SonarArray;
import com.facebook.sonar.core.SonarConnection;
import com.facebook.sonar.core.SonarDynamic;
import com.facebook.sonar.core.SonarObject;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
/**
* A NodeDescriptor is an object which known how to expose an Object of type T to the ew Inspector.
@@ -90,18 +92,33 @@ public abstract class NodeDescriptor<T> {
*/
public abstract String getName(T node) throws Exception;
/** Gets name for AX tree. */
public String getAXName(T node) throws Exception {
return "";
}
/** @return The number of children this node exposes in the inspector. */
public abstract int getChildCount(T node) throws Exception;
/** @return The child at index. */
public abstract Object getChildAt(T node, int index) throws Exception;
/** Gets child at index for AX tree. Ignores non-view children. */
public @Nullable Object getAXChildAt(T node, int index) throws Exception {
return null;
}
/**
* Get the data to show for this node in the sidebar of the inspector. The object will be showen
* in order and with a header matching the given name.
*/
public abstract List<Named<SonarObject>> getData(T node) throws Exception;
/** Gets data for AX tree */
public List<Named<SonarObject>> getAXData(T node) throws Exception {
return Collections.EMPTY_LIST;
}
/**
* Set a value on the provided node at the given path. The path will match a key path in the data
* provided by {@link this#getData(Object)} and the value will be of the same type as the value
@@ -115,6 +132,11 @@ public abstract class NodeDescriptor<T> {
*/
public abstract List<Named<String>> getAttributes(T node) throws Exception;
/** Gets attributes for AX tree */
public List<Named<String>> getAXAttributes(T node) throws Exception {
return Collections.EMPTY_LIST;
}
/**
* Highlight this node. Use {@link HighlightedOverlay} if possible. This is used to highlight a
* node which is selected in the inspector. The plugin automatically takes care of de-selecting