prism 2.0.0.rc1-x86_64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. checksums.yaml +7 -0
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +870 -0
  4. data/CODE_OF_CONDUCT.md +76 -0
  5. data/CONTRIBUTING.md +58 -0
  6. data/LICENSE.md +7 -0
  7. data/Makefile +145 -0
  8. data/README.md +81 -0
  9. data/config.yml +4752 -0
  10. data/docs/build_system.md +119 -0
  11. data/docs/configuration.md +69 -0
  12. data/docs/cruby_compilation.md +27 -0
  13. data/docs/design.md +53 -0
  14. data/docs/encoding.md +121 -0
  15. data/docs/fuzzing.md +81 -0
  16. data/docs/heredocs.md +36 -0
  17. data/docs/javascript.md +133 -0
  18. data/docs/local_variable_depth.md +229 -0
  19. data/docs/mapping.md +117 -0
  20. data/docs/parser_translation.md +24 -0
  21. data/docs/parsing_rules.md +22 -0
  22. data/docs/releasing.md +147 -0
  23. data/docs/relocation.md +32 -0
  24. data/docs/ripper_translation.md +63 -0
  25. data/docs/ruby_api.md +45 -0
  26. data/docs/ruby_parser_translation.md +19 -0
  27. data/docs/serialization.md +230 -0
  28. data/docs/testing.md +72 -0
  29. data/ext/prism/api_node.c +7005 -0
  30. data/ext/prism/extconf.rb +126 -0
  31. data/ext/prism/extension.c +1783 -0
  32. data/ext/prism/extension.h +19 -0
  33. data/include/prism/arena.h +37 -0
  34. data/include/prism/ast.h +10371 -0
  35. data/include/prism/buffer.h +52 -0
  36. data/include/prism/comments.h +55 -0
  37. data/include/prism/compiler/accel.h +24 -0
  38. data/include/prism/compiler/align.h +36 -0
  39. data/include/prism/compiler/assume.h +25 -0
  40. data/include/prism/compiler/exported.h +24 -0
  41. data/include/prism/compiler/fallthrough.h +22 -0
  42. data/include/prism/compiler/filesystem.h +32 -0
  43. data/include/prism/compiler/flex_array.h +19 -0
  44. data/include/prism/compiler/force_inline.h +21 -0
  45. data/include/prism/compiler/format.h +25 -0
  46. data/include/prism/compiler/inline.h +17 -0
  47. data/include/prism/compiler/nodiscard.h +22 -0
  48. data/include/prism/compiler/nonnull.h +18 -0
  49. data/include/prism/compiler/unused.h +18 -0
  50. data/include/prism/constant_pool.h +81 -0
  51. data/include/prism/diagnostic.h +93 -0
  52. data/include/prism/errors_format.h +53 -0
  53. data/include/prism/excludes.h +29 -0
  54. data/include/prism/integer.h +41 -0
  55. data/include/prism/internal/allocator.h +68 -0
  56. data/include/prism/internal/allocator_debug.h +88 -0
  57. data/include/prism/internal/arena.h +108 -0
  58. data/include/prism/internal/bit.h +42 -0
  59. data/include/prism/internal/buffer.h +91 -0
  60. data/include/prism/internal/char.h +145 -0
  61. data/include/prism/internal/comments.h +53 -0
  62. data/include/prism/internal/constant_pool.h +152 -0
  63. data/include/prism/internal/diagnostic.h +389 -0
  64. data/include/prism/internal/encoding.h +242 -0
  65. data/include/prism/internal/integer.h +68 -0
  66. data/include/prism/internal/isinf.h +16 -0
  67. data/include/prism/internal/line_offset_list.h +34 -0
  68. data/include/prism/internal/list.h +62 -0
  69. data/include/prism/internal/magic_comments.h +23 -0
  70. data/include/prism/internal/memchr.h +15 -0
  71. data/include/prism/internal/node.h +38 -0
  72. data/include/prism/internal/options.h +232 -0
  73. data/include/prism/internal/parser.h +984 -0
  74. data/include/prism/internal/regexp.h +26 -0
  75. data/include/prism/internal/serialize.h +39 -0
  76. data/include/prism/internal/source.h +72 -0
  77. data/include/prism/internal/static_literals.h +100 -0
  78. data/include/prism/internal/stringy.h +35 -0
  79. data/include/prism/internal/strncasecmp.h +18 -0
  80. data/include/prism/internal/strpbrk.h +33 -0
  81. data/include/prism/internal/tokens.h +11 -0
  82. data/include/prism/json.h +32 -0
  83. data/include/prism/line_offset_list.h +61 -0
  84. data/include/prism/magic_comments.h +35 -0
  85. data/include/prism/node.h +94 -0
  86. data/include/prism/options.h +354 -0
  87. data/include/prism/parser.h +404 -0
  88. data/include/prism/prettyprint.h +31 -0
  89. data/include/prism/serialize.h +115 -0
  90. data/include/prism/source.h +155 -0
  91. data/include/prism/stream.h +28 -0
  92. data/include/prism/string_query.h +63 -0
  93. data/include/prism/stringy.h +72 -0
  94. data/include/prism/version.h +38 -0
  95. data/include/prism.h +131 -0
  96. data/lib/prism/3.3/prism.so +0 -0
  97. data/lib/prism/3.4/prism.so +0 -0
  98. data/lib/prism/4.0/prism.so +0 -0
  99. data/lib/prism/compiler.rb +815 -0
  100. data/lib/prism/desugar_compiler.rb +463 -0
  101. data/lib/prism/dispatcher.rb +2383 -0
  102. data/lib/prism/dot_visitor.rb +4848 -0
  103. data/lib/prism/dsl.rb +1369 -0
  104. data/lib/prism/ffi.rb +740 -0
  105. data/lib/prism/inspect_visitor.rb +2425 -0
  106. data/lib/prism/lex_compat.rb +953 -0
  107. data/lib/prism/mutation_compiler.rb +780 -0
  108. data/lib/prism/node.rb +33204 -0
  109. data/lib/prism/node_ext.rb +504 -0
  110. data/lib/prism/node_find.rb +215 -0
  111. data/lib/prism/parse_result/errors.rb +72 -0
  112. data/lib/prism/parse_result/newlines.rb +423 -0
  113. data/lib/prism/parse_result.rb +1221 -0
  114. data/lib/prism/pattern.rb +314 -0
  115. data/lib/prism/polyfill/append_as_bytes.rb +15 -0
  116. data/lib/prism/polyfill/byteindex.rb +13 -0
  117. data/lib/prism/polyfill/scan_byte.rb +14 -0
  118. data/lib/prism/polyfill/unpack1.rb +14 -0
  119. data/lib/prism/polyfill/warn.rb +36 -0
  120. data/lib/prism/reflection.rb +427 -0
  121. data/lib/prism/relocation.rb +567 -0
  122. data/lib/prism/serialize.rb +5308 -0
  123. data/lib/prism/string_query.rb +46 -0
  124. data/lib/prism/translation/parser/builder.rb +70 -0
  125. data/lib/prism/translation/parser/compiler.rb +2226 -0
  126. data/lib/prism/translation/parser/lexer.rb +769 -0
  127. data/lib/prism/translation/parser.rb +376 -0
  128. data/lib/prism/translation/parser_current.rb +26 -0
  129. data/lib/prism/translation/parser_versions.rb +36 -0
  130. data/lib/prism/translation/ripper/filter.rb +53 -0
  131. data/lib/prism/translation/ripper/lexer.rb +133 -0
  132. data/lib/prism/translation/ripper/sexp.rb +118 -0
  133. data/lib/prism/translation/ripper/shim.rb +7 -0
  134. data/lib/prism/translation/ripper.rb +4278 -0
  135. data/lib/prism/translation/ruby_parser.rb +1721 -0
  136. data/lib/prism/translation.rb +20 -0
  137. data/lib/prism/visitor.rb +1440 -0
  138. data/lib/prism.rb +168 -0
  139. data/prism.gemspec +234 -0
  140. data/rbi/generated/prism/compiler.rbi +489 -0
  141. data/rbi/generated/prism/desugar_compiler.rbi +306 -0
  142. data/rbi/generated/prism/dispatcher.rbi +1138 -0
  143. data/rbi/generated/prism/dot_visitor.rbi +618 -0
  144. data/rbi/generated/prism/dsl.rbi +751 -0
  145. data/rbi/generated/prism/inspect_visitor.rbi +503 -0
  146. data/rbi/generated/prism/lex_compat.rbi +162 -0
  147. data/rbi/generated/prism/mutation_compiler.rbi +464 -0
  148. data/rbi/generated/prism/node.rbi +13681 -0
  149. data/rbi/generated/prism/node_ext.rbi +259 -0
  150. data/rbi/generated/prism/node_find.rbi +79 -0
  151. data/rbi/generated/prism/parse_result/errors.rbi +21 -0
  152. data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
  153. data/rbi/generated/prism/parse_result.rbi +764 -0
  154. data/rbi/generated/prism/pattern.rbi +134 -0
  155. data/rbi/generated/prism/reflection.rbi +89 -0
  156. data/rbi/generated/prism/relocation.rbi +329 -0
  157. data/rbi/generated/prism/serialize.rbi +181 -0
  158. data/rbi/generated/prism/string_query.rbi +36 -0
  159. data/rbi/generated/prism/translation.rbi +7 -0
  160. data/rbi/generated/prism/visitor.rbi +650 -0
  161. data/rbi/generated/prism.rbi +86 -0
  162. data/rbi/prism/translation/parser.rbi +11 -0
  163. data/rbi/prism/translation/parser_versions.rbi +28 -0
  164. data/rbi/prism/translation/ripper.rbi +15 -0
  165. data/rbi/rubyvm/node_find.rbi +14 -0
  166. data/sig/generated/prism/compiler.rbs +492 -0
  167. data/sig/generated/prism/desugar_compiler.rbs +305 -0
  168. data/sig/generated/prism/dispatcher.rbs +1292 -0
  169. data/sig/generated/prism/dot_visitor.rbs +635 -0
  170. data/sig/generated/prism/dsl.rbs +928 -0
  171. data/sig/generated/prism/inspect_visitor.rbs +509 -0
  172. data/sig/generated/prism/lex_compat.rbs +166 -0
  173. data/sig/generated/prism/mutation_compiler.rbs +464 -0
  174. data/sig/generated/prism/node.rbs +20160 -0
  175. data/sig/generated/prism/node_ext.rbs +290 -0
  176. data/sig/generated/prism/node_find.rbs +90 -0
  177. data/sig/generated/prism/parse_result/errors.rbs +22 -0
  178. data/sig/generated/prism/parse_result/newlines.rbs +223 -0
  179. data/sig/generated/prism/parse_result.rbs +859 -0
  180. data/sig/generated/prism/pattern.rbs +156 -0
  181. data/sig/generated/prism/reflection.rbs +101 -0
  182. data/sig/generated/prism/relocation.rbs +428 -0
  183. data/sig/generated/prism/serialize.rbs +195 -0
  184. data/sig/generated/prism/string_query.rbs +36 -0
  185. data/sig/generated/prism/translation.rbs +8 -0
  186. data/sig/generated/prism/visitor.rbs +1111 -0
  187. data/sig/generated/prism.rbs +84 -0
  188. data/sig/manifest.yaml +2 -0
  189. data/src/arena.c +117 -0
  190. data/src/buffer.c +380 -0
  191. data/src/char.c +289 -0
  192. data/src/comments.c +454 -0
  193. data/src/constant_pool.c +406 -0
  194. data/src/diagnostic.c +886 -0
  195. data/src/encoding.c +5345 -0
  196. data/src/errors_format.c +519 -0
  197. data/src/integer.c +681 -0
  198. data/src/json.c +5733 -0
  199. data/src/line_offset_list.c +100 -0
  200. data/src/list.c +24 -0
  201. data/src/memchr.c +37 -0
  202. data/src/node.c +4515 -0
  203. data/src/options.c +451 -0
  204. data/src/parser.c +349 -0
  205. data/src/prettyprint.c +9024 -0
  206. data/src/prism.c +23739 -0
  207. data/src/regexp.c +1706 -0
  208. data/src/serialize.c +2309 -0
  209. data/src/source.c +518 -0
  210. data/src/static_literals.c +685 -0
  211. data/src/string_query.c +166 -0
  212. data/src/stringy.c +91 -0
  213. data/src/strncasecmp.c +37 -0
  214. data/src/strpbrk.c +447 -0
  215. data/src/tokens.c +724 -0
  216. metadata +259 -0
