prism 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/config.yml +39 -27
  4. data/docs/configuration.md +1 -0
  5. data/ext/prism/api_node.c +814 -807
  6. data/ext/prism/extension.c +5 -3
  7. data/ext/prism/extension.h +1 -1
  8. data/include/prism/ast.h +38 -16
  9. data/include/prism/diagnostic.h +12 -5
  10. data/include/prism/options.h +2 -2
  11. data/include/prism/parser.h +10 -0
  12. data/include/prism/static_literals.h +8 -6
  13. data/include/prism/version.h +2 -2
  14. data/lib/prism/dot_visitor.rb +22 -6
  15. data/lib/prism/dsl.rb +8 -8
  16. data/lib/prism/ffi.rb +3 -3
  17. data/lib/prism/inspect_visitor.rb +2156 -0
  18. data/lib/prism/lex_compat.rb +1 -1
  19. data/lib/prism/mutation_compiler.rb +2 -2
  20. data/lib/prism/node.rb +589 -1715
  21. data/lib/prism/node_ext.rb +34 -5
  22. data/lib/prism/parse_result.rb +78 -0
  23. data/lib/prism/pattern.rb +12 -6
  24. data/lib/prism/polyfill/byteindex.rb +13 -0
  25. data/lib/prism/polyfill/unpack1.rb +14 -0
  26. data/lib/prism/reflection.rb +13 -13
  27. data/lib/prism/serialize.rb +21 -14
  28. data/lib/prism/translation/parser/compiler.rb +2 -2
  29. data/lib/prism/translation/parser.rb +6 -6
  30. data/lib/prism/translation/ripper.rb +13 -9
  31. data/lib/prism/translation/ruby_parser.rb +4 -4
  32. data/lib/prism.rb +2 -1
  33. data/prism.gemspec +36 -38
  34. data/rbi/prism/compiler.rbi +3 -5
  35. data/rbi/prism/inspect_visitor.rbi +12 -0
  36. data/rbi/prism/node.rbi +354 -319
  37. data/rbi/prism/parse_result.rbi +23 -0
  38. data/rbi/prism/translation/ripper.rbi +1 -11
  39. data/sig/prism/dsl.rbs +3 -3
  40. data/sig/prism/inspect_visitor.rbs +22 -0
  41. data/sig/prism/node.rbs +64 -47
  42. data/sig/prism/parse_result.rbs +12 -0
  43. data/src/diagnostic.c +38 -24
  44. data/src/node.c +41 -16
  45. data/src/options.c +2 -2
  46. data/src/prettyprint.c +61 -18
  47. data/src/prism.c +607 -185
  48. data/src/serialize.c +5 -2
  49. data/src/static_literals.c +120 -34
  50. data/src/token_type.c +4 -4
  51. metadata +7 -9
  52. data/lib/prism/node_inspector.rb +0 -68
  53. data/lib/prism/polyfill/string.rb +0 -12
  54. data/rbi/prism/desugar_compiler.rbi +0 -5
  55. data/rbi/prism/mutation_compiler.rbi +0 -5
  56. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  57. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  58. data/rbi/prism/translation/ruby_parser.rbi +0 -11
@@ -16,6 +16,9 @@ class Prism::Source
16
16
  sig { returns(Encoding) }
17
17
  def encoding; end
18
18
 
19
+ sig { returns(T::Array[Integer]) }
20
+ def lines; end
21
+
19
22
  sig { params(byte_offset: Integer, length: Integer).returns(String) }
20
23
  def slice(byte_offset, length); end
21
24
 
@@ -41,6 +44,20 @@ class Prism::Source
41
44
  def code_units_column(byte_offset, encoding); end
42
45
  end
43
46
 
47
+ class Prism::ASCIISource < Prism::Source
48
+ sig { params(byte_offset: Integer).returns(Integer) }
49
+ def character_offset(byte_offset); end
50
+
51
+ sig { params(byte_offset: Integer).returns(Integer) }
52
+ def character_column(byte_offset); end
53
+
54
+ sig { params(byte_offset: Integer, encoding: Encoding).returns(Integer) }
55
+ def code_units_offset(byte_offset, encoding); end
56
+
57
+ sig { params(byte_offset: Integer, encoding: Encoding).returns(Integer) }
58
+ def code_units_column(byte_offset, encoding); end
59
+ end
60
+
44
61
  class Prism::Location
45
62
  sig { returns(Prism::Source) }
