use alloc::format;
use alloc::string::String;
use crate::query::match_ast;
use crate::syntax::builders::reserved_word::build_reserved_word_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
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 childs = match_ast(graph, n_id, &[], None);
let expression = childs.get("__1__").copied().flatten().map_or_else(
|| String::from("PackageName Unnamed"),
|c_id| format!("PackageName {}", node_to_str(graph, c_id)),
);
Ok(Some(build_reserved_word_node(args, n_id, expression)))
}