fluidattacks-blends-domain 0.17.1

Blends functional core: pure AST graph to syntax graph (no_std)
Documentation
use alloc::vec::Vec;

use crate::query::adj_ast;
use crate::syntax::builders::class_body::build_class_body_node;
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 c_ids = adj_ast(graph, n_id, None, &[]);

    let inner = c_ids
        .get(1..c_ids.len().saturating_sub(1))
        .unwrap_or_default();

    // The `;` after a field declaration has no reader, so keeping it would hang
    // a `MissingNode` off the body. Typescript already drops it.
    let members: Vec<NodeId> = inner
        .iter()
        .copied()
        .filter(|c_id| graph.label_type(*c_id) != Some(";"))
        .collect();

    build_class_body_node(args, n_id, &members).map(Some)
}