fluidattacks-blends-domain 0.2.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Cfg builder that routes a declaration-like node to its block child.

use crate::syntax::cfg::{SyntaxCfgArgs, SyntaxCfgError};
use crate::syntax::SyntaxNode;
use crate::NodeId;

pub fn build(
    args: &mut SyntaxCfgArgs<'_>,
    n_id: NodeId,
    nxt_id: Option<NodeId>,
) -> Result<NodeId, SyntaxCfgError> {
    let Some(block_id) = args.graph.nodes.get(&n_id).and_then(SyntaxNode::block_id) else {
        return Ok(n_id);
    };
    let built = args.generic(block_id, nxt_id)?;
    args.graph.add_cfg_edge(n_id, built);
    Ok(n_id)
}