lib_ruby_parser_ast/nodes/types/
xstr.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 executable string (i.e. `` `sh #{script_name}` ``)
9#[derive(Debug, Clone, PartialEq)]
10#[repr(C)]
11pub struct Xstr {
12    /// A list of string parts (static literals and interpolated expressions)
13    pub parts: Vec<Node>,
14
15    /// Location of the string begin
16    ///
17    /// ```text
18    /// `#{foo}`
19    /// ~
20    ///
21    /// %X{#{foo}}
22    /// ~~~
23    /// ```
24    pub begin_l: Loc,
25
26    /// Location of the string end
27    ///
28    /// ```text
29    /// `#{foo}`
30    ///        ~
31    ///
32    /// %X{#{foo}}
33    ///          ~
34    /// ```
35    pub end_l: Loc,
36
37    /// Location of the full expression
38    ///
39    /// ```text
40    /// `#{foo}`
41    /// ~~~~~~~~
42    ///
43    /// %X{#{foo}}
44    /// ~~~~~~~~~~
45    /// ```
46    pub expression_l: Loc,
47
48}
49
50impl InnerNode for Xstr {
51    fn expression(&self) -> &Loc {
52        &self.expression_l
53    }
54
55    fn inspected_children(&self, indent: usize) -> Vec<String> {
56        let mut result = InspectVec::new(indent);
57        result.push_nodes(&self.parts);
58        
59        result.strings()
60    }
61
62    fn str_type(&self) -> &'static str {
63        "xstr"
64    }
65
66    fn print_with_locs(&self) {
67        println!("{}", self.inspect(0));
68        for node in self.parts.iter() { node.inner_ref().print_with_locs(); }
69        self.begin_l.print("begin");
70        self.end_l.print("end");
71        self.expression_l.print("expression");
72        
73    }
74}