fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::adj_ast,
    syntax::{builders::file::build_file_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 c_ids: Vec<NodeId> = adj_ast(graph, n_id, Some(1), &[])
        .into_iter()
        .filter_map(|c_id| match graph.label_type(c_id) {
            Some("php_tag" | "empty_statement") => None,
            Some("expression_statement") => adj_ast(graph, c_id, Some(1), &[]).first().copied(),
            _ => Some(c_id),
        })
        .collect();

    build_file_node(args, n_id, &c_ids).map(Some)
}