# androidx.compose.ui.tooling.data

## Interfaces

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext` | Context with data for creating group nodes. |

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/CallGroup` | A group that represents the invocation of a component |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache` | A cache of `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceInformationContext` that optionally can be specified when using `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/Group` | A group in the slot table. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/JoinedKey` | A key that has being joined together to form one key. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/NodeGroup` | A group that represents an emitted node |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ParameterInformation` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation` | Source location of the call that produced the call group. |

## Annotations

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi` |   |

## Extension functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/Group` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData.https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).asTree()()` Return a group tree for for the slot table that represents the entire content of the slot table. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ParameterInformation>` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup.https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionGroup).findParameters(androidx.compose.ui.tooling.data.ContextCache)(cache: https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache?)` Return the parameters found for this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<R>` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData>.https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)( prepareResult: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, createNode: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup, https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<R>) -> T?, createResult: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance, T?, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance>) -> R?, cache: https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache )` Processes a set of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData` instances and constructs a list of trees of custom nodes. |
| `T?` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData.https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)( factory: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup, https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>) -> T?, cache: https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache )` Return a tree of custom nodes for the slot table. |

## Extension properties summary

|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/UiToolingDataApi https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/Group.https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.ui.tooling.data.Group).position()` The source position of the group extracted from the key, if one exists for the group. |

## Extension functions

### CompositionData.asTree

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/SlotTree.jvmAndAndroid.kt+function:asTree) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
@UiToolingDataApi
fun CompositionData.asTree(): Group
```

Return a group tree for for the slot table that represents the entire content of the slot table.

### CompositionGroup.findParameters

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/SlotTree.jvmAndAndroid.kt+function:findParameters) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.3.0)

```
@UiToolingDataApi
fun CompositionGroup.findParameters(cache: ContextCache? = null): List<ParameterInformation>
```

Return the parameters found for this `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup`.

### Set.makeTree

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/CompositionDataTree.kt+function:makeTree)

```
@UiToolingDataApi
fun <T : Any?, R : Any?> Set<CompositionData>.makeTree(
    prepareResult: (CompositionInstance) -> Unit,
    createNode: (CompositionGroup, SourceContext, List<T>, List<R>) -> T?,
    createResult: (CompositionInstance, T?, List<CompositionInstance>) -> R?,
    cache: ContextCache = ContextCache()
): List<R>
```

Processes a set of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData` instances and constructs a list of trees of custom nodes.

This function builds a hierarchy from the provided compositions and then uses the `mapTree` to transform each root composition into a custom tree structure defined by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)`. Results from `mapTree` that are `null` will be excluded from the final list.

The processing involves:

1. Building a lookup map from `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance` to `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData`.

2. Constructing a parent-to-children hierarchy of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance`s.

3. Recursively traversing the hierarchy to map each composition using the provided `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)`, potentially stitching children processed from sub-compositions.

| Parameters |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData>` | A set of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionData` to be processed into trees. |
| `prepareResult: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Give the caller a chance to setup data structures for a composition. |
| `createNode: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup, https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<R>) -> T?` | A function that takes a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup`, its `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext`, a list of already processed children of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` from the current composition, and an optional list of children of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` from stitched sub-compositions. It returns a custom node of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` or `null`. |
| `createResult: (https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance, T?, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionInstance>) -> R?` | Create a result `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` from the top node `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` for this composition and the specified child compositions. |
| `cache: https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache = ContextCache()` | An optional `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/ContextCache` to optimize `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext` creation. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<R>` | A list of root nodes of type `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(kotlin.collections.Set).makeTree(kotlin.Function1,kotlin.Function4,kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` representing the successfully processed trees. |

### CompositionData.mapTree

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/SlotTree.jvmAndAndroid.kt+function:mapTree)

```
@UiToolingDataApi
fun <T : Any?> CompositionData.mapTree(
    factory: (CompositionGroup, SourceContext, List<T>) -> T?,
    cache: ContextCache = ContextCache()
): T?
```

Return a tree of custom nodes for the slot table.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` method will be called for every `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup` in the slot tree and can be used to create custom nodes based on the passed arguments. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceContext` argument gives access to additional information encoded in the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup#sourceInfo()`. A return of null from `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` means that the entire subtree will be ignored.

A `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` can optionally be specified. If a client is calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/package-summary#(androidx.compose.runtime.tooling.CompositionData).mapTree(kotlin.Function3,androidx.compose.ui.tooling.data.ContextCache)` multiple times, this can save some time if the values of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/CompositionGroup#sourceInfo()` are not unique.

## Extension properties

### Group.position

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/SlotTree.jvmAndAndroid.kt+symbol:position) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
@UiToolingDataApi
val Group.position: String?
```

The source position of the group extracted from the key, if one exists for the group.