46
63
  def source; end
@@ -78,6 +95,9 @@ class Prism::Location
78
95
  sig { returns(String) }
79
96
  def inspect; end
80
97
 
98
+ sig { returns(T::Array[String]) }
99
+ def source_lines; end
100
+
81
101
  sig { returns(String) }
82
102
  def slice; end
83
103
 
@@ -134,6 +154,9 @@ class Prism::Location
134
154
 
135
155
  sig { params(other: Prism::Location).returns(Prism::Location) }
136
156
  def join(other); end
157
+
158
+ sig { params(string: String).returns(Prism::Location) }
159
+ def adjoin(string); end
137
160
  end
138
161
 
139
162
  class Prism::Comment
@@ -1,12 +1,10 @@
1
1
  # typed: strict
2
2
 
3
3
  class Prism::Translation::Ripper < Prism::Compiler
4
- Result = type_member
5
-
6
4
  sig { returns(T::Boolean) }
7
5
  def error?; end
8
6
 
9
- sig { returns(T.nilable(Result)) }
7
+ sig { returns(T.untyped) }
10
8
  def parse; end
11
9
 
12
10
  sig { params(source: String, filename: String, lineno: Integer, raise_errors: T.untyped).returns(T.untyped) }
@@ -15,11 +13,3 @@ class Prism::Translation::Ripper < Prism::Compiler
15
13
  sig { params(source: String, filename: String, lineno: Integer, raise_errors: T.untyped).returns(T.untyped) }
16
14
  def self.sexp(source, filename = "-", lineno = 1, raise_errors: false); end
17
15
  end
18
-
19
- class Prism::Translation::Ripper::SexpBuilder < Prism::Translation::Ripper
20
- Result = type_member { { fixed: T::Array[T.untyped] } }
21
- end
22
-
23
- class Prism::Translation::Ripper::SexpBuilderPP < Prism::Translation::Ripper::SexpBuilder
24
- Result = type_member { { fixed: T::Array[T.untyped] } }
25
- end
data/sig/prism/dsl.rbs CHANGED
@@ -118,7 +118,7 @@ module Prism
118
118
  def ConstantPathAndWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathAndWriteNode
119
119
 
120
120
  # Create a new ConstantPathNode node
121
- def ConstantPathNode: (Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, ?Source source, ?Location location) -> ConstantPathNode
121
+ def ConstantPathNode: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, ?Source source, ?Location location) -> ConstantPathNode
122
122
 
123
123
  # Create a new ConstantPathOperatorWriteNode node
124
124
  def ConstantPathOperatorWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, Symbol operator, ?Source source, ?Location location) -> ConstantPathOperatorWriteNode
@@ -127,7 +127,7 @@ module Prism
127
127
  def ConstantPathOrWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathOrWriteNode
128
128
 
129
129
  # Create a new ConstantPathTargetNode node
130
- def ConstantPathTargetNode: (Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, ?Source source, ?Location location) -> ConstantPathTargetNode
130
+ def ConstantPathTargetNode: (Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, ?Source source, ?Location location) -> ConstantPathTargetNode
131
131
 
132
132
  # Create a new ConstantPathWriteNode node
133
133
  def ConstantPathWriteNode: (ConstantPathNode target, Location operator_loc, Prism::node value, ?Source source, ?Location location) -> ConstantPathWriteNode
@@ -400,7 +400,7 @@ module Prism
400
400
  def RetryNode: (?Source source, ?Location location) -> RetryNode
401
401
 
402
402
  # Create a new ReturnNode node
403
- def ReturnNode: (Location keyword_loc, ArgumentsNode? arguments, ?Source source, ?Location location) -> ReturnNode
403
+ def ReturnNode: (Integer flags, Location keyword_loc, ArgumentsNode? arguments, ?Source source, ?Location location) -> ReturnNode
404
404
 
405
405
  # Create a new SelfNode node
406
406
  def SelfNode: (?Source source, ?Location location) -> SelfNode
@@ -0,0 +1,22 @@
1
+ module Prism
2
+ class InspectVisitor < Visitor
3
+ class Replace
4
+ attr_reader value: String
5
+
6
+ def initialize: (String value) -> void
7
+ end
8
+
9
+ attr_reader indent: String
10
+ attr_reader commands: Array[[String | node | Replace, String]]
11
+
12
+ def initialize: (?String indent) -> void
13
+ def compose: () -> String
14
+
15
+ def self.compose: (node node) -> String
16
+
17
+ private
18
+
19
+ def inspect_node: (String name, node node) -> String
20
+ def inspect_location: (Location? location) -> String
21
+ end
22
+ end
data/sig/prism/node.rbs CHANGED
@@ -16,9 +16,13 @@ module Prism
16
16
 
