fluidattacks-blends-domain 0.41.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
mod common;
mod fixed;
mod repetition;
use crate::ast::node_utils::AstNodeAndId;
use crate::ast::{AstGraph, AstNode};
use crate::syntax::_node_builders::core::SyntaxNodeBuildError;
use crate::syntax::_node_builders::languages::rust::array_expression::common::FilteredChildren;
use crate::syntax::_node_builders::languages::rust::array_expression::fixed::build_fixed_array_expression;
use crate::syntax::_node_builders::languages::rust::array_expression::repetition::build_array_repetition;
use crate::syntax::core_nodes::{ArrayExpression, CoreSyntaxNodeWithId};

pub fn build_array_expression(
    graph: &AstGraph,
    node: &AstNode,
    build_syntax_node: impl Fn(AstNodeAndId) -> Result<CoreSyntaxNodeWithId, SyntaxNodeBuildError>,
) -> Result<ArrayExpression, SyntaxNodeBuildError> {
    let removed_delimiters = FilteredChildren::removed_delimiters(graph, node)?;
    let is_repeated_exp = removed_delimiters
        .filtered_children_items()
        .iter()
        .any(|(n, _)| n.kind == ";");
    if is_repeated_exp {
        return build_array_repetition(build_syntax_node, &removed_delimiters)
            .map(ArrayExpression::Repetition);
    }
    build_fixed_array_expression(build_syntax_node, &removed_delimiters).map(ArrayExpression::Fixed)
}