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.
- checksums.yaml +7 -0
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +870 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +58 -0
- data/LICENSE.md +7 -0
- data/Makefile +145 -0
- data/README.md +81 -0
- data/config.yml +4752 -0
- data/docs/build_system.md +119 -0
- data/docs/configuration.md +69 -0
- data/docs/cruby_compilation.md +27 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +121 -0
- data/docs/fuzzing.md +81 -0
- data/docs/heredocs.md +36 -0
- data/docs/javascript.md +133 -0
- data/docs/local_variable_depth.md +229 -0
- data/docs/mapping.md +117 -0
- data/docs/parser_translation.md +24 -0
- data/docs/parsing_rules.md +22 -0
- data/docs/releasing.md +147 -0
- data/docs/relocation.md +32 -0
- data/docs/ripper_translation.md +63 -0
- data/docs/ruby_api.md +45 -0
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +230 -0
- data/docs/testing.md +72 -0
- data/ext/prism/api_node.c +7005 -0
- data/ext/prism/extconf.rb +126 -0
- data/ext/prism/extension.c +1783 -0
- data/ext/prism/extension.h +19 -0
- data/include/prism/arena.h +37 -0
- data/include/prism/ast.h +10371 -0
- data/include/prism/buffer.h +52 -0
- data/include/prism/comments.h +55 -0
- data/include/prism/compiler/accel.h +24 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/exported.h +24 -0
- data/include/prism/compiler/fallthrough.h +22 -0
- data/include/prism/compiler/filesystem.h +32 -0
- data/include/prism/compiler/flex_array.h +19 -0
- data/include/prism/compiler/force_inline.h +21 -0
- data/include/prism/compiler/format.h +25 -0
- data/include/prism/compiler/inline.h +17 -0
- data/include/prism/compiler/nodiscard.h +22 -0
- data/include/prism/compiler/nonnull.h +18 -0
- data/include/prism/compiler/unused.h +18 -0
- data/include/prism/constant_pool.h +81 -0
- data/include/prism/diagnostic.h +93 -0
- data/include/prism/errors_format.h +53 -0
- data/include/prism/excludes.h +29 -0
- data/include/prism/integer.h +41 -0
- data/include/prism/internal/allocator.h +68 -0
- data/include/prism/internal/allocator_debug.h +88 -0
- data/include/prism/internal/arena.h +108 -0
- data/include/prism/internal/bit.h +42 -0
- data/include/prism/internal/buffer.h +91 -0
- data/include/prism/internal/char.h +145 -0
- data/include/prism/internal/comments.h +53 -0
- data/include/prism/internal/constant_pool.h +152 -0
- data/include/prism/internal/diagnostic.h +389 -0
- data/include/prism/internal/encoding.h +242 -0
- data/include/prism/internal/integer.h +68 -0
- data/include/prism/internal/isinf.h +16 -0
- data/include/prism/internal/line_offset_list.h +34 -0
- data/include/prism/internal/list.h +62 -0
- data/include/prism/internal/magic_comments.h +23 -0
- data/include/prism/internal/memchr.h +15 -0
- data/include/prism/internal/node.h +38 -0
- data/include/prism/internal/options.h +232 -0
- data/include/prism/internal/parser.h +984 -0
- data/include/prism/internal/regexp.h +26 -0
- data/include/prism/internal/serialize.h +39 -0
- data/include/prism/internal/source.h +72 -0
- data/include/prism/internal/static_literals.h +100 -0
- data/include/prism/internal/stringy.h +35 -0
- data/include/prism/internal/strncasecmp.h +18 -0
- data/include/prism/internal/strpbrk.h +33 -0
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/json.h +32 -0
- data/include/prism/line_offset_list.h +61 -0
- data/include/prism/magic_comments.h +35 -0
- data/include/prism/node.h +94 -0
- data/include/prism/options.h +354 -0
- data/include/prism/parser.h +404 -0
- data/include/prism/prettyprint.h +31 -0
- data/include/prism/serialize.h +115 -0
- data/include/prism/source.h +155 -0
- data/include/prism/stream.h +28 -0
- data/include/prism/string_query.h +63 -0
- data/include/prism/stringy.h +72 -0
- data/include/prism/version.h +38 -0
- data/include/prism.h +131 -0
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/compiler.rb +815 -0
- data/lib/prism/desugar_compiler.rb +463 -0
- data/lib/prism/dispatcher.rb +2383 -0
- data/lib/prism/dot_visitor.rb +4848 -0
- data/lib/prism/dsl.rb +1369 -0
- data/lib/prism/ffi.rb +740 -0
- data/lib/prism/inspect_visitor.rb +2425 -0
- data/lib/prism/lex_compat.rb +953 -0
- data/lib/prism/mutation_compiler.rb +780 -0
- data/lib/prism/node.rb +33204 -0
- data/lib/prism/node_ext.rb +504 -0
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +72 -0
- data/lib/prism/parse_result/newlines.rb +423 -0
- data/lib/prism/parse_result.rb +1221 -0
- data/lib/prism/pattern.rb +314 -0
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/polyfill/warn.rb +36 -0
- data/lib/prism/reflection.rb +427 -0
- data/lib/prism/relocation.rb +567 -0
- data/lib/prism/serialize.rb +5308 -0
- data/lib/prism/string_query.rb +46 -0
- data/lib/prism/translation/parser/builder.rb +70 -0
- data/lib/prism/translation/parser/compiler.rb +2226 -0
- data/lib/prism/translation/parser/lexer.rb +769 -0
- data/lib/prism/translation/parser.rb +376 -0
- data/lib/prism/translation/parser_current.rb +26 -0
- data/lib/prism/translation/parser_versions.rb +36 -0
- data/lib/prism/translation/ripper/filter.rb +53 -0
- data/lib/prism/translation/ripper/lexer.rb +133 -0
- data/lib/prism/translation/ripper/sexp.rb +118 -0
- data/lib/prism/translation/ripper/shim.rb +7 -0
- data/lib/prism/translation/ripper.rb +4278 -0
- data/lib/prism/translation/ruby_parser.rb +1721 -0
- data/lib/prism/translation.rb +20 -0
- data/lib/prism/visitor.rb +1440 -0
- data/lib/prism.rb +168 -0
- data/prism.gemspec +234 -0
- data/rbi/generated/prism/compiler.rbi +489 -0
- data/rbi/generated/prism/desugar_compiler.rbi +306 -0
- data/rbi/generated/prism/dispatcher.rbi +1138 -0
- data/rbi/generated/prism/dot_visitor.rbi +618 -0
- data/rbi/generated/prism/dsl.rbi +751 -0
- data/rbi/generated/prism/inspect_visitor.rbi +503 -0
- data/rbi/generated/prism/lex_compat.rbi +162 -0
- data/rbi/generated/prism/mutation_compiler.rbi +464 -0
- data/rbi/generated/prism/node.rbi +13681 -0
- data/rbi/generated/prism/node_ext.rbi +259 -0
- data/rbi/generated/prism/node_find.rbi +79 -0
- data/rbi/generated/prism/parse_result/errors.rbi +21 -0
- data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
- data/rbi/generated/prism/parse_result.rbi +764 -0
- data/rbi/generated/prism/pattern.rbi +134 -0
- data/rbi/generated/prism/reflection.rbi +89 -0
- data/rbi/generated/prism/relocation.rbi +329 -0
- data/rbi/generated/prism/serialize.rbi +181 -0
- data/rbi/generated/prism/string_query.rbi +36 -0
- data/rbi/generated/prism/translation.rbi +7 -0
- data/rbi/generated/prism/visitor.rbi +650 -0
- data/rbi/generated/prism.rbi +86 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser_versions.rbi +28 -0
- data/rbi/prism/translation/ripper.rbi +15 -0
- data/rbi/rubyvm/node_find.rbi +14 -0
- data/sig/generated/prism/compiler.rbs +492 -0
- data/sig/generated/prism/desugar_compiler.rbs +305 -0
- data/sig/generated/prism/dispatcher.rbs +1292 -0
- data/sig/generated/prism/dot_visitor.rbs +635 -0
- data/sig/generated/prism/dsl.rbs +928 -0
- data/sig/generated/prism/inspect_visitor.rbs +509 -0
- data/sig/generated/prism/lex_compat.rbs +166 -0
- data/sig/generated/prism/mutation_compiler.rbs +464 -0
- data/sig/generated/prism/node.rbs +20160 -0
- data/sig/generated/prism/node_ext.rbs +290 -0
- data/sig/generated/prism/node_find.rbs +90 -0
- data/sig/generated/prism/parse_result/errors.rbs +22 -0
- data/sig/generated/prism/parse_result/newlines.rbs +223 -0
- data/sig/generated/prism/parse_result.rbs +859 -0
- data/sig/generated/prism/pattern.rbs +156 -0
- data/sig/generated/prism/reflection.rbs +101 -0
- data/sig/generated/prism/relocation.rbs +428 -0
- data/sig/generated/prism/serialize.rbs +195 -0
- data/sig/generated/prism/string_query.rbs +36 -0
- data/sig/generated/prism/translation.rbs +8 -0
- data/sig/generated/prism/visitor.rbs +1111 -0
- data/sig/generated/prism.rbs +84 -0
- data/sig/manifest.yaml +2 -0
- data/src/arena.c +117 -0
- data/src/buffer.c +380 -0
- data/src/char.c +289 -0
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +886 -0
- data/src/encoding.c +5345 -0
- data/src/errors_format.c +519 -0
- data/src/integer.c +681 -0
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/memchr.c +37 -0
- data/src/node.c +4515 -0
- data/src/options.c +451 -0
- data/src/parser.c +349 -0
- data/src/prettyprint.c +9024 -0
- data/src/prism.c +23739 -0
- data/src/regexp.c +1706 -0
- data/src/serialize.c +2309 -0
- data/src/source.c +518 -0
- data/src/static_literals.c +685 -0
- data/src/string_query.c +166 -0
- data/src/stringy.c +91 -0
- data/src/strncasecmp.c +37 -0
- data/src/strpbrk.c +447 -0
- data/src/tokens.c +724 -0
- metadata +259 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Generated from lib/prism/node_ext.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# --
|
|
4
|
+
# Here we are reopening the prism module to provide methods on nodes that aren't
|
|
5
|
+
# templated and are meant as convenience methods.
|
|
6
|
+
# ++
|
|
7
|
+
module Prism
|
|
8
|
+
class Node
|
|
9
|
+
# : (*String replacements) -> void
|
|
10
|
+
def deprecated: (*String replacements) -> void
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module RegularExpressionOptions
|
|
14
|
+
# Returns a numeric value that represents the flags that were used to create
|
|
15
|
+
# the regular expression.
|
|
16
|
+
#
|
|
17
|
+
# : (Integer flags) -> Integer
|
|
18
|
+
def self.options: (Integer flags) -> Integer
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class InterpolatedMatchLastLineNode < Node
|
|
22
|
+
# Returns a numeric value that represents the flags that were used to create
|
|
23
|
+
# the regular expression.
|
|
24
|
+
#
|
|
25
|
+
# : () -> Integer
|
|
26
|
+
def options: () -> Integer
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class InterpolatedRegularExpressionNode < Node
|
|
30
|
+
# Returns a numeric value that represents the flags that were used to create
|
|
31
|
+
# the regular expression.
|
|
32
|
+
#
|
|
33
|
+
# : () -> Integer
|
|
34
|
+
def options: () -> Integer
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class MatchLastLineNode < Node
|
|
38
|
+
# Returns a numeric value that represents the flags that were used to create
|
|
39
|
+
# the regular expression.
|
|
40
|
+
#
|
|
41
|
+
# : () -> Integer
|
|
42
|
+
def options: () -> Integer
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class RegularExpressionNode < Node
|
|
46
|
+
# Returns a numeric value that represents the flags that were used to create
|
|
47
|
+
# the regular expression.
|
|
48
|
+
#
|
|
49
|
+
# : () -> Integer
|
|
50
|
+
def options: () -> Integer
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
module HeredocQuery
|
|
54
|
+
# Returns true if this node was represented as a heredoc in the source code.
|
|
55
|
+
#
|
|
56
|
+
# : (String? opening) -> bool?
|
|
57
|
+
def self.heredoc?: (String? opening) -> bool?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class InterpolatedStringNode < Node
|
|
61
|
+
# Returns true if this node was represented as a heredoc in the source code.
|
|
62
|
+
#
|
|
63
|
+
# : () -> bool?
|
|
64
|
+
def heredoc?: () -> bool?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class InterpolatedXStringNode < Node
|
|
68
|
+
# Returns true if this node was represented as a heredoc in the source code.
|
|
69
|
+
#
|
|
70
|
+
# : () -> bool?
|
|
71
|
+
def heredoc?: () -> bool?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class StringNode < Node
|
|
75
|
+
# Returns true if this node was represented as a heredoc in the source code.
|
|
76
|
+
#
|
|
77
|
+
# : () -> bool?
|
|
78
|
+
def heredoc?: () -> bool?
|
|
79
|
+
|
|
80
|
+
# Occasionally it's helpful to treat a string as if it were interpolated so
|
|
81
|
+
# that there's a consistent interface for working with strings.
|
|
82
|
+
#
|
|
83
|
+
# : () -> InterpolatedStringNode
|
|
84
|
+
def to_interpolated: () -> InterpolatedStringNode
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class XStringNode < Node
|
|
88
|
+
# Returns true if this node was represented as a heredoc in the source code.
|
|
89
|
+
#
|
|
90
|
+
# : () -> bool?
|
|
91
|
+
def heredoc?: () -> bool?
|
|
92
|
+
|
|
93
|
+
# Occasionally it's helpful to treat a string as if it were interpolated so
|
|
94
|
+
# that there's a consistent interface for working with strings.
|
|
95
|
+
#
|
|
96
|
+
# : () -> InterpolatedXStringNode
|
|
97
|
+
def to_interpolated: () -> InterpolatedXStringNode
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class ImaginaryNode < Node
|
|
101
|
+
# Returns the value of the node as a Ruby Complex.
|
|
102
|
+
#
|
|
103
|
+
# : () -> Complex
|
|
104
|
+
def value: () -> Complex
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class RationalNode < Node
|
|
108
|
+
# Returns the value of the node as a Ruby Rational.
|
|
109
|
+
#
|
|
110
|
+
# : () -> Rational
|
|
111
|
+
def value: () -> Rational
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class ConstantReadNode < Node
|
|
115
|
+
# Returns the list of parts for the full name of this constant.
|
|
116
|
+
# For example: [:Foo]
|
|
117
|
+
#
|
|
118
|
+
# : () -> Array[Symbol]
|
|
119
|
+
def full_name_parts: () -> Array[Symbol]
|
|
120
|
+
|
|
121
|
+
# Returns the full name of this constant. For example: "Foo"
|
|
122
|
+
#
|
|
123
|
+
# : () -> String
|
|
124
|
+
def full_name: () -> String
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class ConstantWriteNode < Node
|
|
128
|
+
# Returns the list of parts for the full name of this constant.
|
|
129
|
+
# For example: [:Foo]
|
|
130
|
+
#
|
|
131
|
+
# : () -> Array[Symbol]
|
|
132
|
+
def full_name_parts: () -> Array[Symbol]
|
|
133
|
+
|
|
134
|
+
# Returns the full name of this constant. For example: "Foo"
|
|
135
|
+
#
|
|
136
|
+
# : () -> String
|
|
137
|
+
def full_name: () -> String
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class ConstantPathNode < Node
|
|
141
|
+
# An error class raised when dynamic parts are found while computing a
|
|
142
|
+
# constant path's full name. For example:
|
|
143
|
+
# Foo::Bar::Baz -> does not raise because all parts of the constant path are
|
|
144
|
+
# simple constants
|
|
145
|
+
# var::Bar::Baz -> raises because the first part of the constant path is a
|
|
146
|
+
# local variable
|
|
147
|
+
class DynamicPartsInConstantPathError < StandardError
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# An error class raised when error recovery nodes are found while computing a
|
|
151
|
+
# constant path's full name. For example:
|
|
152
|
+
# Foo:: -> raises because the constant path is missing the last part
|
|
153
|
+
class ErrorRecoveryNodesInConstantPathError < StandardError
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Returns the list of parts for the full name of this constant path.
|
|
157
|
+
# For example: [:Foo, :Bar]
|
|
158
|
+
#
|
|
159
|
+
# : () -> Array[Symbol]
|
|
160
|
+
def full_name_parts: () -> Array[Symbol]
|
|
161
|
+
|
|
162
|
+
# Returns the full name of this constant path. For example: "Foo::Bar"
|
|
163
|
+
#
|
|
164
|
+
# : () -> String
|
|
165
|
+
def full_name: () -> String
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class ConstantPathTargetNode < Node
|
|
169
|
+
# Returns the list of parts for the full name of this constant path.
|
|
170
|
+
# For example: [:Foo, :Bar]
|
|
171
|
+
#
|
|
172
|
+
# : () -> Array[Symbol]
|
|
173
|
+
def full_name_parts: () -> Array[Symbol]
|
|
174
|
+
|
|
175
|
+
# Returns the full name of this constant path. For example: "Foo::Bar"
|
|
176
|
+
#
|
|
177
|
+
# : () -> String
|
|
178
|
+
def full_name: () -> String
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
class ConstantTargetNode < Node
|
|
182
|
+
# Returns the list of parts for the full name of this constant.
|
|
183
|
+
# For example: [:Foo]
|
|
184
|
+
#
|
|
185
|
+
# : () -> Array[Symbol]
|
|
186
|
+
def full_name_parts: () -> Array[Symbol]
|
|
187
|
+
|
|
188
|
+
# Returns the full name of this constant. For example: "Foo"
|
|
189
|
+
#
|
|
190
|
+
# : () -> String
|
|
191
|
+
def full_name: () -> String
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class ParametersNode < Node
|
|
195
|
+
# Mirrors the Method#parameters method.
|
|
196
|
+
#
|
|
197
|
+
# : () -> Array[[Symbol, Symbol] | [Symbol]]
|
|
198
|
+
def signature: () -> Array[[ Symbol, Symbol ] | [ Symbol ]]
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
class CallNode < Node
|
|
202
|
+
# When a call node has the attribute_write flag set, it means that the call
|
|
203
|
+
# is using the attribute write syntax. This is either a method call to []=
|
|
204
|
+
# or a method call to a method that ends with =. Either way, the = sign is
|
|
205
|
+
# present in the source.
|
|
206
|
+
#
|
|
207
|
+
# Prism returns the message_loc _without_ the = sign attached, because there
|
|
208
|
+
# can be any amount of space between the message and the = sign. However,
|
|
209
|
+
# sometimes you want the location of the full message including the inner
|
|
210
|
+
# space and the = sign. This method provides that.
|
|
211
|
+
#
|
|
212
|
+
# : () -> Location?
|
|
213
|
+
def full_message_loc: () -> Location?
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# :stopdoc:
|
|
217
|
+
class InNode < Node
|
|
218
|
+
# : () -> String
|
|
219
|
+
def in: () -> String
|
|
220
|
+
|
|
221
|
+
# : () -> Location
|
|
222
|
+
def in_loc: () -> Location
|
|
223
|
+
|
|
224
|
+
# : () -> String?
|
|
225
|
+
def then: () -> String?
|
|
226
|
+
|
|
227
|
+
# : () -> Location?
|
|
228
|
+
def then_loc: () -> Location?
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
class MatchPredicateNode < Node
|
|
232
|
+
# : () -> String
|
|
233
|
+
def operator: () -> String
|
|
234
|
+
|
|
235
|
+
# : () -> Location
|
|
236
|
+
def operator_loc: () -> Location
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
class UnlessNode < Node
|
|
240
|
+
# : () -> String
|
|
241
|
+
def keyword: () -> String
|
|
242
|
+
|
|
243
|
+
# : () -> Location
|
|
244
|
+
def keyword_loc: () -> Location
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
class UntilNode < Node
|
|
248
|
+
# : () -> String
|
|
249
|
+
def keyword: () -> String
|
|
250
|
+
|
|
251
|
+
# : () -> Location
|
|
252
|
+
def keyword_loc: () -> Location
|
|
253
|
+
|
|
254
|
+
# : () -> String?
|
|
255
|
+
def closing: () -> String?
|
|
256
|
+
|
|
257
|
+
# : () -> Location?
|
|
258
|
+
def closing_loc: () -> Location?
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
class WhenNode < Node
|
|
262
|
+
# : () -> String
|
|
263
|
+
def keyword: () -> String
|
|
264
|
+
|
|
265
|
+
# : () -> Location
|
|
266
|
+
def keyword_loc: () -> Location
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
class WhileNode < Node
|
|
270
|
+
# : () -> String
|
|
271
|
+
def keyword: () -> String
|
|
272
|
+
|
|
273
|
+
# : () -> Location
|
|
274
|
+
def keyword_loc: () -> Location
|
|
275
|
+
|
|
276
|
+
# : () -> String?
|
|
277
|
+
def closing: () -> String?
|
|
278
|
+
|
|
279
|
+
# : () -> Location?
|
|
280
|
+
def closing_loc: () -> Location?
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
class SymbolNode < Node
|
|
284
|
+
# : () -> String
|
|
285
|
+
def value: () -> String
|
|
286
|
+
|
|
287
|
+
# : () -> Location
|
|
288
|
+
def value_loc: () -> Location
|
|
289
|
+
end
|
|
290
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Generated from lib/prism/node_find.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Prism
|
|
4
|
+
# Finds the Prism AST node corresponding to a given Method, UnboundMethod,
|
|
5
|
+
# Proc, or Thread::Backtrace::Location. On CRuby, uses node_id from the
|
|
6
|
+
# instruction sequence for an exact match. On other implementations, falls
|
|
7
|
+
# back to best-effort matching by source location line number.
|
|
8
|
+
#
|
|
9
|
+
# This module is autoloaded so that programs that don't use Prism.find don't
|
|
10
|
+
# pay for its definition.
|
|
11
|
+
module NodeFind
|
|
12
|
+
# Find the node for the given callable or backtrace location.
|
|
13
|
+
#
|
|
14
|
+
# : (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
|
|
15
|
+
def self.find: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
|
|
16
|
+
|
|
17
|
+
# Base class that handles parsing a file.
|
|
18
|
+
class Find
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
# Parse the given file path, returning a ParseResult or nil.
|
|
22
|
+
#
|
|
23
|
+
# : (String? file) -> ParseResult?
|
|
24
|
+
def parse_file: (String? file) -> ParseResult?
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Finds the AST node for a Method, UnboundMethod, Proc or Thread::Backtrace::Location
|
|
28
|
+
# using the #source_range
|
|
29
|
+
class SourceRangeFind < Find
|
|
30
|
+
# Find the node for the given callable using the #source_range.
|
|
31
|
+
#
|
|
32
|
+
# : (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
|
|
33
|
+
def find: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Finds the AST node for a Method, UnboundMethod, or Proc using the node_id
|
|
37
|
+
# from the instruction sequence.
|
|
38
|
+
class RubyVMCallableFind < Find
|
|
39
|
+
# Find the node for the given callable using the ISeq node_id.
|
|
40
|
+
#
|
|
41
|
+
# : (Method | UnboundMethod | Proc callable) -> Node?
|
|
42
|
+
def find: (Method | UnboundMethod | Proc callable) -> Node?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Finds the AST node for a Thread::Backtrace::Location using the node_id
|
|
46
|
+
# from the backtrace location.
|
|
47
|
+
class RubyVMBacktraceLocationFind < Find
|
|
48
|
+
# Find the node for the given backtrace location using node_id.
|
|
49
|
+
#
|
|
50
|
+
# : (Thread::Backtrace::Location location) -> Node?
|
|
51
|
+
def find: (Thread::Backtrace::Location location) -> Node?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Finds the AST node for a Method or UnboundMethod using best-effort line
|
|
55
|
+
# matching. Used on non-CRuby implementations.
|
|
56
|
+
class LineMethodFind < Find
|
|
57
|
+
# Find the node for the given method by matching on name and line.
|
|
58
|
+
#
|
|
59
|
+
# : (Method | UnboundMethod callable) -> Node?
|
|
60
|
+
def find: (Method | UnboundMethod callable) -> Node?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Finds the AST node for a lambda using best-effort line matching. Used
|
|
64
|
+
# on non-CRuby implementations.
|
|
65
|
+
class LineLambdaFind < Find
|
|
66
|
+
# Find the node for the given lambda by matching on line.
|
|
67
|
+
#
|
|
68
|
+
# : (Proc callable) -> Node?
|
|
69
|
+
def find: (Proc callable) -> Node?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Finds the AST node for a non-lambda Proc using best-effort line
|
|
73
|
+
# matching. Used on non-CRuby implementations.
|
|
74
|
+
class LineProcFind < Find
|
|
75
|
+
# Find the node for the given proc by matching on line.
|
|
76
|
+
#
|
|
77
|
+
# : (Proc callable) -> Node?
|
|
78
|
+
def find: (Proc callable) -> Node?
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Finds the AST node for a Thread::Backtrace::Location using best-effort
|
|
82
|
+
# line matching. Used on non-CRuby implementations.
|
|
83
|
+
class LineBacktraceLocationFind < Find
|
|
84
|
+
# Find the node for the given backtrace location by matching on line.
|
|
85
|
+
#
|
|
86
|
+
# : (Thread::Backtrace::Location location) -> Node?
|
|
87
|
+
def find: (Thread::Backtrace::Location location) -> Node?
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated from lib/prism/parse_result/errors.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Prism
|
|
4
|
+
class ParseResult < Result
|
|
5
|
+
# An object to represent the set of errors on a parse result. This object
|
|
6
|
+
# can be used to format the errors in a human-readable way.
|
|
7
|
+
class Errors
|
|
8
|
+
# The parse result that contains the errors.
|
|
9
|
+
attr_reader parse_result: ParseResult
|
|
10
|
+
|
|
11
|
+
# Initialize a new set of errors from the given parse result.
|
|
12
|
+
#
|
|
13
|
+
# : (ParseResult parse_result) -> void
|
|
14
|
+
def initialize: (ParseResult parse_result) -> void
|
|
15
|
+
|
|
16
|
+
# Formats the errors in a human-readable way and return them as a string.
|
|
17
|
+
#
|
|
18
|
+
# : () -> String
|
|
19
|
+
def format: () -> String
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Generated from lib/prism/parse_result/newlines.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Prism
|
|
4
|
+
class ParseResult < Result
|
|
5
|
+
# The :line tracepoint event gets fired whenever the Ruby VM encounters an
|
|
6
|
+
# expression on a new line. The types of expressions that can trigger this
|
|
7
|
+
# event are:
|
|
8
|
+
#
|
|
9
|
+
# * if statements
|
|
10
|
+
# * unless statements
|
|
11
|
+
# * nodes that are children of statements lists
|
|
12
|
+
#
|
|
13
|
+
# In order to keep track of the newlines, we have a list of offsets that
|
|
14
|
+
# come back from the parser. We assign these offsets to the first nodes that
|
|
15
|
+
# we find in the tree that are on those lines.
|
|
16
|
+
#
|
|
17
|
+
# Note that the logic in this file should be kept in sync with the Java
|
|
18
|
+
# MarkNewlinesVisitor, since that visitor is responsible for marking the
|
|
19
|
+
# newlines for JRuby/TruffleRuby.
|
|
20
|
+
#
|
|
21
|
+
# This file is autoloaded only when `mark_newlines!` is called, so the
|
|
22
|
+
# re-opening of the various nodes in this file will only be performed in
|
|
23
|
+
# that case. We do that to avoid storing the extra `@newline` instance
|
|
24
|
+
# variable on every node if we don't need it.
|
|
25
|
+
class Newlines < Visitor
|
|
26
|
+
@lines: Array[bool]
|
|
27
|
+
|
|
28
|
+
# Create a new Newlines visitor with the given newline offsets.
|
|
29
|
+
#
|
|
30
|
+
# : (Integer lines) -> void
|
|
31
|
+
def initialize: (Integer lines) -> void
|
|
32
|
+
|
|
33
|
+
# Permit block nodes to mark newlines within themselves.
|
|
34
|
+
#
|
|
35
|
+
# : (BlockNode node) -> void
|
|
36
|
+
def visit_block_node: (BlockNode node) -> void
|
|
37
|
+
|
|
38
|
+
# Permit lambda nodes to mark newlines within themselves.
|
|
39
|
+
#
|
|
40
|
+
# : (LambdaNode node) -> void
|
|
41
|
+
def visit_lambda_node: (LambdaNode node) -> void
|
|
42
|
+
|
|
43
|
+
# Permit def nodes to mark newlines within themselves. The body of an
|
|
44
|
+
# endless method definition never emits newline events, so in that case
|
|
45
|
+
# mark every line as already seen while visiting it instead. Nested
|
|
46
|
+
# scopes (blocks, lambdas, etc.) reset the lines and emit events again.
|
|
47
|
+
#
|
|
48
|
+
# : (DefNode node) -> void
|
|
49
|
+
def visit_def_node: (DefNode node) -> void
|
|
50
|
+
|
|
51
|
+
# Permit class nodes to mark newlines within themselves.
|
|
52
|
+
#
|
|
53
|
+
# : (ClassNode node) -> void
|
|
54
|
+
def visit_class_node: (ClassNode node) -> void
|
|
55
|
+
|
|
56
|
+
# Permit module nodes to mark newlines within themselves.
|
|
57
|
+
#
|
|
58
|
+
# : (ModuleNode node) -> void
|
|
59
|
+
def visit_module_node: (ModuleNode node) -> void
|
|
60
|
+
|
|
61
|
+
# Permit singleton class nodes to mark newlines within themselves.
|
|
62
|
+
#
|
|
63
|
+
# : (SingletonClassNode node) -> void
|
|
64
|
+
def visit_singleton_class_node: (SingletonClassNode node) -> void
|
|
65
|
+
|
|
66
|
+
# Statements inside string interpolation do not emit newline events, so
|
|
67
|
+
# mark every line as already seen while visiting them. Nested scopes
|
|
68
|
+
# (blocks, lambdas, defs, etc.) reset the lines and emit events again.
|
|
69
|
+
#
|
|
70
|
+
# : (EmbeddedStatementsNode node) -> void
|
|
71
|
+
def visit_embedded_statements_node: (EmbeddedStatementsNode node) -> void
|
|
72
|
+
|
|
73
|
+
# The predicate of a while loop is compiled at the end of the loop,
|
|
74
|
+
# after the body, so any statements it contains (from parentheses)
|
|
75
|
+
# emit their line events again even if the lines were already seen.
|
|
76
|
+
#
|
|
77
|
+
# : (WhileNode node) -> void
|
|
78
|
+
def visit_while_node: (WhileNode node) -> void
|
|
79
|
+
|
|
80
|
+
# The predicate of an until loop is compiled at the end of the loop,
|
|
81
|
+
# after the body, so any statements it contains (from parentheses)
|
|
82
|
+
# emit their line events again even if the lines were already seen.
|
|
83
|
+
#
|
|
84
|
+
# : (UntilNode node) -> void
|
|
85
|
+
def visit_until_node: (UntilNode node) -> void
|
|
86
|
+
|
|
87
|
+
# Mark if nodes as newlines.
|
|
88
|
+
#
|
|
89
|
+
# : (IfNode node) -> void
|
|
90
|
+
def visit_if_node: (IfNode node) -> void
|
|
91
|
+
|
|
92
|
+
# Mark unless nodes as newlines.
|
|
93
|
+
#
|
|
94
|
+
# : (UnlessNode node) -> void
|
|
95
|
+
def visit_unless_node: (UnlessNode node) -> void
|
|
96
|
+
|
|
97
|
+
# Permit statements lists to mark newlines within themselves.
|
|
98
|
+
#
|
|
99
|
+
# : (StatementsNode node) -> void
|
|
100
|
+
def visit_statements_node: (StatementsNode node) -> void
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
class Node
|
|
105
|
+
@newline_flag: bool
|
|
106
|
+
|
|
107
|
+
# : () -> bool
|
|
108
|
+
def newline_flag?: () -> bool
|
|
109
|
+
|
|
110
|
+
# : (Array[bool] lines) -> void
|
|
111
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class BeginNode < Node
|
|
115
|
+
# : (Array[bool] lines) -> void
|
|
116
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
class ParenthesesNode < Node
|
|
120
|
+
# : (Array[bool] lines) -> void
|
|
121
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
class IfNode < Node
|
|
125
|
+
# : (Array[bool] lines) -> void
|
|
126
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class UnlessNode < Node
|
|
130
|
+
# : (Array[bool] lines) -> void
|
|
131
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
class UntilNode < Node
|
|
135
|
+
# : (Array[bool] lines) -> void
|
|
136
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
class WhileNode < Node
|
|
140
|
+
# : (Array[bool] lines) -> void
|
|
141
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
class RescueModifierNode < Node
|
|
145
|
+
# : (Array[bool] lines) -> void
|
|
146
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
class LocalVariableWriteNode < Node
|
|
150
|
+
# : (Array[bool] lines) -> void
|
|
151
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
class InstanceVariableWriteNode < Node
|
|
155
|
+
# : (Array[bool] lines) -> void
|
|
156
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
class ClassVariableWriteNode < Node
|
|
160
|
+
# : (Array[bool] lines) -> void
|
|
161
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
class GlobalVariableWriteNode < Node
|
|
165
|
+
# : (Array[bool] lines) -> void
|
|
166
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
class ConstantWriteNode < Node
|
|
170
|
+
# : (Array[bool] lines) -> void
|
|
171
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
class ConstantPathWriteNode < Node
|
|
175
|
+
# : (Array[bool] lines) -> void
|
|
176
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
class MultiWriteNode < Node
|
|
180
|
+
# : (Array[bool] lines) -> void
|
|
181
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
class CallNode < Node
|
|
185
|
+
# : (Array[bool] lines) -> void
|
|
186
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class ArrayNode < Node
|
|
190
|
+
# : (Array[bool] lines) -> void
|
|
191
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class HashNode < Node
|
|
195
|
+
# : (Array[bool] lines) -> void
|
|
196
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
class InterpolatedMatchLastLineNode < Node
|
|
200
|
+
# : (Array[bool] lines) -> void
|
|
201
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
class InterpolatedRegularExpressionNode < Node
|
|
205
|
+
# : (Array[bool] lines) -> void
|
|
206
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
class InterpolatedStringNode < Node
|
|
210
|
+
# : (Array[bool] lines) -> void
|
|
211
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
class InterpolatedSymbolNode < Node
|
|
215
|
+
# : (Array[bool] lines) -> void
|
|
216
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
class InterpolatedXStringNode < Node
|
|
220
|
+
# : (Array[bool] lines) -> void
|
|
221
|
+
def newline_flag!: (Array[bool] lines) -> void
|
|
222
|
+
end
|
|
223
|
+
end
|