fluidattacks-blends-domain 0.2.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::adj_ast;
use crate::syntax::builders::file::build_file_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{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 valid = &[
        "class_declaration",
        "delegate_declaration",
        "enum_declaration",
        "extern_alias_directive",
        "identifier",
        "interface_declaration",
        "record_declaration",
        "record_struct_declaration",
        "struct_declaration",
        "using_directive",
    ];

    let childs_id: Vec<NodeId> = adj_ast(graph, n_id, Some(1), &[])
        .into_iter()
        .filter(|child| {
            graph
                .label_type(*child)
                .is_some_and(|kind| valid.contains(&kind))
        })
        .collect();

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