use crate::query::pred_ast;
use crate::syntax::builders::parameter::build_parameter_node;
use crate::syntax::builders::symbol_lookup::build_symbol_lookup_node;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::{CodeGraph, NodeId};
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let symbol = node_to_str(args.ast_graph, n_id);
let parent_is_inferred =
pred_ast(args.ast_graph, n_id, None)
.first()
.is_some_and(|parent_id| {
args.ast_graph.label_type(*parent_id) == Some("inferred_parameters")
});
if parent_is_inferred {
return build_parameter_node(args, n_id, Some(symbol), None, None, &[], None, None)
.map(Some);
}
Ok(Some(build_symbol_lookup_node(args, n_id, symbol)))
}