fluidattacks-blends-domain 0.6.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::query::match_ast;
use crate::syntax::builders::switch_statement::build_switch_statement_node;
use crate::syntax::fields::java::switch_expression;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::{CodeGraph, NodeId};

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;
    let body_id = args.required_field_alt(n_id, switch_expression::BODY)?;
    let mut condition_id = args.required_field_alt(n_id, switch_expression::CONDITION)?;
    if graph.label_type(condition_id) == Some("parenthesized_expression") {
        if let Some(inner) = match_ast(graph, condition_id, &[], None)
            .get("__1__")
            .copied()
            .flatten()
        {
            condition_id = inner;
        }
    }
    build_switch_statement_node(args, n_id, body_id, condition_id).map(Some)
}