17
17
  def start_offset: () -> Integer
18
18
  def end_offset: () -> Integer
19
+ def source_lines: () -> Array[String]
20
+ alias script_lines source_lines
19
21
  def slice: () -> String
22
+ def slice_lines: () -> String
20
23
  def pretty_print: (untyped q) -> untyped
21
24
  def to_dot: () -> String
25
+ def tunnel: (Integer line, Integer column) -> Array[Prism::node]
22
26
  end
23
27
 
24
28
  type node_singleton = singleton(Node) & _NodeSingleton
@@ -31,7 +35,7 @@ module Prism
31
35
  def compact_child_nodes: () -> Array[Prism::node]
32
36
  def comment_targets: () -> Array[Prism::node | Location]
33
37
  def fields: () -> Array[Prism::Reflection::Field]
34
- def inspect: (?untyped) -> String
38
+ def inspect: () -> String
35
39
  def type: () -> Symbol
36
40
  end
37
41
 
@@ -125,12 +129,13 @@ module Prism
125
129
  class ArgumentsNode < Node
126
130
  include _Node
127
131
 
128
- private attr_reader flags: Integer
132
+ attr_reader flags: Integer
129
133
  attr_reader arguments: Array[Prism::node]
130
134
 
131
135
  def initialize: (Source source, Integer flags, Array[Prism::node] arguments, Location location) -> void
132
136
  def copy: (?flags: Integer, ?arguments: Array[Prism::node], ?location: Location) -> ArgumentsNode
133
137
  def deconstruct_keys: (Array[Symbol] keys) -> { flags: Integer, arguments: Array[Prism::node], location: Location }
138
+ def contains_keywords?: () -> bool
134
139
  def contains_keyword_splat?: () -> bool
135
140
  def type: () -> :arguments_node
136
141
  | ...
@@ -144,7 +149,7 @@ module Prism
144
149
  class ArrayNode < Node
145
150
  include _Node
146
151
 
147
- private attr_reader flags: Integer
152
+ attr_reader flags: Integer
148
153
  attr_reader elements: Array[Prism::node]
149
154
  attr_reader opening_loc: Location?
150
155
  attr_reader closing_loc: Location?
@@ -304,7 +309,7 @@ module Prism
304
309
  class BlockLocalVariableNode < Node
305
310
  include _Node
306
311
 
307
- private attr_reader flags: Integer
312
+ attr_reader flags: Integer
308
313
  attr_reader name: Symbol
309
314
 
310
315
  def initialize: (Source source, Integer flags, Symbol name, Location location) -> void
@@ -347,7 +352,7 @@ module Prism
347
352
  class BlockParameterNode < Node
348
353
  include _Node
349
354
 
350
- private attr_reader flags: Integer
355
+ attr_reader flags: Integer
351
356
  attr_reader name: Symbol?
352
357
  attr_reader name_loc: Location?
353
358
  attr_reader operator_loc: Location
@@ -414,7 +419,7 @@ module Prism
414
419
  class CallAndWriteNode < Node
415
420
  include _Node
416
421
 
417
- private attr_reader flags: Integer
422
+ attr_reader flags: Integer
418
423
  attr_reader receiver: Prism::node?
419
424
  attr_reader call_operator_loc: Location?
420
425
  attr_reader message_loc: Location?
@@ -460,7 +465,7 @@ module Prism
460
465
  class CallNode < Node
461
466
  include _Node
462
467
 
463
- private attr_reader flags: Integer
468
+ attr_reader flags: Integer
464
469
  attr_reader receiver: Prism::node?
465
470
  attr_reader call_operator_loc: Location?
466
471
  attr_reader name: Symbol
@@ -493,7 +498,7 @@ module Prism
493
498
  class CallOperatorWriteNode < Node
494
499
  include _Node
495
500
 
496
- private attr_reader flags: Integer
501
+ attr_reader flags: Integer
497
502
  attr_reader receiver: Prism::node?
498
503
  attr_reader call_operator_loc: Location?
499
504
  attr_reader message_loc: Location?
