prism 0.27.0 → 0.29.0

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/config.yml +68 -44
  4. data/docs/configuration.md +1 -0
  5. data/ext/prism/api_node.c +854 -847
  6. data/ext/prism/extconf.rb +27 -23
  7. data/ext/prism/extension.c +5 -3
  8. data/ext/prism/extension.h +1 -1
  9. data/include/prism/ast.h +70 -48
  10. data/include/prism/diagnostic.h +23 -6
  11. data/include/prism/options.h +2 -2
  12. data/include/prism/parser.h +10 -0
  13. data/include/prism/static_literals.h +8 -6
  14. data/include/prism/version.h +2 -2
  15. data/lib/prism/desugar_compiler.rb +4 -4
  16. data/lib/prism/dot_visitor.rb +54 -38
  17. data/lib/prism/dsl.rb +24 -24
  18. data/lib/prism/ffi.rb +4 -4
  19. data/lib/prism/inspect_visitor.rb +2156 -0
  20. data/lib/prism/lex_compat.rb +1 -1
  21. data/lib/prism/mutation_compiler.rb +2 -2
  22. data/lib/prism/node.rb +737 -1863
  23. data/lib/prism/node_ext.rb +176 -5
  24. data/lib/prism/parse_result/comments.rb +1 -1
  25. data/lib/prism/parse_result/newlines.rb +1 -1
  26. data/lib/prism/parse_result.rb +78 -0
  27. data/lib/prism/pattern.rb +12 -6
  28. data/lib/prism/polyfill/byteindex.rb +13 -0
  29. data/lib/prism/polyfill/unpack1.rb +14 -0
  30. data/lib/prism/reflection.rb +20 -20
  31. data/lib/prism/serialize.rb +32 -15
  32. data/lib/prism/translation/parser/compiler.rb +156 -26
  33. data/lib/prism/translation/parser.rb +7 -7
  34. data/lib/prism/translation/ripper.rb +29 -25
  35. data/lib/prism/translation/ruby_parser.rb +13 -13
  36. data/lib/prism.rb +2 -1
  37. data/prism.gemspec +37 -38
  38. data/rbi/prism/compiler.rbi +3 -5
  39. data/rbi/prism/inspect_visitor.rbi +12 -0
  40. data/rbi/prism/node.rbi +405 -370
  41. data/rbi/prism/node_ext.rbi +5 -0
  42. data/rbi/prism/parse_result.rbi +23 -0
  43. data/rbi/prism/translation/ripper.rbi +1 -11
  44. data/sig/prism/dsl.rbs +12 -12
  45. data/sig/prism/inspect_visitor.rbs +22 -0
  46. data/sig/prism/lex_compat.rbs +10 -0
  47. data/sig/prism/node.rbs +108 -91
  48. data/sig/prism/node_ext.rbs +4 -0
  49. data/sig/prism/parse_result.rbs +12 -0
  50. data/src/diagnostic.c +66 -33
  51. data/src/node.c +89 -64
  52. data/src/options.c +2 -2
  53. data/src/prettyprint.c +109 -66
  54. data/src/prism.c +862 -317
  55. data/src/serialize.c +21 -18
  56. data/src/static_literals.c +120 -34
  57. data/src/token_type.c +6 -6
  58. metadata +8 -9
  59. data/lib/prism/node_inspector.rb +0 -68
  60. data/lib/prism/polyfill/string.rb +0 -12
  61. data/rbi/prism/desugar_compiler.rbi +0 -5
  62. data/rbi/prism/mutation_compiler.rbi +0 -5
  63. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  64. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  65. data/rbi/prism/translation/ruby_parser.rbi +0 -11
@@ -3,6 +3,17 @@
3
3
  # Here we are reopening the prism module to provide methods on nodes that aren't
4
4
  # templated and are meant as convenience methods.
5
5
  module Prism
6
+ class Node
7
+ def deprecated(*replacements) # :nodoc:
8
+ suggest = replacements.map { |replacement| "#{self.class}##{replacement}" }
9
+ warn(<<~MSG, category: :deprecated)
10
+ [deprecation]: #{self.class}##{caller_locations(1, 1)[0].label} is deprecated \
11
+ and will be removed in the next major version. Use #{suggest.join("/")} instead.
12
+ #{(caller(1, 3) || []).join("\n")}
13
+ MSG
14
+ end
15
+ end
16
+
6
17
  module RegularExpressionOptions # :nodoc:
