extractComponentRefs function
Extract structured component references from a node tree.
Returns both local component keys (libraryProjectId is null) and library component references (libraryProjectId is non-null).
Implementation
Set<ComponentRef> extractComponentRefs(FFNode node) {
final refs = <ComponentRef>{};
void traverse(FFNode current) {
if (current.isComponent && current.hasComponentClassKeyRef()) {
final keyRef = current.componentClassKeyRef;
final depId = keyRef.dependencyProjectId;
refs.add((
key: keyRef.key,
libraryProjectId: depId.isEmpty ? null : depId,
));
}
for (final child in current.children) {
traverse(child);
}
}
traverse(node);
return refs;
}