fluidattacks-blends-domain 0.41.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::ast::node_utils::{children, AstNodeAndId};
use crate::ast::{AstGraph, AstNode};
use crate::syntax::_node_builders::core::SyntaxNodeBuildError;
use crate::syntax::core_nodes::{ArgumentList, CoreSyntaxNodeWithId};
use alloc::vec::Vec;

/// Builds the argument list of a call, building each argument with `build_syntax_node`
/// Fails on the first argument that cannot be resolved or built
#[allow(dead_code, reason = "will be used later on the rust readers")]
pub fn build_arguments(
    graph: &AstGraph,
    node: &AstNode,
    build_syntax_node: impl Fn(AstNodeAndId) -> Result<CoreSyntaxNodeWithId, SyntaxNodeBuildError>,
) -> Result<ArgumentList, SyntaxNodeBuildError> {
    children(graph, node)
        .map_err(SyntaxNodeBuildError::ResolutionError)
        .and_then(|children| {
            children
                .into_iter()
                .filter(|(child, _)| child.kind != ",")
                .map(build_syntax_node)
                .collect::<Result<Vec<_>, _>>()
        })
        .map(|args| ArgumentList { args })
}

#[cfg(test)]
mod tests;