use alloc::borrow::ToOwned;
use crate::query::{label_text, match_ast_d};
use crate::syntax::builders::string_literal::build_string_literal_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::NodeId;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let value = match_ast_d(graph, n_id, "string_content", None)
.and_then(|value_id| label_text(graph, value_id))
.filter(|text| !text.is_empty())
.map_or_else(|| node_to_str(graph, n_id), ToOwned::to_owned);
Ok(Some(build_string_literal_node(args, n_id, value, &[])?))
}