use crate::query::adj_ast;
use crate::syntax::builders::unary_expression::build_unary_expression_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 (operand_id, operator) = match adj_ast(graph, n_id, None, &[]).as_slice() {
[operand, operator, ..] => (*operand, node_to_str(graph, *operator)),
_ => return Err(SyntaxGraphError::UnexpectedAstShape),
};
build_unary_expression_node(args, n_id, operator, operand_id).map(Some)
}