7
18
  # Returns a numeric value that represents the flags that were used to create
8
19
  # the regular expression.
@@ -143,11 +154,12 @@ module Prism
143
154
  current = self #: node?
144
155
 
145
156
  while current.is_a?(ConstantPathNode)
146
- child = current.child
147
- if child.is_a?(MissingNode)
157
+ name = current.name
158
+ if name.nil?
148
159
  raise MissingNodesInConstantPathError, "Constant path contains missing nodes. Cannot compute full name"
149
160
  end
150
- parts.unshift(child.name)
161
+
162
+ parts.unshift(name)
151
163
  current = current.parent
152
164
  end
153
165
 
@@ -162,6 +174,14 @@ module Prism
162
174
  def full_name
163
175
  full_name_parts.join("::")
164
176
  end
177
+
178
+ # Previously, we had a child node on this class that contained either a
179
+ # constant read or a missing node. To not cause a breaking change, we
180
+ # continue to supply that API.
181
+ def child
182
+ deprecated("name", "name_loc")
183
+ name ? ConstantReadNode.new(source, name, name_loc) : MissingNode.new(source, location)
184
+ end
165
185
  end
166
186
 
167
187
  class ConstantPathTargetNode < Node
@@ -179,17 +199,25 @@ module Prism
179
199
  raise ConstantPathNode::DynamicPartsInConstantPathError, "Constant target path contains dynamic parts. Cannot compute full name"
180
200
  end
181
201
 
182
- if child.is_a?(MissingNode)
202
+ if name.nil?
183
203
  raise ConstantPathNode::MissingNodesInConstantPathError, "Constant target path contains missing nodes. Cannot compute full name"
184
204
  end
185
205
 
186
- parts.push(child.name)
206
+ parts.push(name)
187
207
  end
188
208
 
189
209
  # Returns the full name of this constant path. For example: "Foo::Bar"
190
210
  def full_name
191
211
  full_name_parts.join("::")
192
212
  end
213
+
214
+ # Previously, we had a child node on this class that contained either a
215
+ # constant read or a missing node. To not cause a breaking change, we
216
+ # continue to supply that API.
217
+ def child
218
+ deprecated("name", "name_loc")
219
+ name ? ConstantReadNode.new(source, name, name_loc) : MissingNode.new(source, location)
220
+ end
193
221
  end
194
222
 
195
223
  class ConstantTargetNode < Node
@@ -257,4 +285,147 @@ module Prism
257
285
  names
258
286
  end
259
287
  end
