fluidattacks-blends-domain 0.44.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    syntax::{
        _node_builders::languages::rust::{
            arguments::build_arguments, transform::build_syntax_node,
        },
        builders::argument_list::build_argument_list_node,
        core_nodes::{CoreSyntaxNode, CoreSyntaxNodeWithId},
        readers::rust::generic_reader::generic_reader,
        SyntaxGraphArgs, SyntaxGraphError,
    },
    NodeId,
};
use alloc::vec::Vec;

fn unwrap_borrow((node, n_id): &CoreSyntaxNodeWithId) -> NodeId {
    match node {
        CoreSyntaxNode::ReferenceExpression(reference) => reference.value.1,
        _ => *n_id,
    }
}

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    generic_reader(
        args,
        n_id,
        |g, n| build_arguments(g, n, |n| build_syntax_node(g, n)),
        |a, node| {
            let c_ids: Vec<NodeId> = node.args.iter().map(unwrap_borrow).collect();
            build_argument_list_node(a, n_id, &c_ids).map(Some)
        },
    )
}