fluidattacks-blends-domain 0.6.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::{adj_ast, match_ast};
use crate::syntax::builders::using_statement::build_using_statement_node;
use crate::syntax::fields::c_sharp::using_statement;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{CodeGraph, NodeId};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let mut block_id = args.required_field_alt(n_id, using_statement::BODY)?;
    if graph.label_type(block_id) == Some("expression_statement") {
        block_id = adj_ast(graph, block_id, None, &[])
            .into_iter()
            .next()
            .ok_or(SyntaxGraphError::UnexpectedAstShape)?;
    }
    let declaration_id = match_ast(graph, n_id, &["variable_declaration"], None)
        .get("variable_declaration")
        .copied()
        .flatten();
    build_using_statement_node(args, n_id, block_id, declaration_id).map(Some)
}