@@ -524,7 +529,7 @@ module Prism
524
529
  class CallOrWriteNode < Node
525
530
  include _Node
526
531
 
527
- private attr_reader flags: Integer
532
+ attr_reader flags: Integer
528
533
  attr_reader receiver: Prism::node?
529
534
  attr_reader call_operator_loc: Location?
530
535
  attr_reader message_loc: Location?
@@ -563,7 +568,7 @@ module Prism
563
568
  class CallTargetNode < Node
564
569
  include _Node
565
570
 
566
- private attr_reader flags: Integer
571
+ attr_reader flags: Integer
567
572
  attr_reader receiver: Prism::node
568
573
  attr_reader call_operator_loc: Location
569
574
  attr_reader name: Symbol
@@ -889,12 +894,13 @@ module Prism
889
894
  include _Node
890
895
 
891
896
  attr_reader parent: Prism::node?
892
- attr_reader child: ConstantReadNode | MissingNode
897
+ attr_reader name: Symbol?
893
898
  attr_reader delimiter_loc: Location
899
+ attr_reader name_loc: Location
894
900
 
895
- def initialize: (Source source, Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, Location location) -> void
896
- def copy: (?parent: Prism::node?, ?child: ConstantReadNode | MissingNode, ?delimiter_loc: Location, ?location: Location) -> ConstantPathNode
897
- def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, child: ConstantReadNode | MissingNode, delimiter_loc: Location, location: Location }
901
+ def initialize: (Source source, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
902
+ def copy: (?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location, ?location: Location) -> ConstantPathNode
903
+ def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, name: Symbol?, delimiter_loc: Location, name_loc: Location, location: Location }
898
904
  def delimiter: () -> String
899
905
  def type: () -> :constant_path_node
900
906
  | ...
@@ -949,12 +955,13 @@ module Prism
949
955
  include _Node
950
956
 
951
957
  attr_reader parent: Prism::node?
952
- attr_reader child: ConstantReadNode | MissingNode
958
+ attr_reader name: Symbol?
953
959
  attr_reader delimiter_loc: Location
960
+ attr_reader name_loc: Location
954
961
 
955
- def initialize: (Source source, Prism::node? parent, ConstantReadNode | MissingNode child, Location delimiter_loc, Location location) -> void
956
- def copy: (?parent: Prism::node?, ?child: ConstantReadNode | MissingNode, ?delimiter_loc: Location, ?location: Location) -> ConstantPathTargetNode
957
- def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, child: ConstantReadNode | MissingNode, delimiter_loc: Location, location: Location }
962
+ def initialize: (Source source, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc, Location location) -> void
963
+ def copy: (?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location, ?location: Location) -> ConstantPathTargetNode
964
+ def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?, name: Symbol?, delimiter_loc: Location, name_loc: Location, location: Location }
958
965
  def delimiter: () -> String
959
966
  def type: () -> :constant_path_target_node
960
967
  | ...
@@ -1239,7 +1246,7 @@ module Prism
1239
1246
  class FlipFlopNode < Node
1240
1247
  include _Node
1241
1248
 
1242
- private attr_reader flags: Integer
1249
+ attr_reader flags: Integer
1243
1250
  attr_reader left: Prism::node?
1244
1251
  attr_reader right: Prism::node?
1245
1252
  attr_reader operator_loc: Location
@@ -1640,7 +1647,7 @@ module Prism
1640
1647
  class IndexAndWriteNode < Node
1641
1648
  include _Node
1642
1649
 
1643
- private attr_reader flags: Integer
1650
+ attr_reader flags: Integer
1644
1651
  attr_reader receiver: Prism::node?
1645
1652
  attr_reader call_operator_loc: Location?
1646
1653
  attr_reader opening_loc: Location
@@ -1673,7 +1680,7 @@ module Prism
1673
1680
  class IndexOperatorWriteNode < Node
1674
1681
  include _Node
1675
1682
 
1676
- private attr_reader flags: Integer
1683
+ attr_reader flags: Integer
1677
1684
  attr_reader receiver: Prism::node?
1678
1685
  attr_reader call_operator_loc: Location?
1679
1686
  attr_reader opening_loc: Location
@@ -1706,7 +1713,7 @@ module Prism
1706
1713
  class IndexOrWriteNode < Node
1707
1714
  include _Node
1708
1715
 
1709
- private attr_reader flags: Integer
1716
+ attr_reader flags: Integer
1710
1717
  attr_reader receiver: Prism::node?
