Descriptor clean up
Summary: 1. The base class descriptor was removed, this was given that we have chained descriptor there is no need for this anymore 2. The Base interface node descriptor no longer has a mutable list based api. You simply return a list. The mutable list based api was specifically to allow chaining and this quirk is isoltated to the chained descriptor 3. AbstractChainedDescriptor and ChainedDescriptor were merged Reviewed By: lblasa Differential Revision: D39496073 fbshipit-source-id: fb3ec629ec3b27f587bdbd0b323624a4bc4ebea3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f5a5e1b19d
commit
2090120cda
@@ -8,52 +8,56 @@
|
||||
package com.facebook.flipper.plugins.uidebugger.litho
|
||||
|
||||
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
|
||||
import com.facebook.flipper.plugins.uidebugger.descriptors.Descriptor
|
||||
import com.facebook.flipper.plugins.uidebugger.descriptors.NodeDescriptor
|
||||
import com.facebook.litho.DebugComponent
|
||||
import com.facebook.litho.LithoView
|
||||
|
||||
object LithoViewDescriptor : Descriptor<LithoView>() {
|
||||
object LithoViewDescriptor : NodeDescriptor<LithoView> {
|
||||
override fun getId(node: LithoView): String = System.identityHashCode(node).toString()
|
||||
|
||||
override fun getName(node: LithoView): String = "LithoView"
|
||||
|
||||
override fun getChildren(node: LithoView, children: MutableList<Any>) {
|
||||
override fun getChildren(node: LithoView): List<Any> {
|
||||
val result = mutableListOf<Any>()
|
||||
val debugComponent = DebugComponent.getRootInstance(node)
|
||||
if (debugComponent != null) {
|
||||
children.add(debugComponent)
|
||||
result.add(debugComponent)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getActiveChild(node: LithoView): Any? = null
|
||||
|
||||
override fun getData(node: LithoView, builder: MutableMap<String, InspectableObject>) {}
|
||||
override fun getData(node: LithoView) = mapOf<String, InspectableObject>()
|
||||
}
|
||||
|
||||
object DebugComponentDescriptor : Descriptor<DebugComponent>() {
|
||||
object DebugComponentDescriptor : NodeDescriptor<DebugComponent> {
|
||||
override fun getId(node: DebugComponent): String = System.identityHashCode(node).toString()
|
||||
|
||||
override fun getName(node: DebugComponent): String {
|
||||
return node.component.simpleName
|
||||
}
|
||||
|
||||
// TODO the mutable list thing doesnt make sense for non chained descriptors, should just return
|
||||
override fun getChildren(node: DebugComponent, children: MutableList<Any>) {
|
||||
override fun getChildren(node: DebugComponent): List<Any> {
|
||||
val result = mutableListOf<Any>()
|
||||
|
||||
val mountedView = node.mountedView
|
||||
val mountedDrawable = node.mountedDrawable
|
||||
|
||||
if (mountedView != null) {
|
||||
children.add(mountedView)
|
||||
result.add(mountedView)
|
||||
} else if (mountedDrawable != null) {
|
||||
children.add(mountedDrawable)
|
||||
result.add(mountedDrawable)
|
||||
} else {
|
||||
for (child in node.childComponents) {
|
||||
children.add(child)
|
||||
result.add(child)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getActiveChild(node: DebugComponent): Any? = null
|
||||
|
||||
// todo same here
|
||||
override fun getData(node: DebugComponent, builder: MutableMap<String, InspectableObject>) {}
|
||||
override fun getData(node: DebugComponent) = mapOf<String, InspectableObject>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user