fluidattacks-blends-domain 0.37.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    syntax::{
        builders::{
            member_access::build_member_access_node, symbol_lookup::build_symbol_lookup_node,
        },
        fields::rust::scoped_identifier,
        SyntaxGraphArgs, SyntaxGraphError,
    },
    utilities::text_nodes::node_to_str,
    NodeId,
};

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

    if let Some(path_id) = args.optional_field_alt(n_id, scoped_identifier::PATH) {
        let expression = node_to_str(graph, path_id);
        return build_member_access_node(args, n_id, member, expression, path_id).map(Some);
    }

    Ok(Some(build_symbol_lookup_node(args, n_id, member)))
}