1711
1718
  attr_reader call_operator_loc: Location?
1712
1719
  attr_reader opening_loc: Location
@@ -1747,7 +1754,7 @@ module Prism
1747
1754
  class IndexTargetNode < Node
1748
1755
  include _Node
1749
1756
 
1750
- private attr_reader flags: Integer
1757
+ attr_reader flags: Integer
1751
1758
  attr_reader receiver: Prism::node
1752
1759
  attr_reader opening_loc: Location
1753
1760
  attr_reader arguments: ArgumentsNode?
@@ -1893,7 +1900,7 @@ module Prism
1893
1900
  class IntegerNode < Node
1894
1901
  include _Node
1895
1902
 
1896
- private attr_reader flags: Integer
1903
+ attr_reader flags: Integer
1897
1904
  attr_reader value: Integer
1898
1905
 
1899
1906
  def initialize: (Source source, Integer flags, Integer value, Location location) -> void
@@ -1915,7 +1922,7 @@ module Prism
1915
1922
  class InterpolatedMatchLastLineNode < Node
1916
1923
  include _Node
1917
1924
 
1918
- private attr_reader flags: Integer
1925
+ attr_reader flags: Integer
1919
1926
  attr_reader opening_loc: Location
1920
1927
  attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode]
1921
1928
  attr_reader closing_loc: Location
@@ -1948,7 +1955,7 @@ module Prism
1948
1955
  class InterpolatedRegularExpressionNode < Node
1949
1956
  include _Node
1950
1957
 
1951
- private attr_reader flags: Integer
1958
+ attr_reader flags: Integer
1952
1959
  attr_reader opening_loc: Location
1953
1960
  attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode]
1954
1961
  attr_reader closing_loc: Location
@@ -1981,7 +1988,7 @@ module Prism
1981
1988
  class InterpolatedStringNode < Node
1982
1989
  include _Node
1983
1990
 
1984
- private attr_reader flags: Integer
1991
+ attr_reader flags: Integer
1985
1992
  attr_reader opening_loc: Location?
1986
1993
  attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode]
1987
1994
  attr_reader closing_loc: Location?
@@ -2063,7 +2070,7 @@ module Prism
2063
2070
  class KeywordHashNode < Node
2064
2071
  include _Node
2065
2072
 
2066
- private attr_reader flags: Integer
2073
+ attr_reader flags: Integer
2067
2074
  attr_reader elements: Array[AssocNode | AssocSplatNode]
2068
2075
 
2069
2076
  def initialize: (Source source, Integer flags, Array[AssocNode | AssocSplatNode] elements, Location location) -> void
@@ -2083,7 +2090,7 @@ module Prism
2083
2090
  class KeywordRestParameterNode < Node
2084
2091
  include _Node
2085
2092
 
2086
- private attr_reader flags: Integer
2093
+ attr_reader flags: Integer
2087
2094
  attr_reader name: Symbol?
2088
2095
  attr_reader name_loc: Location?
2089
2096
  attr_reader operator_loc: Location
@@ -2254,7 +2261,7 @@ module Prism
2254
2261
  class MatchLastLineNode < Node
2255
2262
  include _Node
2256
2263
 
2257
- private attr_reader flags: Integer
2264
+ attr_reader flags: Integer
2258
2265
  attr_reader opening_loc: Location
2259
2266
  attr_reader content_loc: Location
2260
2267
  attr_reader closing_loc: Location
@@ -2524,7 +2531,7 @@ module Prism
2524
2531
  class OptionalKeywordParameterNode < Node
2525
2532
  include _Node
2526
2533
 
2527
- private attr_reader flags: Integer
2534
+ attr_reader flags: Integer
2528
2535
  attr_reader name: Symbol
2529
2536
  attr_reader name_loc: Location
2530
2537
  attr_reader value: Prism::node
@@ -2546,7 +2553,7 @@ module Prism
2546
2553
  class OptionalParameterNode < Node
2547
2554
  include _Node
2548
2555
 
2549
- private attr_reader flags: Integer
2556
+ attr_reader flags: Integer
2550
2557
  attr_reader name: Symbol
2551
2558
  attr_reader name_loc: Location
2552
2559
  attr_reader operator_loc: Location
@@ -2740,7 +2747,7 @@ module Prism
2740
2747
  class RangeNode < Node
2741
2748
  include _Node