288
+
289
+ class CallNode < Node
290
+ # When a call node has the attribute_write flag set, it means that the call
291
+ # is using the attribute write syntax. This is either a method call to []=
292
+ # or a method call to a method that ends with =. Either way, the = sign is
293
+ # present in the source.
294
+ #
295
+ # Prism returns the message_loc _without_ the = sign attached, because there
296
+ # can be any amount of space between the message and the = sign. However,
297
+ # sometimes you want the location of the full message including the inner
298
+ # space and the = sign. This method provides that.
299
+ def full_message_loc
300
+ attribute_write? ? message_loc&.adjoin("=") : message_loc
301
+ end
302
+ end
303
+
304
+ class CallOperatorWriteNode < Node
305
+ # Returns the binary operator used to modify the receiver. This method is
306
+ # deprecated in favor of #binary_operator.
307
+ def operator
308
+ deprecated("binary_operator")
309
+ binary_operator
310
+ end
311
+
312
+ # Returns the location of the binary operator used to modify the receiver.
313
+ # This method is deprecated in favor of #binary_operator_loc.
314
+ def operator_loc
315
+ deprecated("binary_operator_loc")
316
+ binary_operator_loc
317
+ end
318
+ end
319
+
320
+ class ClassVariableOperatorWriteNode < Node
321
+ # Returns the binary operator used to modify the receiver. This method is
322
+ # deprecated in favor of #binary_operator.
323
+ def operator
324
+ deprecated("binary_operator")
325
+ binary_operator
326
+ end
327
+
328
+ # Returns the location of the binary operator used to modify the receiver.
329
+ # This method is deprecated in favor of #binary_operator_loc.
330
+ def operator_loc
331
+ deprecated("binary_operator_loc")
332
+ binary_operator_loc
333
+ end
334
+ end
335
+
336
+ class ConstantOperatorWriteNode < Node
337
+ # Returns the binary operator used to modify the receiver. This method is
338
+ # deprecated in favor of #binary_operator.
339
+ def operator
340
+ deprecated("binary_operator")
341
+ binary_operator
342
+ end
343
+
344
+ # Returns the location of the binary operator used to modify the receiver.
345
+ # This method is deprecated in favor of #binary_operator_loc.
346
+ def operator_loc
347
+ deprecated("binary_operator_loc")
348
+ binary_operator_loc
349
+ end
350
+ end
351
+
352
+ class ConstantPathOperatorWriteNode < Node
353
+ # Returns the binary operator used to modify the receiver. This method is
354
+ # deprecated in favor of #binary_operator.
355
+ def operator
356
+ deprecated("binary_operator")
357
+ binary_operator
358
+ end
359
+
360
+ # Returns the location of the binary operator used to modify the receiver.
361
+ # This method is deprecated in favor of #binary_operator_loc.
362
+ def operator_loc
363
+ deprecated("binary_operator_loc")
364
+ binary_operator_loc
365
+ end
366
+ end
367
+
368
+ class GlobalVariableOperatorWriteNode < Node
369
+ # Returns the binary operator used to modify the receiver. This method is
370
+ # deprecated in favor of #binary_operator.
371
+ def operator
372
+ deprecated("binary_operator")
373
+ binary_operator
374
+ end
375
+
376
+ # Returns the location of the binary operator used to modify the receiver.
377
+ # This method is deprecated in favor of #binary_operator_loc.
378
+ def operator_loc
379
+ deprecated("binary_operator_loc")
380
+ binary_operator_loc
381
+ end
382
+ end
383
+
384
+ class IndexOperatorWriteNode < Node
385
+ # Returns the binary operator used to modify the receiver. This method is
386
+ # deprecated in favor of #binary_operator.
387
+ def operator
388
+ deprecated("binary_operator")
389
+ binary_operator
390
+ end
391
+
392
+ # Returns the location of the binary operator used to modify the receiver.
393
+ # This method is deprecated in favor of #binary_operator_loc.
394
+ def operator_loc
395
+ deprecated("binary_operator_loc")
396
+ binary_operator_loc
397
+ end
398
+ end
399
+
400
+ class InstanceVariableOperatorWriteNode < Node
401
+ # Returns the binary operator used to modify the receiver. This method is
402
+ # deprecated in favor of #binary_operator.
403
+ def operator
404
+ deprecated("binary_operator")
405
+ binary_operator
406
+ end
407
+
408
+ # Returns the location of the binary operator used to modify the receiver.
409
+ # This method is deprecated in favor of #binary_operator_loc.
410
+ def operator_loc
411
+ deprecated("binary_operator_loc")
412
+ binary_operator_loc
413
+ end
414
+ end
415
+
416
+ class LocalVariableOperatorWriteNode < Node
417
+ # Returns the binary operator used to modify the receiver. This method is
418
+ # deprecated in favor of #binary_operator.
419
+ def operator
420
+ deprecated("binary_operator")
421
+ binary_operator
422
+ end
423
+
424
+ # Returns the location of the binary operator used to modify the receiver.
425
+ # This method is deprecated in favor of #binary_operator_loc.
426
+ def operator_loc
427
+ deprecated("binary_operator_loc")
428
+ binary_operator_loc
429
+ end
430
+ end
260
431
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prism
4
- class ParseResult
4
+ class ParseResult < Result
5
5
  # When we've parsed the source, we have both the syntax tree and the list of
6
6
  # comments that we found in the source. This class is responsible for
7
7
  # walking the tree and finding the nearest location to attach each comment.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prism
4
- class ParseResult
4
+ class ParseResult < Result
5
5
  # The :line tracepoint event gets fired whenever the Ruby VM encounters an
6
6
  # expression on a new line. The types of expressions that can trigger this
7
7
  # event are:
@@ -5,6 +5,14 @@ module Prism
5
5
  # conjunction with locations to allow them to resolve line numbers and source
6
6
  # ranges.
7
7
  class Source
