use alloc::vec::Vec;
use crate::query::adj_ast;
use crate::syntax::builders::array_node::build_array_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{CodeGraph, NodeId};
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let valid: Vec<NodeId> = adj_ast(graph, n_id, None, &[])
.into_iter()
.filter(|id| {
!matches!(
graph.label_type(*id),
Some("(" | ")" | "," | "[" | "]" | "{" | "}")
)
})
.collect();
build_array_node(args, n_id, &valid).map(Some)
}