use crate::syntax::builders::binary_operation::build_binary_operation_node;
use crate::syntax::fields::javascript::binary_expression;
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 left_id = args.required_field_alt(n_id, binary_expression::LEFT)?;
let right_id = args.required_field_alt(n_id, binary_expression::RIGHT)?;
let operator = node_to_str(
graph,
args.required_field_alt(n_id, binary_expression::OPERATOR)?,
);
build_binary_operation_node(args, n_id, operator, Some(left_id), Some(right_id)).map(Some)
}