8
+ # Create a new source object with the given source code. This method should
9
+ # be used instead of `new` and it will return either a `Source` or a
10
+ # specialized and more performant `ASCIISource` if no multibyte characters
11
+ # are present in the source code.
12
+ def self.for(source, start_line = 1, offsets = [])
13
+ source.ascii_only? ? ASCIISource.new(source, start_line, offsets): new(source, start_line, offsets)
14
+ end
15
+
8
16
  # The source code that this source object represents.
9
17
  attr_reader :source
10
18
 
@@ -27,6 +35,11 @@ module Prism
27
35
  source.encoding
28
36
  end
29
37
 
38
+ # Returns the lines of the source code as an array of strings.
39
+ def lines
40
+ source.lines
41
+ end
42
+
30
43
  # Perform a byteslice on the source code using the given byte offset and
31
44
  # byte length.
32
45
  def slice(byte_offset, length)
@@ -45,6 +58,12 @@ module Prism
45
58
  offsets[find_line(byte_offset)]
46
59
  end
47
60
 
61
+ # Returns the byte offset of the end of the line corresponding to the given
62
+ # byte offset.
63
+ def line_end(byte_offset)
64
+ offsets[find_line(byte_offset) + 1] || source.bytesize
65
+ end
66
+
48
67
  # Return the column number for the given byte offset.
49
68
  def column(byte_offset)
50
69
  byte_offset - line_start(byte_offset)
@@ -100,6 +119,39 @@ module Prism
100
119
  end
101
120
  end
102
121
 
122
+ # Specialized version of Prism::Source for source code that includes ASCII
123
+ # characters only. This class is used to apply performance optimizations that
124
+ # cannot be applied to sources that include multibyte characters. Sources that
125
+ # include multibyte characters are represented by the Prism::Source class.
126
+ class ASCIISource < Source
127
+ # Return the character offset for the given byte offset.
128
+ def character_offset(byte_offset)
129
+ byte_offset
130
+ end
131
+
132
+ # Return the column number in characters for the given byte offset.
133
+ def character_column(byte_offset)
134
+ byte_offset - line_start(byte_offset)
135
+ end
136
+
137
+ # Returns the offset from the start of the file for the given byte offset
138
+ # counting in code units for the given encoding.
139
+ #
140
+ # This method is tested with UTF-8, UTF-16, and UTF-32. If there is the
141
+ # concept of code units that differs from the number of characters in other
142
+ # encodings, it is not captured here.
143
+ def code_units_offset(byte_offset, encoding)
144
+ byte_offset
145
+ end
146
+
147
+ # Specialized version of `code_units_column` that does not depend on
148
+ # `code_units_offset`, which is a more expensive operation. This is
149
+ # essentialy the same as `Prism::Source#column`.
150
+ def code_units_column(byte_offset, encoding)
151
+ byte_offset - line_start(byte_offset)
152
+ end
153
+ end
154
+
103
155
  # This represents a location in the source.
104
156
  class Location
105
157
  # A Source object that is used to determine more information from the given
@@ -171,11 +223,25 @@ module Prism
171
223
  "#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
172
224
  end
173
225
 
226
+ # Returns all of the lines of the source code associated with this location.
227
+ def source_lines
228
+ source.lines
229
+ end
230
+
174
231
  # The source code that this location represents.
175
232
  def slice
176
233
  source.slice(start_offset, length)
177
234
  end
178
235
 
236
+ # The source code that this location represents starting from the beginning
237
+ # of the line that this location starts on to the end of the line that this
238
+ # location ends on.
239
+ def slice_lines
240
+ line_start = source.line_start(start_offset)
241
+ line_end = source.line_end(end_offset)
242
+ source.slice(line_start, line_end - line_start)
243
+ end
244
+
179
245
  # The character offset from the beginning of the source where this location
180
246
  # starts.
181
247
  def start_character_offset
@@ -281,6 +347,18 @@ module Prism
281
347
 
282
348
  Location.new(source, start_offset, other.end_offset - start_offset)
283
349
  end
