fluidattacks-blends-domain 0.35.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::match_ast_group_d;
use crate::syntax::builders::array_node::build_array_node;
use crate::syntax::readers::go::common::literal_elements;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;

    // The body of a composite literal is the list of what it holds, whether
    // those are keyed fields or plain elements.
    let childs = match_ast_group_d(graph, n_id, "keyed_element", None);
    if !childs.is_empty() {
        return build_array_node(args, n_id, &childs, None).map(Some);
    }

    let elements = literal_elements(graph, n_id);
    build_array_node(args, n_id, &elements, None).map(Some)
}