Make metadata tags a map and rename to custom attributes

Summary: This will allow a lot more flexibility and will be essential for making bloks work

Reviewed By: lblasa

Differential Revision: D44871256

fbshipit-source-id: 59d9fdccea7b18406eac532080e80a69a251267b
This commit is contained in:
Luke De Feo
2023-04-18 08:01:50 -07:00
committed by Facebook GitHub Bot
parent eee74044ff
commit c2fc54057a
2 changed files with 9 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ package com.facebook.flipper.plugins.uidebugger.descriptors
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue import com.facebook.flipper.plugins.uidebugger.model.InspectableValue
import com.facebook.flipper.plugins.uidebugger.model.Metadata import com.facebook.flipper.plugins.uidebugger.model.Metadata
import com.facebook.flipper.plugins.uidebugger.model.MetadataId import com.facebook.flipper.plugins.uidebugger.model.MetadataId
import kotlinx.serialization.json.JsonPrimitive
/** /**
* Registry of attribute metadata. There's two types of attributes: * Registry of attribute metadata. There's two types of attributes:
@@ -34,7 +35,8 @@ object MetadataRegister {
namespace: String, namespace: String,
name: String, name: String,
mutable: Boolean = false, mutable: Boolean = false,
possibleValues: Set<InspectableValue>? = emptySet() possibleValues: Set<InspectableValue>? = null,
customAttributes: Map<String, JsonPrimitive>? = null
): MetadataId { ): MetadataId {
val key = key(namespace, name) val key = key(namespace, name)
register[key]?.let { m -> register[key]?.let { m ->
@@ -43,7 +45,8 @@ object MetadataRegister {
synchronized(lock) { synchronized(lock) {
val identifier = ++generator val identifier = ++generator
val metadata = Metadata(identifier, type, namespace, name, mutable, possibleValues) val metadata =
Metadata(identifier, type, namespace, name, mutable, possibleValues, customAttributes)
register[key] = metadata register[key] = metadata
pendingKeys.add(key) pendingKeys.add(key)

View File

@@ -7,6 +7,8 @@
package com.facebook.flipper.plugins.uidebugger.model package com.facebook.flipper.plugins.uidebugger.model
import kotlinx.serialization.json.JsonPrimitive
typealias MetadataId = Int typealias MetadataId = Int
/** /**
@@ -22,5 +24,5 @@ data class Metadata(
val name: String, val name: String,
val mutable: kotlin.Boolean, val mutable: kotlin.Boolean,
val possibleValues: Set<InspectableValue>? = emptySet(), val possibleValues: Set<InspectableValue>? = emptySet(),
val tags: List<String>? = emptyList() val customAttributes: Map<String, JsonPrimitive>? = null
) {} )