fluidattacks-blends-domain 0.32.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    query::{adj_ast, match_ast_group_d},
    syntax::{
        builders::method_declaration::{
            build_method_declaration_node, MethodDirectChildren, MethodListChildren,
        },
        SyntaxGraphArgs, SyntaxGraphError,
    },
    CodeGraph, NodeId,
};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;

    let parameters_list =
        match_ast_group_d(graph, n_id, "lambda_function_type_parameters", Some(1));

    let body_id = adj_ast(graph, n_id, Some(1), &[])
        .into_iter()
        .find(|&c_id| matches!(graph.label_type(c_id), Some("statements" | "function_body")));

    let direct_children = MethodDirectChildren {
        block_id: body_id,
        parameters_id: parameters_list.first().copied(),
        ..MethodDirectChildren::default()
    };

    build_method_declaration_node(
        args,
        n_id,
        None,
        &direct_children,
        &MethodListChildren::default(),
        None,
    )
    .map(Some)
}