fluidattacks-blends-domain 0.2.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
//! Cfg builder that fans a switch body out into every section, or into
//! the single section a deterministic multifile switch resolves to.

use crate::query::adj_ast;
use crate::syntax::cfg::dispatchers::multifile::get_deterministic_path_id;
use crate::syntax::cfg::{SyntaxCfgArgs, SyntaxCfgError};
use crate::NodeId;

pub fn build(
    args: &mut SyntaxCfgArgs<'_>,
    n_id: NodeId,
    nxt_id: Option<NodeId>,
) -> Result<NodeId, SyntaxCfgError> {
    if args.is_multifile {
        if let Some(f_id) = get_deterministic_path_id(args.graph, n_id) {
            let built = args.generic(f_id, nxt_id)?;
            args.graph.add_cfg_edge(n_id, built);
            return Ok(n_id);
        }
    }

    for c_id in adj_ast(args.graph, n_id, None, &[]) {
        let built = args.generic(c_id, nxt_id)?;
        args.graph.add_cfg_edge(n_id, built);
    }
    Ok(n_id)
}