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};
const VALID_PARAMETERS: &[&str] = &[
"method_definition",
"pair",
"pair_pattern",
"property_signature",
"rest_pattern",
"shorthand_property_identifier",
"shorthand_property_identifier_pattern",
"spread_element",
];
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(|c_id| {
graph
.label_type(*c_id)
.is_some_and(|label| VALID_PARAMETERS.contains(&label))
})
.collect();
build_object_node(args, n_id, &c_ids, None, None).map(Some)
}