use alloc::string::String;
use crate::syntax::builders::utils::{enter_scope_stack, exit_scope_stack_if_current};
use crate::syntax::SyntaxNode;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::NodeId;
#[allow(
dead_code,
reason = "wired when a consuming language reader lands, #26553"
)]
pub fn build_module_node(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
name: String,
block_id: Option<NodeId>,
access_modifiers: Option<String>,
) -> Result<NodeId, SyntaxGraphError> {
args.syntax_graph.add_node(
n_id,
SyntaxNode::Declaration {
name,
block_id,
access_modifiers: access_modifiers.filter(|value| !value.is_empty()),
},
);
enter_scope_stack(args.syntax_graph, args.metadata, n_id);
if let Some(block_id) = block_id {
let built = args.generic(block_id)?;
args.syntax_graph.add_ast_edge(n_id, built);
}
exit_scope_stack_if_current(args.metadata, n_id);
Ok(n_id)
}