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