use crate::{
query::{adj_ast, match_ast_d},
syntax::{
builders::execution_block::build_execution_block_node, SyntaxGraphArgs, SyntaxGraphError,
},
CodeGraph, NodeId,
};
use alloc::vec::Vec;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let source_id = match_ast_d(graph, n_id, "statements", Some(1)).unwrap_or(n_id);
let filtered_ids: Vec<NodeId> = adj_ast(graph, source_id, Some(1), &[])
.into_iter()
.filter(|&c_id| !matches!(graph.label_type(c_id), Some("{" | "}")))
.collect();
build_execution_block_node(args, n_id, &filtered_ids).map(Some)
}