2742
2749
 
2743
- private attr_reader flags: Integer
2750
+ attr_reader flags: Integer
2744
2751
  attr_reader left: Prism::node?
2745
2752
  attr_reader right: Prism::node?
2746
2753
  attr_reader operator_loc: Location
@@ -2795,7 +2802,7 @@ module Prism
2795
2802
  class RegularExpressionNode < Node
2796
2803
  include _Node
2797
2804
 
2798
- private attr_reader flags: Integer
2805
+ attr_reader flags: Integer
2799
2806
  attr_reader opening_loc: Location
2800
2807
  attr_reader content_loc: Location
2801
2808
  attr_reader closing_loc: Location
@@ -2831,7 +2838,7 @@ module Prism
2831
2838
  class RequiredKeywordParameterNode < Node
2832
2839
  include _Node
2833
2840
 
2834
- private attr_reader flags: Integer
2841
+ attr_reader flags: Integer
2835
2842
  attr_reader name: Symbol
2836
2843
  attr_reader name_loc: Location
2837
2844
 
@@ -2852,7 +2859,7 @@ module Prism
2852
2859
  class RequiredParameterNode < Node
2853
2860
  include _Node
2854
2861
 
2855
- private attr_reader flags: Integer
2862
+ attr_reader flags: Integer
2856
2863
  attr_reader name: Symbol
2857
2864
 
2858
2865
  def initialize: (Source source, Integer flags, Symbol name, Location location) -> void
@@ -2921,7 +2928,7 @@ module Prism
2921
2928
  class RestParameterNode < Node
2922
2929
  include _Node
2923
2930
 
2924
- private attr_reader flags: Integer
2931
+ attr_reader flags: Integer
2925
2932
  attr_reader name: Symbol?
2926
2933
  attr_reader name_loc: Location?
2927
2934
  attr_reader operator_loc: Location
@@ -2959,12 +2966,14 @@ module Prism
2959
2966
  class ReturnNode < Node
2960
2967
  include _Node
2961
2968
 
2969
+ attr_reader flags: Integer
2962
2970
  attr_reader keyword_loc: Location
2963
2971
  attr_reader arguments: ArgumentsNode?
2964
2972
 
