fluidattacks-blends-domain 0.26.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::fields::php::namespace_definition;
use crate::{
    syntax::{builders::namespace::build_namespace_node, SyntaxGraphArgs, SyntaxGraphError},
    utilities::text_nodes::node_to_str,
    NodeId,
};
use alloc::borrow::ToOwned;
pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;

    let name = args
        .optional_field_alt(n_id, namespace_definition::NAME)
        .map_or_else(
            || "anonymous_namespace".to_owned(),
            |label_n_id| node_to_str(graph, label_n_id),
        );

    let block_id = args.optional_field_alt(n_id, namespace_definition::BODY);

    build_namespace_node(args, n_id, name, block_id).map(Some)
}