use alloc::string::String;
use alloc::vec::Vec;
use crate::query::adj_ast;
use crate::syntax::builders::object::build_object_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 c_ids: Vec<NodeId> = adj_ast(graph, n_id, None, &[])
.into_iter()
.filter(|id| {
!matches!(
graph.label_type(*id),
Some("new" | "{" | "(" | "}" | ")" | "," | "name_equals" | "=")
)
})
.collect();
build_object_node(
args,
n_id,
&c_ids,
Some(String::from("AnonymousObject")),
None,
)
.map(Some)
}