fluidattacks-blends-domain 0.23.0

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), &[]);

    let mut filtered_ids: Vec<NodeId> = Vec::new();

    for id in c_ids {
        if graph.label_type(id) == Some("statement") {
            filtered_ids.extend(adj_ast(graph, id, Some(1), &[]));
            continue;
        }
        filtered_ids.push(id);
    }

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