use alloc::vec::Vec;
use crate::query::{label_text, match_ast_group_d};
use crate::syntax::builders::symbol_lookup::build_symbol_lookup_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;
#[expect(
clippy::unnecessary_wraps,
reason = "the signature must match the reader dispatch table"
)]
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let parts: Vec<&str> = match_ast_group_d(graph, n_id, "identifier", Some(1))
.into_iter()
.filter_map(|id| label_text(graph, id))
.collect();
let var_name = parts.join(".");
Ok(Some(build_symbol_lookup_node(args, n_id, var_name)))
}