lib_ruby_parser_ast/nodes/types/
if_ternary.rs1use crate::nodes::InnerNode;
4use crate::nodes::InspectVec;
5use crate::Loc;
6use crate::Node;
7
8#[derive(Debug, Clone, PartialEq)]
10#[repr(C)]
11pub struct IfTernary {
12 pub cond: Box<Node>,
14
15 pub if_true: Box<Node>,
17
18 pub if_false: Box<Node>,
20
21 pub question_l: Loc,
28
29 pub colon_l: Loc,
36
37 pub expression_l: Loc,
44
45}
46
47impl InnerNode for IfTernary {
48 fn expression(&self) -> &Loc {
49 &self.expression_l
50 }
51
52 fn inspected_children(&self, indent: usize) -> Vec<String> {
53 let mut result = InspectVec::new(indent);
54 result.push_node(&self.cond);
55 result.push_node(&self.if_true);
56 result.push_node(&self.if_false);
57
58 result.strings()
59 }
60
61 fn str_type(&self) -> &'static str {
62 "if"
63 }
64
65 fn print_with_locs(&self) {
66 println!("{}", self.inspect(0));
67 self.cond.inner_ref().print_with_locs();
68 self.if_true.inner_ref().print_with_locs();
69 self.if_false.inner_ref().print_with_locs();
70 self.question_l.print("question");
71 self.colon_l.print("colon");
72 self.expression_l.print("expression");
73
74 }
75}