fluidattacks-blends-domain 0.35.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::{adj_ast, match_ast_d},
    syntax::{
        builders::execution_block::build_execution_block_node, SyntaxGraphArgs, SyntaxGraphError,
    },
    CodeGraph, NodeId,
};
use alloc::vec::Vec;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;

    let c_ids: Vec<NodeId> = match_ast_d(graph, n_id, "expression", Some(1))
        .or_else(|| match_ast_d(graph, n_id, "comparison_expression", Some(1)))
        .map_or_else(
            || {
                adj_ast(graph, n_id, Some(1), &[])
                    .into_iter()
                    .filter(|&c_id| !matches!(graph.label_type(c_id), Some("{" | "}")))
                    .collect()
            },
            |expr| alloc::vec![expr],
        );

    build_execution_block_node(args, n_id, &c_ids).map(Some)
}