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;
#[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;