fluidattacks-blends-domain 0.6.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::builders::class_declaration::build_class_node;
use crate::syntax::fields::java::interface_declaration;
use crate::syntax::metadata::java::add_class_to_metadata;
use crate::syntax::readers::java::common::extract_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> {
    let name_id = args.required_field_alt(n_id, interface_declaration::NAME)?;
    let name = node_to_str(args.ast_graph, name_id);
    let body_id = args.required_field_alt(n_id, interface_declaration::BODY)?;

    if args.syntax_graph.nodes.contains_key(&NodeId(0)) {
        add_class_to_metadata(args, n_id, &name)?;
    }

    let (modifiers_id, access_modifiers) = extract_modifiers(args.ast_graph, n_id);
    build_class_node(
        args,
        n_id,
        name,
        Some(body_id),
        &[],
        None,
        modifiers_id,
        access_modifiers,
    )
    .map(Some)
}