use crate::syntax::builders::parameter::build_parameter_node;
use crate::syntax::fields::c_sharp::catch_declaration;
use crate::syntax::{SyntaxGraphArgs, SyntaxGraphError};
use crate::utilities::text_nodes::node_to_str;
use crate::NodeId;
pub fn reader(
args: &mut SyntaxGraphArgs<'_>,
n_id: NodeId,
) -> Result<Option<NodeId>, SyntaxGraphError> {
let graph = args.ast_graph;
let variable = args
.optional_field_alt(n_id, catch_declaration::NAME)
.map_or_else(
|| node_to_str(graph, n_id),
|name_id| node_to_str(graph, name_id),
);
let variable_type = args
.required_field_alt(n_id, catch_declaration::TYPE)
.ok()
.map(|type_id| node_to_str(graph, type_id));
build_parameter_node(
args,
n_id,
Some(variable),
variable_type,
None,
&[],
None,
None,
)
.map(Some)
}