fluidattacks-blends-domain 0.6.0

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::builders::annotation::build_annotation_node;
use crate::syntax::fields::java::{annotation, marker_annotation};
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::{CodeGraph, NodeId};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let (annotation_id, args_id) = match args.ast_graph.label_type(n_id) {
        Some("annotation") => (
            args.required_field_alt(n_id, annotation::NAME)?,
            Some(args.required_field_alt(n_id, annotation::ARGUMENTS)?),
        ),
        Some("marker_annotation") => (
            args.required_field_alt(n_id, marker_annotation::NAME)?,
            None,
        ),
        _ => return Err(SyntaxGraphError::UnexpectedAstShape),
    };
    let annotation_name = node_to_str(args.ast_graph, annotation_id);
    build_annotation_node(args, n_id, annotation_name, args_id).map(Some)
}