findDeclaringGroup

fun Component.findDeclaringGroup(): CompositionGroup?

The group that declared this component, or null where no composition this library mounted declared it - a component built by hand, and one whose composition has not recorded yet.

CompositionGroup.node holds the SwingComponentNode for the component. The group itself does not carry the declaration site; attachComposeStackTrace is what leads back to the declaring code.

The search starts at this component and walks up its Swing ancestors, and the nearest composition that declared it wins: a component declared inside a nested setContent composition is answered by that composition rather than by the one around it, and a component that hosts a content composition of its own is still answered with the group that declared it.

The answer reads the composition's slot table as it stands, and the next recomposition of that composition retires it: descending a group held across one fails. Read what you need while the answer is fresh and ask again afterwards, holding CompositionGroup.identity in between.

A composition answers only once it has recorded - one mounted while isDebugInspectorInfoEnabled was on, or one the switch reached afterwards.

Must be called on the Event Dispatch Thread.