fluidattacks-blends-domain 0.6.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::{get_node_by_path, match_ast_group_d};
use crate::syntax::builders::class_declaration::build_class_node;
use crate::syntax::fields::c_sharp::class_declaration;
use crate::syntax::readers::c_sharp::common::access_modifiers;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::NodeId;

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    // Adopting the identifier line as `label_l` is deferred to a later change.
    let graph = args.ast_graph;
    let name_id = args.required_field_alt(n_id, class_declaration::NAME)?;
    let name = node_to_str(graph, name_id);
    let block_id = args.optional_field_alt(n_id, class_declaration::BODY);
    let attr_list_ids = match_ast_group_d(graph, n_id, "attribute_list", Some(1));
    let inherited_class = get_node_by_path(graph, n_id, &["base_list", "identifier"])
        .map(|id| node_to_str(graph, id));
    let modifiers = access_modifiers(graph, n_id);

    build_class_node(
        args,
        n_id,
        name,
        block_id,
        &attr_list_ids,
        inherited_class,
        None,
        modifiers,
    )
    .map(Some)
}