2965
- def initialize: (Source source, Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
2966
- def copy: (?keyword_loc: Location, ?arguments: ArgumentsNode?, ?location: Location) -> ReturnNode
2967
- def deconstruct_keys: (Array[Symbol] keys) -> { keyword_loc: Location, arguments: ArgumentsNode?, location: Location }
2973
+ def initialize: (Source source, Integer flags, Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
2974
+ def copy: (?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?, ?location: Location) -> ReturnNode
2975
+ def deconstruct_keys: (Array[Symbol] keys) -> { flags: Integer, keyword_loc: Location, arguments: ArgumentsNode?, location: Location }
2976
+ def redundant?: () -> bool
2968
2977
  def keyword: () -> String
2969
2978
  def type: () -> :return_node
2970
2979
  | ...
@@ -2995,7 +3004,7 @@ module Prism
2995
3004
  class ShareableConstantNode < Node
2996
3005
  include _Node
2997
3006
 
2998
- private attr_reader flags: Integer
3007
+ attr_reader flags: Integer
2999
3008
  attr_reader write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode
3000
3009
 
3001
3010
  def initialize: (Source source, Integer flags, ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode write, Location location) -> void
@@ -3057,7 +3066,7 @@ module Prism
3057
3066
  class SourceFileNode < Node
3058
3067
  include _Node
3059
3068
 
3060
- private attr_reader flags: Integer
3069
+ attr_reader flags: Integer
3061
3070
  attr_reader filepath: String
3062
3071
 
3063
3072
  def initialize: (Source source, Integer flags, String filepath, Location location) -> void
@@ -3137,7 +3146,7 @@ module Prism
3137
3146
  class StringNode < Node
3138
3147
  include _Node
3139
3148
 
3140
- private attr_reader flags: Integer
3149
+ attr_reader flags: Integer
3141
3150
  attr_reader opening_loc: Location?
3142
3151
  attr_reader content_loc: Location
3143
3152
  attr_reader closing_loc: Location?
@@ -3195,7 +3204,7 @@ module Prism
3195
3204
  class SymbolNode < Node
3196
3205
  include _Node
3197
3206
 
3198
- private attr_reader flags: Integer
3207
+ attr_reader flags: Integer
3199
3208
  attr_reader opening_loc: Location?
3200
3209
  attr_reader value_loc: Location?
3201
3210
  attr_reader closing_loc: Location?
@@ -3288,7 +3297,7 @@ module Prism
3288
3297
  class UntilNode < Node
3289
3298
  include _Node
3290
3299
 
3291
- private attr_reader flags: Integer
3300
+ attr_reader flags: Integer
3292
3301
  attr_reader keyword_loc: Location
3293
3302
  attr_reader closing_loc: Location?
3294
3303
  attr_reader predicate: Prism::node
@@ -3339,7 +3348,7 @@ module Prism
3339
3348
  class WhileNode < Node
3340
3349
  include _Node
3341
3350
 
3342
- private attr_reader flags: Integer
3351
+ attr_reader flags: Integer
3343
3352
  attr_reader keyword_loc: Location
3344
3353
  attr_reader closing_loc: Location?
3345
3354
  attr_reader predicate: Prism::node
@@ -3363,7 +3372,7 @@ module Prism
3363
3372
  class XStringNode < Node
3364
3373
  include _Node
3365
3374
 
3366
- private attr_reader flags: Integer
3375
+ attr_reader flags: Integer
3367
3376
  attr_reader opening_loc: Location
3368
3377
  attr_reader content_loc: Location
3369
3378
  attr_reader closing_loc: Location
@@ -3407,6 +3416,8 @@ module Prism
3407
3416
 
3408
3417
  # Flags for arguments nodes.
3409
3418
  module ArgumentsNodeFlags
3419
+ # if arguments contain keywords
3420
+ CONTAINS_KEYWORDS: Integer
3410
3421
  # if arguments contain keyword splat
3411
3422
  CONTAINS_KEYWORD_SPLAT: Integer
3412
3423
  end
@@ -3507,6 +3518,12 @@ module Prism
3507
3518
  FORCED_US_ASCII_ENCODING: Integer
3508
3519
  end
3509
3520
 
3521
+ # Flags for return nodes.
3522
+ module ReturnNodeFlags
3523
+ # a return statement that is redundant because it is the last statement in a method
3524
+ REDUNDANT: Integer
3525
+ end
3526
+
3510
3527
  # Flags for shareable constant nodes.
3511
3528
  module ShareableConstantNodeFlags
3512
3529
  # constant writes that should be modified with shareable constant value literal
@@ -6,9 +6,11 @@ module Prism
6
6
 
7
7
  def initialize: (String source, ?Integer start_line, ?Array[Integer] offsets) -> void
8
8
  def encoding: () -> Encoding
9
+ def lines: () -> Array[String]
9
10
  def slice: (Integer byte_offset, Integer length) -> String
10
11
  def line: (Integer byte_offset) -> Integer
11
12
  def line_start: (Integer byte_offset) -> Integer
13
+ def line_end: (Integer byte_offset) -> Integer
12
14
  def line_offset: (Integer byte_offset) -> Integer
13
15
  def column: (Integer byte_offset) -> Integer
14
16
  def character_offset: (Integer byte_offset) -> Integer
@@ -17,6 +19,13 @@ module Prism
17
19
  def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer
18
20
  end
19
21
 
22
+ class ASCIISource < Source
23
+ def character_offset: (Integer byte_offset) -> Integer
24
+ def character_column: (Integer byte_offset) -> Integer
25
+ def code_units_offset: (Integer byte_offset, Encoding encoding) -> Integer
26
+ def code_units_column: (Integer byte_offset, Encoding encoding) -> Integer
27
+ end
28
+
20
29
  class Location
21
30
  attr_reader source: Source
22
31
  attr_reader start_offset: Integer
@@ -30,7 +39,9 @@ module Prism
30
39
  def comments: () -> Array[comment]
31
40
  def copy: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location
32
41
  def chop: () -> Location
42
+ def source_lines: () -> Array[String]
33
43
  def slice: () -> String
44
+ def slice_lines: () -> String
34
45
  def start_character_offset: () -> Integer
35
46
  def end_offset: () -> Integer
36
47
  def end_character_offset: () -> Integer
@@ -44,6 +55,7 @@ module Prism
44
55
  def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
45
56
  def pretty_print: (untyped q) -> untyped
46
57
  def join: (Location other) -> Location
58
+ def adjoin: (String string) -> Location
47
59
  end
48
60
 
49
61
  class Comment