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,72 @@
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+ #--
4
+ # rbs_inline: enabled
5
+
6
+ require "stringio"
7
+
8
+ module Prism
9
+ class ParseResult < Result
10
+ # An object to represent the set of errors on a parse result. This object
11
+ # can be used to format the errors in a human-readable way.
12
+ class Errors
13
+ # The parse result that contains the errors.
14
+ attr_reader :parse_result #: ParseResult
15
+
16
+ # Initialize a new set of errors from the given parse result.
17
+ #
18
+ #: (ParseResult parse_result) -> void
19
+ def initialize(parse_result)
20
+ @parse_result = parse_result
21
+ end
22
+
23
+ # Formats the errors in a human-readable way and return them as a string.
24
+ #
25
+ #: () -> String
26
+ def format
27
+ error_lines = {} #: Hash[Integer, Array[ParseError]]
28
+ parse_result.errors.each do |error|
29
+ location = error.location
30
+ (location.start_line..location.end_line).each do |line|
31
+ error_lines[line] ||= []
32
+ error_lines[line] << error
33
+ end
34
+ end
35
+
36
+ source_lines = parse_result.source.source.lines
37
+ source_lines << "" if error_lines.key?(source_lines.size + 1)
38
+
39
+ io = StringIO.new
40
+ source_lines.each.with_index(1) do |line, line_number|
41
+ io.puts(line)
42
+
43
+ (error_lines.delete(line_number) || []).each do |error|
44
+ location = error.location
45
+
46
+ case line_number
47
+ when location.start_line
48
+ io.print(" " * location.start_column + "^")
49
+
50
+ if location.start_line == location.end_line
51
+ if location.start_column != location.end_column
52
+ io.print("~" * (location.end_column - location.start_column - 1))
53
+ end
54
+
55
+ io.puts(" " + error.message)
56
+ else
57
+ io.puts("~" * (line.bytesize - location.start_column))
58
+ end
59
+ when location.end_line
60
+ io.puts("~" * location.end_column + " " + error.message)
61
+ else
62
+ io.puts("~" * line.bytesize)
63
+ end
64
+ end
65
+ end
66
+
67
+ io.puts
68
+ io.string
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,423 @@
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+ #--
4
+ # rbs_inline: enabled
5
+
6
+ module Prism
7
+ class ParseResult < Result
8
+ # The :line tracepoint event gets fired whenever the Ruby VM encounters an
9
+ # expression on a new line. The types of expressions that can trigger this
10
+ # event are:
11
+ #
12
+ # * if statements
13
+ # * unless statements
14
+ # * nodes that are children of statements lists
15
+ #
16
+ # In order to keep track of the newlines, we have a list of offsets that
17
+ # come back from the parser. We assign these offsets to the first nodes that
18
+ # we find in the tree that are on those lines.
19
+ #
20
+ # Note that the logic in this file should be kept in sync with the Java
21
+ # MarkNewlinesVisitor, since that visitor is responsible for marking the
22
+ # newlines for JRuby/TruffleRuby.
23
+ #
24
+ # This file is autoloaded only when `mark_newlines!` is called, so the
25
+ # re-opening of the various nodes in this file will only be performed in
26
+ # that case. We do that to avoid storing the extra `@newline` instance
27
+ # variable on every node if we don't need it.
28
+ class Newlines < Visitor
29
+ # The map of lines indices to whether or not they have been marked as
30
+ # emitting a newline event.
31
+ # @rbs @lines: Array[bool]
32
+
33
+ # Create a new Newlines visitor with the given newline offsets.
34
+ #
35
+ #: (Integer lines) -> void
36
+ def initialize(lines)
37
+ @lines = Array.new(1 + lines, false)
38
+ end
39
+
40
+ # Permit block nodes to mark newlines within themselves.
41
+ #
42
+ #: (BlockNode node) -> void
43
+ def visit_block_node(node)
44
+ old_lines = @lines
45
+ @lines = Array.new(old_lines.size, false)
46
+
47
+ begin
48
+ super(node)
49
+ ensure
50
+ @lines = old_lines
51
+ end
52
+ end
53
+
54
+ # Permit lambda nodes to mark newlines within themselves.
55
+ #
56
+ #: (LambdaNode node) -> void
57
+ def visit_lambda_node(node)
58
+ old_lines = @lines
59
+ @lines = Array.new(old_lines.size, false)
60
+
61
+ begin
62
+ super(node)
63
+ ensure
64
+ @lines = old_lines
65
+ end
66
+ end
67
+
68
+ # Permit def nodes to mark newlines within themselves. The body of an
69
+ # endless method definition never emits newline events, so in that case
70
+ # mark every line as already seen while visiting it instead. Nested
71
+ # scopes (blocks, lambdas, etc.) reset the lines and emit events again.
72
+ #
73
+ #: (DefNode node) -> void
74
+ def visit_def_node(node)
75
+ old_lines = @lines
76
+ @lines = Array.new(old_lines.size, !node.equal_loc.nil?)
77
+
78
+ begin
79
+ super(node)
80
+ ensure
81
+ @lines = old_lines
82
+ end
83
+ end
84
+
85
+ # Permit class nodes to mark newlines within themselves.
86
+ #
87
+ #: (ClassNode node) -> void
88
+ def visit_class_node(node)
89
+ old_lines = @lines
90
+ @lines = Array.new(old_lines.size, false)
91
+
92
+ begin
93
+ super(node)
94
+ ensure
95
+ @lines = old_lines
96
+ end
97
+ end
98
+
99
+ # Permit module nodes to mark newlines within themselves.
100
+ #
101
+ #: (ModuleNode node) -> void
102
+ def visit_module_node(node)
103
+ old_lines = @lines
104
+ @lines = Array.new(old_lines.size, false)
105
+
106
+ begin
107
+ super(node)
108
+ ensure
109
+ @lines = old_lines
110
+ end
111
+ end
112
+
113
+ # Permit singleton class nodes to mark newlines within themselves.
114
+ #
115
+ #: (SingletonClassNode node) -> void
116
+ def visit_singleton_class_node(node)
117
+ old_lines = @lines
118
+ @lines = Array.new(old_lines.size, false)
119
+
120
+ begin
121
+ super(node)
122
+ ensure
123
+ @lines = old_lines
124
+ end
125
+ end
126
+
127
+ # Statements inside string interpolation do not emit newline events, so
128
+ # mark every line as already seen while visiting them. Nested scopes
129
+ # (blocks, lambdas, defs, etc.) reset the lines and emit events again.
130
+ #
131
+ #: (EmbeddedStatementsNode node) -> void
132
+ def visit_embedded_statements_node(node)
133
+ old_lines = @lines
134
+ @lines = Array.new(old_lines.size, true)
135
+
136
+ begin
137
+ super(node)
138
+ ensure
139
+ @lines = old_lines
140
+ end
141
+ end
142
+
143
+ # The predicate of a while loop is compiled at the end of the loop,
144
+ # after the body, so any statements it contains (from parentheses)
145
+ # emit their line events again even if the lines were already seen.
146
+ #
147
+ #: (WhileNode node) -> void
148
+ def visit_while_node(node)
149
+ old_lines = @lines
150
+ @lines = Array.new(old_lines.size, false)
151
+
152
+ begin
153
+ visit(node.predicate)
154
+ ensure
155
+ @lines = old_lines
156
+ end
157
+
158
+ visit(node.statements)
159
+ end
160
+
161
+ # The predicate of an until loop is compiled at the end of the loop,
162
+ # after the body, so any statements it contains (from parentheses)
163
+ # emit their line events again even if the lines were already seen.
164
+ #
165
+ #: (UntilNode node) -> void
166
+ def visit_until_node(node)
167
+ old_lines = @lines
168
+ @lines = Array.new(old_lines.size, false)
169
+
170
+ begin
171
+ visit(node.predicate)
172
+ ensure
173
+ @lines = old_lines
174
+ end
175
+
176
+ visit(node.statements)
177
+ end
178
+
179
+ # Mark if nodes as newlines.
180
+ #
181
+ #: (IfNode node) -> void
182
+ def visit_if_node(node)
183
+ node.newline_flag!(@lines)
184
+ super(node)
185
+ end
186
+
187
+ # Mark unless nodes as newlines.
188
+ #
189
+ #: (UnlessNode node) -> void
190
+ def visit_unless_node(node)
191
+ node.newline_flag!(@lines)
192
+ super(node)
193
+ end
194
+
195
+ # Permit statements lists to mark newlines within themselves.
196
+ #
197
+ #: (StatementsNode node) -> void
198
+ def visit_statements_node(node)
199
+ node.body.each do |child|
200
+ child.newline_flag!(@lines)
201
+ end
202
+ super(node)
203
+ end
204
+ end
205
+ end
206
+
207
+ class Node
208
+ # Tracks whether or not this node should emit a newline event when the
209
+ # instructions that it represents are executed.
210
+ # @rbs @newline_flag: bool
211
+
212
+ #: () -> bool
213
+ def newline_flag? # :nodoc:
214
+ !!defined?(@newline_flag)
215
+ end
216
+
217
+ #: (Array[bool] lines) -> void
218
+ def newline_flag!(lines) # :nodoc:
219
+ line = location.start_line
220
+ unless lines[line]
221
+ lines[line] = true
222
+ @newline_flag = true
223
+ end
224
+ end
225
+ end
226
+
227
+ class BeginNode < Node
228
+ #: (Array[bool] lines) -> void
229
+ def newline_flag!(lines) # :nodoc:
230
+ # Never mark BeginNode with a newline flag, mark children instead.
231
+ end
232
+ end
233
+
234
+ class ParenthesesNode < Node
235
+ #: (Array[bool] lines) -> void
236
+ def newline_flag!(lines) # :nodoc:
237
+ # Never mark ParenthesesNode with a newline flag, mark children instead.
238
+ end
239
+ end
240
+
241
+ class IfNode < Node
242
+ #: (Array[bool] lines) -> void
243
+ def newline_flag!(lines) # :nodoc:
244
+ predicate.newline_flag!(lines)
245
+ end
246
+ end
247
+
248
+ class UnlessNode < Node
249
+ #: (Array[bool] lines) -> void
250
+ def newline_flag!(lines) # :nodoc:
251
+ predicate.newline_flag!(lines)
252
+ end
253
+ end
254
+
255
+ class UntilNode < Node
256
+ #: (Array[bool] lines) -> void
257
+ def newline_flag!(lines) # :nodoc:
258
+ if location.start_offset == keyword_loc.start_offset && predicate.is_a?(ParenthesesNode)
259
+ # A parenthesized predicate emits its own line event when it is
260
+ # compiled at the end of the loop, in addition to this one.
261
+ super
262
+ else
263
+ predicate.newline_flag!(lines)
264
+ end
265
+ end
266
+ end
267
+
268
+ class WhileNode < Node
269
+ #: (Array[bool] lines) -> void
270
+ def newline_flag!(lines) # :nodoc:
271
+ if location.start_offset == keyword_loc.start_offset && predicate.is_a?(ParenthesesNode)
272
+ # A parenthesized predicate emits its own line event when it is
273
+ # compiled at the end of the loop, in addition to this one.
274
+ super
275
+ else
276
+ predicate.newline_flag!(lines)
277
+ end
278
+ end
279
+ end
280
+
281
+ class RescueModifierNode < Node
282
+ #: (Array[bool] lines) -> void
283
+ def newline_flag!(lines) # :nodoc:
284
+ expression.newline_flag!(lines)
285
+ end
286
+ end
287
+
288
+ # The line event for a statement is emitted where its first instruction is
289
+ # compiled, so nodes whose first instruction comes from a sub-expression
290
+ # delegate their newline flag to that sub-expression: assignments to their
291
+ # value, calls to their receiver, and array, hash, and interpolated string
292
+ # literals to their first element. Static literals are the exception: they
293
+ # are compiled to a single instruction on the first line of the literal, so
294
+ # they do not delegate.
295
+
296
+ class LocalVariableWriteNode < Node
297
+ #: (Array[bool] lines) -> void
298
+ def newline_flag!(lines) # :nodoc:
299
+ value.newline_flag!(lines)
300
+ end
301
+ end
302
+
303
+ class InstanceVariableWriteNode < Node
304
+ #: (Array[bool] lines) -> void
305
+ def newline_flag!(lines) # :nodoc:
306
+ value.newline_flag!(lines)
307
+ end
308
+ end
309
+
310
+ class ClassVariableWriteNode < Node
311
+ #: (Array[bool] lines) -> void
312
+ def newline_flag!(lines) # :nodoc:
313
+ value.newline_flag!(lines)
314
+ end
315
+ end
316
+
317
+ class GlobalVariableWriteNode < Node
318
+ #: (Array[bool] lines) -> void
319
+ def newline_flag!(lines) # :nodoc:
320
+ value.newline_flag!(lines)
321
+ end
322
+ end
323
+
324
+ class ConstantWriteNode < Node
325
+ #: (Array[bool] lines) -> void
326
+ def newline_flag!(lines) # :nodoc:
327
+ value.newline_flag!(lines)
328
+ end
329
+ end
330
+
331
+ class ConstantPathWriteNode < Node
332
+ #: (Array[bool] lines) -> void
333
+ def newline_flag!(lines) # :nodoc:
334
+ value.newline_flag!(lines)
335
+ end
336
+ end
337
+
338
+ class MultiWriteNode < Node
339
+ #: (Array[bool] lines) -> void
340
+ def newline_flag!(lines) # :nodoc:
341
+ value.newline_flag!(lines)
342
+ end
343
+ end
344
+
345
+ class CallNode < Node
346
+ #: (Array[bool] lines) -> void
347
+ def newline_flag!(lines) # :nodoc:
348
+ if (receiver = self.receiver)
349
+ receiver.newline_flag!(lines)
350
+ else
351
+ super
352
+ end
353
+ end
354
+ end
355
+
356
+ class ArrayNode < Node
357
+ #: (Array[bool] lines) -> void
358
+ def newline_flag!(lines) # :nodoc:
359
+ first = elements.first
360
+ if first && !static_literal?
361
+ first.newline_flag!(lines)
362
+ else
363
+ super
364
+ end
365
+ end
366
+ end
367
+
368
+ class HashNode < Node
369
+ #: (Array[bool] lines) -> void
370
+ def newline_flag!(lines) # :nodoc:
371
+ first = elements.first
372
+ if first && !static_literal?
373
+ first.newline_flag!(lines)
374
+ else
375
+ super
376
+ end
377
+ end
378
+ end
379
+
380
+ class InterpolatedMatchLastLineNode < Node
381
+ #: (Array[bool] lines) -> void
382
+ def newline_flag!(lines) # :nodoc:
383
+ first = parts.first
384
+ first.newline_flag!(lines) if first
385
+ end
386
+ end
387
+
388
+ class InterpolatedRegularExpressionNode < Node
389
+ #: (Array[bool] lines) -> void
390
+ def newline_flag!(lines) # :nodoc:
391
+ first = parts.first
392
+ first.newline_flag!(lines) if first
393
+ end
394
+ end
395
+
396
+ class InterpolatedStringNode < Node
397
+ #: (Array[bool] lines) -> void
398
+ def newline_flag!(lines) # :nodoc:
399
+ first = parts.first
400
+ if first && !static_literal?
401
+ first.newline_flag!(lines)
402
+ else
403
+ super
404
+ end
405
+ end
406
+ end
407
+
408
+ class InterpolatedSymbolNode < Node
409
+ #: (Array[bool] lines) -> void
410
+ def newline_flag!(lines) # :nodoc:
411
+ first = parts.first
412
+ first.newline_flag!(lines) if first
413
+ end
414
+ end
415
+
416
+ class InterpolatedXStringNode < Node
417
+ #: (Array[bool] lines) -> void
418
+ def newline_flag!(lines) # :nodoc:
419
+ first = parts.first
420
+ first.newline_flag!(lines) if first
421
+ end
422
+ end
423
+ end