rbs 3.9.4 → 4.1.1
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/.github/dependabot.yml +16 -14
- data/.github/workflows/bundle-update.yml +63 -0
- data/.github/workflows/c-check.yml +66 -0
- data/.github/workflows/comments.yml +5 -3
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/jruby.yml +79 -0
- data/.github/workflows/release-gems.yml +164 -0
- data/.github/workflows/ruby.yml +84 -30
- data/.github/workflows/rust.yml +186 -0
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +5 -2
- data/.github/workflows/wasm.yml +55 -0
- data/.github/workflows/windows.yml +9 -3
- data/.gitignore +16 -0
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +430 -0
- data/Dockerfile.jruby +53 -0
- data/README.md +41 -4
- data/Rakefile +777 -60
- data/Steepfile +11 -0
- data/config.yml +660 -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 +220 -154
- 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 +2 -1
- 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 +151 -0
- data/docs/rust.md +96 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +48 -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 +1855 -0
- data/ext/rbs_extension/ast_translation.h +41 -0
- data/ext/rbs_extension/class_constants.c +187 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +23 -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 +603 -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 +1047 -0
- data/include/rbs/defines.h +99 -0
- data/include/rbs/lexer.h +207 -0
- data/include/rbs/location.h +40 -0
- data/include/rbs/parser.h +153 -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 +10 -10
- 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 +24 -4
- 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 +121 -65
- data/lib/rbs/definition_builder/method_builder.rb +74 -33
- data/lib/rbs/definition_builder.rb +177 -20
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -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 +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +196 -45
- data/lib/rbs/prototype/runtime.rb +12 -2
- 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 +91 -79
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +44 -8
- 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 +137 -0
- data/lib/rbs/wasm/runtime.rb +196 -0
- data/lib/rbs/wasm/serialization_schema.rb +110 -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 +37 -5
- 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 +50 -0
- data/sig/environment/module_entry.rbs +50 -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 +77 -13
- 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 +10 -8
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +15 -0
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +1628 -0
- data/src/lexer.c +3221 -0
- data/src/lexer.re +155 -0
- data/src/lexstate.c +221 -0
- data/src/location.c +31 -0
- data/src/parser.c +4258 -0
- data/src/serialize.c +958 -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 +21308 -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 +748 -347
- 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 +5 -5
- 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 +3 -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 +1209 -95
- 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_reader.rbs +8 -8
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- data/wasm/README.md +60 -0
- data/wasm/rbs_wasm.c +423 -0
- metadata +131 -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
data/rbs.gemspec
CHANGED
|
@@ -30,20 +30,52 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
31
31
|
`git ls-files -z`.split("\x0").reject do |f|
|
|
32
32
|
[
|
|
33
|
-
%r{^(test|spec|features|bin|steep|benchmark|templates)/},
|
|
34
|
-
/Gemfile
|
|
33
|
+
%r{^(test|spec|features|bin|steep|benchmark|templates|rust|\.vscode)/},
|
|
34
|
+
/Gemfile/,
|
|
35
35
|
].any? {|r| f.match(r) }
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
# JRuby cannot load the MRI C extension. On JRuby (and in the `java` platform
|
|
40
|
+
# gem, built with RBS_PLATFORM=java) RBS runs the WebAssembly-backed parser, so
|
|
41
|
+
# ship the prebuilt parser (built by `rake wasm:build`) and skip the C
|
|
42
|
+
# extension. The Chicory/ASM jars the runtime needs are NOT shipped in the gem:
|
|
43
|
+
# they are declared as `jar-dependencies` requirements below and fetched from
|
|
44
|
+
# Maven Central at install time (see lib/rbs/wasm/jars.rb).
|
|
45
|
+
building_java_gem = ENV["RBS_PLATFORM"] == "java"
|
|
46
|
+
on_jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
|
47
|
+
|
|
48
|
+
if building_java_gem || on_jruby
|
|
49
|
+
# Only stamp the platform when building the release gem; leave it unset for
|
|
50
|
+
# local development on JRuby so it still matches a `ruby` platform lockfile.
|
|
51
|
+
spec.platform = "java" if building_java_gem
|
|
52
|
+
# rbs_parser.wasm is a build artifact (not tracked in git), so add it
|
|
53
|
+
# explicitly. lib/rbs_jars.rb is committed, so git ls-files already has it.
|
|
54
|
+
spec.files += Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
55
|
+
Dir.glob("lib/rbs/wasm/rbs_parser.wasm")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# jar-dependencies (bundled with JRuby) downloads these jars from Maven when
|
|
59
|
+
# the gem is installed, keeping the gem small and avoiding conflicting copies.
|
|
60
|
+
# Only the top-level artifacts are declared; Maven resolves the rest (runtime,
|
|
61
|
+
# wasm, asm, ...) transitively. lib/rbs_jars.rb require_jars the full resolved
|
|
62
|
+
# set at load time.
|
|
63
|
+
spec.add_dependency "jar-dependencies", ">= 0.1.7"
|
|
64
|
+
spec.requirements << "jar com.dylibso.chicory:compiler, 1.7.5"
|
|
65
|
+
spec.requirements << "jar com.dylibso.chicory:wasi, 1.7.5"
|
|
66
|
+
else
|
|
67
|
+
spec.extensions = %w{ext/rbs_extension/extconf.rb}
|
|
68
|
+
end
|
|
39
69
|
|
|
40
70
|
if false
|
|
41
|
-
spec.required_ruby_version = ">= 3.
|
|
71
|
+
spec.required_ruby_version = ">= 3.4"
|
|
42
72
|
end
|
|
43
73
|
|
|
44
74
|
spec.bindir = "exe"
|
|
45
75
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
46
76
|
spec.require_paths = ["lib"]
|
|
47
|
-
spec.required_ruby_version = ">= 3.
|
|
77
|
+
spec.required_ruby_version = ">= 3.2"
|
|
48
78
|
spec.add_dependency "logger"
|
|
79
|
+
spec.add_dependency "prism", ">= 1.6.0"
|
|
80
|
+
spec.add_dependency "tsort"
|
|
49
81
|
end
|
data/schema/typeParam.json
CHANGED
|
@@ -28,9 +28,25 @@
|
|
|
28
28
|
}
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
|
+
"lower_bound": {
|
|
32
|
+
"oneOf": [
|
|
33
|
+
{
|
|
34
|
+
"$ref": "types.json#/definitions/classInstance"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"$ref": "types.json#/definitions/classSingleton"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"$ref": "types.json#/definitions/interface"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "null"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
31
47
|
"location": {
|
|
32
48
|
"$ref": "location.json"
|
|
33
49
|
}
|
|
34
50
|
},
|
|
35
|
-
"required": ["name", "variance", "unchecked", "upper_bound", "location"]
|
|
51
|
+
"required": ["name", "variance", "unchecked", "upper_bound", "lower_bound", "location"]
|
|
36
52
|
}
|
data/sig/ancestor_builder.rbs
CHANGED
|
@@ -146,7 +146,7 @@ module RBS
|
|
|
146
146
|
extended_modules: Array[Definition::Ancestor::Instance]?,
|
|
147
147
|
extended_interfaces: Array[Definition::Ancestor::Instance]?) -> void
|
|
148
148
|
|
|
149
|
-
def mixin_ancestors0: (AST::Declarations::Class | AST::Declarations::Module | AST::Declarations::Interface,
|
|
149
|
+
def mixin_ancestors0: (AST::Declarations::Class | AST::Declarations::Module | AST::Declarations::Interface | AST::Ruby::Declarations::ClassDecl | AST::Ruby::Declarations::ModuleDecl,
|
|
150
150
|
TypeName,
|
|
151
151
|
align_params: Substitution?,
|
|
152
152
|
included_modules: Array[Definition::Ancestor::Instance]?,
|
data/sig/annotate/formatter.rbs
CHANGED
|
@@ -17,8 +17,8 @@ module RBS
|
|
|
17
17
|
|
|
18
18
|
def self.translate: (RDoc::Markup::Document) -> String?
|
|
19
19
|
|
|
20
|
-
def self.each_part: (RDoc::Markup::Document
|
|
21
|
-
| (RDoc::Markup::Document
|
|
20
|
+
def self.each_part: (RDoc::Markup::Document) { (RDoc::Markup::Document) -> void } -> void
|
|
21
|
+
| (RDoc::Markup::Document) -> Enumerator[RDoc::Markup::Document, void]
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -8,16 +8,17 @@ module RBS
|
|
|
8
8
|
|
|
9
9
|
def initialize: (source: RDocSource) -> void
|
|
10
10
|
|
|
11
|
-
def annotate_file: (Pathname
|
|
11
|
+
def annotate_file: (Pathname) -> void
|
|
12
|
+
| %a{deprecated: it preserves the format by default} (Pathname, preserve: bool) -> void
|
|
12
13
|
|
|
13
|
-
def annotate_decls: (Array[AST::Declarations::t], ?outer: Array[Namespace]) -> void
|
|
14
|
+
def annotate_decls: (Array[AST::Declarations::t], Rewriter, ?outer: Array[Namespace]) -> void
|
|
14
15
|
|
|
15
16
|
interface _PathTester
|
|
16
17
|
def test_path: (String) -> bool
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
interface _WithRDocComment
|
|
20
|
-
def comment: () -> (RDoc::
|
|
21
|
+
def comment: () -> (RDoc::Comment | String)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def each_part: (Array[Object & _WithRDocComment], tester: _PathTester) { ([RDoc::Markup::Document, Object & _WithRDocComment]) -> void } -> void
|
|
@@ -50,15 +51,15 @@ module RBS
|
|
|
50
51
|
|
|
51
52
|
def resolve_doc_source: (Annotations::Copy?, tester: _PathTester) { () -> String? } -> String?
|
|
52
53
|
|
|
53
|
-
def annotate_class: (AST::Declarations::Class | AST::Declarations::Module, outer: Array[Namespace]) -> void
|
|
54
|
+
def annotate_class: (AST::Declarations::Class | AST::Declarations::Module, Rewriter, outer: Array[Namespace]) -> void
|
|
54
55
|
|
|
55
|
-
def annotate_constant: (AST::Declarations::Constant, outer: Array[Namespace]) -> void
|
|
56
|
+
def annotate_constant: (AST::Declarations::Constant, Rewriter, outer: Array[Namespace]) -> void
|
|
56
57
|
|
|
57
|
-
def annotate_method: (TypeName, AST::Members::MethodDefinition) -> void
|
|
58
|
+
def annotate_method: (TypeName, AST::Members::MethodDefinition, Rewriter) -> void
|
|
58
59
|
|
|
59
|
-
def annotate_alias: (TypeName, AST::Members::Alias) -> void
|
|
60
|
+
def annotate_alias: (TypeName, AST::Members::Alias, Rewriter) -> void
|
|
60
61
|
|
|
61
|
-
def annotate_attribute: (TypeName, AST::Members::AttrReader | AST::Members::AttrWriter | AST::Members::AttrAccessor) -> void
|
|
62
|
+
def annotate_attribute: (TypeName, AST::Members::AttrReader | AST::Members::AttrWriter | AST::Members::AttrAccessor, Rewriter) -> void
|
|
62
63
|
|
|
63
64
|
def annotations: (_Annotated) -> Annotations
|
|
64
65
|
|
|
@@ -70,10 +71,12 @@ module RBS
|
|
|
70
71
|
# - If empty string is given as `comment`, it deletes the original comment.
|
|
71
72
|
# - If `nil` is given as `comment`, it keeps the original comment.
|
|
72
73
|
#
|
|
73
|
-
def replace_comment: (
|
|
74
|
+
def replace_comment: (_Commented, String?, Rewriter) -> void
|
|
74
75
|
|
|
75
76
|
interface _Commented
|
|
76
|
-
def comment: () -> AST::Comment?
|
|
77
|
+
%a{pure} def comment: () -> AST::Comment?
|
|
78
|
+
%a{pure} def location: () -> Location[untyped, untyped]?
|
|
79
|
+
def annotations: () -> Array[AST::Annotation]
|
|
77
80
|
end
|
|
78
81
|
|
|
79
82
|
def resolve_name: (TypeName, outer: Array[Namespace]) -> TypeName
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
module RBS
|
|
2
|
+
module AST
|
|
3
|
+
module Ruby
|
|
4
|
+
module Annotations
|
|
5
|
+
type leading_annotation = ColonMethodTypeAnnotation
|
|
6
|
+
| MethodTypesAnnotation
|
|
7
|
+
| SkipAnnotation
|
|
8
|
+
| ReturnTypeAnnotation
|
|
9
|
+
| InstanceVariableAnnotation
|
|
10
|
+
| ModuleSelfAnnotation
|
|
11
|
+
| ParamTypeAnnotation
|
|
12
|
+
| SplatParamTypeAnnotation
|
|
13
|
+
| DoubleSplatParamTypeAnnotation
|
|
14
|
+
| BlockParamTypeAnnotation
|
|
15
|
+
|
|
16
|
+
type trailing_annotation = NodeTypeAssertion
|
|
17
|
+
| TypeApplicationAnnotation
|
|
18
|
+
| ClassAliasAnnotation
|
|
19
|
+
| ModuleAliasAnnotation
|
|
20
|
+
|
|
21
|
+
type t = leading_annotation | trailing_annotation
|
|
22
|
+
|
|
23
|
+
class Base
|
|
24
|
+
# Location that covers all of the annotation
|
|
25
|
+
#
|
|
26
|
+
attr_reader location: Location
|
|
27
|
+
|
|
28
|
+
# Location of `@rbs`, `@rbs!`, or `:` prefix
|
|
29
|
+
#
|
|
30
|
+
attr_reader prefix_location: Location
|
|
31
|
+
|
|
32
|
+
def initialize: (Location location, Location prefix_location) -> void
|
|
33
|
+
|
|
34
|
+
def buffer: () -> Buffer
|
|
35
|
+
|
|
36
|
+
# Returns the type fingerprint for this annotation
|
|
37
|
+
def type_fingerprint: () -> untyped
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# `: TYPE` annotation attached to nodes
|
|
41
|
+
#
|
|
42
|
+
class NodeTypeAssertion < Base
|
|
43
|
+
attr_reader type: Types::t
|
|
44
|
+
|
|
45
|
+
def initialize: (location: Location, prefix_location: Location, type: Types::t) -> void
|
|
46
|
+
|
|
47
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
48
|
+
|
|
49
|
+
def type_fingerprint: () -> untyped
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class AliasAnnotation < Base
|
|
53
|
+
attr_reader keyword_location: Location
|
|
54
|
+
|
|
55
|
+
attr_reader type_name_location: Location?
|
|
56
|
+
|
|
57
|
+
# The name of the module that will be the target of the alias
|
|
58
|
+
#
|
|
59
|
+
# - `nil` if the module/class name is unspecified
|
|
60
|
+
# - `TypeName` object if the module/class name is specified
|
|
61
|
+
#
|
|
62
|
+
attr_reader type_name: TypeName?
|
|
63
|
+
|
|
64
|
+
def initialize: (location: Location, prefix_location: Location, keyword_location: Location, type_name: TypeName?, type_name_location: Location?) -> void
|
|
65
|
+
|
|
66
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# `: class-alias` annotation
|
|
70
|
+
#
|
|
71
|
+
# ```
|
|
72
|
+
# : class-alias Foo::Bar
|
|
73
|
+
# ^ -- prefix_location
|
|
74
|
+
# ^^^^^^^^^^^^ -- keyword_location
|
|
75
|
+
# ^^^^^^^^ -- type_name_location
|
|
76
|
+
# ```
|
|
77
|
+
#
|
|
78
|
+
class ClassAliasAnnotation < AliasAnnotation
|
|
79
|
+
def type_fingerprint: () -> untyped
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# `: module-alias` annotation
|
|
83
|
+
#
|
|
84
|
+
# ```
|
|
85
|
+
# : module-alias Foo::Bar
|
|
86
|
+
# ^ -- prefix_location
|
|
87
|
+
# ^^^^^^^^^^^^ -- keyword_location
|
|
88
|
+
# ^^^^^^^^ -- type_name_location
|
|
89
|
+
# ```
|
|
90
|
+
#
|
|
91
|
+
class ModuleAliasAnnotation < AliasAnnotation
|
|
92
|
+
def type_fingerprint: () -> untyped
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# `: METHOD-TYPE` annotation in leading comments
|
|
96
|
+
#
|
|
97
|
+
class ColonMethodTypeAnnotation < Base
|
|
98
|
+
attr_reader annotations: Array[AST::Annotation]
|
|
99
|
+
|
|
100
|
+
attr_reader method_type: MethodType
|
|
101
|
+
|
|
102
|
+
def initialize: (location: Location, prefix_location: Location, annotations: Array[AST::Annotation], method_type: MethodType) -> void
|
|
103
|
+
|
|
104
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
105
|
+
|
|
106
|
+
def type_fingerprint: () -> untyped
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# `@rbs METHOD-TYPEs` annotation in leading comments
|
|
110
|
+
#
|
|
111
|
+
# ```
|
|
112
|
+
# @rbs () -> void | %a{foo} () -> String | ...
|
|
113
|
+
# ^^^^ -- prefix_location
|
|
114
|
+
# ^ -- vertical_bar_locations[0]
|
|
115
|
+
# ^ -- vertical_bar_locations[1]
|
|
116
|
+
# ^^^ -- dot3_location
|
|
117
|
+
# ```
|
|
118
|
+
class MethodTypesAnnotation < Base
|
|
119
|
+
class Overload = AST::Members::MethodDefinition::Overload
|
|
120
|
+
|
|
121
|
+
attr_reader overloads: Array[Overload]
|
|
122
|
+
|
|
123
|
+
attr_reader vertical_bar_locations: Array[Location]
|
|
124
|
+
|
|
125
|
+
attr_reader dot3_location: Location?
|
|
126
|
+
|
|
127
|
+
def initialize: (location: Location, prefix_location: Location, overloads: Array[Overload], vertical_bar_locations: Array[Location], dot3_location: Location?) -> void
|
|
128
|
+
|
|
129
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
130
|
+
|
|
131
|
+
def type_fingerprint: () -> untyped
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# `@rbs skip -- comment` annotation in leading comments
|
|
135
|
+
#
|
|
136
|
+
class SkipAnnotation < Base
|
|
137
|
+
attr_reader skip_location: Location
|
|
138
|
+
attr_reader comment_location: Location?
|
|
139
|
+
|
|
140
|
+
def initialize: (location: Location, prefix_location: Location, skip_location: Location, comment_location: Location?) -> void
|
|
141
|
+
|
|
142
|
+
def type_fingerprint: () -> untyped
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# `@rbs return: T -- comment` annotation in leading comments
|
|
146
|
+
#
|
|
147
|
+
# ```
|
|
148
|
+
# @rbs return: String -- Returns a string
|
|
149
|
+
# ^^^ -- prefix_location
|
|
150
|
+
# ^^^^^^ -- return_location
|
|
151
|
+
# ^ -- colon_location
|
|
152
|
+
# ^^^^^^^^^^^^^^^^^^^ -- comment
|
|
153
|
+
# ```
|
|
154
|
+
class ReturnTypeAnnotation < Base
|
|
155
|
+
attr_reader return_location: Location
|
|
156
|
+
|
|
157
|
+
attr_reader colon_location: Location
|
|
158
|
+
|
|
159
|
+
attr_reader return_type: Types::t
|
|
160
|
+
|
|
161
|
+
attr_reader comment_location: Location?
|
|
162
|
+
|
|
163
|
+
def initialize: (
|
|
164
|
+
location: Location,
|
|
165
|
+
prefix_location: Location,
|
|
166
|
+
return_location: Location,
|
|
167
|
+
colon_location: Location,
|
|
168
|
+
return_type: Types::t,
|
|
169
|
+
comment_location: Location?,
|
|
170
|
+
) -> void
|
|
171
|
+
|
|
172
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
173
|
+
|
|
174
|
+
def type_fingerprint: () -> untyped
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# `[T1, T2, ...]` annotation in trailing comments
|
|
178
|
+
#
|
|
179
|
+
# ```
|
|
180
|
+
# #[String, Integer]
|
|
181
|
+
# ^ -- prefix_location
|
|
182
|
+
# ^ -- comma_locations[0]
|
|
183
|
+
# ^ -- close_bracket_location
|
|
184
|
+
# ```
|
|
185
|
+
#
|
|
186
|
+
class TypeApplicationAnnotation < Base
|
|
187
|
+
attr_reader type_args: Array[Types::t]
|
|
188
|
+
|
|
189
|
+
attr_reader close_bracket_location: Location
|
|
190
|
+
|
|
191
|
+
attr_reader comma_locations: Array[Location]
|
|
192
|
+
|
|
193
|
+
def initialize: (
|
|
194
|
+
location: Location,
|
|
195
|
+
prefix_location: Location,
|
|
196
|
+
type_args: Array[Types::t],
|
|
197
|
+
close_bracket_location: Location,
|
|
198
|
+
comma_locations: Array[Location],
|
|
199
|
+
) -> void
|
|
200
|
+
|
|
201
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
202
|
+
|
|
203
|
+
def type_fingerprint: () -> untyped
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# `@rbs IVAR-NAME : TYPE` annotation in leading comments
|
|
207
|
+
#
|
|
208
|
+
# ```
|
|
209
|
+
# @rbs @foo : String -- comment
|
|
210
|
+
# ^^^^ -- prefix_location
|
|
211
|
+
# ^^^^ -- ivar_name_location
|
|
212
|
+
# ^ -- colon_location
|
|
213
|
+
# ^^^^^^^^^^ -- comment_location
|
|
214
|
+
# ```
|
|
215
|
+
class InstanceVariableAnnotation < Base
|
|
216
|
+
attr_reader ivar_name: Symbol
|
|
217
|
+
|
|
218
|
+
attr_reader ivar_name_location: Location
|
|
219
|
+
|
|
220
|
+
attr_reader colon_location: Location
|
|
221
|
+
|
|
222
|
+
attr_reader type: Types::t
|
|
223
|
+
|
|
224
|
+
attr_reader comment_location: Location?
|
|
225
|
+
|
|
226
|
+
def initialize: (
|
|
227
|
+
location: Location,
|
|
228
|
+
prefix_location: Location,
|
|
229
|
+
ivar_name: Symbol,
|
|
230
|
+
ivar_name_location: Location,
|
|
231
|
+
colon_location: Location,
|
|
232
|
+
type: Types::t,
|
|
233
|
+
comment_location: Location?,
|
|
234
|
+
) -> void
|
|
235
|
+
|
|
236
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
237
|
+
|
|
238
|
+
def type_fingerprint: () -> untyped
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# `@rbs module-self: NAME[ARGS] -- comment` annotation in leading comments
|
|
242
|
+
#
|
|
243
|
+
# ```
|
|
244
|
+
# @rbs module-self: _Each[String, Integer] -- comment
|
|
245
|
+
# ^^^^ -- prefix_location
|
|
246
|
+
# ^^^^^^^^^^^ -- keyword_location
|
|
247
|
+
# ^ -- colon_location
|
|
248
|
+
# ^ -- open_bracket_location
|
|
249
|
+
# ^ -- args_comma_locations[0]
|
|
250
|
+
# ^ -- close_bracket_location
|
|
251
|
+
# ^^^^^^^^^^ -- comment_location
|
|
252
|
+
# ```
|
|
253
|
+
#
|
|
254
|
+
class ModuleSelfAnnotation < Base
|
|
255
|
+
attr_reader keyword_location: Location
|
|
256
|
+
|
|
257
|
+
attr_reader colon_location: Location
|
|
258
|
+
|
|
259
|
+
attr_reader name: TypeName
|
|
260
|
+
|
|
261
|
+
attr_reader args: Array[Types::t]
|
|
262
|
+
|
|
263
|
+
attr_reader open_bracket_location: Location?
|
|
264
|
+
|
|
265
|
+
attr_reader close_bracket_location: Location?
|
|
266
|
+
|
|
267
|
+
attr_reader args_comma_locations: Array[Location]
|
|
268
|
+
|
|
269
|
+
attr_reader comment_location: Location?
|
|
270
|
+
|
|
271
|
+
def initialize: (
|
|
272
|
+
location: Location,
|
|
273
|
+
prefix_location: Location,
|
|
274
|
+
keyword_location: Location,
|
|
275
|
+
colon_location: Location,
|
|
276
|
+
name: TypeName,
|
|
277
|
+
args: Array[Types::t],
|
|
278
|
+
open_bracket_location: Location?,
|
|
279
|
+
close_bracket_location: Location?,
|
|
280
|
+
args_comma_locations: Array[Location],
|
|
281
|
+
comment_location: Location?,
|
|
282
|
+
) -> void
|
|
283
|
+
|
|
284
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
285
|
+
|
|
286
|
+
def type_fingerprint: () -> untyped
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
class ParamTypeAnnotation < Base
|
|
290
|
+
attr_reader name_location: Location
|
|
291
|
+
|
|
292
|
+
attr_reader colon_location: Location
|
|
293
|
+
|
|
294
|
+
attr_reader param_type: Types::t
|
|
295
|
+
|
|
296
|
+
attr_reader comment_location: Location?
|
|
297
|
+
|
|
298
|
+
def initialize: (
|
|
299
|
+
location: Location,
|
|
300
|
+
prefix_location: Location,
|
|
301
|
+
name_location: Location,
|
|
302
|
+
colon_location: Location,
|
|
303
|
+
param_type: Types::t,
|
|
304
|
+
comment_location: Location?,
|
|
305
|
+
) -> void
|
|
306
|
+
|
|
307
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
308
|
+
|
|
309
|
+
def type_fingerprint: () -> untyped
|
|
310
|
+
|
|
311
|
+
%a{pure}
|
|
312
|
+
def name: () -> Symbol
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# `@rbs *name: Type -- comment` annotation in leading comments
|
|
316
|
+
#
|
|
317
|
+
# ```
|
|
318
|
+
# @rbs *a: String -- comment
|
|
319
|
+
# ^^^^ -- prefix_location
|
|
320
|
+
# ^ -- star_location
|
|
321
|
+
# ^ -- name_location
|
|
322
|
+
# ^ -- colon_location
|
|
323
|
+
# ^^^^^^^^^^ -- comment_location
|
|
324
|
+
# ```
|
|
325
|
+
#
|
|
326
|
+
# ```
|
|
327
|
+
# @rbs *: String
|
|
328
|
+
# ^^^^ -- prefix_location
|
|
329
|
+
# ^ -- star_location
|
|
330
|
+
# ^ -- colon_location
|
|
331
|
+
# ```
|
|
332
|
+
#
|
|
333
|
+
class SplatParamTypeAnnotation < Base
|
|
334
|
+
attr_reader star_location: Location
|
|
335
|
+
|
|
336
|
+
attr_reader name_location: Location?
|
|
337
|
+
|
|
338
|
+
attr_reader colon_location: Location
|
|
339
|
+
|
|
340
|
+
attr_reader param_type: Types::t
|
|
341
|
+
|
|
342
|
+
attr_reader comment_location: Location?
|
|
343
|
+
|
|
344
|
+
def initialize: (
|
|
345
|
+
location: Location,
|
|
346
|
+
prefix_location: Location,
|
|
347
|
+
star_location: Location,
|
|
348
|
+
name_location: Location?,
|
|
349
|
+
colon_location: Location,
|
|
350
|
+
param_type: Types::t,
|
|
351
|
+
comment_location: Location?,
|
|
352
|
+
) -> void
|
|
353
|
+
|
|
354
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
355
|
+
|
|
356
|
+
def type_fingerprint: () -> untyped
|
|
357
|
+
|
|
358
|
+
%a{pure}
|
|
359
|
+
def name: () -> Symbol?
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# `@rbs **name: Type -- comment` annotation in leading comments
|
|
363
|
+
#
|
|
364
|
+
# ```
|
|
365
|
+
# @rbs **b: bool -- comment
|
|
366
|
+
# ^^^^ -- prefix_location
|
|
367
|
+
# ^^ -- star2_location
|
|
368
|
+
# ^ -- name_location
|
|
369
|
+
# ^ -- colon_location
|
|
370
|
+
# ^^^^^^^^^^ -- comment_location
|
|
371
|
+
# ```
|
|
372
|
+
#
|
|
373
|
+
# ```
|
|
374
|
+
# @rbs **: bool
|
|
375
|
+
# ^^^^ -- prefix_location
|
|
376
|
+
# ^^ -- star2_location
|
|
377
|
+
# ^ -- colon_location
|
|
378
|
+
# ```
|
|
379
|
+
#
|
|
380
|
+
class DoubleSplatParamTypeAnnotation < Base
|
|
381
|
+
attr_reader star2_location: Location
|
|
382
|
+
|
|
383
|
+
attr_reader name_location: Location?
|
|
384
|
+
|
|
385
|
+
attr_reader colon_location: Location
|
|
386
|
+
|
|
387
|
+
attr_reader param_type: Types::t
|
|
388
|
+
|
|
389
|
+
attr_reader comment_location: Location?
|
|
390
|
+
|
|
391
|
+
def initialize: (
|
|
392
|
+
location: Location,
|
|
393
|
+
prefix_location: Location,
|
|
394
|
+
star2_location: Location,
|
|
395
|
+
name_location: Location?,
|
|
396
|
+
colon_location: Location,
|
|
397
|
+
param_type: Types::t,
|
|
398
|
+
comment_location: Location?,
|
|
399
|
+
) -> void
|
|
400
|
+
|
|
401
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
402
|
+
|
|
403
|
+
def type_fingerprint: () -> untyped
|
|
404
|
+
|
|
405
|
+
%a{pure}
|
|
406
|
+
def name: () -> Symbol?
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
# `@rbs &name: TYPE -- comment` annotation in leading comments
|
|
410
|
+
#
|
|
411
|
+
# ```
|
|
412
|
+
# @rbs &block: () -> void -- comment
|
|
413
|
+
# ^^^^ -- prefix_location
|
|
414
|
+
# ^ -- ampersand_location
|
|
415
|
+
# ^^^^^ -- name_location
|
|
416
|
+
# ^ -- colon_location
|
|
417
|
+
# ^^^^^^^^^^ -- type_location
|
|
418
|
+
# ^^^^^^^^^^ -- comment_location
|
|
419
|
+
# ```
|
|
420
|
+
#
|
|
421
|
+
# ```
|
|
422
|
+
# @rbs &: ? () -> void
|
|
423
|
+
# ^^^^ -- prefix_location
|
|
424
|
+
# ^ -- ampersand_location
|
|
425
|
+
# ^ -- colon_location
|
|
426
|
+
# ^ -- question_location
|
|
427
|
+
# ^^^^^^^^^^ -- type_location
|
|
428
|
+
# ```
|
|
429
|
+
#
|
|
430
|
+
class BlockParamTypeAnnotation < Base
|
|
431
|
+
attr_reader ampersand_location: Location
|
|
432
|
+
|
|
433
|
+
attr_reader name_location: Location?
|
|
434
|
+
|
|
435
|
+
attr_reader colon_location: Location
|
|
436
|
+
|
|
437
|
+
attr_reader type_location: Location
|
|
438
|
+
|
|
439
|
+
attr_reader type: Types::function
|
|
440
|
+
|
|
441
|
+
attr_reader question_location: Location?
|
|
442
|
+
|
|
443
|
+
attr_reader comment_location: Location?
|
|
444
|
+
|
|
445
|
+
def initialize: (
|
|
446
|
+
location: Location,
|
|
447
|
+
prefix_location: Location,
|
|
448
|
+
ampersand_location: Location,
|
|
449
|
+
name_location: Location?,
|
|
450
|
+
colon_location: Location,
|
|
451
|
+
question_location: Location?,
|
|
452
|
+
type_location: Location,
|
|
453
|
+
type: Types::function,
|
|
454
|
+
comment_location: Location?,
|
|
455
|
+
) -> void
|
|
456
|
+
|
|
457
|
+
def map_type_name: () { (TypeName) -> TypeName } -> self
|
|
458
|
+
|
|
459
|
+
def type_fingerprint: () -> untyped
|
|
460
|
+
|
|
461
|
+
%a{pure} def name: () -> Symbol?
|
|
462
|
+
|
|
463
|
+
def optional?: () -> bool
|
|
464
|
+
|
|
465
|
+
def required?: () -> bool
|
|
466
|
+
end
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
end
|