fluidattacks-blends-domain 0.2.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::execution_block::build_execution_block_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{CodeGraph, NodeId};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    // Drop the surrounding `{` `}`, and any `;` separators.
    let all = adj_ast(graph, n_id, None, &[]);
    let inner = all.get(1..all.len().saturating_sub(1)).unwrap_or(&[]);
    let c_ids: Vec<NodeId> = inner
        .iter()
        .copied()
        .filter(|c_id| graph.label_type(*c_id) != Some(";"))
        .collect();
    build_execution_block_node(args, n_id, &c_ids).map(Some)
}