fluidattacks-blends-domain 0.6.0

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
18
use alloc::string::String;

use crate::query::{label_text, match_ast_d};
use crate::syntax::builders::attribute::build_attribute_node;
use crate::syntax::fields::c_sharp::attribute;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let arg_list = match_ast_d(graph, n_id, "attribute_argument_list", Some(1));
    let name_id = args.required_field_alt(n_id, attribute::NAME)?;
    let attr_name = String::from(label_text(graph, name_id).unwrap_or_default());
    build_attribute_node(args, n_id, attr_name, arg_list).map(Some)
}