use crate::{
query::match_ast_d,
syntax::{
builders::import_statement::{build_import_node, ImportElement},
SyntaxGraphArgs, SyntaxGraphError,
},
utilities::text_nodes::node_to_str,
NodeId,
};
use alloc::string::String;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let expression = match_ast_d(graph, n_id, "identifier", Some(1))
.map_or_else(String::new, |identifier_n_id| {
node_to_str(graph, identifier_n_id)
});
let element = ImportElement {
expression: Some(expression),
..ImportElement::default()
};
build_import_node(args, n_id, &element).map(Some)
}