onAppEventAdded method
Update the graph when an app event is added.
Creates the app event node and adds edges to its global handler action block and data type dependencies.
Implementation
void onAppEventAdded(FFAppEvent appEvent) {
if (!appEvent.hasIdentifier() || appEvent.identifier.key.isEmpty) {
return;
}
final eventKey = appEvent.identifier.key;
final nodeId = NodeIds.appEvent(eventKey);
// Add the app event node if it doesn't exist
if (!graph.hasNode(nodeId)) {
graph.addNode(
DependencyNode(id: nodeId, type: DependencyNodeType.appEvent),
);
}
// App event -> global handler action block
if (appEvent.globalHandlerActionComponentIdentifier.key.isNotEmpty) {
final abNodeId = NodeIds.actionBlock(
appEvent.globalHandlerActionComponentIdentifier.key,
);
if (!graph.hasNode(abNodeId)) {
graph.addNode(
DependencyNode(id: abNodeId, type: DependencyNodeType.actionBlock),
);
}
graph.addDependency(nodeId, abNodeId);
}
// App event -> data type dependencies
if (appEvent.hasData &&
appEvent.hasDataTypeParameter() &&
appEvent.dataTypeParameter.hasDataType() &&
appEvent.dataTypeParameter.dataType.hasSubType()) {
final subType = appEvent.dataTypeParameter.dataType.subType;
if (subType.hasDataStructIdentifier() &&
subType.dataStructIdentifier.key.isNotEmpty) {
final dsNodeId = NodeIds.dataStruct(subType.dataStructIdentifier.key);
if (!graph.hasNode(dsNodeId)) {
graph.addNode(
DependencyNode(id: dsNodeId, type: DependencyNodeType.dataStruct),
);
}
graph.addDependency(nodeId, dsNodeId);
}
if (subType.hasEnumIdentifier() &&
subType.enumIdentifier.key.isNotEmpty) {
final enumNodeId = NodeIds.enumType(subType.enumIdentifier.key);
if (!graph.hasNode(enumNodeId)) {
graph.addNode(
DependencyNode(id: enumNodeId, type: DependencyNodeType.enumType),
);
}
graph.addDependency(nodeId, enumNodeId);
}
}
}