fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use alloc::vec::Vec;

use crate::{
    query::{adj_ast, match_ast_group_d},
    syntax::{
        builders::string_literal::build_string_literal_node, SyntaxGraphArgs, SyntaxGraphError,
    },
    utilities::text_nodes::node_to_str,
    NodeId,
};

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

    let text = node_to_str(graph, n_id);

    let valid_nodes: Vec<NodeId> = match_ast_group_d(graph, n_id, "interpolation", Some(1))
        .into_iter()
        .flat_map(|interp| adj_ast(graph, interp, Some(1), &["identifier", "element_reference"]))
        .collect();

    build_string_literal_node(args, n_id, text, &valid_nodes).map(Some)
}