prism 0.26.0 → 0.28.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -1
- data/Makefile +3 -2
- data/config.yml +305 -20
- data/docs/configuration.md +1 -0
- data/ext/prism/api_node.c +884 -879
- data/ext/prism/extconf.rb +23 -4
- data/ext/prism/extension.c +16 -9
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +298 -9
- data/include/prism/diagnostic.h +15 -5
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +10 -0
- data/include/prism/static_literals.h +8 -6
- data/include/prism/version.h +2 -2
- data/lib/prism/dot_visitor.rb +22 -6
- data/lib/prism/dsl.rb +8 -8
- data/lib/prism/ffi.rb +4 -4
- data/lib/prism/inspect_visitor.rb +2156 -0
- data/lib/prism/lex_compat.rb +18 -1
- data/lib/prism/mutation_compiler.rb +2 -2
- data/lib/prism/node.rb +2345 -1964
- data/lib/prism/node_ext.rb +34 -5
- data/lib/prism/parse_result/newlines.rb +0 -2
- data/lib/prism/parse_result.rb +137 -13
- data/lib/prism/pattern.rb +12 -6
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/reflection.rb +21 -31
- data/lib/prism/serialize.rb +27 -17
- data/lib/prism/translation/parser/compiler.rb +34 -15
- data/lib/prism/translation/parser.rb +6 -6
- data/lib/prism/translation/ripper.rb +72 -68
- data/lib/prism/translation/ruby_parser.rb +69 -31
- data/lib/prism.rb +3 -2
- data/prism.gemspec +36 -38
- data/rbi/prism/compiler.rbi +3 -5
- data/rbi/prism/inspect_visitor.rbi +12 -0
- data/rbi/prism/node.rbi +359 -321
- data/rbi/prism/parse_result.rbi +85 -34
- data/rbi/prism/reflection.rbi +7 -13
- data/rbi/prism/translation/ripper.rbi +1 -11
- data/rbi/prism.rbi +9 -9
- data/sig/prism/dsl.rbs +3 -3
- data/sig/prism/inspect_visitor.rbs +22 -0
- data/sig/prism/node.rbs +68 -48
- data/sig/prism/parse_result.rbs +42 -10
- data/sig/prism/reflection.rbs +2 -8
- data/sig/prism/serialize.rbs +2 -3
- data/sig/prism.rbs +9 -9
- data/src/diagnostic.c +44 -24
- data/src/node.c +41 -16
- data/src/options.c +2 -2
- data/src/prettyprint.c +61 -18
- data/src/prism.c +623 -188
- data/src/serialize.c +5 -2
- data/src/static_literals.c +120 -34
- data/src/token_type.c +4 -4
- data/src/util/pm_integer.c +9 -2
- metadata +7 -9
- data/lib/prism/node_inspector.rb +0 -68
- data/lib/prism/polyfill/string.rb +0 -12
- data/rbi/prism/desugar_compiler.rbi +0 -5
- data/rbi/prism/mutation_compiler.rbi +0 -5
- data/rbi/prism/translation/parser/compiler.rbi +0 -13
- data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
- data/rbi/prism/translation/ruby_parser.rbi +0 -11
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: (
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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,
|
896
|
-
def copy: (?parent: Prism::node?, ?
|
897
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?,
|
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
|
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,
|
956
|
-
def copy: (?parent: Prism::node?, ?
|
957
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { parent: Prism::node?,
|
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
|
-
|
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
|
@@ -1515,13 +1522,16 @@ module Prism
|
|
1515
1522
|
def self.type: () -> :hash_pattern_node
|
1516
1523
|
end
|
1517
1524
|
|
1518
|
-
# Represents the use of the `if` keyword, either in the block form or the modifier form.
|
1525
|
+
# Represents the use of the `if` keyword, either in the block form or the modifier form, or a ternary expression.
|
1519
1526
|
#
|
1520
1527
|
# bar if foo
|
1521
1528
|
# ^^^^^^^^^^
|
1522
1529
|
#
|
1523
1530
|
# if foo then bar end
|
1524
1531
|
# ^^^^^^^^^^^^^^^^^^^
|
1532
|
+
#
|
1533
|
+
# foo ? bar : baz
|
1534
|
+
# ^^^^^^^^^^^^^^^
|
1525
1535
|
class IfNode < Node
|
1526
1536
|
include _Node
|
1527
1537
|
|
@@ -1637,7 +1647,7 @@ module Prism
|
|
1637
1647
|
class IndexAndWriteNode < Node
|
1638
1648
|
include _Node
|
1639
1649
|
|
1640
|
-
|
1650
|
+
attr_reader flags: Integer
|
1641
1651
|
attr_reader receiver: Prism::node?
|
1642
1652
|
attr_reader call_operator_loc: Location?
|
1643
1653
|
attr_reader opening_loc: Location
|
@@ -1670,7 +1680,7 @@ module Prism
|
|
1670
1680
|
class IndexOperatorWriteNode < Node
|
1671
1681
|
include _Node
|
1672
1682
|
|
1673
|
-
|
1683
|
+
attr_reader flags: Integer
|
1674
1684
|
attr_reader receiver: Prism::node?
|
1675
1685
|
attr_reader call_operator_loc: Location?
|
1676
1686
|
attr_reader opening_loc: Location
|
@@ -1703,7 +1713,7 @@ module Prism
|
|
1703
1713
|
class IndexOrWriteNode < Node
|
1704
1714
|
include _Node
|
1705
1715
|
|
1706
|
-
|
1716
|
+
attr_reader flags: Integer
|
1707
1717
|
attr_reader receiver: Prism::node?
|
1708
1718
|
attr_reader call_operator_loc: Location?
|
1709
1719
|
attr_reader opening_loc: Location
|
@@ -1744,7 +1754,7 @@ module Prism
|
|
1744
1754
|
class IndexTargetNode < Node
|
1745
1755
|
include _Node
|
1746
1756
|
|
1747
|
-
|
1757
|
+
attr_reader flags: Integer
|
1748
1758
|
attr_reader receiver: Prism::node
|
1749
1759
|
attr_reader opening_loc: Location
|
1750
1760
|
attr_reader arguments: ArgumentsNode?
|
@@ -1890,7 +1900,7 @@ module Prism
|
|
1890
1900
|
class IntegerNode < Node
|
1891
1901
|
include _Node
|
1892
1902
|
|
1893
|
-
|
1903
|
+
attr_reader flags: Integer
|
1894
1904
|
attr_reader value: Integer
|
1895
1905
|
|
1896
1906
|
def initialize: (Source source, Integer flags, Integer value, Location location) -> void
|
@@ -1912,7 +1922,7 @@ module Prism
|
|
1912
1922
|
class InterpolatedMatchLastLineNode < Node
|
1913
1923
|
include _Node
|
1914
1924
|
|
1915
|
-
|
1925
|
+
attr_reader flags: Integer
|
1916
1926
|
attr_reader opening_loc: Location
|
1917
1927
|
attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode]
|
1918
1928
|
attr_reader closing_loc: Location
|
@@ -1945,7 +1955,7 @@ module Prism
|
|
1945
1955
|
class InterpolatedRegularExpressionNode < Node
|
1946
1956
|
include _Node
|
1947
1957
|
|
1948
|
-
|
1958
|
+
attr_reader flags: Integer
|
1949
1959
|
attr_reader opening_loc: Location
|
1950
1960
|
attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode]
|
1951
1961
|
attr_reader closing_loc: Location
|
@@ -1978,7 +1988,7 @@ module Prism
|
|
1978
1988
|
class InterpolatedStringNode < Node
|
1979
1989
|
include _Node
|
1980
1990
|
|
1981
|
-
|
1991
|
+
attr_reader flags: Integer
|
1982
1992
|
attr_reader opening_loc: Location?
|
1983
1993
|
attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode]
|
1984
1994
|
attr_reader closing_loc: Location?
|
@@ -2060,7 +2070,7 @@ module Prism
|
|
2060
2070
|
class KeywordHashNode < Node
|
2061
2071
|
include _Node
|
2062
2072
|
|
2063
|
-
|
2073
|
+
attr_reader flags: Integer
|
2064
2074
|
attr_reader elements: Array[AssocNode | AssocSplatNode]
|
2065
2075
|
|
2066
2076
|
def initialize: (Source source, Integer flags, Array[AssocNode | AssocSplatNode] elements, Location location) -> void
|
@@ -2080,7 +2090,7 @@ module Prism
|
|
2080
2090
|
class KeywordRestParameterNode < Node
|
2081
2091
|
include _Node
|
2082
2092
|
|
2083
|
-
|
2093
|
+
attr_reader flags: Integer
|
2084
2094
|
attr_reader name: Symbol?
|
2085
2095
|
attr_reader name_loc: Location?
|
2086
2096
|
attr_reader operator_loc: Location
|
@@ -2251,7 +2261,7 @@ module Prism
|
|
2251
2261
|
class MatchLastLineNode < Node
|
2252
2262
|
include _Node
|
2253
2263
|
|
2254
|
-
|
2264
|
+
attr_reader flags: Integer
|
2255
2265
|
attr_reader opening_loc: Location
|
2256
2266
|
attr_reader content_loc: Location
|
2257
2267
|
attr_reader closing_loc: Location
|
@@ -2521,7 +2531,7 @@ module Prism
|
|
2521
2531
|
class OptionalKeywordParameterNode < Node
|
2522
2532
|
include _Node
|
2523
2533
|
|
2524
|
-
|
2534
|
+
attr_reader flags: Integer
|
2525
2535
|
attr_reader name: Symbol
|
2526
2536
|
attr_reader name_loc: Location
|
2527
2537
|
attr_reader value: Prism::node
|
@@ -2543,7 +2553,7 @@ module Prism
|
|
2543
2553
|
class OptionalParameterNode < Node
|
2544
2554
|
include _Node
|
2545
2555
|
|
2546
|
-
|
2556
|
+
attr_reader flags: Integer
|
2547
2557
|
attr_reader name: Symbol
|
2548
2558
|
attr_reader name_loc: Location
|
2549
2559
|
attr_reader operator_loc: Location
|
@@ -2737,7 +2747,7 @@ module Prism
|
|
2737
2747
|
class RangeNode < Node
|
2738
2748
|
include _Node
|
2739
2749
|
|
2740
|
-
|
2750
|
+
attr_reader flags: Integer
|
2741
2751
|
attr_reader left: Prism::node?
|
2742
2752
|
attr_reader right: Prism::node?
|
2743
2753
|
attr_reader operator_loc: Location
|
@@ -2792,7 +2802,7 @@ module Prism
|
|
2792
2802
|
class RegularExpressionNode < Node
|
2793
2803
|
include _Node
|
2794
2804
|
|
2795
|
-
|
2805
|
+
attr_reader flags: Integer
|
2796
2806
|
attr_reader opening_loc: Location
|
2797
2807
|
attr_reader content_loc: Location
|
2798
2808
|
attr_reader closing_loc: Location
|
@@ -2828,7 +2838,7 @@ module Prism
|
|
2828
2838
|
class RequiredKeywordParameterNode < Node
|
2829
2839
|
include _Node
|
2830
2840
|
|
2831
|
-
|
2841
|
+
attr_reader flags: Integer
|
2832
2842
|
attr_reader name: Symbol
|
2833
2843
|
attr_reader name_loc: Location
|
2834
2844
|
|
@@ -2849,7 +2859,7 @@ module Prism
|
|
2849
2859
|
class RequiredParameterNode < Node
|
2850
2860
|
include _Node
|
2851
2861
|
|
2852
|
-
|
2862
|
+
attr_reader flags: Integer
|
2853
2863
|
attr_reader name: Symbol
|
2854
2864
|
|
2855
2865
|
def initialize: (Source source, Integer flags, Symbol name, Location location) -> void
|
@@ -2918,7 +2928,7 @@ module Prism
|
|
2918
2928
|
class RestParameterNode < Node
|
2919
2929
|
include _Node
|
2920
2930
|
|
2921
|
-
|
2931
|
+
attr_reader flags: Integer
|
2922
2932
|
attr_reader name: Symbol?
|
2923
2933
|
attr_reader name_loc: Location?
|
2924
2934
|
attr_reader operator_loc: Location
|
@@ -2956,12 +2966,14 @@ module Prism
|
|
2956
2966
|
class ReturnNode < Node
|
2957
2967
|
include _Node
|
2958
2968
|
|
2969
|
+
attr_reader flags: Integer
|
2959
2970
|
attr_reader keyword_loc: Location
|
2960
2971
|
attr_reader arguments: ArgumentsNode?
|
2961
2972
|
|
2962
|
-
def initialize: (Source source, Location keyword_loc, ArgumentsNode? arguments, Location location) -> void
|
2963
|
-
def copy: (?keyword_loc: Location, ?arguments: ArgumentsNode?, ?location: Location) -> ReturnNode
|
2964
|
-
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
|
2965
2977
|
def keyword: () -> String
|
2966
2978
|
def type: () -> :return_node
|
2967
2979
|
| ...
|
@@ -2992,7 +3004,7 @@ module Prism
|
|
2992
3004
|
class ShareableConstantNode < Node
|
2993
3005
|
include _Node
|
2994
3006
|
|
2995
|
-
|
3007
|
+
attr_reader flags: Integer
|
2996
3008
|
attr_reader write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode
|
2997
3009
|
|
2998
3010
|
def initialize: (Source source, Integer flags, ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode write, Location location) -> void
|
@@ -3054,7 +3066,7 @@ module Prism
|
|
3054
3066
|
class SourceFileNode < Node
|
3055
3067
|
include _Node
|
3056
3068
|
|
3057
|
-
|
3069
|
+
attr_reader flags: Integer
|
3058
3070
|
attr_reader filepath: String
|
3059
3071
|
|
3060
3072
|
def initialize: (Source source, Integer flags, String filepath, Location location) -> void
|
@@ -3134,7 +3146,7 @@ module Prism
|
|
3134
3146
|
class StringNode < Node
|
3135
3147
|
include _Node
|
3136
3148
|
|
3137
|
-
|
3149
|
+
attr_reader flags: Integer
|
3138
3150
|
attr_reader opening_loc: Location?
|
3139
3151
|
attr_reader content_loc: Location
|
3140
3152
|
attr_reader closing_loc: Location?
|
@@ -3192,7 +3204,7 @@ module Prism
|
|
3192
3204
|
class SymbolNode < Node
|
3193
3205
|
include _Node
|
3194
3206
|
|
3195
|
-
|
3207
|
+
attr_reader flags: Integer
|
3196
3208
|
attr_reader opening_loc: Location?
|
3197
3209
|
attr_reader value_loc: Location?
|
3198
3210
|
attr_reader closing_loc: Location?
|
@@ -3285,7 +3297,7 @@ module Prism
|
|
3285
3297
|
class UntilNode < Node
|
3286
3298
|
include _Node
|
3287
3299
|
|
3288
|
-
|
3300
|
+
attr_reader flags: Integer
|
3289
3301
|
attr_reader keyword_loc: Location
|
3290
3302
|
attr_reader closing_loc: Location?
|
3291
3303
|
attr_reader predicate: Prism::node
|
@@ -3336,7 +3348,7 @@ module Prism
|
|
3336
3348
|
class WhileNode < Node
|
3337
3349
|
include _Node
|
3338
3350
|
|
3339
|
-
|
3351
|
+
attr_reader flags: Integer
|
3340
3352
|
attr_reader keyword_loc: Location
|
3341
3353
|
attr_reader closing_loc: Location?
|
3342
3354
|
attr_reader predicate: Prism::node
|
@@ -3360,7 +3372,7 @@ module Prism
|
|
3360
3372
|
class XStringNode < Node
|
3361
3373
|
include _Node
|
3362
3374
|
|
3363
|
-
|
3375
|
+
attr_reader flags: Integer
|
3364
3376
|
attr_reader opening_loc: Location
|
3365
3377
|
attr_reader content_loc: Location
|
3366
3378
|
attr_reader closing_loc: Location
|
@@ -3404,6 +3416,8 @@ module Prism
|
|
3404
3416
|
|
3405
3417
|
# Flags for arguments nodes.
|
3406
3418
|
module ArgumentsNodeFlags
|
3419
|
+
# if arguments contain keywords
|
3420
|
+
CONTAINS_KEYWORDS: Integer
|
3407
3421
|
# if arguments contain keyword splat
|
3408
3422
|
CONTAINS_KEYWORD_SPLAT: Integer
|
3409
3423
|
end
|
@@ -3504,6 +3518,12 @@ module Prism
|
|
3504
3518
|
FORCED_US_ASCII_ENCODING: Integer
|
3505
3519
|
end
|
3506
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
|
+
|
3507
3527
|
# Flags for shareable constant nodes.
|
3508
3528
|
module ShareableConstantNodeFlags
|
3509
3529
|
# constant writes that should be modified with shareable constant value literal
|
data/sig/prism/parse_result.rbs
CHANGED
@@ -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
|
@@ -41,16 +52,17 @@ module Prism
|
|
41
52
|
def start_character_column: () -> Integer
|
42
53
|
def end_column: () -> Integer
|
43
54
|
def end_character_column: () -> Integer
|
44
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
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
|
50
62
|
attr_reader location: Location
|
51
63
|
|
52
64
|
def initialize: (Location location) -> void
|
53
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
65
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
54
66
|
end
|
55
67
|
|
56
68
|
interface _Comment
|
@@ -76,7 +88,7 @@ module Prism
|
|
76
88
|
def key: () -> String
|
77
89
|
def value: () -> String
|
78
90
|
|
79
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
91
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
80
92
|
end
|
81
93
|
|
82
94
|
class ParseError
|
@@ -86,7 +98,7 @@ module Prism
|
|
86
98
|
attr_reader level: Symbol
|
87
99
|
|
88
100
|
def initialize: (Symbol type, String message, Location location, Symbol level) -> void
|
89
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
101
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
90
102
|
end
|
91
103
|
|
92
104
|
class ParseWarning
|
@@ -96,11 +108,10 @@ module Prism
|
|
96
108
|
attr_reader level: Symbol
|
97
109
|
|
98
110
|
def initialize: (Symbol type, String message, Location location, Symbol level) -> void
|
99
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
111
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
100
112
|
end
|
101
113
|
|
102
|
-
class
|
103
|
-
attr_reader value: T
|
114
|
+
class Result
|
104
115
|
attr_reader comments: Array[comment]
|
105
116
|
attr_reader magic_comments: Array[MagicComment]
|
106
117
|
attr_reader data_loc: Location?
|
@@ -108,12 +119,33 @@ module Prism
|
|
108
119
|
attr_reader warnings: Array[ParseWarning]
|
109
120
|
attr_reader source: Source
|
110
121
|
|
111
|
-
def initialize: (
|
112
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
122
|
+
def initialize: (Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
123
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
113
124
|
def success?: () -> bool
|
114
125
|
def failure?: () -> bool
|
115
126
|
end
|
116
127
|
|
128
|
+
class ParseResult < Result
|
129
|
+
attr_reader value: ProgramNode
|
130
|
+
|
131
|
+
def initialize: (ProgramNode value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
132
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
133
|
+
end
|
134
|
+
|
135
|
+
class LexResult < Result
|
136
|
+
attr_reader value: Array[[Token, Integer]]
|
137
|
+
|
138
|
+
def initialize: (Array[[Token, Integer]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
139
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
140
|
+
end
|
141
|
+
|
142
|
+
class ParseLexResult < Result
|
143
|
+
attr_reader value: [ProgramNode, Array[[Token, Integer]]]
|
144
|
+
|
145
|
+
def initialize: ([ProgramNode, Array[[Token, Integer]]] value, Array[comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
146
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
147
|
+
end
|
148
|
+
|
117
149
|
class Token
|
118
150
|
attr_reader source: Source
|
119
151
|
attr_reader type: Symbol
|
@@ -121,7 +153,7 @@ module Prism
|
|
121
153
|
attr_reader location: Location
|
122
154
|
|
123
155
|
def initialize: (Source source, Symbol type, String value, Location location) -> void
|
124
|
-
def deconstruct_keys: (Array[Symbol] keys) ->
|
156
|
+
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
|
125
157
|
def pretty_print: (untyped q) -> untyped
|
126
158
|
def ==: (untyped other) -> bool
|
127
159
|
end
|
data/sig/prism/reflection.rbs
CHANGED
@@ -33,10 +33,10 @@ module Prism
|
|
33
33
|
class OptionalLocationField < Field
|
34
34
|
end
|
35
35
|
|
36
|
-
class
|
36
|
+
class IntegerField < Field
|
37
37
|
end
|
38
38
|
|
39
|
-
class
|
39
|
+
class FloatField < Field
|
40
40
|
end
|
41
41
|
|
42
42
|
class FlagsField < Field
|
@@ -45,12 +45,6 @@ module Prism
|
|
45
45
|
def initialize: (Symbol name, Array[Symbol] flags) -> void
|
46
46
|
end
|
47
47
|
|
48
|
-
class IntegerField < Field
|
49
|
-
end
|
50
|
-
|
51
|
-
class DoubleField < Field
|
52
|
-
end
|
53
|
-
|
54
48
|
def self.fields_for: (node_singleton node) -> Array[Field]
|
55
49
|
end
|
56
50
|
end
|
data/sig/prism/serialize.rbs
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Prism
|
2
2
|
module Serialize
|
3
|
-
def self.load: (String, String) -> ParseResult
|
4
|
-
|
5
|
-
def self.load_tokens: (Source, String) -> ParseResult[Array[Token]] # TODO: check if array[token] is right
|
3
|
+
def self.load: (String, String) -> ParseResult
|
4
|
+
def self.load_tokens: (Source, String) -> LexResult
|
6
5
|
end
|
7
6
|
end
|
data/sig/prism.rbs
CHANGED
@@ -17,7 +17,7 @@ module Prism
|
|
17
17
|
?frozen_string_literal: bool,
|
18
18
|
?verbose: bool,
|
19
19
|
?scopes: Array[Array[Symbol]]
|
20
|
-
) -> ParseResult
|
20
|
+
) -> ParseResult
|
21
21
|
|
22
22
|
def self.lex: (
|
23
23
|
String source,
|
@@ -28,7 +28,7 @@ module Prism
|
|
28
28
|
?frozen_string_literal: bool,
|
29
29
|
?verbose: bool,
|
30
30
|
?scopes: Array[Array[Symbol]]
|
31
|
-
) ->
|
31
|
+
) -> LexResult
|
32
32
|
|
33
33
|
def self.lex_compat: (
|
34
34
|
String source,
|
@@ -39,7 +39,7 @@ module Prism
|
|
39
39
|
?frozen_string_literal: bool,
|
40
40
|
?verbose: bool,
|
41
41
|
?scopes: Array[Array[Symbol]]
|
42
|
-
) ->
|
42
|
+
) -> LexCompat::Result
|
43
43
|
|
44
44
|
def self.parse_lex: (
|
45
45
|
String source,
|
@@ -50,7 +50,7 @@ module Prism
|
|
50
50
|
?frozen_string_literal: bool,
|
51
51
|
?verbose: bool,
|
52
52
|
?scopes: Array[Array[Symbol]]
|
53
|
-
) ->
|
53
|
+
) -> ParseLexResult
|
54
54
|
|
55
55
|
def self.dump: (
|
56
56
|
String source,
|
@@ -99,7 +99,7 @@ module Prism
|
|
99
99
|
def self.load: (
|
100
100
|
String source,
|
101
101
|
String serialized
|
102
|
-
) -> ParseResult
|
102
|
+
) -> ParseResult
|
103
103
|
|
104
104
|
def self.lex_ripper: (
|
105
105
|
String source
|
@@ -115,7 +115,7 @@ module Prism
|
|
115
115
|
?frozen_string_literal: bool,
|
116
116
|
?verbose: bool,
|
117
117
|
?scopes: Array[Array[Symbol]]
|
118
|
-
) -> ParseResult
|
118
|
+
) -> ParseResult
|
119
119
|
|
120
120
|
def self.lex_file: (
|
121
121
|
String filepath,
|
@@ -125,7 +125,7 @@ module Prism
|
|
125
125
|
?frozen_string_literal: bool,
|
126
126
|
?verbose: bool,
|
127
127
|
?scopes: Array[Array[Symbol]]
|
128
|
-
) ->
|
128
|
+
) -> LexResult
|
129
129
|
|
130
130
|
def self.parse_lex_file: (
|
131
131
|
String filepath,
|
@@ -135,7 +135,7 @@ module Prism
|
|
135
135
|
?frozen_string_literal: bool,
|
136
136
|
?verbose: bool,
|
137
137
|
?scopes: Array[Array[Symbol]]
|
138
|
-
) ->
|
138
|
+
) -> ParseLexResult
|
139
139
|
|
140
140
|
def self.dump_file: (
|
141
141
|
String filepath,
|
@@ -190,5 +190,5 @@ module Prism
|
|
190
190
|
?frozen_string_literal: bool,
|
191
191
|
?verbose: bool,
|
192
192
|
?scopes: Array[Array[Symbol]]
|
193
|
-
) -> ParseResult
|
193
|
+
) -> ParseResult
|
194
194
|
end
|