fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::fields::ruby::element_reference;
use crate::{
    query::adj_ast,
    syntax::{
        builders::element_access::build_element_access_node, SyntaxGraphArgs, SyntaxGraphError,
    },
    CodeGraph, NodeId,
};

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

    let argument_id = adj_ast(graph, n_id, Some(1), &[])
        .into_iter()
        .find(|&child| child != expr_id && !matches!(graph.label_type(child), Some("[" | "]")));

    build_element_access_node(args, n_id, expr_id, argument_id).map(Some)
}