rbs 3.9.4 → 4.2.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/.clang-format +75 -0
- data/.clangd +2 -0
- data/.dockerignore +37 -0
- data/.gitattributes +1 -0
- data/.github/dependabot.yml +16 -14
- data/.github/workflows/bundle-update.yml +63 -0
- data/.github/workflows/c-check.yml +66 -0
- data/.github/workflows/changelog.yml +121 -0
- data/.github/workflows/comments.yml +6 -4
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/jruby.yml +74 -0
- data/.github/workflows/release-gems.yml +234 -0
- data/.github/workflows/ruby.yml +86 -32
- data/.github/workflows/rust.yml +186 -0
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +6 -3
- data/.github/workflows/wasm.yml +55 -0
- data/.github/workflows/windows.yml +10 -4
- data/.gitignore +16 -0
- data/.rubocop.yml +1 -2
- data/CHANGELOG.md +502 -0
- data/Dockerfile.jruby +53 -0
- data/README.md +42 -5
- data/Rakefile +892 -111
- data/Steepfile +11 -0
- data/config.yml +665 -62
- data/core/array.rbs +541 -398
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +9 -8
- data/core/class.rbs +11 -8
- data/core/comparable.rbs +55 -34
- data/core/complex.rbs +104 -78
- data/core/dir.rbs +61 -49
- data/core/encoding.rbs +12 -15
- data/core/enumerable.rbs +297 -196
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator/product.rbs +5 -5
- data/core/enumerator.rbs +91 -28
- data/core/errno.rbs +11 -2
- data/core/errors.rbs +58 -29
- data/core/exception.rbs +13 -13
- data/core/fiber.rbs +74 -54
- data/core/file.rbs +260 -1151
- data/core/file_constants.rbs +463 -0
- data/core/file_stat.rbs +534 -0
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -116
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1151 -829
- data/core/integer.rbs +156 -195
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +222 -155
- data/core/kernel.rbs +239 -163
- data/core/marshal.rbs +4 -4
- data/core/match_data.rbs +16 -14
- data/core/math.rbs +107 -66
- data/core/method.rbs +69 -33
- data/core/module.rbs +302 -150
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +77 -63
- data/core/object.rbs +9 -11
- data/core/object_space/weak_key_map.rbs +7 -7
- data/core/object_space.rbs +30 -23
- data/core/pathname.rbs +1312 -0
- data/core/proc.rbs +95 -58
- data/core/process.rbs +222 -202
- data/core/ractor.rbs +364 -518
- data/core/random.rbs +21 -3
- data/core/range.rbs +181 -79
- data/core/rational.rbs +60 -89
- data/core/rbs/ops.rbs +154 -0
- data/core/rbs/unnamed/argf.rbs +63 -56
- data/core/rbs/unnamed/env_class.rbs +19 -14
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +11 -118
- data/core/regexp.rbs +258 -214
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +78 -34
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +6 -70
- data/core/rubygems/requirement.rbs +5 -15
- data/core/rubygems/rubygems.rbs +18 -81
- data/core/rubygems/specification.rbs +8 -0
- data/core/rubygems/version.rbs +2 -163
- data/core/set.rbs +493 -363
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +43 -42
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +139 -83
- data/core/time.rbs +81 -50
- data/core/trace_point.rbs +41 -35
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +24 -16
- data/core/warning.rbs +7 -7
- data/docs/CONTRIBUTING.md +3 -2
- data/docs/aliases.md +79 -0
- data/docs/collection.md +3 -3
- data/docs/config.md +171 -0
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +634 -0
- data/docs/rbs_by_example.md +20 -20
- data/docs/release.md +303 -0
- data/docs/rust.md +96 -0
- data/docs/sigs.md +3 -3
- data/docs/stdlib.md +8 -0
- data/docs/syntax.md +60 -18
- data/docs/type_fingerprint.md +21 -0
- data/docs/wasm_serialization.md +80 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +1870 -0
- data/ext/rbs_extension/ast_translation.h +41 -0
- data/ext/rbs_extension/class_constants.c +189 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +24 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +26 -1
- data/ext/rbs_extension/legacy_location.c +299 -0
- data/ext/rbs_extension/legacy_location.h +82 -0
- data/ext/rbs_extension/main.c +639 -23
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +1055 -0
- data/include/rbs/defines.h +104 -0
- data/include/rbs/lexer.h +208 -0
- data/include/rbs/location.h +40 -0
- data/include/rbs/parser.h +187 -0
- data/include/rbs/serialize.h +39 -0
- data/include/rbs/string.h +47 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -70
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +24 -0
- data/include/rbs.h +9 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +30 -32
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +11 -11
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +451 -0
- data/lib/rbs/ast/ruby/comment_block.rb +247 -0
- data/lib/rbs/ast/ruby/declarations.rb +291 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +762 -0
- data/lib/rbs/ast/type_param.rb +25 -5
- data/lib/rbs/buffer.rb +142 -20
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +63 -126
- data/lib/rbs/cli.rb +59 -29
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
- data/lib/rbs/collection/sources/git.rb +7 -0
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +129 -70
- data/lib/rbs/definition_builder/method_builder.rb +74 -33
- data/lib/rbs/definition_builder.rb +181 -21
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +81 -0
- data/lib/rbs/environment/module_entry.rb +91 -0
- data/lib/rbs/environment.rb +410 -215
- data/lib/rbs/environment_loader.rb +2 -8
- data/lib/rbs/errors.rb +31 -21
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +568 -0
- data/lib/rbs/location_aux.rb +36 -4
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/namespace.rb +47 -18
- data/lib/rbs/parser_aux.rb +37 -7
- data/lib/rbs/prototype/helpers.rb +24 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +196 -45
- data/lib/rbs/prototype/runtime/value_object_generator.rb +0 -1
- data/lib/rbs/prototype/runtime.rb +13 -3
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +120 -44
- data/lib/rbs/rewriter.rb +70 -0
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +7 -4
- data/lib/rbs/test/type_check.rb +25 -3
- data/lib/rbs/type_name.rb +34 -21
- data/lib/rbs/types.rb +135 -81
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +47 -11
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/deserializer.rb +213 -0
- data/lib/rbs/wasm/location.rb +61 -0
- data/lib/rbs/wasm/parser.rb +174 -0
- data/lib/rbs/wasm/runtime.rb +211 -0
- data/lib/rbs/wasm/serialization_schema.rb +111 -0
- data/lib/rbs.rb +25 -2
- data/lib/rbs_jars.rb +39 -0
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +8 -3
- data/rbs.gemspec +34 -6
- data/schema/function.json +12 -1
- data/schema/typeParam.json +17 -1
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +13 -10
- data/sig/ast/ruby/annotations.rbs +470 -0
- data/sig/ast/ruby/comment_block.rbs +127 -0
- data/sig/ast/ruby/declarations.rbs +158 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +198 -0
- data/sig/buffer.rbs +81 -5
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/collection/config/lockfile_generator.rbs +2 -0
- data/sig/definition.rbs +6 -0
- data/sig/definition_builder.rbs +3 -1
- data/sig/environment/class_entry.rbs +56 -0
- data/sig/environment/module_entry.rbs +65 -0
- data/sig/environment.rbs +94 -87
- data/sig/errors.rbs +26 -20
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +126 -0
- data/sig/location.rbs +32 -7
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -2
- data/sig/method_builder.rbs +9 -4
- data/sig/namespace.rbs +20 -5
- data/sig/parser.rbs +79 -15
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/prototype/rbi.rbs +33 -4
- data/sig/resolver/type_name_resolver.rbs +36 -10
- data/sig/rewriter.rbs +45 -0
- data/sig/source.rbs +48 -0
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +15 -5
- data/sig/types.rbs +21 -9
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +17 -2
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +1644 -0
- data/src/lexer.c +3223 -0
- data/src/lexer.re +187 -0
- data/src/lexstate.c +222 -0
- data/src/location.c +31 -0
- data/src/parser.c +4318 -0
- data/src/serialize.c +965 -0
- data/src/string.c +41 -0
- data/src/util/rbs_allocator.c +171 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +18 -92
- data/src/util/rbs_encoding.c +21454 -0
- data/src/util/rbs_unescape.c +167 -0
- data/stdlib/abbrev/0/array.rbs +1 -1
- data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +7 -4
- data/stdlib/csv/0/csv.rbs +5 -5
- data/stdlib/date/0/date.rbs +92 -79
- data/stdlib/date/0/date_time.rbs +25 -24
- data/stdlib/delegate/0/delegator.rbs +11 -7
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +117 -1
- data/stdlib/erb/0/erb.rbs +754 -353
- data/stdlib/etc/0/etc.rbs +73 -54
- data/stdlib/fileutils/0/fileutils.rbs +179 -160
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
- data/stdlib/json/0/json.rbs +232 -185
- data/stdlib/monitor/0/monitor.rbs +9 -9
- data/stdlib/net-http/0/net-http.rbs +162 -134
- data/stdlib/objspace/0/objspace.rbs +17 -34
- data/stdlib/open-uri/0/open-uri.rbs +48 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +521 -397
- data/stdlib/optparse/0/optparse.rbs +26 -17
- data/stdlib/pathname/0/pathname.rbs +11 -1381
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +65 -12
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +4 -3
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +2 -2
- data/stdlib/resolv/0/resolv.rbs +26 -69
- data/stdlib/ripper/0/ripper.rbs +25 -19
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +3 -3
- data/stdlib/singleton/0/singleton.rbs +6 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -9
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +23 -10
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +11 -3
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +1211 -96
- data/stdlib/strscan/0/string_scanner.rbs +101 -80
- data/stdlib/tempfile/0/manifest.yaml +3 -0
- data/stdlib/tempfile/0/tempfile.rbs +25 -21
- data/stdlib/time/0/time.rbs +8 -6
- data/stdlib/timeout/0/timeout.rbs +58 -7
- data/stdlib/tsort/0/cyclic.rbs +4 -1
- data/stdlib/tsort/0/interfaces.rbs +8 -8
- data/stdlib/tsort/0/tsort.rbs +16 -15
- data/stdlib/uri/0/common.rbs +42 -20
- data/stdlib/uri/0/file.rbs +3 -3
- data/stdlib/uri/0/generic.rbs +21 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_file.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +8 -8
- data/stdlib/zlib/0/gzip_writer.rbs +16 -13
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- data/wasm/README.md +109 -0
- data/wasm/rbs_wasm.c +479 -0
- metadata +133 -19
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
|
@@ -13,25 +13,22 @@ module RBS
|
|
|
13
13
|
@include_filename = true
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def annotate_file(path, preserve:)
|
|
17
|
-
|
|
16
|
+
def annotate_file(path, preserve: true)
|
|
17
|
+
buffer, _, decls = Parser.parse_signature(path.read())
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
rewriter = Rewriter.new(buffer)
|
|
20
|
+
annotate_decls(decls, rewriter)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
path.open("w") do |io|
|
|
24
|
-
Writer.new(out: io).preserve!(preserve: preserve).write(decls)
|
|
25
|
-
end
|
|
22
|
+
path.write(rewriter.string)
|
|
26
23
|
end
|
|
27
24
|
|
|
28
|
-
def annotate_decls(decls, outer: [])
|
|
25
|
+
def annotate_decls(decls, rewriter, outer: [])
|
|
29
26
|
decls.each do |decl|
|
|
30
27
|
case decl
|
|
31
28
|
when AST::Declarations::Class, AST::Declarations::Module
|
|
32
|
-
annotate_class(decl, outer: outer)
|
|
29
|
+
annotate_class(decl, rewriter, outer: outer)
|
|
33
30
|
when AST::Declarations::Constant
|
|
34
|
-
annotate_constant(decl, outer: outer)
|
|
31
|
+
annotate_constant(decl, rewriter, outer: outer)
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
34
|
end
|
|
@@ -39,7 +36,9 @@ module RBS
|
|
|
39
36
|
def each_part(subjects, tester:)
|
|
40
37
|
if block_given?
|
|
41
38
|
subjects.each do |subject, docs|
|
|
42
|
-
|
|
39
|
+
comment = subject.comment
|
|
40
|
+
raise if comment.is_a?(String)
|
|
41
|
+
Formatter.each_part(comment.parse) do |doc|
|
|
43
42
|
if tester.test_path(doc.file || raise)
|
|
44
43
|
yield [doc, subject]
|
|
45
44
|
end
|
|
@@ -242,7 +241,7 @@ module RBS
|
|
|
242
241
|
end
|
|
243
242
|
end
|
|
244
243
|
|
|
245
|
-
def annotate_class(decl, outer:)
|
|
244
|
+
def annotate_class(decl, rewriter, outer:)
|
|
246
245
|
annots = annotations(decl)
|
|
247
246
|
|
|
248
247
|
full_name = resolve_name(decl.name, outer: outer)
|
|
@@ -250,7 +249,7 @@ module RBS
|
|
|
250
249
|
text = resolve_doc_source(annots.copy_annotation, tester: annots) { doc_for_class(full_name, tester: annots) }
|
|
251
250
|
end
|
|
252
251
|
|
|
253
|
-
replace_comment(decl, text)
|
|
252
|
+
replace_comment(decl, text, rewriter)
|
|
254
253
|
|
|
255
254
|
unless annots.skip_all?
|
|
256
255
|
outer_ = outer + [decl.name.to_namespace]
|
|
@@ -258,28 +257,28 @@ module RBS
|
|
|
258
257
|
decl.each_member do |member|
|
|
259
258
|
case member
|
|
260
259
|
when AST::Members::MethodDefinition
|
|
261
|
-
annotate_method(full_name, member)
|
|
260
|
+
annotate_method(full_name, member, rewriter)
|
|
262
261
|
when AST::Members::Alias
|
|
263
|
-
annotate_alias(full_name, member)
|
|
262
|
+
annotate_alias(full_name, member, rewriter)
|
|
264
263
|
when AST::Members::AttrReader, AST::Members::AttrAccessor, AST::Members::AttrWriter
|
|
265
|
-
annotate_attribute(full_name, member)
|
|
264
|
+
annotate_attribute(full_name, member, rewriter)
|
|
266
265
|
end
|
|
267
266
|
end
|
|
268
267
|
|
|
269
|
-
annotate_decls(decl.each_decl.to_a, outer: outer_)
|
|
268
|
+
annotate_decls(decl.each_decl.to_a, rewriter, outer: outer_)
|
|
270
269
|
end
|
|
271
270
|
end
|
|
272
271
|
|
|
273
|
-
def annotate_constant(const, outer:)
|
|
272
|
+
def annotate_constant(const, rewriter, outer:)
|
|
274
273
|
annots = Annotations.new([])
|
|
275
274
|
|
|
276
275
|
full_name = resolve_name(const.name, outer: outer)
|
|
277
276
|
text = doc_for_constant(full_name, tester: annots)
|
|
278
277
|
|
|
279
|
-
replace_comment(const, text)
|
|
278
|
+
replace_comment(const, text, rewriter)
|
|
280
279
|
end
|
|
281
280
|
|
|
282
|
-
def annotate_alias(typename, als)
|
|
281
|
+
def annotate_alias(typename, als, rewriter)
|
|
283
282
|
annots = annotations(als)
|
|
284
283
|
|
|
285
284
|
unless annots.skip?
|
|
@@ -293,7 +292,7 @@ module RBS
|
|
|
293
292
|
end
|
|
294
293
|
end
|
|
295
294
|
|
|
296
|
-
replace_comment(als, text)
|
|
295
|
+
replace_comment(als, text, rewriter)
|
|
297
296
|
end
|
|
298
297
|
|
|
299
298
|
def join_docs(docs, separator: "----")
|
|
@@ -309,7 +308,7 @@ module RBS
|
|
|
309
308
|
end
|
|
310
309
|
end
|
|
311
310
|
|
|
312
|
-
def annotate_method(typename, method)
|
|
311
|
+
def annotate_method(typename, method, rewriter)
|
|
313
312
|
annots = annotations(method)
|
|
314
313
|
|
|
315
314
|
unless annots.skip?
|
|
@@ -335,10 +334,10 @@ module RBS
|
|
|
335
334
|
}
|
|
336
335
|
end
|
|
337
336
|
|
|
338
|
-
replace_comment(method, text)
|
|
337
|
+
replace_comment(method, text, rewriter)
|
|
339
338
|
end
|
|
340
339
|
|
|
341
|
-
def annotate_attribute(typename, attr)
|
|
340
|
+
def annotate_attribute(typename, attr, rewriter)
|
|
342
341
|
annots = annotations(attr)
|
|
343
342
|
|
|
344
343
|
unless annots.skip?
|
|
@@ -366,18 +365,17 @@ module RBS
|
|
|
366
365
|
end
|
|
367
366
|
end
|
|
368
367
|
|
|
369
|
-
replace_comment(attr, text)
|
|
368
|
+
replace_comment(attr, text, rewriter)
|
|
370
369
|
end
|
|
371
370
|
|
|
372
|
-
def replace_comment(commented, string)
|
|
371
|
+
def replace_comment(commented, string, rewriter)
|
|
373
372
|
if string
|
|
374
373
|
if string.empty?
|
|
375
|
-
commented.
|
|
374
|
+
rewriter.delete_comment(commented.comment) if commented.comment
|
|
375
|
+
elsif commented.comment
|
|
376
|
+
rewriter.replace_comment(commented.comment, content: string)
|
|
376
377
|
else
|
|
377
|
-
commented.
|
|
378
|
-
:@comment,
|
|
379
|
-
AST::Comment.new(location: nil, string: string)
|
|
380
|
-
)
|
|
378
|
+
rewriter.add_comment(commented.location || raise, *commented.annotations.filter_map(&:location), content: string)
|
|
381
379
|
end
|
|
382
380
|
end
|
|
383
381
|
end
|
|
@@ -23,7 +23,7 @@ module RBS
|
|
|
23
23
|
@stores.clear()
|
|
24
24
|
|
|
25
25
|
RDoc::RI::Paths.each(with_system_dir, with_site_dir, with_home_dir, with_gems_dir ? :latest : false, *extra_dirs.map(&:to_s)) do |path, type|
|
|
26
|
-
store = RDoc::Store.new(
|
|
26
|
+
store = RDoc::Store.new(RDoc::Options.new, path:, type:)
|
|
27
27
|
store.load_all
|
|
28
28
|
|
|
29
29
|
@stores << store
|
data/lib/rbs/ast/annotation.rb
CHANGED
data/lib/rbs/ast/comment.rb
CHANGED
data/lib/rbs/ast/declarations.rb
CHANGED
|
@@ -74,7 +74,7 @@ module RBS
|
|
|
74
74
|
self.class.hash ^ name.hash ^ args.hash
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def to_json(state =
|
|
77
|
+
def to_json(state = nil)
|
|
78
78
|
{
|
|
79
79
|
name: name,
|
|
80
80
|
args: args,
|
|
@@ -130,7 +130,7 @@ module RBS
|
|
|
130
130
|
self.class.hash ^ name.hash ^ type_params.hash ^ super_class.hash ^ members.hash
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
-
def to_json(state =
|
|
133
|
+
def to_json(state = nil)
|
|
134
134
|
{
|
|
135
135
|
declaration: :class,
|
|
136
136
|
name: name,
|
|
@@ -163,10 +163,10 @@ module RBS
|
|
|
163
163
|
alias eql? ==
|
|
164
164
|
|
|
165
165
|
def hash
|
|
166
|
-
self.class.hash ^ name.hash ^ args.hash
|
|
166
|
+
self.class.hash ^ name.hash ^ args.hash
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
def to_json(state =
|
|
169
|
+
def to_json(state = nil)
|
|
170
170
|
{
|
|
171
171
|
name: name,
|
|
172
172
|
args: args,
|
|
@@ -231,7 +231,7 @@ module RBS
|
|
|
231
231
|
self.class.hash ^ name.hash ^ type_params.hash ^ self_types.hash ^ members.hash
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
def to_json(state =
|
|
234
|
+
def to_json(state = nil)
|
|
235
235
|
{
|
|
236
236
|
declaration: :module,
|
|
237
237
|
name: name,
|
|
@@ -288,7 +288,7 @@ module RBS
|
|
|
288
288
|
self.class.hash ^ type_params.hash ^ members.hash
|
|
289
289
|
end
|
|
290
290
|
|
|
291
|
-
def to_json(state =
|
|
291
|
+
def to_json(state = nil)
|
|
292
292
|
{
|
|
293
293
|
declaration: :interface,
|
|
294
294
|
name: name,
|
|
@@ -331,7 +331,7 @@ module RBS
|
|
|
331
331
|
self.class.hash ^ name.hash ^ type_params.hash ^ type.hash
|
|
332
332
|
end
|
|
333
333
|
|
|
334
|
-
def to_json(state =
|
|
334
|
+
def to_json(state = nil)
|
|
335
335
|
{
|
|
336
336
|
declaration: :alias,
|
|
337
337
|
name: name,
|
|
@@ -371,7 +371,7 @@ module RBS
|
|
|
371
371
|
self.class.hash ^ name.hash ^ type.hash
|
|
372
372
|
end
|
|
373
373
|
|
|
374
|
-
def to_json(state =
|
|
374
|
+
def to_json(state = nil)
|
|
375
375
|
{
|
|
376
376
|
declaration: :constant,
|
|
377
377
|
name: name,
|
|
@@ -409,7 +409,7 @@ module RBS
|
|
|
409
409
|
self.class.hash ^ name.hash ^ type.hash
|
|
410
410
|
end
|
|
411
411
|
|
|
412
|
-
def to_json(state =
|
|
412
|
+
def to_json(state = nil)
|
|
413
413
|
{
|
|
414
414
|
declaration: :global,
|
|
415
415
|
name: name,
|
|
@@ -445,7 +445,7 @@ module RBS
|
|
|
445
445
|
end
|
|
446
446
|
|
|
447
447
|
class ClassAlias < AliasDecl
|
|
448
|
-
def to_json(state =
|
|
448
|
+
def to_json(state = nil)
|
|
449
449
|
{
|
|
450
450
|
declaration: :class_alias,
|
|
451
451
|
new_name: new_name,
|
|
@@ -457,7 +457,7 @@ module RBS
|
|
|
457
457
|
end
|
|
458
458
|
|
|
459
459
|
class ModuleAlias < AliasDecl
|
|
460
|
-
def to_json(state =
|
|
460
|
+
def to_json(state = nil)
|
|
461
461
|
{
|
|
462
462
|
declaration: :module_alias,
|
|
463
463
|
new_name: new_name,
|
data/lib/rbs/ast/members.rb
CHANGED
|
@@ -35,7 +35,7 @@ module RBS
|
|
|
35
35
|
update(method_type: self.method_type.sub(subst))
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
def to_json(state =
|
|
38
|
+
def to_json(state = nil)
|
|
39
39
|
{
|
|
40
40
|
annotations: annotations,
|
|
41
41
|
method_type: method_type
|
|
@@ -103,7 +103,7 @@ module RBS
|
|
|
103
103
|
)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
def to_json(state =
|
|
106
|
+
def to_json(state = nil)
|
|
107
107
|
{
|
|
108
108
|
member: :method_definition,
|
|
109
109
|
name: name,
|
|
@@ -145,7 +145,7 @@ module RBS
|
|
|
145
145
|
class InstanceVariable < Base
|
|
146
146
|
include Var
|
|
147
147
|
|
|
148
|
-
def to_json(state =
|
|
148
|
+
def to_json(state = nil)
|
|
149
149
|
{
|
|
150
150
|
member: :instance_variable,
|
|
151
151
|
name: name,
|
|
@@ -159,7 +159,7 @@ module RBS
|
|
|
159
159
|
class ClassInstanceVariable < Base
|
|
160
160
|
include Var
|
|
161
161
|
|
|
162
|
-
def to_json(state =
|
|
162
|
+
def to_json(state = nil)
|
|
163
163
|
{
|
|
164
164
|
member: :class_instance_variable,
|
|
165
165
|
name: name,
|
|
@@ -173,7 +173,7 @@ module RBS
|
|
|
173
173
|
class ClassVariable < Base
|
|
174
174
|
include Var
|
|
175
175
|
|
|
176
|
-
def to_json(state =
|
|
176
|
+
def to_json(state = nil)
|
|
177
177
|
{
|
|
178
178
|
member: :class_variable,
|
|
179
179
|
name: name,
|
|
@@ -215,7 +215,7 @@ module RBS
|
|
|
215
215
|
class Include < Base
|
|
216
216
|
include Mixin
|
|
217
217
|
|
|
218
|
-
def to_json(state =
|
|
218
|
+
def to_json(state = nil)
|
|
219
219
|
{
|
|
220
220
|
member: :include,
|
|
221
221
|
name: name,
|
|
@@ -230,7 +230,7 @@ module RBS
|
|
|
230
230
|
class Extend < Base
|
|
231
231
|
include Mixin
|
|
232
232
|
|
|
233
|
-
def to_json(state =
|
|
233
|
+
def to_json(state = nil)
|
|
234
234
|
{
|
|
235
235
|
member: :extend,
|
|
236
236
|
name: name,
|
|
@@ -245,7 +245,7 @@ module RBS
|
|
|
245
245
|
class Prepend < Base
|
|
246
246
|
include Mixin
|
|
247
247
|
|
|
248
|
-
def to_json(state =
|
|
248
|
+
def to_json(state = nil)
|
|
249
249
|
{
|
|
250
250
|
member: :prepend,
|
|
251
251
|
name: name,
|
|
@@ -311,7 +311,7 @@ module RBS
|
|
|
311
311
|
class AttrReader < Base
|
|
312
312
|
include Attribute
|
|
313
313
|
|
|
314
|
-
def to_json(state =
|
|
314
|
+
def to_json(state = nil)
|
|
315
315
|
{
|
|
316
316
|
member: :attr_reader,
|
|
317
317
|
name: name,
|
|
@@ -329,7 +329,7 @@ module RBS
|
|
|
329
329
|
class AttrAccessor < Base
|
|
330
330
|
include Attribute
|
|
331
331
|
|
|
332
|
-
def to_json(state =
|
|
332
|
+
def to_json(state = nil)
|
|
333
333
|
{
|
|
334
334
|
member: :attr_accessor,
|
|
335
335
|
name: name,
|
|
@@ -347,7 +347,7 @@ module RBS
|
|
|
347
347
|
class AttrWriter < Base
|
|
348
348
|
include Attribute
|
|
349
349
|
|
|
350
|
-
def to_json(state =
|
|
350
|
+
def to_json(state = nil)
|
|
351
351
|
{
|
|
352
352
|
member: :attr_writer,
|
|
353
353
|
name: name,
|
|
@@ -383,7 +383,7 @@ module RBS
|
|
|
383
383
|
class Public < Base
|
|
384
384
|
include LocationOnly
|
|
385
385
|
|
|
386
|
-
def to_json(state =
|
|
386
|
+
def to_json(state = nil)
|
|
387
387
|
{ member: :public, location: location }.to_json(state)
|
|
388
388
|
end
|
|
389
389
|
end
|
|
@@ -391,7 +391,7 @@ module RBS
|
|
|
391
391
|
class Private < Base
|
|
392
392
|
include LocationOnly
|
|
393
393
|
|
|
394
|
-
def to_json(state =
|
|
394
|
+
def to_json(state = nil)
|
|
395
395
|
{ member: :private, location: location }.to_json(state)
|
|
396
396
|
end
|
|
397
397
|
end
|
|
@@ -426,7 +426,7 @@ module RBS
|
|
|
426
426
|
new_name.hash ^ old_name.hash ^ kind.hash
|
|
427
427
|
end
|
|
428
428
|
|
|
429
|
-
def to_json(state =
|
|
429
|
+
def to_json(state = nil)
|
|
430
430
|
{
|
|
431
431
|
member: :alias,
|
|
432
432
|
new_name: new_name,
|