fluidattacks-blends-domain 0.17.1

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

pub fn reader(
    args: &mut SyntaxGraphArgs<'_>,
    n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
    let graph = args.ast_graph;

    let mut value_id = args.required_field_alt(n_id, switch_statement::CONDITION)?;

    if graph.label_type(value_id) == Some("parenthesized_expression") {
        if let Some(clean_val) = adj_ast(graph, value_id, Some(1), &[]).get(1).copied() {
            value_id = clean_val;
        }
    }

    let body_id = args.required_field_alt(n_id, switch_statement::BODY)?;

    build_switch_statement_node(args, n_id, body_id, value_id).map(Some)
}