fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::query::match_ast_group_d;
use crate::syntax::builders::expression_statement::build_expression_statement_node;
use crate::syntax::readers::javascript::variable_declarator::build_declarator;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let var_ids = match_ast_group_d(args.ast_graph, n_id, "variable_declarator", Some(1));
    if let [declarator_id] = var_ids.as_slice() {
        return build_declarator(args, n_id, *declarator_id).map(Some);
    }

    build_expression_statement_node(args, n_id, &var_ids).map(Some)
}