350
+
351
+ # Join this location with the first occurrence of the string in the source
352
+ # that occurs after this location on the same line, and return the new
353
+ # location. This will raise an error if the string does not exist.
354
+ def adjoin(string)
355
+ line_suffix = source.slice(end_offset, source.line_end(end_offset) - end_offset)
356
+
357
+ line_suffix_index = line_suffix.byteindex(string)
358
+ raise "Could not find #{string}" if line_suffix_index.nil?
359
+
360
+ Location.new(source, start_offset, length + line_suffix_index + string.bytesize)
361
+ end
284
362
  end
285
363
 
286
364
  # This represents a comment that was encountered during parsing. It is the
data/lib/prism/pattern.rb CHANGED
@@ -149,7 +149,10 @@ module Prism
149
149
  parent = node.parent
150
150
 
151
151
  if parent.is_a?(ConstantReadNode) && parent.slice == "Prism"
152
- compile_node(node.child)
152
+ name = node.name
153
+ raise CompilationError, node.inspect if name.nil?
154
+
155
+ compile_constant_name(node, name)
153
156
  else
154
157
  compile_error(node)
155
158
  end
@@ -158,14 +161,17 @@ module Prism
158
161
  # in ConstantReadNode
159
162
  # in String
160
163
  def compile_constant_read_node(node)
161
- value = node.slice
164
+ compile_constant_name(node, node.name)
165
+ end
162
166
 
163
- if Prism.const_defined?(value, false)
164
- clazz = Prism.const_get(value)
167
+ # Compile a name associated with a constant.
168
+ def compile_constant_name(node, name)
169
+ if Prism.const_defined?(name, false)
170
+ clazz = Prism.const_get(name)
165
171
 
166
172
  ->(other) { clazz === other }
167
- elsif Object.const_defined?(value, false)
168
- clazz = Object.const_get(value)
173
+ elsif Object.const_defined?(name, false)
174
+ clazz = Object.const_get(name)
169
175
 
170
176
  ->(other) { clazz === other }
171
177
  else
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Polyfill for String#byteindex, which didn't exist until Ruby 3.2.
4
+ if !("".respond_to?(:byteindex))
5
+ String.include(
6
+ Module.new {
7
+ def byteindex(needle, offset = 0)
8
+ charindex = index(needle, offset)
9
+ slice(0...charindex).bytesize if charindex
10
+ end
11
+ }
12
+ )
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
4
+ # have Method#parameters implemented, so we check the arity instead if
5
+ # necessary.
6
+ if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1)
7
+ String.prepend(
8
+ Module.new {
9
+ def unpack1(format, offset: 0) # :nodoc:
10
+ offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore
11
+ end
12
+ }
13
+ )
14
+ end
@@ -112,7 +112,7 @@ module Prism
112
112
  when :and_node
113
113
  [NodeField.new(:left), NodeField.new(:right), LocationField.new(:operator_loc)]
114
114
  when :arguments_node
115
- [FlagsField.new(:flags, [:contains_keyword_splat?]), NodeListField.new(:arguments)]
115
+ [FlagsField.new(:flags, [:contains_keywords?, :contains_keyword_splat?]), NodeListField.new(:arguments)]
116
116
  when :array_node
117
117
  [FlagsField.new(:flags, [:contains_splat?]), NodeListField.new(:elements), OptionalLocationField.new(:opening_loc), OptionalLocationField.new(:closing_loc)]
118
118
  when :array_pattern_node
@@ -142,7 +142,7 @@ module Prism
142
142
  when :call_node
143
143
  [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), ConstantField.new(:name), OptionalLocationField.new(:message_loc), OptionalLocationField.new(:opening_loc), OptionalNodeField.new(:arguments), OptionalLocationField.new(:closing_loc), OptionalNodeField.new(:block)]
144
144
  when :call_operator_write_node
145
- [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), OptionalLocationField.new(:message_loc), ConstantField.new(:read_name), ConstantField.new(:write_name), ConstantField.new(:operator), LocationField.new(:operator_loc), NodeField.new(:value)]
145
+ [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), OptionalLocationField.new(:message_loc), ConstantField.new(:read_name), ConstantField.new(:write_name), ConstantField.new(:binary_operator), LocationField.new(:binary_operator_loc), NodeField.new(:value)]
146
146
  when :call_or_write_node
147
147
  [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), OptionalLocationField.new(:message_loc), ConstantField.new(:read_name), ConstantField.new(:write_name), LocationField.new(:operator_loc), NodeField.new(:value)]
148
148
  when :call_target_node
