fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::match_ast,
    syntax::{
        builders::method_invocation::{build_method_invocation_node, DirectChildren},
        SyntaxGraphArgs, SyntaxGraphError,
    },
    NodeId,
};
use alloc::borrow::ToOwned;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let childs = match_ast(graph, n_id, &["string_content", "interpolation"], Some(1));
    let arg_id = childs
        .get("string_content")
        .copied()
        .flatten()
        .or_else(|| childs.get("interpolation").copied().flatten());

    let children = DirectChildren {
        arguments_id: arg_id,
        ..Default::default()
    };

    build_method_invocation_node(
        args,
        n_id,
        "ruby_subshell_command".to_owned(),
        children,
        None,
    )
    .map(Some)
}