fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    syntax::{
        builders::method_invocation::{build_method_invocation_node, DirectChildren},
        fields::ruby::scope_resolution,
        SyntaxGraphArgs, SyntaxGraphError,
    },
    utilities::text_nodes::node_to_str,
    NodeId,
};
use alloc::format;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let constant_id = args.required_field_alt(n_id, scope_resolution::NAME)?;
    let expression = format!("::{}", node_to_str(graph, constant_id));

    let children = DirectChildren {
        expression_id: Some(constant_id),
        object_id: args.optional_field_alt(n_id, scope_resolution::SCOPE),
        ..Default::default()
    };

    build_method_invocation_node(args, n_id, expression, children, None).map(Some)
}