fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use crate::syntax::fields::php::while_statement;
use crate::{
    query::adj_ast,
    syntax::{
        builders::while_statement::build_while_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 condition_id = args.required_field_alt(n_id, while_statement::CONDITION)?;
    let block = args.required_field_alt(n_id, while_statement::BODY)?;

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

    build_while_statement_node(args, n_id, block, Some(condition_id)).map(Some)
}