fluidattacks-blends-domain 0.22.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::adj_ast,
    syntax::{builders::object::build_object_node, SyntaxGraphArgs, SyntaxGraphError},
    utilities::text_nodes::node_to_str,
    CodeGraph, NodeId,
};
use alloc::string::String;
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 = adj_ast(graph, n_id, Some(1), &[]);

    let mut name = String::new();
    for &child in &c_ids {
        if matches!(
            graph.label_type(child),
            Some("delegation_specifiers" | "type_identifier")
        ) {
            name = node_to_str(graph, child);
        }
    }

    let class_body_ids: Vec<NodeId> = c_ids
        .iter()
        .copied()
        .filter(|&id| graph.label_type(id) == Some("class_body"))
        .collect();

    build_object_node(args, n_id, &class_body_ids, Some(name), None).map(Some)
}