@@ -158,7 +158,7 @@ module Prism
158
158
  when :class_variable_and_write_node
159
159
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
160
160
  when :class_variable_operator_write_node
161
- [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:operator)]
161
+ [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:binary_operator)]
162
162
  when :class_variable_or_write_node
163
163
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
164
164
  when :class_variable_read_node
@@ -170,19 +170,19 @@ module Prism
170
170
  when :constant_and_write_node
171
171
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
172
172
  when :constant_operator_write_node
173
- [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:operator)]
173
+ [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:binary_operator)]
174
174
  when :constant_or_write_node
175
175
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
176
176
  when :constant_path_and_write_node
177
177
  [NodeField.new(:target), LocationField.new(:operator_loc), NodeField.new(:value)]
178
178
  when :constant_path_node
179
- [OptionalNodeField.new(:parent), NodeField.new(:child), LocationField.new(:delimiter_loc)]
179
+ [OptionalNodeField.new(:parent), OptionalConstantField.new(:name), LocationField.new(:delimiter_loc), LocationField.new(:name_loc)]
180
180
  when :constant_path_operator_write_node
181
- [NodeField.new(:target), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:operator)]
181
+ [NodeField.new(:target), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:binary_operator)]
182
182
  when :constant_path_or_write_node
183
183
  [NodeField.new(:target), LocationField.new(:operator_loc), NodeField.new(:value)]
184
184
  when :constant_path_target_node
185
- [OptionalNodeField.new(:parent), NodeField.new(:child), LocationField.new(:delimiter_loc)]
185
+ [OptionalNodeField.new(:parent), OptionalConstantField.new(:name), LocationField.new(:delimiter_loc), LocationField.new(:name_loc)]
186
186
  when :constant_path_write_node
187
187
  [NodeField.new(:target), LocationField.new(:operator_loc), NodeField.new(:value)]
188
188
  when :constant_read_node
@@ -222,7 +222,7 @@ module Prism
222
222
  when :global_variable_and_write_node
223
223
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
224
224
  when :global_variable_operator_write_node
225
- [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:operator)]
225
+ [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:binary_operator)]
226
226
  when :global_variable_or_write_node
227
227
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
228
228
  when :global_variable_read_node
@@ -248,7 +248,7 @@ module Prism
248
248
  when :index_and_write_node
249
249
  [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), LocationField.new(:opening_loc), OptionalNodeField.new(:arguments), LocationField.new(:closing_loc), OptionalNodeField.new(:block), LocationField.new(:operator_loc), NodeField.new(:value)]
250
250
  when :index_operator_write_node
251
- [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), LocationField.new(:opening_loc), OptionalNodeField.new(:arguments), LocationField.new(:closing_loc), OptionalNodeField.new(:block), ConstantField.new(:operator), LocationField.new(:operator_loc), NodeField.new(:value)]
251
+ [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), LocationField.new(:opening_loc), OptionalNodeField.new(:arguments), LocationField.new(:closing_loc), OptionalNodeField.new(:block), ConstantField.new(:binary_operator), LocationField.new(:binary_operator_loc), NodeField.new(:value)]
252
252
  when :index_or_write_node
253
253
  [FlagsField.new(:flags, [:safe_navigation?, :variable_call?, :attribute_write?, :ignore_visibility?]), OptionalNodeField.new(:receiver), OptionalLocationField.new(:call_operator_loc), LocationField.new(:opening_loc), OptionalNodeField.new(:arguments), LocationField.new(:closing_loc), OptionalNodeField.new(:block), LocationField.new(:operator_loc), NodeField.new(:value)]
254
254
  when :index_target_node
@@ -256,7 +256,7 @@ module Prism
256
256
  when :instance_variable_and_write_node
257
257
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
258
258
  when :instance_variable_operator_write_node
259
- [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:operator)]
259
+ [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:binary_operator)]
260
260
  when :instance_variable_or_write_node
261
261
  [ConstantField.new(:name), LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value)]
262
262
  when :instance_variable_read_node
@@ -266,7 +266,7 @@ module Prism
266
266
  when :instance_variable_write_node
267
267
  [ConstantField.new(:name), LocationField.new(:name_loc), NodeField.new(:value), LocationField.new(:operator_loc)]
268
268
  when :integer_node