@@ -0,0 +1,2425 @@
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+
4
+ =begin
5
+ --
6
+ This file is generated by the templates/template.rb script and should not be
7
+ modified manually. See templates/lib/prism/inspect_visitor.rb.erb
8
+ if you are looking to modify the template
9
+ ++
10
+ =end
11
+
12
+ #--
13
+ # rbs_inline: enabled
14
+
15
+ module Prism
16
+ # This visitor is responsible for composing the strings that get returned by
17
+ # the various #inspect methods defined on each of the nodes.
18
+ class InspectVisitor < Visitor
19
+ # Most of the time, we can simply pass down the indent to the next node.
20
+ # However, when we are inside a list we want some extra special formatting
21
+ # when we hit an element in that list. In this case, we have a special
22
+ # command that replaces the subsequent indent with the given value.
23
+ class Replace # :nodoc:
24
+ attr_reader :value #: String
25
+
26
+ #: (String value) -> void
27
+ def initialize(value)
28
+ @value = value
29
+ end
30
+ end
31
+
32
+ private_constant :Replace
33
+
34
+ # The current prefix string.
35
+ # :stopdoc:
36
+ attr_reader :indent #: String
37
+ # :startdoc:
38
+
39
+ # The list of commands that we need to execute in order to compose the
40
+ # final string.
41
+ #: stopdoc:
42
+ attr_reader :commands #: Array[[String | node | Replace, String]]
43
+ # :startdoc:
44
+
45
+ #: (?String indent) -> void
46
+ def initialize(indent = +"") # :nodoc:
47
+ @indent = indent
48
+ @commands = []
49
+ end
50
+
51
+ # Compose an inspect string for the given node.
52
+ #
53
+ #: (node node) -> String
54
+ def self.compose(node)
55
+ visitor = new
56
+ node.accept(visitor)
57
+ visitor.compose
58
+ end
59
+
60
+ # Compose the final string.
61
+ #
62
+ #: () -> String
63
+ def compose # :nodoc:
64
+ buffer = +""
65
+ replace = nil
66
+
67
+ until commands.empty?
68
+ # @type var command: String | node | Replace
69
+ # @type var indent: String
70
+ command, indent = *commands.shift
71
+
72
+ case command
73
+ when String
74
+ buffer << (replace || indent)
75
+ buffer << command
76
+ replace = nil
77
+ when Node
78
+ visitor = InspectVisitor.new(indent)
79
+ command.accept(visitor)
80
+ @commands = [*visitor.commands, *@commands]
81
+ when Replace
82
+ replace = command.value
83
+ else
84
+ raise "Unknown command: #{command.inspect}"
85
+ end
86
+ end
87
+
88
+ buffer
89
+ end
90
+
91
+ #: (AliasGlobalVariableNode node) -> void
92
+ def visit_alias_global_variable_node(node) # :nodoc:
93
+ commands << [inspect_node("AliasGlobalVariableNode", node), indent]
94
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
95
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
96
+ commands << ["├── new_name:\n", indent]
97
+ commands << [node.new_name, "#{indent}│ "]
98
+ commands << ["├── old_name:\n", indent]
99
+ commands << [node.old_name, "#{indent}│ "]
100
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
101
+ end
102
+
103
+ #: (AliasMethodNode node) -> void
104
+ def visit_alias_method_node(node) # :nodoc:
105
+ commands << [inspect_node("AliasMethodNode", node), indent]
106
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
107
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
108
+ commands << ["├── new_name:\n", indent]
109
+ commands << [node.new_name, "#{indent}│ "]
110
+ commands << ["├── old_name:\n", indent]
111
+ commands << [node.old_name, "#{indent}│ "]
112
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
113
+ end
114
+
115
+ #: (AlternationPatternNode node) -> void
116
+ def visit_alternation_pattern_node(node) # :nodoc:
117
+ commands << [inspect_node("AlternationPatternNode", node), indent]
118
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
119
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
120
+ commands << ["├── left:\n", indent]
121
+ commands << [node.left, "#{indent}│ "]
122
+ commands << ["├── right:\n", indent]
123
+ commands << [node.right, "#{indent}│ "]
124
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
125
+ end
126
+
127
+ #: (AndNode node) -> void
128
+ def visit_and_node(node) # :nodoc:
129
+ commands << [inspect_node("AndNode", node), indent]
130
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
131
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
132
+ commands << ["├── left:\n", indent]
133
+ commands << [node.left, "#{indent}│ "]
134
+ commands << ["├── right:\n", indent]
135
+ commands << [node.right, "#{indent}│ "]
136
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
137
+ end
138
+
139
+ #: (ArgumentsNode node) -> void
140
+ def visit_arguments_node(node) # :nodoc:
141
+ commands << [inspect_node("ArgumentsNode", node), indent]
142
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("contains_forwarding" if node.contains_forwarding?), ("contains_keywords" if node.contains_keywords?), ("contains_keyword_splat" if node.contains_keyword_splat?), ("contains_splat" if node.contains_splat?), ("contains_multiple_splats" if node.contains_multiple_splats?)].compact
143
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
144
+ commands << ["└── arguments: (length: #{(arguments = node.arguments).length})\n", indent]
145
+ if arguments.any?
146
+ arguments[0...-1].each do |child|
147
+ commands << [Replace.new("#{indent} ├── "), indent]
148
+ commands << [child, "#{indent} │ "]
149
+ end
150
+ commands << [Replace.new("#{indent} └── "), indent]
151
+ commands << [arguments[-1], "#{indent} "]
152
+ end
153
+ end
154
+
155
+ #: (ArrayNode node) -> void
156
+ def visit_array_node(node) # :nodoc:
157
+ commands << [inspect_node("ArrayNode", node), indent]
158
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("contains_splat" if node.contains_splat?)].compact
159
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
160
+ commands << ["├── elements: (length: #{(elements = node.elements).length})\n", indent]
161
+ if elements.any?
162
+ elements[0...-1].each do |child|
163
+ commands << [Replace.new("#{indent}│ ├── "), indent]
164
+ commands << [child, "#{indent}│ │ "]
165
+ end
166
+ commands << [Replace.new("#{indent}│ └── "), indent]
167
+ commands << [elements[-1], "#{indent}│ "]
168
+ end
169
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
170
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
171
+ end
172
+
173
+ #: (ArrayPatternNode node) -> void
174
+ def visit_array_pattern_node(node) # :nodoc:
175
+ commands << [inspect_node("ArrayPatternNode", node), indent]
176
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
177
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
178
+ if (constant = node.constant).nil?
179
+ commands << ["├── constant: ∅\n", indent]
180
+ else
181
+ commands << ["├── constant:\n", indent]
182
+ commands << [constant, "#{indent}│ "]
183
+ end
184
+ commands << ["├── requireds: (length: #{(requireds = node.requireds).length})\n", indent]
185
+ if requireds.any?
186
+ requireds[0...-1].each do |child|
187
+ commands << [Replace.new("#{indent}│ ├── "), indent]
188
+ commands << [child, "#{indent}│ │ "]
189
+ end
190
+ commands << [Replace.new("#{indent}│ └── "), indent]
191
+ commands << [requireds[-1], "#{indent}│ "]
192
+ end
193
+ if (rest = node.rest).nil?
194
+ commands << ["├── rest: ∅\n", indent]
195
+ else
196
+ commands << ["├── rest:\n", indent]
197
+ commands << [rest, "#{indent}│ "]
198
+ end
199
+ commands << ["├── posts: (length: #{(posts = node.posts).length})\n", indent]
200
+ if posts.any?
201
+ posts[0...-1].each do |child|
202
+ commands << [Replace.new("#{indent}│ ├── "), indent]
203
+ commands << [child, "#{indent}│ │ "]
204
+ end
205
+ commands << [Replace.new("#{indent}│ └── "), indent]
206
+ commands << [posts[-1], "#{indent}│ "]
207
+ end
208
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
209
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
210
+ end
211
+
212
+ #: (AssocNode node) -> void
213
+ def visit_assoc_node(node) # :nodoc:
214
+ commands << [inspect_node("AssocNode", node), indent]
215
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
216
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
217
+ commands << ["├── key:\n", indent]
218
+ commands << [node.key, "#{indent}│ "]
219
+ commands << ["├── value:\n", indent]
220
+ commands << [node.value, "#{indent}│ "]
221
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
222
+ end
223
+
224
+ #: (AssocSplatNode node) -> void
225
+ def visit_assoc_splat_node(node) # :nodoc:
226
+ commands << [inspect_node("AssocSplatNode", node), indent]
227
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
228
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
229
+ if (value = node.value).nil?
230
+ commands << ["├── value: ∅\n", indent]
231
+ else
232
+ commands << ["├── value:\n", indent]
233
+ commands << [value, "#{indent}│ "]
234
+ end
235
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
236
+ end
237
+
238
+ #: (BackReferenceReadNode node) -> void
239
+ def visit_back_reference_read_node(node) # :nodoc:
240
+ commands << [inspect_node("BackReferenceReadNode", node), indent]
241
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
242
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
243
+ commands << ["└── name: #{node.name.inspect}\n", indent]
244
+ end
245
+
246
+ #: (BeginNode node) -> void
247
+ def visit_begin_node(node) # :nodoc:
248
+ commands << [inspect_node("BeginNode", node), indent]
249
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
250
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
251
+ commands << ["├── begin_keyword_loc: #{inspect_location(node.begin_keyword_loc)}\n", indent]
252
+ if (statements = node.statements).nil?
253
+ commands << ["├── statements: ∅\n", indent]
254
+ else
255
+ commands << ["├── statements:\n", indent]
256
+ commands << [statements, "#{indent}│ "]
257
+ end
258
+ if (rescue_clause = node.rescue_clause).nil?
259
+ commands << ["├── rescue_clause: ∅\n", indent]
260
+ else
261
+ commands << ["├── rescue_clause:\n", indent]
262
+ commands << [rescue_clause, "#{indent}│ "]
263
+ end
264
+ if (else_clause = node.else_clause).nil?
265
+ commands << ["├── else_clause: ∅\n", indent]
266
+ else
267
+ commands << ["├── else_clause:\n", indent]
268
+ commands << [else_clause, "#{indent}│ "]
269
+ end
270
+ if (ensure_clause = node.ensure_clause).nil?
271
+ commands << ["├── ensure_clause: ∅\n", indent]
272
+ else
273
+ commands << ["├── ensure_clause:\n", indent]
274
+ commands << [ensure_clause, "#{indent}│ "]
275
+ end
276
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
277
+ end
278
+
279
+ #: (BlockArgumentNode node) -> void
280
+ def visit_block_argument_node(node) # :nodoc:
281
+ commands << [inspect_node("BlockArgumentNode", node), indent]
282
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
283
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
284
+ if (expression = node.expression).nil?
285
+ commands << ["├── expression: ∅\n", indent]
286
+ else
287
+ commands << ["├── expression:\n", indent]
288
+ commands << [expression, "#{indent}│ "]
289
+ end
290
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
291
+ end
292
+
293
+ #: (BlockLocalVariableNode node) -> void
294
+ def visit_block_local_variable_node(node) # :nodoc:
295
+ commands << [inspect_node("BlockLocalVariableNode", node), indent]
296
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
297
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
298
+ commands << ["└── name: #{node.name.inspect}\n", indent]
299
+ end
300
+
301
+ #: (BlockNode node) -> void
302
+ def visit_block_node(node) # :nodoc:
303
+ commands << [inspect_node("BlockNode", node), indent]
304
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
305
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
306
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
307
+ if (parameters = node.parameters).nil?
308
+ commands << ["├── parameters: ∅\n", indent]
309
+ else
310
+ commands << ["├── parameters:\n", indent]
311
+ commands << [parameters, "#{indent}│ "]
312
+ end
313
+ if (body = node.body).nil?
314
+ commands << ["├── body: ∅\n", indent]
315
+ else
316
+ commands << ["├── body:\n", indent]
317
+ commands << [body, "#{indent}│ "]
318
+ end
319
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
320
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
321
+ end
322
+
323
+ #: (BlockParameterNode node) -> void
324
+ def visit_block_parameter_node(node) # :nodoc:
325
+ commands << [inspect_node("BlockParameterNode", node), indent]
326
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
327
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
328
+ if (name = node.name).nil?
329
+ commands << ["├── name: ∅\n", indent]
330
+ else
331
+ commands << ["├── name: #{name.inspect}\n", indent]
332
+ end
333
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
334
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
335
+ end
336
+
337
+ #: (BlockParametersNode node) -> void
338
+ def visit_block_parameters_node(node) # :nodoc:
339
+ commands << [inspect_node("BlockParametersNode", node), indent]
340
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
341
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
342
+ if (parameters = node.parameters).nil?
343
+ commands << ["├── parameters: ∅\n", indent]
344
+ else
345
+ commands << ["├── parameters:\n", indent]
346
+ commands << [parameters, "#{indent}│ "]
347
+ end
348
+ commands << ["├── locals: (length: #{(locals = node.locals).length})\n", indent]
349
+ if locals.any?
350
+ locals[0...-1].each do |child|
351
+ commands << [Replace.new("#{indent}│ ├── "), indent]
352
+ commands << [child, "#{indent}│ │ "]
353
+ end
354
+ commands << [Replace.new("#{indent}│ └── "), indent]
355
+ commands << [locals[-1], "#{indent}│ "]
356
+ end
357
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
358
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
359
+ end
360
+
361
+ #: (BreakNode node) -> void
362
+ def visit_break_node(node) # :nodoc:
363
+ commands << [inspect_node("BreakNode", node), indent]
364
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
365
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
366
+ if (arguments = node.arguments).nil?
367
+ commands << ["├── arguments: ∅\n", indent]
368
+ else
369
+ commands << ["├── arguments:\n", indent]
370
+ commands << [arguments, "#{indent}│ "]
371
+ end
372
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
373
+ end
374
+
375
+ #: (CallAndWriteNode node) -> void
376
+ def visit_call_and_write_node(node) # :nodoc:
377
+ commands << [inspect_node("CallAndWriteNode", node), indent]
378
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
379
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
380
+ if (receiver = node.receiver).nil?
381
+ commands << ["├── receiver: ∅\n", indent]
382
+ else
383
+ commands << ["├── receiver:\n", indent]
384
+ commands << [receiver, "#{indent}│ "]
385
+ end
386
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
387
+ commands << ["├── message_loc: #{inspect_location(node.message_loc)}\n", indent]
388
+ commands << ["├── read_name: #{node.read_name.inspect}\n", indent]
389
+ commands << ["├── write_name: #{node.write_name.inspect}\n", indent]
390
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
391
+ commands << ["└── value:\n", indent]
392
+ commands << [node.value, "#{indent} "]
393
+ end
394
+
395
+ #: (CallNode node) -> void
396
+ def visit_call_node(node) # :nodoc:
397
+ commands << [inspect_node("CallNode", node), indent]
398
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
399
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
400
+ if (receiver = node.receiver).nil?
401
+ commands << ["├── receiver: ∅\n", indent]
402
+ else
403
+ commands << ["├── receiver:\n", indent]
404
+ commands << [receiver, "#{indent}│ "]
405
+ end
406
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
407
+ commands << ["├── name: #{node.name.inspect}\n", indent]
408
+ commands << ["├── message_loc: #{inspect_location(node.message_loc)}\n", indent]
409
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
410
+ if (arguments = node.arguments).nil?
411
+ commands << ["├── arguments: ∅\n", indent]
412
+ else
413
+ commands << ["├── arguments:\n", indent]
414
+ commands << [arguments, "#{indent}│ "]
415
+ end
416
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
417
+ commands << ["├── equal_loc: #{inspect_location(node.equal_loc)}\n", indent]
418
+ if (block = node.block).nil?
419
+ commands << ["└── block: ∅\n", indent]
420
+ else
421
+ commands << ["└── block:\n", indent]
422
+ commands << [block, "#{indent} "]
423
+ end
424
+ end
425
+
426
+ #: (CallOperatorWriteNode node) -> void
427
+ def visit_call_operator_write_node(node) # :nodoc:
428
+ commands << [inspect_node("CallOperatorWriteNode", node), indent]
429
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
430
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
431
+ if (receiver = node.receiver).nil?
432
+ commands << ["├── receiver: ∅\n", indent]
433
+ else
434
+ commands << ["├── receiver:\n", indent]
435
+ commands << [receiver, "#{indent}│ "]
436
+ end
437
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
438
+ commands << ["├── message_loc: #{inspect_location(node.message_loc)}\n", indent]
439
+ commands << ["├── read_name: #{node.read_name.inspect}\n", indent]
440
+ commands << ["├── write_name: #{node.write_name.inspect}\n", indent]
441
+ commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent]
442
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
443
+ commands << ["└── value:\n", indent]
444
+ commands << [node.value, "#{indent} "]
445
+ end
446
+
447
+ #: (CallOrWriteNode node) -> void
448
+ def visit_call_or_write_node(node) # :nodoc:
449
+ commands << [inspect_node("CallOrWriteNode", node), indent]
450
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
451
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
452
+ if (receiver = node.receiver).nil?
453
+ commands << ["├── receiver: ∅\n", indent]
454
+ else
455
+ commands << ["├── receiver:\n", indent]
456
+ commands << [receiver, "#{indent}│ "]
457
+ end
458
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
459
+ commands << ["├── message_loc: #{inspect_location(node.message_loc)}\n", indent]
460
+ commands << ["├── read_name: #{node.read_name.inspect}\n", indent]
461
+ commands << ["├── write_name: #{node.write_name.inspect}\n", indent]
462
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
463
+ commands << ["└── value:\n", indent]
464
+ commands << [node.value, "#{indent} "]
465
+ end
466
+
467
+ #: (CallTargetNode node) -> void
468
+ def visit_call_target_node(node) # :nodoc:
469
+ commands << [inspect_node("CallTargetNode", node), indent]
470
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
471
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
472
+ commands << ["├── receiver:\n", indent]
473
+ commands << [node.receiver, "#{indent}│ "]
474
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
475
+ commands << ["├── name: #{node.name.inspect}\n", indent]
476
+ commands << ["└── message_loc: #{inspect_location(node.message_loc)}\n", indent]
477
+ end
478
+
479
+ #: (CapturePatternNode node) -> void
480
+ def visit_capture_pattern_node(node) # :nodoc:
481
+ commands << [inspect_node("CapturePatternNode", node), indent]
482
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
483
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
484
+ commands << ["├── value:\n", indent]
485
+ commands << [node.value, "#{indent}│ "]
486
+ commands << ["├── target:\n", indent]
487
+ commands << [node.target, "#{indent}│ "]
488
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
489
+ end
490
+
491
+ #: (CaseMatchNode node) -> void
492
+ def visit_case_match_node(node) # :nodoc:
493
+ commands << [inspect_node("CaseMatchNode", node), indent]
494
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
495
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
496
+ if (predicate = node.predicate).nil?
497
+ commands << ["├── predicate: ∅\n", indent]
498
+ else
499
+ commands << ["├── predicate:\n", indent]
500
+ commands << [predicate, "#{indent}│ "]
501
+ end
502
+ commands << ["├── conditions: (length: #{(conditions = node.conditions).length})\n", indent]
503
+ if conditions.any?
504
+ conditions[0...-1].each do |child|
505
+ commands << [Replace.new("#{indent}│ ├── "), indent]
506
+ commands << [child, "#{indent}│ │ "]
507
+ end
508
+ commands << [Replace.new("#{indent}│ └── "), indent]
509
+ commands << [conditions[-1], "#{indent}│ "]
510
+ end
511
+ if (else_clause = node.else_clause).nil?
512
+ commands << ["├── else_clause: ∅\n", indent]
513
+ else
514
+ commands << ["├── else_clause:\n", indent]
515
+ commands << [else_clause, "#{indent}│ "]
516
+ end
517
+ commands << ["├── case_keyword_loc: #{inspect_location(node.case_keyword_loc)}\n", indent]
518
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
519
+ end
520
+
521
+ #: (CaseNode node) -> void
522
+ def visit_case_node(node) # :nodoc:
523
+ commands << [inspect_node("CaseNode", node), indent]
524
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
525
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
526
+ if (predicate = node.predicate).nil?
527
+ commands << ["├── predicate: ∅\n", indent]
528
+ else
529
+ commands << ["├── predicate:\n", indent]
530
+ commands << [predicate, "#{indent}│ "]
531
+ end
532
+ commands << ["├── conditions: (length: #{(conditions = node.conditions).length})\n", indent]
533
+ if conditions.any?
534
+ conditions[0...-1].each do |child|
535
+ commands << [Replace.new("#{indent}│ ├── "), indent]
536
+ commands << [child, "#{indent}│ │ "]
537
+ end
538
+ commands << [Replace.new("#{indent}│ └── "), indent]
539
+ commands << [conditions[-1], "#{indent}│ "]
540
+ end
541
+ if (else_clause = node.else_clause).nil?
542
+ commands << ["├── else_clause: ∅\n", indent]
543
+ else
544
+ commands << ["├── else_clause:\n", indent]
545
+ commands << [else_clause, "#{indent}│ "]
546
+ end
547
+ commands << ["├── case_keyword_loc: #{inspect_location(node.case_keyword_loc)}\n", indent]
548
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
549
+ end
550
+
551
+ #: (ClassNode node) -> void
552
+ def visit_class_node(node) # :nodoc:
553
+ commands << [inspect_node("ClassNode", node), indent]
554
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
555
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
556
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
557
+ commands << ["├── class_keyword_loc: #{inspect_location(node.class_keyword_loc)}\n", indent]
558
+ commands << ["├── constant_path:\n", indent]
559
+ commands << [node.constant_path, "#{indent}│ "]
560
+ commands << ["├── inheritance_operator_loc: #{inspect_location(node.inheritance_operator_loc)}\n", indent]
561
+ if (superclass = node.superclass).nil?
562
+ commands << ["├── superclass: ∅\n", indent]
563
+ else
564
+ commands << ["├── superclass:\n", indent]
565
+ commands << [superclass, "#{indent}│ "]
566
+ end
567
+ if (body = node.body).nil?
568
+ commands << ["├── body: ∅\n", indent]
569
+ else
570
+ commands << ["├── body:\n", indent]
571
+ commands << [body, "#{indent}│ "]
572
+ end
573
+ commands << ["├── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
574
+ commands << ["└── name: #{node.name.inspect}\n", indent]
575
+ end
576
+
577
+ #: (ClassVariableAndWriteNode node) -> void
578
+ def visit_class_variable_and_write_node(node) # :nodoc:
579
+ commands << [inspect_node("ClassVariableAndWriteNode", node), indent]
580
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
581
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
582
+ commands << ["├── name: #{node.name.inspect}\n", indent]
583
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
584
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
585
+ commands << ["└── value:\n", indent]
586
+ commands << [node.value, "#{indent} "]
587
+ end
588
+
589
+ #: (ClassVariableOperatorWriteNode node) -> void
590
+ def visit_class_variable_operator_write_node(node) # :nodoc:
591
+ commands << [inspect_node("ClassVariableOperatorWriteNode", node), indent]
592
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
593
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
594
+ commands << ["├── name: #{node.name.inspect}\n", indent]
595
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
596
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
597
+ commands << ["├── value:\n", indent]
598
+ commands << [node.value, "#{indent}│ "]
599
+ commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent]
600
+ end
601
+
602
+ #: (ClassVariableOrWriteNode node) -> void
603
+ def visit_class_variable_or_write_node(node) # :nodoc:
604
+ commands << [inspect_node("ClassVariableOrWriteNode", node), indent]
605
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
606
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
607
+ commands << ["├── name: #{node.name.inspect}\n", indent]
608
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
609
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
610
+ commands << ["└── value:\n", indent]
611
+ commands << [node.value, "#{indent} "]
612
+ end
613
+
614
+ #: (ClassVariableReadNode node) -> void
615
+ def visit_class_variable_read_node(node) # :nodoc:
616
+ commands << [inspect_node("ClassVariableReadNode", node), indent]
617
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
618
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
619
+ commands << ["└── name: #{node.name.inspect}\n", indent]
620
+ end
621
+
622
+ #: (ClassVariableTargetNode node) -> void
623
+ def visit_class_variable_target_node(node) # :nodoc:
624
+ commands << [inspect_node("ClassVariableTargetNode", node), indent]
625
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
626
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
627
+ commands << ["└── name: #{node.name.inspect}\n", indent]
628
+ end
629
+
630
+ #: (ClassVariableWriteNode node) -> void
631
+ def visit_class_variable_write_node(node) # :nodoc:
632
+ commands << [inspect_node("ClassVariableWriteNode", node), indent]
633
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
634
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
635
+ commands << ["├── name: #{node.name.inspect}\n", indent]
636
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
637
+ commands << ["├── value:\n", indent]
638
+ commands << [node.value, "#{indent}│ "]
639
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
640
+ end
641
+
642
+ #: (ConstantAndWriteNode node) -> void
643
+ def visit_constant_and_write_node(node) # :nodoc:
644
+ commands << [inspect_node("ConstantAndWriteNode", node), indent]
645
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
646
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
647
+ commands << ["├── name: #{node.name.inspect}\n", indent]
648
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
649
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
650
+ commands << ["└── value:\n", indent]
651
+ commands << [node.value, "#{indent} "]
652
+ end
653
+
654
+ #: (ConstantOperatorWriteNode node) -> void
655
+ def visit_constant_operator_write_node(node) # :nodoc:
656
+ commands << [inspect_node("ConstantOperatorWriteNode", node), indent]
657
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
658
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
659
+ commands << ["├── name: #{node.name.inspect}\n", indent]
660
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
661
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
662
+ commands << ["├── value:\n", indent]
663
+ commands << [node.value, "#{indent}│ "]
664
+ commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent]
665
+ end
666
+
667
+ #: (ConstantOrWriteNode node) -> void
668
+ def visit_constant_or_write_node(node) # :nodoc:
669
+ commands << [inspect_node("ConstantOrWriteNode", node), indent]
670
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
671
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
672
+ commands << ["├── name: #{node.name.inspect}\n", indent]
673
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
674
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
675
+ commands << ["└── value:\n", indent]
676
+ commands << [node.value, "#{indent} "]
677
+ end
678
+
679
+ #: (ConstantPathAndWriteNode node) -> void
680
+ def visit_constant_path_and_write_node(node) # :nodoc:
681
+ commands << [inspect_node("ConstantPathAndWriteNode", node), indent]
682
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
683
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
684
+ commands << ["├── target:\n", indent]
685
+ commands << [node.target, "#{indent}│ "]
686
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
687
+ commands << ["└── value:\n", indent]
688
+ commands << [node.value, "#{indent} "]
689
+ end
690
+
691
+ #: (ConstantPathNode node) -> void
692
+ def visit_constant_path_node(node) # :nodoc:
693
+ commands << [inspect_node("ConstantPathNode", node), indent]
694
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
695
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
696
+ if (parent = node.parent).nil?
697
+ commands << ["├── parent: ∅\n", indent]
698
+ else
699
+ commands << ["├── parent:\n", indent]
700
+ commands << [parent, "#{indent}│ "]
701
+ end
702
+ if (name = node.name).nil?
703
+ commands << ["├── name: ∅\n", indent]
704
+ else
705
+ commands << ["├── name: #{name.inspect}\n", indent]
706
+ end
707
+ commands << ["├── delimiter_loc: #{inspect_location(node.delimiter_loc)}\n", indent]
708
+ commands << ["└── name_loc: #{inspect_location(node.name_loc)}\n", indent]
709
+ end
710
+
711
+ #: (ConstantPathOperatorWriteNode node) -> void
712
+ def visit_constant_path_operator_write_node(node) # :nodoc:
713
+ commands << [inspect_node("ConstantPathOperatorWriteNode", node), indent]
714
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
715
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
716
+ commands << ["├── target:\n", indent]
717
+ commands << [node.target, "#{indent}│ "]
718
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
719
+ commands << ["├── value:\n", indent]
720
+ commands << [node.value, "#{indent}│ "]
721
+ commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent]
722
+ end
723
+
724
+ #: (ConstantPathOrWriteNode node) -> void
725
+ def visit_constant_path_or_write_node(node) # :nodoc:
726
+ commands << [inspect_node("ConstantPathOrWriteNode", node), indent]
727
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
728
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
729
+ commands << ["├── target:\n", indent]
730
+ commands << [node.target, "#{indent}│ "]
731
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
732
+ commands << ["└── value:\n", indent]
733
+ commands << [node.value, "#{indent} "]
734
+ end
735
+
736
+ #: (ConstantPathTargetNode node) -> void
737
+ def visit_constant_path_target_node(node) # :nodoc:
738
+ commands << [inspect_node("ConstantPathTargetNode", node), indent]
739
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
740
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
741
+ if (parent = node.parent).nil?
742
+ commands << ["├── parent: ∅\n", indent]
743
+ else
744
+ commands << ["├── parent:\n", indent]
745
+ commands << [parent, "#{indent}│ "]
746
+ end
747
+ if (name = node.name).nil?
748
+ commands << ["├── name: ∅\n", indent]
749
+ else
750
+ commands << ["├── name: #{name.inspect}\n", indent]
751
+ end
752
+ commands << ["├── delimiter_loc: #{inspect_location(node.delimiter_loc)}\n", indent]
753
+ commands << ["└── name_loc: #{inspect_location(node.name_loc)}\n", indent]
754
+ end
755
+
756
+ #: (ConstantPathWriteNode node) -> void
757
+ def visit_constant_path_write_node(node) # :nodoc:
758
+ commands << [inspect_node("ConstantPathWriteNode", node), indent]
759
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
760
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
761
+ commands << ["├── target:\n", indent]
762
+ commands << [node.target, "#{indent}│ "]
763
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
764
+ commands << ["└── value:\n", indent]
765
+ commands << [node.value, "#{indent} "]
766
+ end
767
+
768
+ #: (ConstantReadNode node) -> void
769
+ def visit_constant_read_node(node) # :nodoc:
770
+ commands << [inspect_node("ConstantReadNode", node), indent]
771
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
772
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
773
+ commands << ["└── name: #{node.name.inspect}\n", indent]
774
+ end
775
+
776
+ #: (ConstantTargetNode node) -> void
777
+ def visit_constant_target_node(node) # :nodoc:
778
+ commands << [inspect_node("ConstantTargetNode", node), indent]
779
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
780
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
781
+ commands << ["└── name: #{node.name.inspect}\n", indent]
782
+ end
783
+
784
+ #: (ConstantWriteNode node) -> void
785
+ def visit_constant_write_node(node) # :nodoc:
786
+ commands << [inspect_node("ConstantWriteNode", node), indent]
787
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
788
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
789
+ commands << ["├── name: #{node.name.inspect}\n", indent]
790
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
791
+ commands << ["├── value:\n", indent]
792
+ commands << [node.value, "#{indent}│ "]
793
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
794
+ end
795
+
796
+ #: (DefNode node) -> void
797
+ def visit_def_node(node) # :nodoc:
798
+ commands << [inspect_node("DefNode", node), indent]
799
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
800
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
801
+ commands << ["├── name: #{node.name.inspect}\n", indent]
802
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
803
+ if (receiver = node.receiver).nil?
804
+ commands << ["├── receiver: ∅\n", indent]
805
+ else
806
+ commands << ["├── receiver:\n", indent]
807
+ commands << [receiver, "#{indent}│ "]
808
+ end
809
+ if (parameters = node.parameters).nil?
810
+ commands << ["├── parameters: ∅\n", indent]
811
+ else
812
+ commands << ["├── parameters:\n", indent]
813
+ commands << [parameters, "#{indent}│ "]
814
+ end
815
+ if (body = node.body).nil?
816
+ commands << ["├── body: ∅\n", indent]
817
+ else
818
+ commands << ["├── body:\n", indent]
819
+ commands << [body, "#{indent}│ "]
820
+ end
821
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
822
+ commands << ["├── def_keyword_loc: #{inspect_location(node.def_keyword_loc)}\n", indent]
823
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
824
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
825
+ commands << ["├── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
826
+ commands << ["├── equal_loc: #{inspect_location(node.equal_loc)}\n", indent]
827
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
828
+ end
829
+
830
+ #: (DefinedNode node) -> void
831
+ def visit_defined_node(node) # :nodoc:
832
+ commands << [inspect_node("DefinedNode", node), indent]
833
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
834
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
835
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
836
+ commands << ["├── value:\n", indent]
837
+ commands << [node.value, "#{indent}│ "]
838
+ commands << ["├── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
839
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
840
+ end
841
+
842
+ #: (ElseNode node) -> void
843
+ def visit_else_node(node) # :nodoc:
844
+ commands << [inspect_node("ElseNode", node), indent]
845
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
846
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
847
+ commands << ["├── else_keyword_loc: #{inspect_location(node.else_keyword_loc)}\n", indent]
848
+ if (statements = node.statements).nil?
849
+ commands << ["├── statements: ∅\n", indent]
850
+ else
851
+ commands << ["├── statements:\n", indent]
852
+ commands << [statements, "#{indent}│ "]
853
+ end
854
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
855
+ end
856
+
857
+ #: (EmbeddedStatementsNode node) -> void
858
+ def visit_embedded_statements_node(node) # :nodoc:
859
+ commands << [inspect_node("EmbeddedStatementsNode", node), indent]
860
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
861
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
862
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
863
+ if (statements = node.statements).nil?
864
+ commands << ["├── statements: ∅\n", indent]
865
+ else
866
+ commands << ["├── statements:\n", indent]
867
+ commands << [statements, "#{indent}│ "]
868
+ end
869
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
870
+ end
871
+
872
+ #: (EmbeddedVariableNode node) -> void
873
+ def visit_embedded_variable_node(node) # :nodoc:
874
+ commands << [inspect_node("EmbeddedVariableNode", node), indent]
875
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
876
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
877
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
878
+ commands << ["└── variable:\n", indent]
879
+ commands << [node.variable, "#{indent} "]
880
+ end
881
+
882
+ #: (EnsureNode node) -> void
883
+ def visit_ensure_node(node) # :nodoc:
884
+ commands << [inspect_node("EnsureNode", node), indent]
885
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
886
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
887
+ commands << ["├── ensure_keyword_loc: #{inspect_location(node.ensure_keyword_loc)}\n", indent]
888
+ if (statements = node.statements).nil?
889
+ commands << ["├── statements: ∅\n", indent]
890
+ else
891
+ commands << ["├── statements:\n", indent]
892
+ commands << [statements, "#{indent}│ "]
893
+ end
894
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
895
+ end
896
+
897
+ #: (ErrorRecoveryNode node) -> void
898
+ def visit_error_recovery_node(node) # :nodoc:
899
+ commands << [inspect_node("ErrorRecoveryNode", node), indent]
900
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
901
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
902
+ if (unexpected = node.unexpected).nil?
903
+ commands << ["└── unexpected: ∅\n", indent]
904
+ else
905
+ commands << ["└── unexpected:\n", indent]
906
+ commands << [unexpected, "#{indent} "]
907
+ end
908
+ end
909
+
910
+ #: (FalseNode node) -> void
911
+ def visit_false_node(node) # :nodoc:
912
+ commands << [inspect_node("FalseNode", node), indent]
913
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
914
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
915
+ end
916
+
917
+ #: (FindPatternNode node) -> void
918
+ def visit_find_pattern_node(node) # :nodoc:
919
+ commands << [inspect_node("FindPatternNode", node), indent]
920
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
921
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
922
+ if (constant = node.constant).nil?
923
+ commands << ["├── constant: ∅\n", indent]
924
+ else
925
+ commands << ["├── constant:\n", indent]
926
+ commands << [constant, "#{indent}│ "]
927
+ end
928
+ commands << ["├── left:\n", indent]
929
+ commands << [node.left, "#{indent}│ "]
930
+ commands << ["├── requireds: (length: #{(requireds = node.requireds).length})\n", indent]
931
+ if requireds.any?
932
+ requireds[0...-1].each do |child|
933
+ commands << [Replace.new("#{indent}│ ├── "), indent]
934
+ commands << [child, "#{indent}│ │ "]
935
+ end
936
+ commands << [Replace.new("#{indent}│ └── "), indent]
937
+ commands << [requireds[-1], "#{indent}│ "]
938
+ end
939
+ commands << ["├── right:\n", indent]
940
+ commands << [node.right, "#{indent}│ "]
941
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
942
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
943
+ end
944
+
945
+ #: (FlipFlopNode node) -> void
946
+ def visit_flip_flop_node(node) # :nodoc:
947
+ commands << [inspect_node("FlipFlopNode", node), indent]
948
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("exclude_end" if node.exclude_end?)].compact
949
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
950
+ if (left = node.left).nil?
951
+ commands << ["├── left: ∅\n", indent]
952
+ else
953
+ commands << ["├── left:\n", indent]
954
+ commands << [left, "#{indent}│ "]
955
+ end
956
+ if (right = node.right).nil?
957
+ commands << ["├── right: ∅\n", indent]
958
+ else
959
+ commands << ["├── right:\n", indent]
960
+ commands << [right, "#{indent}│ "]
961
+ end
962
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
963
+ end
964
+
965
+ #: (FloatNode node) -> void
966
+ def visit_float_node(node) # :nodoc:
967
+ commands << [inspect_node("FloatNode", node), indent]
968
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
969
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
970
+ commands << ["└── value: #{node.value.inspect}\n", indent]
971
+ end
972
+
973
+ #: (ForNode node) -> void
974
+ def visit_for_node(node) # :nodoc:
975
+ commands << [inspect_node("ForNode", node), indent]
976
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
977
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
978
+ commands << ["├── index:\n", indent]
979
+ commands << [node.index, "#{indent}│ "]
980
+ commands << ["├── collection:\n", indent]
981
+ commands << [node.collection, "#{indent}│ "]
982
+ if (statements = node.statements).nil?
983
+ commands << ["├── statements: ∅\n", indent]
984
+ else
985
+ commands << ["├── statements:\n", indent]
986
+ commands << [statements, "#{indent}│ "]
987
+ end
988
+ commands << ["├── for_keyword_loc: #{inspect_location(node.for_keyword_loc)}\n", indent]
989
+ commands << ["├── in_keyword_loc: #{inspect_location(node.in_keyword_loc)}\n", indent]
990
+ commands << ["├── do_keyword_loc: #{inspect_location(node.do_keyword_loc)}\n", indent]
991
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
992
+ end
993
+
994
+ #: (ForwardingArgumentsNode node) -> void
995
+ def visit_forwarding_arguments_node(node) # :nodoc:
996
+ commands << [inspect_node("ForwardingArgumentsNode", node), indent]
997
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
998
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
999
+ end
1000
+
1001
+ #: (ForwardingParameterNode node) -> void
1002
+ def visit_forwarding_parameter_node(node) # :nodoc:
1003
+ commands << [inspect_node("ForwardingParameterNode", node), indent]
1004
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1005
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1006
+ end
1007
+
1008
+ #: (ForwardingSuperNode node) -> void
1009
+ def visit_forwarding_super_node(node) # :nodoc:
1010
+ commands << [inspect_node("ForwardingSuperNode", node), indent]
1011
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1012
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1013
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1014
+ if (block = node.block).nil?
1015
+ commands << ["└── block: ∅\n", indent]
1016
+ else
1017
+ commands << ["└── block:\n", indent]
1018
+ commands << [block, "#{indent} "]
1019
+ end
1020
+ end
1021
+
1022
+ #: (GlobalVariableAndWriteNode node) -> void
1023
+ def visit_global_variable_and_write_node(node) # :nodoc:
1024
+ commands << [inspect_node("GlobalVariableAndWriteNode", node), indent]
1025
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1026
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1027
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1028
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1029
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1030
+ commands << ["└── value:\n", indent]
1031
+ commands << [node.value, "#{indent} "]
1032
+ end
1033
+
1034
+ #: (GlobalVariableOperatorWriteNode node) -> void
1035
+ def visit_global_variable_operator_write_node(node) # :nodoc:
1036
+ commands << [inspect_node("GlobalVariableOperatorWriteNode", node), indent]
1037
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1038
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1039
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1040
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1041
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
1042
+ commands << ["├── value:\n", indent]
1043
+ commands << [node.value, "#{indent}│ "]
1044
+ commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent]
1045
+ end
1046
+
1047
+ #: (GlobalVariableOrWriteNode node) -> void
1048
+ def visit_global_variable_or_write_node(node) # :nodoc:
1049
+ commands << [inspect_node("GlobalVariableOrWriteNode", node), indent]
1050
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1051
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1052
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1053
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1054
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1055
+ commands << ["└── value:\n", indent]
1056
+ commands << [node.value, "#{indent} "]
1057
+ end
1058
+
1059
+ #: (GlobalVariableReadNode node) -> void
1060
+ def visit_global_variable_read_node(node) # :nodoc:
1061
+ commands << [inspect_node("GlobalVariableReadNode", node), indent]
1062
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1063
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1064
+ commands << ["└── name: #{node.name.inspect}\n", indent]
1065
+ end
1066
+
1067
+ #: (GlobalVariableTargetNode node) -> void
1068
+ def visit_global_variable_target_node(node) # :nodoc:
1069
+ commands << [inspect_node("GlobalVariableTargetNode", node), indent]
1070
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1071
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1072
+ commands << ["└── name: #{node.name.inspect}\n", indent]
1073
+ end
1074
+
1075
+ #: (GlobalVariableWriteNode node) -> void
1076
+ def visit_global_variable_write_node(node) # :nodoc:
1077
+ commands << [inspect_node("GlobalVariableWriteNode", node), indent]
1078
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1079
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1080
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1081
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1082
+ commands << ["├── value:\n", indent]
1083
+ commands << [node.value, "#{indent}│ "]
1084
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1085
+ end
1086
+
1087
+ #: (HashNode node) -> void
1088
+ def visit_hash_node(node) # :nodoc:
1089
+ commands << [inspect_node("HashNode", node), indent]
1090
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1091
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1092
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1093
+ commands << ["├── elements: (length: #{(elements = node.elements).length})\n", indent]
1094
+ if elements.any?
1095
+ elements[0...-1].each do |child|
1096
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1097
+ commands << [child, "#{indent}│ │ "]
1098
+ end
1099
+ commands << [Replace.new("#{indent}│ └── "), indent]
1100
+ commands << [elements[-1], "#{indent}│ "]
1101
+ end
1102
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1103
+ end
1104
+
1105
+ #: (HashPatternNode node) -> void
1106
+ def visit_hash_pattern_node(node) # :nodoc:
1107
+ commands << [inspect_node("HashPatternNode", node), indent]
1108
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1109
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1110
+ if (constant = node.constant).nil?
1111
+ commands << ["├── constant: ∅\n", indent]
1112
+ else
1113
+ commands << ["├── constant:\n", indent]
1114
+ commands << [constant, "#{indent}│ "]
1115
+ end
1116
+ commands << ["├── elements: (length: #{(elements = node.elements).length})\n", indent]
1117
+ if elements.any?
1118
+ elements[0...-1].each do |child|
1119
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1120
+ commands << [child, "#{indent}│ │ "]
1121
+ end
1122
+ commands << [Replace.new("#{indent}│ └── "), indent]
1123
+ commands << [elements[-1], "#{indent}│ "]
1124
+ end
1125
+ if (rest = node.rest).nil?
1126
+ commands << ["├── rest: ∅\n", indent]
1127
+ else
1128
+ commands << ["├── rest:\n", indent]
1129
+ commands << [rest, "#{indent}│ "]
1130
+ end
1131
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1132
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1133
+ end
1134
+
1135
+ #: (IfNode node) -> void
1136
+ def visit_if_node(node) # :nodoc:
1137
+ commands << [inspect_node("IfNode", node), indent]
1138
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1139
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1140
+ commands << ["├── if_keyword_loc: #{inspect_location(node.if_keyword_loc)}\n", indent]
1141
+ commands << ["├── predicate:\n", indent]
1142
+ commands << [node.predicate, "#{indent}│ "]
1143
+ commands << ["├── then_keyword_loc: #{inspect_location(node.then_keyword_loc)}\n", indent]
1144
+ if (statements = node.statements).nil?
1145
+ commands << ["├── statements: ∅\n", indent]
1146
+ else
1147
+ commands << ["├── statements:\n", indent]
1148
+ commands << [statements, "#{indent}│ "]
1149
+ end
1150
+ if (subsequent = node.subsequent).nil?
1151
+ commands << ["├── subsequent: ∅\n", indent]
1152
+ else
1153
+ commands << ["├── subsequent:\n", indent]
1154
+ commands << [subsequent, "#{indent}│ "]
1155
+ end
1156
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
1157
+ end
1158
+
1159
+ #: (ImaginaryNode node) -> void
1160
+ def visit_imaginary_node(node) # :nodoc:
1161
+ commands << [inspect_node("ImaginaryNode", node), indent]
1162
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1163
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1164
+ commands << ["└── numeric:\n", indent]
1165
+ commands << [node.numeric, "#{indent} "]
1166
+ end
1167
+
1168
+ #: (ImplicitNode node) -> void
1169
+ def visit_implicit_node(node) # :nodoc:
1170
+ commands << [inspect_node("ImplicitNode", node), indent]
1171
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1172
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1173
+ commands << ["└── value:\n", indent]
1174
+ commands << [node.value, "#{indent} "]
1175
+ end
1176
+
1177
+ #: (ImplicitRestNode node) -> void
1178
+ def visit_implicit_rest_node(node) # :nodoc:
1179
+ commands << [inspect_node("ImplicitRestNode", node), indent]
1180
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1181
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1182
+ end
1183
+
1184
+ #: (InNode node) -> void
1185
+ def visit_in_node(node) # :nodoc:
1186
+ commands << [inspect_node("InNode", node), indent]
1187
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1188
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1189
+ commands << ["├── pattern:\n", indent]
1190
+ commands << [node.pattern, "#{indent}│ "]
1191
+ if (statements = node.statements).nil?
1192
+ commands << ["├── statements: ∅\n", indent]
1193
+ else
1194
+ commands << ["├── statements:\n", indent]
1195
+ commands << [statements, "#{indent}│ "]
1196
+ end
1197
+ commands << ["├── in_keyword_loc: #{inspect_location(node.in_keyword_loc)}\n", indent]
1198
+ commands << ["└── then_keyword_loc: #{inspect_location(node.then_keyword_loc)}\n", indent]
1199
+ end
1200
+
1201
+ #: (IndexAndWriteNode node) -> void
1202
+ def visit_index_and_write_node(node) # :nodoc:
1203
+ commands << [inspect_node("IndexAndWriteNode", node), indent]
1204
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
1205
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1206
+ if (receiver = node.receiver).nil?
1207
+ commands << ["├── receiver: ∅\n", indent]
1208
+ else
1209
+ commands << ["├── receiver:\n", indent]
1210
+ commands << [receiver, "#{indent}│ "]
1211
+ end
1212
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
1213
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1214
+ if (arguments = node.arguments).nil?
1215
+ commands << ["├── arguments: ∅\n", indent]
1216
+ else
1217
+ commands << ["├── arguments:\n", indent]
1218
+ commands << [arguments, "#{indent}│ "]
1219
+ end
1220
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1221
+ if (block = node.block).nil?
1222
+ commands << ["├── block: ∅\n", indent]
1223
+ else
1224
+ commands << ["├── block:\n", indent]
1225
+ commands << [block, "#{indent}│ "]
1226
+ end
1227
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1228
+ commands << ["└── value:\n", indent]
1229
+ commands << [node.value, "#{indent} "]
1230
+ end
1231
+
1232
+ #: (IndexOperatorWriteNode node) -> void
1233
+ def visit_index_operator_write_node(node) # :nodoc:
1234
+ commands << [inspect_node("IndexOperatorWriteNode", node), indent]
1235
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
1236
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1237
+ if (receiver = node.receiver).nil?
1238
+ commands << ["├── receiver: ∅\n", indent]
1239
+ else
1240
+ commands << ["├── receiver:\n", indent]
1241
+ commands << [receiver, "#{indent}│ "]
1242
+ end
1243
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
1244
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1245
+ if (arguments = node.arguments).nil?
1246
+ commands << ["├── arguments: ∅\n", indent]
1247
+ else
1248
+ commands << ["├── arguments:\n", indent]
1249
+ commands << [arguments, "#{indent}│ "]
1250
+ end
1251
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1252
+ if (block = node.block).nil?
1253
+ commands << ["├── block: ∅\n", indent]
1254
+ else
1255
+ commands << ["├── block:\n", indent]
1256
+ commands << [block, "#{indent}│ "]
1257
+ end
1258
+ commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent]
1259
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
1260
+ commands << ["└── value:\n", indent]
1261
+ commands << [node.value, "#{indent} "]
1262
+ end
1263
+
1264
+ #: (IndexOrWriteNode node) -> void
1265
+ def visit_index_or_write_node(node) # :nodoc:
1266
+ commands << [inspect_node("IndexOrWriteNode", node), indent]
1267
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
1268
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1269
+ if (receiver = node.receiver).nil?
1270
+ commands << ["├── receiver: ∅\n", indent]
1271
+ else
1272
+ commands << ["├── receiver:\n", indent]
1273
+ commands << [receiver, "#{indent}│ "]
1274
+ end
1275
+ commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent]
1276
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1277
+ if (arguments = node.arguments).nil?
1278
+ commands << ["├── arguments: ∅\n", indent]
1279
+ else
1280
+ commands << ["├── arguments:\n", indent]
1281
+ commands << [arguments, "#{indent}│ "]
1282
+ end
1283
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1284
+ if (block = node.block).nil?
1285
+ commands << ["├── block: ∅\n", indent]
1286
+ else
1287
+ commands << ["├── block:\n", indent]
1288
+ commands << [block, "#{indent}│ "]
1289
+ end
1290
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1291
+ commands << ["└── value:\n", indent]
1292
+ commands << [node.value, "#{indent} "]
1293
+ end
1294
+
1295
+ #: (IndexTargetNode node) -> void
1296
+ def visit_index_target_node(node) # :nodoc:
1297
+ commands << [inspect_node("IndexTargetNode", node), indent]
1298
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("safe_navigation" if node.safe_navigation?), ("variable_call" if node.variable_call?), ("attribute_write" if node.attribute_write?), ("ignore_visibility" if node.ignore_visibility?)].compact
1299
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1300
+ commands << ["├── receiver:\n", indent]
1301
+ commands << [node.receiver, "#{indent}│ "]
1302
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1303
+ if (arguments = node.arguments).nil?
1304
+ commands << ["├── arguments: ∅\n", indent]
1305
+ else
1306
+ commands << ["├── arguments:\n", indent]
1307
+ commands << [arguments, "#{indent}│ "]
1308
+ end
1309
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1310
+ if (block = node.block).nil?
1311
+ commands << ["└── block: ∅\n", indent]
1312
+ else
1313
+ commands << ["└── block:\n", indent]
1314
+ commands << [block, "#{indent} "]
1315
+ end
1316
+ end
1317
+
1318
+ #: (InstanceVariableAndWriteNode node) -> void
1319
+ def visit_instance_variable_and_write_node(node) # :nodoc:
1320
+ commands << [inspect_node("InstanceVariableAndWriteNode", node), indent]
1321
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1322
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1323
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1324
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1325
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1326
+ commands << ["└── value:\n", indent]
1327
+ commands << [node.value, "#{indent} "]
1328
+ end
1329
+
1330
+ #: (InstanceVariableOperatorWriteNode node) -> void
1331
+ def visit_instance_variable_operator_write_node(node) # :nodoc:
1332
+ commands << [inspect_node("InstanceVariableOperatorWriteNode", node), indent]
1333
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1334
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1335
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1336
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1337
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
1338
+ commands << ["├── value:\n", indent]
1339
+ commands << [node.value, "#{indent}│ "]
1340
+ commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent]
1341
+ end
1342
+
1343
+ #: (InstanceVariableOrWriteNode node) -> void
1344
+ def visit_instance_variable_or_write_node(node) # :nodoc:
1345
+ commands << [inspect_node("InstanceVariableOrWriteNode", node), indent]
1346
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1347
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1348
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1349
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1350
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1351
+ commands << ["└── value:\n", indent]
1352
+ commands << [node.value, "#{indent} "]
1353
+ end
1354
+
1355
+ #: (InstanceVariableReadNode node) -> void
1356
+ def visit_instance_variable_read_node(node) # :nodoc:
1357
+ commands << [inspect_node("InstanceVariableReadNode", node), indent]
1358
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1359
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1360
+ commands << ["└── name: #{node.name.inspect}\n", indent]
1361
+ end
1362
+
1363
+ #: (InstanceVariableTargetNode node) -> void
1364
+ def visit_instance_variable_target_node(node) # :nodoc:
1365
+ commands << [inspect_node("InstanceVariableTargetNode", node), indent]
1366
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1367
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1368
+ commands << ["└── name: #{node.name.inspect}\n", indent]
1369
+ end
1370
+
1371
+ #: (InstanceVariableWriteNode node) -> void
1372
+ def visit_instance_variable_write_node(node) # :nodoc:
1373
+ commands << [inspect_node("InstanceVariableWriteNode", node), indent]
1374
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1375
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1376
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1377
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1378
+ commands << ["├── value:\n", indent]
1379
+ commands << [node.value, "#{indent}│ "]
1380
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1381
+ end
1382
+
1383
+ #: (IntegerNode node) -> void
1384
+ def visit_integer_node(node) # :nodoc:
1385
+ commands << [inspect_node("IntegerNode", node), indent]
1386
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("binary" if node.binary?), ("decimal" if node.decimal?), ("octal" if node.octal?), ("hexadecimal" if node.hexadecimal?)].compact
1387
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1388
+ commands << ["└── value: #{node.value.inspect}\n", indent]
1389
+ end
1390
+
1391
+ #: (InterpolatedMatchLastLineNode node) -> void
1392
+ def visit_interpolated_match_last_line_node(node) # :nodoc:
1393
+ commands << [inspect_node("InterpolatedMatchLastLineNode", node), indent]
1394
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("ignore_case" if node.ignore_case?), ("extended" if node.extended?), ("multi_line" if node.multi_line?), ("once" if node.once?), ("euc_jp" if node.euc_jp?), ("ascii_8bit" if node.ascii_8bit?), ("windows_31j" if node.windows_31j?), ("utf_8" if node.utf_8?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("forced_us_ascii_encoding" if node.forced_us_ascii_encoding?)].compact
1395
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1396
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1397
+ commands << ["├── parts: (length: #{(parts = node.parts).length})\n", indent]
1398
+ if parts.any?
1399
+ parts[0...-1].each do |child|
1400
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1401
+ commands << [child, "#{indent}│ │ "]
1402
+ end
1403
+ commands << [Replace.new("#{indent}│ └── "), indent]
1404
+ commands << [parts[-1], "#{indent}│ "]
1405
+ end
1406
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1407
+ end
1408
+
1409
+ #: (InterpolatedRegularExpressionNode node) -> void
1410
+ def visit_interpolated_regular_expression_node(node) # :nodoc:
1411
+ commands << [inspect_node("InterpolatedRegularExpressionNode", node), indent]
1412
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("ignore_case" if node.ignore_case?), ("extended" if node.extended?), ("multi_line" if node.multi_line?), ("once" if node.once?), ("euc_jp" if node.euc_jp?), ("ascii_8bit" if node.ascii_8bit?), ("windows_31j" if node.windows_31j?), ("utf_8" if node.utf_8?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("forced_us_ascii_encoding" if node.forced_us_ascii_encoding?)].compact
1413
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1414
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1415
+ commands << ["├── parts: (length: #{(parts = node.parts).length})\n", indent]
1416
+ if parts.any?
1417
+ parts[0...-1].each do |child|
1418
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1419
+ commands << [child, "#{indent}│ │ "]
1420
+ end
1421
+ commands << [Replace.new("#{indent}│ └── "), indent]
1422
+ commands << [parts[-1], "#{indent}│ "]
1423
+ end
1424
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1425
+ end
1426
+
1427
+ #: (InterpolatedStringNode node) -> void
1428
+ def visit_interpolated_string_node(node) # :nodoc:
1429
+ commands << [inspect_node("InterpolatedStringNode", node), indent]
1430
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("frozen" if node.frozen?), ("mutable" if node.mutable?)].compact
1431
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1432
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1433
+ commands << ["├── parts: (length: #{(parts = node.parts).length})\n", indent]
1434
+ if parts.any?
1435
+ parts[0...-1].each do |child|
1436
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1437
+ commands << [child, "#{indent}│ │ "]
1438
+ end
1439
+ commands << [Replace.new("#{indent}│ └── "), indent]
1440
+ commands << [parts[-1], "#{indent}│ "]
1441
+ end
1442
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1443
+ end
1444
+
1445
+ #: (InterpolatedSymbolNode node) -> void
1446
+ def visit_interpolated_symbol_node(node) # :nodoc:
1447
+ commands << [inspect_node("InterpolatedSymbolNode", node), indent]
1448
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1449
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1450
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1451
+ commands << ["├── parts: (length: #{(parts = node.parts).length})\n", indent]
1452
+ if parts.any?
1453
+ parts[0...-1].each do |child|
1454
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1455
+ commands << [child, "#{indent}│ │ "]
1456
+ end
1457
+ commands << [Replace.new("#{indent}│ └── "), indent]
1458
+ commands << [parts[-1], "#{indent}│ "]
1459
+ end
1460
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1461
+ end
1462
+
1463
+ #: (InterpolatedXStringNode node) -> void
1464
+ def visit_interpolated_x_string_node(node) # :nodoc:
1465
+ commands << [inspect_node("InterpolatedXStringNode", node), indent]
1466
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1467
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1468
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1469
+ commands << ["├── parts: (length: #{(parts = node.parts).length})\n", indent]
1470
+ if parts.any?
1471
+ parts[0...-1].each do |child|
1472
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1473
+ commands << [child, "#{indent}│ │ "]
1474
+ end
1475
+ commands << [Replace.new("#{indent}│ └── "), indent]
1476
+ commands << [parts[-1], "#{indent}│ "]
1477
+ end
1478
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1479
+ end
1480
+
1481
+ #: (ItLocalVariableReadNode node) -> void
1482
+ def visit_it_local_variable_read_node(node) # :nodoc:
1483
+ commands << [inspect_node("ItLocalVariableReadNode", node), indent]
1484
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1485
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1486
+ end
1487
+
1488
+ #: (ItParametersNode node) -> void
1489
+ def visit_it_parameters_node(node) # :nodoc:
1490
+ commands << [inspect_node("ItParametersNode", node), indent]
1491
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1492
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1493
+ end
1494
+
1495
+ #: (KeywordHashNode node) -> void
1496
+ def visit_keyword_hash_node(node) # :nodoc:
1497
+ commands << [inspect_node("KeywordHashNode", node), indent]
1498
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("symbol_keys" if node.symbol_keys?)].compact
1499
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1500
+ commands << ["└── elements: (length: #{(elements = node.elements).length})\n", indent]
1501
+ if elements.any?
1502
+ elements[0...-1].each do |child|
1503
+ commands << [Replace.new("#{indent} ├── "), indent]
1504
+ commands << [child, "#{indent} │ "]
1505
+ end
1506
+ commands << [Replace.new("#{indent} └── "), indent]
1507
+ commands << [elements[-1], "#{indent} "]
1508
+ end
1509
+ end
1510
+
1511
+ #: (KeywordRestParameterNode node) -> void
1512
+ def visit_keyword_rest_parameter_node(node) # :nodoc:
1513
+ commands << [inspect_node("KeywordRestParameterNode", node), indent]
1514
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
1515
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1516
+ if (name = node.name).nil?
1517
+ commands << ["├── name: ∅\n", indent]
1518
+ else
1519
+ commands << ["├── name: #{name.inspect}\n", indent]
1520
+ end
1521
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1522
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1523
+ end
1524
+
1525
+ #: (LambdaNode node) -> void
1526
+ def visit_lambda_node(node) # :nodoc:
1527
+ commands << [inspect_node("LambdaNode", node), indent]
1528
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1529
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1530
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
1531
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1532
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1533
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1534
+ if (parameters = node.parameters).nil?
1535
+ commands << ["├── parameters: ∅\n", indent]
1536
+ else
1537
+ commands << ["├── parameters:\n", indent]
1538
+ commands << [parameters, "#{indent}│ "]
1539
+ end
1540
+ if (body = node.body).nil?
1541
+ commands << ["└── body: ∅\n", indent]
1542
+ else
1543
+ commands << ["└── body:\n", indent]
1544
+ commands << [body, "#{indent} "]
1545
+ end
1546
+ end
1547
+
1548
+ #: (LocalVariableAndWriteNode node) -> void
1549
+ def visit_local_variable_and_write_node(node) # :nodoc:
1550
+ commands << [inspect_node("LocalVariableAndWriteNode", node), indent]
1551
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1552
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1553
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1554
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1555
+ commands << ["├── value:\n", indent]
1556
+ commands << [node.value, "#{indent}│ "]
1557
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1558
+ commands << ["└── depth: #{node.depth.inspect}\n", indent]
1559
+ end
1560
+
1561
+ #: (LocalVariableOperatorWriteNode node) -> void
1562
+ def visit_local_variable_operator_write_node(node) # :nodoc:
1563
+ commands << [inspect_node("LocalVariableOperatorWriteNode", node), indent]
1564
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1565
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1566
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1567
+ commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent]
1568
+ commands << ["├── value:\n", indent]
1569
+ commands << [node.value, "#{indent}│ "]
1570
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1571
+ commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent]
1572
+ commands << ["└── depth: #{node.depth.inspect}\n", indent]
1573
+ end
1574
+
1575
+ #: (LocalVariableOrWriteNode node) -> void
1576
+ def visit_local_variable_or_write_node(node) # :nodoc:
1577
+ commands << [inspect_node("LocalVariableOrWriteNode", node), indent]
1578
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1579
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1580
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1581
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1582
+ commands << ["├── value:\n", indent]
1583
+ commands << [node.value, "#{indent}│ "]
1584
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1585
+ commands << ["└── depth: #{node.depth.inspect}\n", indent]
1586
+ end
1587
+
1588
+ #: (LocalVariableReadNode node) -> void
1589
+ def visit_local_variable_read_node(node) # :nodoc:
1590
+ commands << [inspect_node("LocalVariableReadNode", node), indent]
1591
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1592
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1593
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1594
+ commands << ["└── depth: #{node.depth.inspect}\n", indent]
1595
+ end
1596
+
1597
+ #: (LocalVariableTargetNode node) -> void
1598
+ def visit_local_variable_target_node(node) # :nodoc:
1599
+ commands << [inspect_node("LocalVariableTargetNode", node), indent]
1600
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1601
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1602
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1603
+ commands << ["└── depth: #{node.depth.inspect}\n", indent]
1604
+ end
1605
+
1606
+ #: (LocalVariableWriteNode node) -> void
1607
+ def visit_local_variable_write_node(node) # :nodoc:
1608
+ commands << [inspect_node("LocalVariableWriteNode", node), indent]
1609
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1610
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1611
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1612
+ commands << ["├── depth: #{node.depth.inspect}\n", indent]
1613
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1614
+ commands << ["├── value:\n", indent]
1615
+ commands << [node.value, "#{indent}│ "]
1616
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1617
+ end
1618
+
1619
+ #: (MatchLastLineNode node) -> void
1620
+ def visit_match_last_line_node(node) # :nodoc:
1621
+ commands << [inspect_node("MatchLastLineNode", node), indent]
1622
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("ignore_case" if node.ignore_case?), ("extended" if node.extended?), ("multi_line" if node.multi_line?), ("once" if node.once?), ("euc_jp" if node.euc_jp?), ("ascii_8bit" if node.ascii_8bit?), ("windows_31j" if node.windows_31j?), ("utf_8" if node.utf_8?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("forced_us_ascii_encoding" if node.forced_us_ascii_encoding?)].compact
1623
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1624
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1625
+ commands << ["├── content_loc: #{inspect_location(node.content_loc)}\n", indent]
1626
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1627
+ commands << ["└── unescaped: #{node.unescaped.inspect}\n", indent]
1628
+ end
1629
+
1630
+ #: (MatchPredicateNode node) -> void
1631
+ def visit_match_predicate_node(node) # :nodoc:
1632
+ commands << [inspect_node("MatchPredicateNode", node), indent]
1633
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1634
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1635
+ commands << ["├── value:\n", indent]
1636
+ commands << [node.value, "#{indent}│ "]
1637
+ commands << ["├── pattern:\n", indent]
1638
+ commands << [node.pattern, "#{indent}│ "]
1639
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1640
+ end
1641
+
1642
+ #: (MatchRequiredNode node) -> void
1643
+ def visit_match_required_node(node) # :nodoc:
1644
+ commands << [inspect_node("MatchRequiredNode", node), indent]
1645
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1646
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1647
+ commands << ["├── value:\n", indent]
1648
+ commands << [node.value, "#{indent}│ "]
1649
+ commands << ["├── pattern:\n", indent]
1650
+ commands << [node.pattern, "#{indent}│ "]
1651
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1652
+ end
1653
+
1654
+ #: (MatchWriteNode node) -> void
1655
+ def visit_match_write_node(node) # :nodoc:
1656
+ commands << [inspect_node("MatchWriteNode", node), indent]
1657
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1658
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1659
+ commands << ["├── call:\n", indent]
1660
+ commands << [node.call, "#{indent}│ "]
1661
+ commands << ["└── targets: (length: #{(targets = node.targets).length})\n", indent]
1662
+ if targets.any?
1663
+ targets[0...-1].each do |child|
1664
+ commands << [Replace.new("#{indent} ├── "), indent]
1665
+ commands << [child, "#{indent} │ "]
1666
+ end
1667
+ commands << [Replace.new("#{indent} └── "), indent]
1668
+ commands << [targets[-1], "#{indent} "]
1669
+ end
1670
+ end
1671
+
1672
+ #: (ModuleNode node) -> void
1673
+ def visit_module_node(node) # :nodoc:
1674
+ commands << [inspect_node("ModuleNode", node), indent]
1675
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1676
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1677
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
1678
+ commands << ["├── module_keyword_loc: #{inspect_location(node.module_keyword_loc)}\n", indent]
1679
+ commands << ["├── constant_path:\n", indent]
1680
+ commands << [node.constant_path, "#{indent}│ "]
1681
+ if (body = node.body).nil?
1682
+ commands << ["├── body: ∅\n", indent]
1683
+ else
1684
+ commands << ["├── body:\n", indent]
1685
+ commands << [body, "#{indent}│ "]
1686
+ end
1687
+ commands << ["├── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
1688
+ commands << ["└── name: #{node.name.inspect}\n", indent]
1689
+ end
1690
+
1691
+ #: (MultiTargetNode node) -> void
1692
+ def visit_multi_target_node(node) # :nodoc:
1693
+ commands << [inspect_node("MultiTargetNode", node), indent]
1694
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1695
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1696
+ commands << ["├── lefts: (length: #{(lefts = node.lefts).length})\n", indent]
1697
+ if lefts.any?
1698
+ lefts[0...-1].each do |child|
1699
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1700
+ commands << [child, "#{indent}│ │ "]
1701
+ end
1702
+ commands << [Replace.new("#{indent}│ └── "), indent]
1703
+ commands << [lefts[-1], "#{indent}│ "]
1704
+ end
1705
+ if (rest = node.rest).nil?
1706
+ commands << ["├── rest: ∅\n", indent]
1707
+ else
1708
+ commands << ["├── rest:\n", indent]
1709
+ commands << [rest, "#{indent}│ "]
1710
+ end
1711
+ commands << ["├── rights: (length: #{(rights = node.rights).length})\n", indent]
1712
+ if rights.any?
1713
+ rights[0...-1].each do |child|
1714
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1715
+ commands << [child, "#{indent}│ │ "]
1716
+ end
1717
+ commands << [Replace.new("#{indent}│ └── "), indent]
1718
+ commands << [rights[-1], "#{indent}│ "]
1719
+ end
1720
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
1721
+ commands << ["└── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
1722
+ end
1723
+
1724
+ #: (MultiWriteNode node) -> void
1725
+ def visit_multi_write_node(node) # :nodoc:
1726
+ commands << [inspect_node("MultiWriteNode", node), indent]
1727
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1728
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1729
+ commands << ["├── lefts: (length: #{(lefts = node.lefts).length})\n", indent]
1730
+ if lefts.any?
1731
+ lefts[0...-1].each do |child|
1732
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1733
+ commands << [child, "#{indent}│ │ "]
1734
+ end
1735
+ commands << [Replace.new("#{indent}│ └── "), indent]
1736
+ commands << [lefts[-1], "#{indent}│ "]
1737
+ end
1738
+ if (rest = node.rest).nil?
1739
+ commands << ["├── rest: ∅\n", indent]
1740
+ else
1741
+ commands << ["├── rest:\n", indent]
1742
+ commands << [rest, "#{indent}│ "]
1743
+ end
1744
+ commands << ["├── rights: (length: #{(rights = node.rights).length})\n", indent]
1745
+ if rights.any?
1746
+ rights[0...-1].each do |child|
1747
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1748
+ commands << [child, "#{indent}│ │ "]
1749
+ end
1750
+ commands << [Replace.new("#{indent}│ └── "), indent]
1751
+ commands << [rights[-1], "#{indent}│ "]
1752
+ end
1753
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
1754
+ commands << ["├── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
1755
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1756
+ commands << ["└── value:\n", indent]
1757
+ commands << [node.value, "#{indent} "]
1758
+ end
1759
+
1760
+ #: (NextNode node) -> void
1761
+ def visit_next_node(node) # :nodoc:
1762
+ commands << [inspect_node("NextNode", node), indent]
1763
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1764
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1765
+ if (arguments = node.arguments).nil?
1766
+ commands << ["├── arguments: ∅\n", indent]
1767
+ else
1768
+ commands << ["├── arguments:\n", indent]
1769
+ commands << [arguments, "#{indent}│ "]
1770
+ end
1771
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1772
+ end
1773
+
1774
+ #: (NilNode node) -> void
1775
+ def visit_nil_node(node) # :nodoc:
1776
+ commands << [inspect_node("NilNode", node), indent]
1777
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1778
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1779
+ end
1780
+
1781
+ #: (NoBlockParameterNode node) -> void
1782
+ def visit_no_block_parameter_node(node) # :nodoc:
1783
+ commands << [inspect_node("NoBlockParameterNode", node), indent]
1784
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1785
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1786
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1787
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1788
+ end
1789
+
1790
+ #: (NoKeywordsParameterNode node) -> void
1791
+ def visit_no_keywords_parameter_node(node) # :nodoc:
1792
+ commands << [inspect_node("NoKeywordsParameterNode", node), indent]
1793
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1794
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1795
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1796
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1797
+ end
1798
+
1799
+ #: (NumberedParametersNode node) -> void
1800
+ def visit_numbered_parameters_node(node) # :nodoc:
1801
+ commands << [inspect_node("NumberedParametersNode", node), indent]
1802
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1803
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1804
+ commands << ["└── maximum: #{node.maximum.inspect}\n", indent]
1805
+ end
1806
+
1807
+ #: (NumberedReferenceReadNode node) -> void
1808
+ def visit_numbered_reference_read_node(node) # :nodoc:
1809
+ commands << [inspect_node("NumberedReferenceReadNode", node), indent]
1810
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1811
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1812
+ commands << ["└── number: #{node.number.inspect}\n", indent]
1813
+ end
1814
+
1815
+ #: (OptionalKeywordParameterNode node) -> void
1816
+ def visit_optional_keyword_parameter_node(node) # :nodoc:
1817
+ commands << [inspect_node("OptionalKeywordParameterNode", node), indent]
1818
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
1819
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1820
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1821
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1822
+ commands << ["└── value:\n", indent]
1823
+ commands << [node.value, "#{indent} "]
1824
+ end
1825
+
1826
+ #: (OptionalParameterNode node) -> void
1827
+ def visit_optional_parameter_node(node) # :nodoc:
1828
+ commands << [inspect_node("OptionalParameterNode", node), indent]
1829
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
1830
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1831
+ commands << ["├── name: #{node.name.inspect}\n", indent]
1832
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
1833
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1834
+ commands << ["└── value:\n", indent]
1835
+ commands << [node.value, "#{indent} "]
1836
+ end
1837
+
1838
+ #: (OrNode node) -> void
1839
+ def visit_or_node(node) # :nodoc:
1840
+ commands << [inspect_node("OrNode", node), indent]
1841
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1842
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1843
+ commands << ["├── left:\n", indent]
1844
+ commands << [node.left, "#{indent}│ "]
1845
+ commands << ["├── right:\n", indent]
1846
+ commands << [node.right, "#{indent}│ "]
1847
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1848
+ end
1849
+
1850
+ #: (ParametersNode node) -> void
1851
+ def visit_parameters_node(node) # :nodoc:
1852
+ commands << [inspect_node("ParametersNode", node), indent]
1853
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1854
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1855
+ commands << ["├── requireds: (length: #{(requireds = node.requireds).length})\n", indent]
1856
+ if requireds.any?
1857
+ requireds[0...-1].each do |child|
1858
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1859
+ commands << [child, "#{indent}│ │ "]
1860
+ end
1861
+ commands << [Replace.new("#{indent}│ └── "), indent]
1862
+ commands << [requireds[-1], "#{indent}│ "]
1863
+ end
1864
+ commands << ["├── optionals: (length: #{(optionals = node.optionals).length})\n", indent]
1865
+ if optionals.any?
1866
+ optionals[0...-1].each do |child|
1867
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1868
+ commands << [child, "#{indent}│ │ "]
1869
+ end
1870
+ commands << [Replace.new("#{indent}│ └── "), indent]
1871
+ commands << [optionals[-1], "#{indent}│ "]
1872
+ end
1873
+ if (rest = node.rest).nil?
1874
+ commands << ["├── rest: ∅\n", indent]
1875
+ else
1876
+ commands << ["├── rest:\n", indent]
1877
+ commands << [rest, "#{indent}│ "]
1878
+ end
1879
+ commands << ["├── posts: (length: #{(posts = node.posts).length})\n", indent]
1880
+ if posts.any?
1881
+ posts[0...-1].each do |child|
1882
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1883
+ commands << [child, "#{indent}│ │ "]
1884
+ end
1885
+ commands << [Replace.new("#{indent}│ └── "), indent]
1886
+ commands << [posts[-1], "#{indent}│ "]
1887
+ end
1888
+ commands << ["├── keywords: (length: #{(keywords = node.keywords).length})\n", indent]
1889
+ if keywords.any?
1890
+ keywords[0...-1].each do |child|
1891
+ commands << [Replace.new("#{indent}│ ├── "), indent]
1892
+ commands << [child, "#{indent}│ │ "]
1893
+ end
1894
+ commands << [Replace.new("#{indent}│ └── "), indent]
1895
+ commands << [keywords[-1], "#{indent}│ "]
1896
+ end
1897
+ if (keyword_rest = node.keyword_rest).nil?
1898
+ commands << ["├── keyword_rest: ∅\n", indent]
1899
+ else
1900
+ commands << ["├── keyword_rest:\n", indent]
1901
+ commands << [keyword_rest, "#{indent}│ "]
1902
+ end
1903
+ if (block = node.block).nil?
1904
+ commands << ["└── block: ∅\n", indent]
1905
+ else
1906
+ commands << ["└── block:\n", indent]
1907
+ commands << [block, "#{indent} "]
1908
+ end
1909
+ end
1910
+
1911
+ #: (ParenthesesNode node) -> void
1912
+ def visit_parentheses_node(node) # :nodoc:
1913
+ commands << [inspect_node("ParenthesesNode", node), indent]
1914
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("multiple_statements" if node.multiple_statements?)].compact
1915
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1916
+ if (body = node.body).nil?
1917
+ commands << ["├── body: ∅\n", indent]
1918
+ else
1919
+ commands << ["├── body:\n", indent]
1920
+ commands << [body, "#{indent}│ "]
1921
+ end
1922
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1923
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1924
+ end
1925
+
1926
+ #: (PinnedExpressionNode node) -> void
1927
+ def visit_pinned_expression_node(node) # :nodoc:
1928
+ commands << [inspect_node("PinnedExpressionNode", node), indent]
1929
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1930
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1931
+ commands << ["├── expression:\n", indent]
1932
+ commands << [node.expression, "#{indent}│ "]
1933
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1934
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
1935
+ commands << ["└── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
1936
+ end
1937
+
1938
+ #: (PinnedVariableNode node) -> void
1939
+ def visit_pinned_variable_node(node) # :nodoc:
1940
+ commands << [inspect_node("PinnedVariableNode", node), indent]
1941
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1942
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1943
+ commands << ["├── variable:\n", indent]
1944
+ commands << [node.variable, "#{indent}│ "]
1945
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
1946
+ end
1947
+
1948
+ #: (PostExecutionNode node) -> void
1949
+ def visit_post_execution_node(node) # :nodoc:
1950
+ commands << [inspect_node("PostExecutionNode", node), indent]
1951
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1952
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1953
+ if (statements = node.statements).nil?
1954
+ commands << ["├── statements: ∅\n", indent]
1955
+ else
1956
+ commands << ["├── statements:\n", indent]
1957
+ commands << [statements, "#{indent}│ "]
1958
+ end
1959
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1960
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1961
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1962
+ end
1963
+
1964
+ #: (PreExecutionNode node) -> void
1965
+ def visit_pre_execution_node(node) # :nodoc:
1966
+ commands << [inspect_node("PreExecutionNode", node), indent]
1967
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1968
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1969
+ if (statements = node.statements).nil?
1970
+ commands << ["├── statements: ∅\n", indent]
1971
+ else
1972
+ commands << ["├── statements:\n", indent]
1973
+ commands << [statements, "#{indent}│ "]
1974
+ end
1975
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
1976
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
1977
+ commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
1978
+ end
1979
+
1980
+ #: (ProgramNode node) -> void
1981
+ def visit_program_node(node) # :nodoc:
1982
+ commands << [inspect_node("ProgramNode", node), indent]
1983
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
1984
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1985
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
1986
+ commands << ["└── statements:\n", indent]
1987
+ commands << [node.statements, "#{indent} "]
1988
+ end
1989
+
1990
+ #: (RangeNode node) -> void
1991
+ def visit_range_node(node) # :nodoc:
1992
+ commands << [inspect_node("RangeNode", node), indent]
1993
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("exclude_end" if node.exclude_end?)].compact
1994
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
1995
+ if (left = node.left).nil?
1996
+ commands << ["├── left: ∅\n", indent]
1997
+ else
1998
+ commands << ["├── left:\n", indent]
1999
+ commands << [left, "#{indent}│ "]
2000
+ end
2001
+ if (right = node.right).nil?
2002
+ commands << ["├── right: ∅\n", indent]
2003
+ else
2004
+ commands << ["├── right:\n", indent]
2005
+ commands << [right, "#{indent}│ "]
2006
+ end
2007
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
2008
+ end
2009
+
2010
+ #: (RationalNode node) -> void
2011
+ def visit_rational_node(node) # :nodoc:
2012
+ commands << [inspect_node("RationalNode", node), indent]
2013
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("binary" if node.binary?), ("decimal" if node.decimal?), ("octal" if node.octal?), ("hexadecimal" if node.hexadecimal?)].compact
2014
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2015
+ commands << ["├── numerator: #{node.numerator.inspect}\n", indent]
2016
+ commands << ["└── denominator: #{node.denominator.inspect}\n", indent]
2017
+ end
2018
+
2019
+ #: (RedoNode node) -> void
2020
+ def visit_redo_node(node) # :nodoc:
2021
+ commands << [inspect_node("RedoNode", node), indent]
2022
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2023
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2024
+ end
2025
+
2026
+ #: (RegularExpressionNode node) -> void
2027
+ def visit_regular_expression_node(node) # :nodoc:
2028
+ commands << [inspect_node("RegularExpressionNode", node), indent]
2029
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("ignore_case" if node.ignore_case?), ("extended" if node.extended?), ("multi_line" if node.multi_line?), ("once" if node.once?), ("euc_jp" if node.euc_jp?), ("ascii_8bit" if node.ascii_8bit?), ("windows_31j" if node.windows_31j?), ("utf_8" if node.utf_8?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("forced_us_ascii_encoding" if node.forced_us_ascii_encoding?)].compact
2030
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2031
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
2032
+ commands << ["├── content_loc: #{inspect_location(node.content_loc)}\n", indent]
2033
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
2034
+ commands << ["└── unescaped: #{node.unescaped.inspect}\n", indent]
2035
+ end
2036
+
2037
+ #: (RequiredKeywordParameterNode node) -> void
2038
+ def visit_required_keyword_parameter_node(node) # :nodoc:
2039
+ commands << [inspect_node("RequiredKeywordParameterNode", node), indent]
2040
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
2041
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2042
+ commands << ["├── name: #{node.name.inspect}\n", indent]
2043
+ commands << ["└── name_loc: #{inspect_location(node.name_loc)}\n", indent]
2044
+ end
2045
+
2046
+ #: (RequiredParameterNode node) -> void
2047
+ def visit_required_parameter_node(node) # :nodoc:
2048
+ commands << [inspect_node("RequiredParameterNode", node), indent]
2049
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
2050
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2051
+ commands << ["└── name: #{node.name.inspect}\n", indent]
2052
+ end
2053
+
2054
+ #: (RescueModifierNode node) -> void
2055
+ def visit_rescue_modifier_node(node) # :nodoc:
2056
+ commands << [inspect_node("RescueModifierNode", node), indent]
2057
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2058
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2059
+ commands << ["├── expression:\n", indent]
2060
+ commands << [node.expression, "#{indent}│ "]
2061
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2062
+ commands << ["└── rescue_expression:\n", indent]
2063
+ commands << [node.rescue_expression, "#{indent} "]
2064
+ end
2065
+
2066
+ #: (RescueNode node) -> void
2067
+ def visit_rescue_node(node) # :nodoc:
2068
+ commands << [inspect_node("RescueNode", node), indent]
2069
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2070
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2071
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2072
+ commands << ["├── exceptions: (length: #{(exceptions = node.exceptions).length})\n", indent]
2073
+ if exceptions.any?
2074
+ exceptions[0...-1].each do |child|
2075
+ commands << [Replace.new("#{indent}│ ├── "), indent]
2076
+ commands << [child, "#{indent}│ │ "]
2077
+ end
2078
+ commands << [Replace.new("#{indent}│ └── "), indent]
2079
+ commands << [exceptions[-1], "#{indent}│ "]
2080
+ end
2081
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
2082
+ if (reference = node.reference).nil?
2083
+ commands << ["├── reference: ∅\n", indent]
2084
+ else
2085
+ commands << ["├── reference:\n", indent]
2086
+ commands << [reference, "#{indent}│ "]
2087
+ end
2088
+ commands << ["├── then_keyword_loc: #{inspect_location(node.then_keyword_loc)}\n", indent]
2089
+ if (statements = node.statements).nil?
2090
+ commands << ["├── statements: ∅\n", indent]
2091
+ else
2092
+ commands << ["├── statements:\n", indent]
2093
+ commands << [statements, "#{indent}│ "]
2094
+ end
2095
+ if (subsequent = node.subsequent).nil?
2096
+ commands << ["└── subsequent: ∅\n", indent]
2097
+ else
2098
+ commands << ["└── subsequent:\n", indent]
2099
+ commands << [subsequent, "#{indent} "]
2100
+ end
2101
+ end
2102
+
2103
+ #: (RestParameterNode node) -> void
2104
+ def visit_rest_parameter_node(node) # :nodoc:
2105
+ commands << [inspect_node("RestParameterNode", node), indent]
2106
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("repeated_parameter" if node.repeated_parameter?)].compact
2107
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2108
+ if (name = node.name).nil?
2109
+ commands << ["├── name: ∅\n", indent]
2110
+ else
2111
+ commands << ["├── name: #{name.inspect}\n", indent]
2112
+ end
2113
+ commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
2114
+ commands << ["└── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
2115
+ end
2116
+
2117
+ #: (RetryNode node) -> void
2118
+ def visit_retry_node(node) # :nodoc:
2119
+ commands << [inspect_node("RetryNode", node), indent]
2120
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2121
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2122
+ end
2123
+
2124
+ #: (ReturnNode node) -> void
2125
+ def visit_return_node(node) # :nodoc:
2126
+ commands << [inspect_node("ReturnNode", node), indent]
2127
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2128
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2129
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2130
+ if (arguments = node.arguments).nil?
2131
+ commands << ["└── arguments: ∅\n", indent]
2132
+ else
2133
+ commands << ["└── arguments:\n", indent]
2134
+ commands << [arguments, "#{indent} "]
2135
+ end
2136
+ end
2137
+
2138
+ #: (SelfNode node) -> void
2139
+ def visit_self_node(node) # :nodoc:
2140
+ commands << [inspect_node("SelfNode", node), indent]
2141
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2142
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2143
+ end
2144
+
2145
+ #: (ShareableConstantNode node) -> void
2146
+ def visit_shareable_constant_node(node) # :nodoc:
2147
+ commands << [inspect_node("ShareableConstantNode", node), indent]
2148
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("literal" if node.literal?), ("experimental_everything" if node.experimental_everything?), ("experimental_copy" if node.experimental_copy?)].compact
2149
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2150
+ commands << ["└── write:\n", indent]
2151
+ commands << [node.write, "#{indent} "]
2152
+ end
2153
+
2154
+ #: (SingletonClassNode node) -> void
2155
+ def visit_singleton_class_node(node) # :nodoc:
2156
+ commands << [inspect_node("SingletonClassNode", node), indent]
2157
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2158
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2159
+ commands << ["├── locals: #{node.locals.inspect}\n", indent]
2160
+ commands << ["├── class_keyword_loc: #{inspect_location(node.class_keyword_loc)}\n", indent]
2161
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
2162
+ commands << ["├── expression:\n", indent]
2163
+ commands << [node.expression, "#{indent}│ "]
2164
+ if (body = node.body).nil?
2165
+ commands << ["├── body: ∅\n", indent]
2166
+ else
2167
+ commands << ["├── body:\n", indent]
2168
+ commands << [body, "#{indent}│ "]
2169
+ end
2170
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
2171
+ end
2172
+
2173
+ #: (SourceEncodingNode node) -> void
2174
+ def visit_source_encoding_node(node) # :nodoc:
2175
+ commands << [inspect_node("SourceEncodingNode", node), indent]
2176
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2177
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2178
+ end
2179
+
2180
+ #: (SourceFileNode node) -> void
2181
+ def visit_source_file_node(node) # :nodoc:
2182
+ commands << [inspect_node("SourceFileNode", node), indent]
2183
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("frozen" if node.frozen?), ("mutable" if node.mutable?)].compact
2184
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2185
+ commands << ["└── filepath: #{node.filepath.inspect}\n", indent]
2186
+ end
2187
+
2188
+ #: (SourceLineNode node) -> void
2189
+ def visit_source_line_node(node) # :nodoc:
2190
+ commands << [inspect_node("SourceLineNode", node), indent]
2191
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2192
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2193
+ end
2194
+
2195
+ #: (SplatNode node) -> void
2196
+ def visit_splat_node(node) # :nodoc:
2197
+ commands << [inspect_node("SplatNode", node), indent]
2198
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2199
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2200
+ commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
2201
+ if (expression = node.expression).nil?
2202
+ commands << ["└── expression: ∅\n", indent]
2203
+ else
2204
+ commands << ["└── expression:\n", indent]
2205
+ commands << [expression, "#{indent} "]
2206
+ end
2207
+ end
2208
+
2209
+ #: (StatementsNode node) -> void
2210
+ def visit_statements_node(node) # :nodoc:
2211
+ commands << [inspect_node("StatementsNode", node), indent]
2212
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2213
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2214
+ commands << ["└── body: (length: #{(body = node.body).length})\n", indent]
2215
+ if body.any?
2216
+ body[0...-1].each do |child|
2217
+ commands << [Replace.new("#{indent} ├── "), indent]
2218
+ commands << [child, "#{indent} │ "]
2219
+ end
2220
+ commands << [Replace.new("#{indent} └── "), indent]
2221
+ commands << [body[-1], "#{indent} "]
2222
+ end
2223
+ end
2224
+
2225
+ #: (StringNode node) -> void
2226
+ def visit_string_node(node) # :nodoc:
2227
+ commands << [inspect_node("StringNode", node), indent]
2228
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("frozen" if node.frozen?), ("mutable" if node.mutable?)].compact
2229
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2230
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
2231
+ commands << ["├── content_loc: #{inspect_location(node.content_loc)}\n", indent]
2232
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
2233
+ commands << ["└── unescaped: #{node.unescaped.inspect}\n", indent]
2234
+ end
2235
+
2236
+ #: (SuperNode node) -> void
2237
+ def visit_super_node(node) # :nodoc:
2238
+ commands << [inspect_node("SuperNode", node), indent]
2239
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2240
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2241
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2242
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
2243
+ if (arguments = node.arguments).nil?
2244
+ commands << ["├── arguments: ∅\n", indent]
2245
+ else
2246
+ commands << ["├── arguments:\n", indent]
2247
+ commands << [arguments, "#{indent}│ "]
2248
+ end
2249
+ commands << ["├── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
2250
+ if (block = node.block).nil?
2251
+ commands << ["└── block: ∅\n", indent]
2252
+ else
2253
+ commands << ["└── block:\n", indent]
2254
+ commands << [block, "#{indent} "]
2255
+ end
2256
+ end
2257
+
2258
+ #: (SymbolNode node) -> void
2259
+ def visit_symbol_node(node) # :nodoc:
2260
+ commands << [inspect_node("SymbolNode", node), indent]
2261
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?), ("forced_us_ascii_encoding" if node.forced_us_ascii_encoding?)].compact
2262
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2263
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
2264
+ commands << ["├── content_loc: #{inspect_location(node.content_loc)}\n", indent]
2265
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
2266
+ commands << ["└── unescaped: #{node.unescaped.inspect}\n", indent]
2267
+ end
2268
+
2269
+ #: (TrueNode node) -> void
2270
+ def visit_true_node(node) # :nodoc:
2271
+ commands << [inspect_node("TrueNode", node), indent]
2272
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2273
+ commands << ["└── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2274
+ end
2275
+
2276
+ #: (UndefNode node) -> void
2277
+ def visit_undef_node(node) # :nodoc:
2278
+ commands << [inspect_node("UndefNode", node), indent]
2279
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2280
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2281
+ commands << ["├── names: (length: #{(names = node.names).length})\n", indent]
2282
+ if names.any?
2283
+ names[0...-1].each do |child|
2284
+ commands << [Replace.new("#{indent}│ ├── "), indent]
2285
+ commands << [child, "#{indent}│ │ "]
2286
+ end
2287
+ commands << [Replace.new("#{indent}│ └── "), indent]
2288
+ commands << [names[-1], "#{indent}│ "]
2289
+ end
2290
+ commands << ["└── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2291
+ end
2292
+
2293
+ #: (UnlessNode node) -> void
2294
+ def visit_unless_node(node) # :nodoc:
2295
+ commands << [inspect_node("UnlessNode", node), indent]
2296
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2297
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2298
+ commands << ["├── unless_keyword_loc: #{inspect_location(node.unless_keyword_loc)}\n", indent]
2299
+ commands << ["├── predicate:\n", indent]
2300
+ commands << [node.predicate, "#{indent}│ "]
2301
+ commands << ["├── then_keyword_loc: #{inspect_location(node.then_keyword_loc)}\n", indent]
2302
+ if (statements = node.statements).nil?
2303
+ commands << ["├── statements: ∅\n", indent]
2304
+ else
2305
+ commands << ["├── statements:\n", indent]
2306
+ commands << [statements, "#{indent}│ "]
2307
+ end
2308
+ if (else_clause = node.else_clause).nil?
2309
+ commands << ["├── else_clause: ∅\n", indent]
2310
+ else
2311
+ commands << ["├── else_clause:\n", indent]
2312
+ commands << [else_clause, "#{indent}│ "]
2313
+ end
2314
+ commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
2315
+ end
2316
+
2317
+ #: (UntilNode node) -> void
2318
+ def visit_until_node(node) # :nodoc:
2319
+ commands << [inspect_node("UntilNode", node), indent]
2320
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("begin_modifier" if node.begin_modifier?)].compact
2321
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2322
+ commands << ["├── until_keyword_loc: #{inspect_location(node.until_keyword_loc)}\n", indent]
2323
+ commands << ["├── do_keyword_loc: #{inspect_location(node.do_keyword_loc)}\n", indent]
2324
+ commands << ["├── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
2325
+ commands << ["├── predicate:\n", indent]
2326
+ commands << [node.predicate, "#{indent}│ "]
2327
+ if (statements = node.statements).nil?
2328
+ commands << ["└── statements: ∅\n", indent]
2329
+ else
2330
+ commands << ["└── statements:\n", indent]
2331
+ commands << [statements, "#{indent} "]
2332
+ end
2333
+ end
2334
+
2335
+ #: (WhenNode node) -> void
2336
+ def visit_when_node(node) # :nodoc:
2337
+ commands << [inspect_node("WhenNode", node), indent]
2338
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2339
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2340
+ commands << ["├── when_keyword_loc: #{inspect_location(node.when_keyword_loc)}\n", indent]
2341
+ commands << ["├── conditions: (length: #{(conditions = node.conditions).length})\n", indent]
2342
+ if conditions.any?
2343
+ conditions[0...-1].each do |child|
2344
+ commands << [Replace.new("#{indent}│ ├── "), indent]
2345
+ commands << [child, "#{indent}│ │ "]
2346
+ end
2347
+ commands << [Replace.new("#{indent}│ └── "), indent]
2348
+ commands << [conditions[-1], "#{indent}│ "]
2349
+ end
2350
+ commands << ["├── then_keyword_loc: #{inspect_location(node.then_keyword_loc)}\n", indent]
2351
+ if (statements = node.statements).nil?
2352
+ commands << ["└── statements: ∅\n", indent]
2353
+ else
2354
+ commands << ["└── statements:\n", indent]
2355
+ commands << [statements, "#{indent} "]
2356
+ end
2357
+ end
2358
+
2359
+ #: (WhileNode node) -> void
2360
+ def visit_while_node(node) # :nodoc:
2361
+ commands << [inspect_node("WhileNode", node), indent]
2362
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("begin_modifier" if node.begin_modifier?)].compact
2363
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2364
+ commands << ["├── while_keyword_loc: #{inspect_location(node.while_keyword_loc)}\n", indent]
2365
+ commands << ["├── do_keyword_loc: #{inspect_location(node.do_keyword_loc)}\n", indent]
2366
+ commands << ["├── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
2367
+ commands << ["├── predicate:\n", indent]
2368
+ commands << [node.predicate, "#{indent}│ "]
2369
+ if (statements = node.statements).nil?
2370
+ commands << ["└── statements: ∅\n", indent]
2371
+ else
2372
+ commands << ["└── statements:\n", indent]
2373
+ commands << [statements, "#{indent} "]
2374
+ end
2375
+ end
2376
+
2377
+ #: (XStringNode node) -> void
2378
+ def visit_x_string_node(node) # :nodoc:
2379
+ commands << [inspect_node("XStringNode", node), indent]
2380
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ("forced_utf8_encoding" if node.forced_utf8_encoding?), ("forced_binary_encoding" if node.forced_binary_encoding?)].compact
2381
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2382
+ commands << ["├── opening_loc: #{inspect_location(node.opening_loc)}\n", indent]
2383
+ commands << ["├── content_loc: #{inspect_location(node.content_loc)}\n", indent]
2384
+ commands << ["├── closing_loc: #{inspect_location(node.closing_loc)}\n", indent]
2385
+ commands << ["└── unescaped: #{node.unescaped.inspect}\n", indent]
2386
+ end
2387
+
2388
+ #: (YieldNode node) -> void
2389
+ def visit_yield_node(node) # :nodoc:
2390
+ commands << [inspect_node("YieldNode", node), indent]
2391
+ flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
2392
+ commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
2393
+ commands << ["├── keyword_loc: #{inspect_location(node.keyword_loc)}\n", indent]
2394
+ commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
2395
+ if (arguments = node.arguments).nil?
2396
+ commands << ["├── arguments: ∅\n", indent]
2397
+ else
2398
+ commands << ["├── arguments:\n", indent]
2399
+ commands << [arguments, "#{indent}│ "]
2400
+ end
2401
+ commands << ["└── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
2402
+ end
2403
+
2404
+ private
2405
+
2406
+ # Compose a header for the given node.
2407
+ #
2408
+ #: (String name, node node) -> String
2409
+ def inspect_node(name, node) # :nodoc:
2410
+ location = node.location
2411
+ "@ #{name} (location: (#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}))\n"
2412
+ end
2413
+
2414
+ # Compose a string representing the given inner location field.
2415
+ #
2416
+ #: (Location? location) -> String
2417
+ def inspect_location(location) # :nodoc:
2418
+ if location
2419
+ "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}) = #{location.slice.inspect}"
2420
+ else
2421
+ "∅"
2422
+ end
2423
+ end
2424
+ end
2425
+ end