fluidattacks-blends-domain 0.6.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
//! Counterpart of `blends/syntax/readers/yaml/flow_sequence.py`.

use alloc::vec::Vec;

use crate::query::adj_ast;
use crate::syntax::builders::array_node::build_array_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{CodeGraph, NodeId};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let invalid_types = ["[", "]", "{", "}", ",", ";"];
    let graph = args.ast_graph;
    let valid_childs: Vec<NodeId> = adj_ast(graph, n_id, None, &[])
        .into_iter()
        .filter(|c_id| {
            !graph
                .label_type(*c_id)
                .is_some_and(|kind| invalid_types.contains(&kind))
        })
        .collect();
    build_array_node(args, n_id, &valid_childs).map(Some)
}