fluidattacks-blends-domain 0.6.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
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 valid_children: Vec<NodeId> = adj_ast(args.ast_graph, n_id, None, &[])
        .into_iter()
        .filter(|&child_id| {
            matches!(
                args.ast_graph.label_type(child_id),
                Some(
                    "array_initializer"
                        | "binary_expression"
                        | "cast_expression"
                        | "decimal_integer_literal"
                        | "identifier"
                        | "field_access"
                        | "object"
                        | "object_creation_expression"
                        | "string"
                        | "string_literal"
                )
            )
        })
        .collect();
    build_array_node(args, n_id, &valid_children).map(Some)
}