use crate::query::adj_ast;
use crate::syntax::builders::parenthesized_expression::build_parenthesized_expression_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let childs = adj_ast(args.ast_graph, n_id, Some(1), &[]);
let c_id = if childs.len() == 3 {
childs.get(1).copied()
} else {
childs.iter().nth_back(1).copied()
}
.ok_or(SyntaxGraphError::UnexpectedAstShape)?;
build_parenthesized_expression_node(args, n_id, c_id).map(Some)
}