269
- [FlagsField.new(:flags, [:binary?, :decimal?, :octal?, :hexadecimal?]), Integer.new(:value)]
269
+ [FlagsField.new(:flags, [:binary?, :decimal?, :octal?, :hexadecimal?]), IntegerField.new(:value)]
270
270
  when :interpolated_match_last_line_node
271
271
  [FlagsField.new(:flags, [:ignore_case?, :extended?, :multi_line?, :once?, :euc_jp?, :ascii_8bit?, :windows_31j?, :utf_8?, :forced_utf8_encoding?, :forced_binary_encoding?, :forced_us_ascii_encoding?]), LocationField.new(:opening_loc), NodeListField.new(:parts), LocationField.new(:closing_loc)]
272
272
  when :interpolated_regular_expression_node
@@ -286,17 +286,17 @@ module Prism
286
286
  when :lambda_node
287
287
  [ConstantListField.new(:locals), LocationField.new(:operator_loc), LocationField.new(:opening_loc), LocationField.new(:closing_loc), OptionalNodeField.new(:parameters), OptionalNodeField.new(:body)]
288
288
  when :local_variable_and_write_node
289
- [LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:name), Integer.new(:depth)]
289
+ [LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:name), IntegerField.new(:depth)]
290
290
  when :local_variable_operator_write_node
291
- [LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:name), ConstantField.new(:operator), Integer.new(:depth)]
291
+ [LocationField.new(:name_loc), LocationField.new(:binary_operator_loc), NodeField.new(:value), ConstantField.new(:name), ConstantField.new(:binary_operator), IntegerField.new(:depth)]
292
292
  when :local_variable_or_write_node
293
- [LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:name), Integer.new(:depth)]
293
+ [LocationField.new(:name_loc), LocationField.new(:operator_loc), NodeField.new(:value), ConstantField.new(:name), IntegerField.new(:depth)]
294
294
  when :local_variable_read_node
295
- [ConstantField.new(:name), Integer.new(:depth)]
295
+ [ConstantField.new(:name), IntegerField.new(:depth)]
296
296
  when :local_variable_target_node
297
- [ConstantField.new(:name), Integer.new(:depth)]
297
+ [ConstantField.new(:name), IntegerField.new(:depth)]
298
298
  when :local_variable_write_node
299
- [ConstantField.new(:name), Integer.new(:depth), LocationField.new(:name_loc), NodeField.new(:value), LocationField.new(:operator_loc)]
299
+ [ConstantField.new(:name), IntegerField.new(:depth), LocationField.new(:name_loc), NodeField.new(:value), LocationField.new(:operator_loc)]
300
300
  when :match_last_line_node
301
301
  [FlagsField.new(:flags, [:ignore_case?, :extended?, :multi_line?, :once?, :euc_jp?, :ascii_8bit?, :windows_31j?, :utf_8?, :forced_utf8_encoding?, :forced_binary_encoding?, :forced_us_ascii_encoding?]), LocationField.new(:opening_loc), LocationField.new(:content_loc), LocationField.new(:closing_loc), StringField.new(:unescaped)]
302
302
  when :match_predicate_node
@@ -320,9 +320,9 @@ module Prism
320
320
  when :no_keywords_parameter_node
321
321
  [LocationField.new(:operator_loc), LocationField.new(:keyword_loc)]
322
322
  when :numbered_parameters_node
323
- [Integer.new(:maximum)]
323
+ [IntegerField.new(:maximum)]
324
324
  when :numbered_reference_read_node
325
- [Integer.new(:number)]
325
+ [IntegerField.new(:number)]
326
326
  when :optional_keyword_parameter_node
327
327
  [FlagsField.new(:flags, [:repeated_parameter?]), ConstantField.new(:name), LocationField.new(:name_loc), NodeField.new(:value)]
328
328
  when :optional_parameter_node
@@ -364,7 +364,7 @@ module Prism
364
364
  when :retry_node
365
365
  []
366
366
  when :return_node
367
- [LocationField.new(:keyword_loc), OptionalNodeField.new(:arguments)]
367
+ [FlagsField.new(:flags, [:redundant?]), LocationField.new(:keyword_loc), OptionalNodeField.new(:arguments)]
368
368
  when :self_node
369
369
  []
370
370
  when :shareable_constant_node