lib_ruby_parser_ast/nodes/types/
kwoptarg.rs

1// This file is autogenerated by codegen/node_file.liquid
2
3use crate::nodes::InnerNode;
4use crate::nodes::InspectVec;
5use crate::Loc;
6use crate::Node;
7
8/// Represents an optional keyword argument (i.e. `foo` in `def m(foo: 42); end`)
9#[derive(Debug, Clone, PartialEq)]
10#[repr(C)]
11pub struct Kwoptarg {
12    /// Name of the optional keyword argument
13    pub name: String,
14
15    /// Default value of the optional keyword argument
16    pub default: Box<Node>,
17
18    /// Location of the argument name
19    ///
20    /// ```text
21    /// def m(foo: 1); end
22    ///       ~~~
23    /// ```
24    pub name_l: Loc,
25
26    /// Location of the argument name
27    ///
28    /// ```text
29    /// def m(foo: 1); end
30    ///       ~~~~~~
31    /// ```
32    pub expression_l: Loc,
33
34}
35
36impl InnerNode for Kwoptarg {
37    fn expression(&self) -> &Loc {
38        &self.expression_l
39    }
40
41    fn inspected_children(&self, indent: usize) -> Vec<String> {
42        let mut result = InspectVec::new(indent);
43        result.push_str(&self.name);
44        result.push_node(&self.default);
45        
46        result.strings()
47    }
48
49    fn str_type(&self) -> &'static str {
50        "kwoptarg"
51    }
52
53    fn print_with_locs(&self) {
54        println!("{}", self.inspect(0));
55        self.default.inner_ref().print_with_locs();
56        self.name_l.print("name");
57        self.expression_l.print("expression");
58        
59    }
60}