use alloc::string::String;
use crate::query::{label_text, match_ast_d};
use crate::syntax::builders::attribute::build_attribute_node;
use crate::syntax::fields::c_sharp::attribute;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let arg_list = match_ast_d(graph, n_id, "attribute_argument_list", Some(1));
let name_id = args.required_field_alt(n_id, attribute::NAME)?;
let attr_name = String::from(label_text(graph, name_id).unwrap_or_default());
build_attribute_node(args, n_id, attr_name, arg_list).map(Some)
}