fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::builders::parameter::build_parameter_node;
use crate::syntax::fields::go::parameter_declaration;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let name_id = args.optional_field_alt(n_id, parameter_declaration::NAME);
    let type_id = args.required_field_alt(n_id, parameter_declaration::TYPE)?;

    let graph = args.ast_graph;
    let variable = name_id.map(|id| node_to_str(graph, id));
    let variable_type = node_to_str(graph, type_id);

    build_parameter_node(
        args,
        n_id,
        variable,
        Some(variable_type),
        None,
        &[],
        None,
        None,
    )
    .map(Some)
}