fluidattacks-blends-domain 0.40.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::{
    syntax::{
        builders::{
            symbol_lookup::build_symbol_lookup_node, unary_expression::build_unary_expression_node,
        },
        fields::swift::prefix_expression,
        SyntaxGraphArgs, SyntaxGraphError,
    },
    utilities::text_nodes::node_to_str,
    NodeId,
};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let operation_id = args.required_field_alt(n_id, prefix_expression::OPERATION)?;
    let operator = node_to_str(args.ast_graph, operation_id);

    if operator == "." {
        let prefix = node_to_str(args.ast_graph, n_id);
        return Ok(Some(build_symbol_lookup_node(args, n_id, prefix)));
    }

    let operand_id = args.required_field_alt(n_id, prefix_expression::TARGET)?;
    build_unary_expression_node(args, n_id, operator, operand_id).map(Some)
}