steep 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +27 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +48 -90
- data/Rakefile +10 -6
- data/Steepfile +1 -0
- data/bin/setup +1 -0
- data/bin/smoke_runner.rb +9 -14
- data/exe/rbs +3 -0
- data/exe/ruby-signature +3 -0
- data/exe/steep +1 -0
- data/lib/steep.rb +32 -26
- data/lib/steep/annotation_parser.rb +167 -0
- data/lib/steep/ast/annotation/collection.rb +7 -7
- data/lib/steep/ast/types.rb +60 -0
- data/lib/steep/ast/types/any.rb +1 -1
- data/lib/steep/ast/types/factory.rb +535 -0
- data/lib/steep/ast/types/name.rb +3 -3
- data/lib/steep/ast/types/var.rb +1 -1
- data/lib/steep/cli.rb +56 -240
- data/lib/steep/drivers/annotations.rb +36 -19
- data/lib/steep/drivers/check.rb +55 -91
- data/lib/steep/drivers/init.rb +54 -0
- data/lib/steep/drivers/langserver.rb +241 -150
- data/lib/steep/drivers/print_project.rb +56 -0
- data/lib/steep/drivers/signature_error_printer.rb +25 -0
- data/lib/steep/drivers/trace_printer.rb +25 -0
- data/lib/steep/drivers/utils/driver_helper.rb +26 -0
- data/lib/steep/drivers/validate.rb +18 -38
- data/lib/steep/drivers/vendor.rb +46 -0
- data/lib/steep/drivers/watch.rb +78 -140
- data/lib/steep/errors.rb +22 -13
- data/lib/steep/interface/interface.rb +91 -0
- data/lib/steep/interface/method.rb +0 -4
- data/lib/steep/interface/method_type.rb +362 -2
- data/lib/steep/interface/substitution.rb +22 -0
- data/lib/steep/project.rb +25 -233
- data/lib/steep/project/dsl.rb +132 -0
- data/lib/steep/project/file.rb +93 -76
- data/lib/steep/project/file_loader.rb +63 -0
- data/lib/steep/project/options.rb +7 -0
- data/lib/steep/project/target.rb +190 -0
- data/lib/steep/signature/errors.rb +25 -77
- data/lib/steep/signature/validator.rb +122 -0
- data/lib/steep/source.rb +12 -7
- data/lib/steep/subtyping/check.rb +357 -633
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/subtyping/trace.rb +23 -0
- data/lib/steep/type_construction.rb +509 -455
- data/lib/steep/type_inference/constant_env.rb +16 -24
- data/lib/steep/type_inference/type_env.rb +26 -18
- data/lib/steep/version.rb +1 -1
- data/sample/Steepfile +6 -0
- data/sample/lib/conference.rb +12 -0
- data/sample/sig/conference.rbs +6 -0
- data/smoke/alias/Steepfile +4 -0
- data/smoke/alias/a.rb +2 -2
- data/smoke/alias/{a.rbi → a.rbs} +1 -1
- data/smoke/and/Steepfile +4 -0
- data/smoke/array/Steepfile +4 -0
- data/smoke/array/a.rb +2 -2
- data/smoke/array/b.rb +4 -4
- data/smoke/array/c.rb +2 -2
- data/smoke/block/Steepfile +5 -0
- data/smoke/block/{a.rbi → a.rbs} +1 -1
- data/smoke/block/{c.rbi → c.rbs} +0 -0
- data/smoke/block/d.rb +6 -6
- data/smoke/case/Steepfile +4 -0
- data/smoke/case/a.rb +4 -3
- data/smoke/class/Steepfile +4 -0
- data/smoke/class/a.rb +1 -4
- data/smoke/class/a.rbs +24 -0
- data/smoke/class/h.rb +6 -2
- data/smoke/class/{h.rbi → h.rbs} +1 -2
- data/smoke/class/i.rb +1 -2
- data/smoke/class/i.rbs +9 -0
- data/smoke/const/Steepfile +4 -0
- data/smoke/dstr/Steepfile +4 -0
- data/smoke/ensure/Steepfile +4 -0
- data/smoke/ensure/a.rb +1 -1
- data/smoke/enumerator/Steepfile +4 -0
- data/smoke/enumerator/a.rb +7 -7
- data/smoke/enumerator/b.rb +6 -6
- data/smoke/extension/Steepfile +4 -0
- data/smoke/extension/{a.rbi → a.rbs} +2 -2
- data/smoke/extension/{e.rbi → e.rbs} +2 -2
- data/smoke/hash/Steepfile +4 -0
- data/smoke/hash/{a.rbi → a.rbs} +0 -0
- data/smoke/hash/b.rb +2 -2
- data/smoke/hash/c.rb +1 -1
- data/smoke/hash/e.rbs +3 -0
- data/smoke/hash/f.rb +1 -1
- data/smoke/hello/Steepfile +4 -0
- data/smoke/hello/hello.rbs +7 -0
- data/smoke/if/Steepfile +4 -0
- data/smoke/implements/Steepfile +4 -0
- data/smoke/implements/a.rbs +6 -0
- data/smoke/initialize/Steepfile +4 -0
- data/smoke/initialize/a.rbs +3 -0
- data/smoke/integer/Steepfile +4 -0
- data/smoke/integer/a.rb +5 -3
- data/smoke/interface/Steepfile +4 -0
- data/smoke/interface/{a.rbi → a.rbs} +0 -0
- data/smoke/kwbegin/Steepfile +4 -0
- data/smoke/lambda/Steepfile +4 -0
- data/smoke/lambda/a.rb +9 -2
- data/smoke/literal/Steepfile +4 -0
- data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
- data/smoke/map/Steepfile +4 -0
- data/smoke/map/a.rb +1 -1
- data/smoke/method/Steepfile +4 -0
- data/smoke/method/{a.rbi → a.rbs} +0 -0
- data/smoke/method/b.rb +1 -4
- data/smoke/method/d.rb +1 -0
- data/smoke/method/d.rbs +3 -0
- data/smoke/module/Steepfile +4 -0
- data/smoke/module/a.rb +1 -1
- data/smoke/module/a.rbs +16 -0
- data/smoke/module/c.rb +1 -1
- data/smoke/regexp/Steepfile +4 -0
- data/smoke/regexp/a.rb +2 -2
- data/smoke/regexp/b.rb +16 -16
- data/smoke/regression/Steepfile +5 -0
- data/smoke/regression/array.rb +2 -2
- data/smoke/regression/hash.rb +2 -2
- data/smoke/regression/poly_new.rb +2 -0
- data/smoke/regression/poly_new.rbs +4 -0
- data/smoke/regression/set_divide.rb +2 -2
- data/smoke/rescue/Steepfile +4 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +4 -0
- data/smoke/self/a.rbs +4 -0
- data/smoke/skip/Steepfile +4 -0
- data/smoke/stdout/Steepfile +4 -0
- data/smoke/stdout/{a.rbi → a.rbs} +1 -1
- data/smoke/super/Steepfile +4 -0
- data/smoke/super/a.rbs +10 -0
- data/smoke/type_case/Steepfile +4 -0
- data/smoke/type_case/a.rb +1 -1
- data/smoke/yield/Steepfile +4 -0
- data/smoke/yield/a.rb +2 -2
- data/steep.gemspec +14 -7
- data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
- data/vendor/ruby-signature/.gitignore +12 -0
- data/vendor/ruby-signature/.rubocop.yml +15 -0
- data/vendor/ruby-signature/BSDL +22 -0
- data/vendor/ruby-signature/COPYING +56 -0
- data/vendor/ruby-signature/Gemfile +6 -0
- data/vendor/ruby-signature/README.md +93 -0
- data/vendor/ruby-signature/Rakefile +66 -0
- data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
- data/vendor/ruby-signature/bin/console +14 -0
- data/vendor/ruby-signature/bin/query-rdoc +103 -0
- data/vendor/ruby-signature/bin/setup +10 -0
- data/vendor/ruby-signature/bin/sort +88 -0
- data/vendor/ruby-signature/bin/test_runner.rb +17 -0
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
- data/vendor/ruby-signature/docs/sigs.md +148 -0
- data/vendor/ruby-signature/docs/stdlib.md +152 -0
- data/vendor/ruby-signature/docs/syntax.md +528 -0
- data/vendor/ruby-signature/exe/rbs +3 -0
- data/vendor/ruby-signature/exe/ruby-signature +7 -0
- data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
- data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
- data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
- data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +244 -54
- data/.travis.yml +0 -7
- data/lib/steep/ast/signature/alias.rb +0 -19
- data/lib/steep/ast/signature/class.rb +0 -33
- data/lib/steep/ast/signature/const.rb +0 -17
- data/lib/steep/ast/signature/env.rb +0 -138
- data/lib/steep/ast/signature/extension.rb +0 -21
- data/lib/steep/ast/signature/gvar.rb +0 -17
- data/lib/steep/ast/signature/interface.rb +0 -31
- data/lib/steep/ast/signature/members.rb +0 -115
- data/lib/steep/ast/signature/module.rb +0 -21
- data/lib/steep/drivers/print_interface.rb +0 -94
- data/lib/steep/drivers/scaffold.rb +0 -321
- data/lib/steep/drivers/utils/each_signature.rb +0 -31
- data/lib/steep/interface/abstract.rb +0 -68
- data/lib/steep/interface/builder.rb +0 -637
- data/lib/steep/interface/instantiated.rb +0 -163
- data/lib/steep/interface/ivar_chain.rb +0 -26
- data/lib/steep/parser.y +0 -1278
- data/lib/steep/project/listener.rb +0 -53
- data/smoke/class/a.rbi +0 -24
- data/smoke/class/d.rb +0 -9
- data/smoke/class/e.rb +0 -12
- data/smoke/class/i.rbi +0 -9
- data/smoke/hash/e.rbi +0 -3
- data/smoke/hello/hello.rbi +0 -7
- data/smoke/implements/a.rbi +0 -6
- data/smoke/initialize/a.rbi +0 -3
- data/smoke/module/a.rbi +0 -16
- data/smoke/self/a.rbi +0 -4
- data/smoke/super/a.rbi +0 -10
- data/stdlib/builtin.rbi +0 -787
data/smoke/regression/array.rb
CHANGED
data/smoke/regression/hash.rb
CHANGED
data/smoke/rescue/a.rb
CHANGED
@@ -34,7 +34,7 @@ d = begin
|
|
34
34
|
|
35
35
|
# @type var e: Integer
|
36
36
|
|
37
|
-
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array
|
37
|
+
# !expects IncompatibleAssignment: lhs_type=::Integer, rhs_type=(::Array[::Integer] | ::Integer | ::String | ::Symbol)
|
38
38
|
e = begin
|
39
39
|
'foo'
|
40
40
|
rescue RuntimeError
|
data/smoke/self/a.rbs
ADDED
data/smoke/super/a.rbs
ADDED
data/smoke/type_case/a.rb
CHANGED
data/smoke/yield/a.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class A
|
2
|
-
# @type method foo: () { (Integer) -> Integer } ->
|
2
|
+
# @type method foo: () { (Integer) -> Integer } -> untyped
|
3
3
|
def foo()
|
4
4
|
# @type var x: String
|
5
5
|
|
@@ -10,7 +10,7 @@ class A
|
|
10
10
|
yield(x)
|
11
11
|
end
|
12
12
|
|
13
|
-
# @type method bar: () ->
|
13
|
+
# @type method bar: () -> untyped
|
14
14
|
def bar()
|
15
15
|
# !expects UnexpectedYield
|
16
16
|
yield 4
|
data/steep.gemspec
CHANGED
@@ -14,26 +14,33 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/soutaro/steep"
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject {|f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
|
-
|
20
|
-
|
19
|
+
} + Dir.chdir("vendor/ruby-signature") {
|
20
|
+
`git ls-files -z`.split("\x0")
|
21
|
+
.reject {|f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
.map {|f| File.join("vendor/ruby-signature", f) }
|
23
|
+
}
|
24
|
+
spec.files << "vendor/ruby-signature/lib/ruby/signature/parser.rb"
|
25
|
+
|
21
26
|
spec.bindir = "exe"
|
22
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
28
|
spec.require_paths = ["lib"]
|
24
29
|
|
25
|
-
spec.required_ruby_version = '>= 2.
|
30
|
+
spec.required_ruby_version = '>= 2.6.0'
|
26
31
|
|
27
32
|
spec.add_development_dependency "bundler", ">= 1.13"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
34
|
spec.add_development_dependency "minitest", "~> 5.0"
|
30
35
|
spec.add_development_dependency "racc", "~> 1.4"
|
36
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.3.6"
|
37
|
+
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
31
38
|
|
32
|
-
spec.add_runtime_dependency "parser", "~> 2.
|
39
|
+
spec.add_runtime_dependency "parser", "~> 2.7.0"
|
33
40
|
spec.add_runtime_dependency "ast_utils", "~> 0.3.0"
|
34
41
|
spec.add_runtime_dependency "activesupport", ">= 5.1"
|
35
42
|
spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
|
36
43
|
spec.add_runtime_dependency "listen", "~> 3.1"
|
37
44
|
spec.add_runtime_dependency "pry", "~> 0.12.2"
|
38
|
-
spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0"
|
45
|
+
spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0.1"
|
39
46
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request: {}
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: "ubuntu-latest"
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
container_tag:
|
15
|
+
- master-nightly-bionic
|
16
|
+
- 2.6.5-bionic
|
17
|
+
- 2.7.0-bionic
|
18
|
+
container:
|
19
|
+
image: rubylang/ruby:${{ matrix.container_tag }}
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v1
|
22
|
+
- name: Run test
|
23
|
+
run: |
|
24
|
+
ruby -v
|
25
|
+
gem install bundler
|
26
|
+
bundle install --jobs 4 --retry 3
|
27
|
+
bundle exec rake
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require: rubocop-rubycw
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.7
|
4
|
+
DisabledByDefault: true
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/bundle/**/*'
|
7
|
+
Rubycw/Rubycw:
|
8
|
+
Enabled: true
|
9
|
+
Exclude:
|
10
|
+
- 'test/**/*_test.rb'
|
11
|
+
|
12
|
+
Lint/DuplicateMethods:
|
13
|
+
Enabled: true
|
14
|
+
Include:
|
15
|
+
- 'test/**/*_test.rb'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 2019 Soutaro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
ruby-signature is copyrighted free software by Soutaro Matsumoto <matsumoto@soutaro.com>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# Ruby::Signature
|
2
|
+
|
3
|
+
Ruby::Signature provides syntax and semantics definition for the `Ruby Signature` language, `.rbs` files.
|
4
|
+
It consists of a parser, the syntax, and class definition interpreter, the semantics.
|
5
|
+
|
6
|
+
## Build
|
7
|
+
|
8
|
+
We haven't published a gem yet.
|
9
|
+
You need to install the dependencies, and build its parser with `bin/setup`.
|
10
|
+
|
11
|
+
```
|
12
|
+
$ bin/setup
|
13
|
+
$ bundle exec exe/ruby-signature
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```
|
19
|
+
$ ruby-signature list
|
20
|
+
$ ruby-signature ancestors ::Object
|
21
|
+
$ ruby-signature methods ::Object
|
22
|
+
$ ruby-signature method ::Object tap
|
23
|
+
```
|
24
|
+
|
25
|
+
### ruby-signature [--class|--module|interface] list
|
26
|
+
|
27
|
+
```
|
28
|
+
$ ruby-signature list
|
29
|
+
```
|
30
|
+
|
31
|
+
This command lists all of the classes/modules/interfaces defined in `.rbs` files.
|
32
|
+
|
33
|
+
### ruby-signature ancestors [--singleton|--instance] CLASS
|
34
|
+
|
35
|
+
```
|
36
|
+
$ ruby-signature ancestors Array # ([].class.ancestors)
|
37
|
+
$ ruby-signature ancestors --singleton Array # (Array.class.ancestors)
|
38
|
+
```
|
39
|
+
|
40
|
+
This command prints the _ancestors_ of the class.
|
41
|
+
The name of the command is borrowed from `Class#ancestors`, but the semantics is a bit different.
|
42
|
+
The `ancestors` command is more precise (I believe).
|
43
|
+
|
44
|
+
### ruby-signature methods [--singleton|--instance] CLASS
|
45
|
+
|
46
|
+
```
|
47
|
+
$ ruby-signature methods ::Integer # 1.methods
|
48
|
+
$ ruby-signature methods --singleton ::Object # Object.methods
|
49
|
+
```
|
50
|
+
|
51
|
+
This command prints all methods provided for the class.
|
52
|
+
|
53
|
+
### ruby-signature method [--singleton|--instance] CLASS METHOD
|
54
|
+
|
55
|
+
```
|
56
|
+
$ ruby-signature method ::Integer '+' # 1+2
|
57
|
+
$ ruby-signature method --singleton ::Object tap # Object.tap { ... }
|
58
|
+
```
|
59
|
+
|
60
|
+
This command prints type and properties of the method.
|
61
|
+
|
62
|
+
### Options
|
63
|
+
|
64
|
+
It accepts two global options, `-r` and `-I`.
|
65
|
+
|
66
|
+
`-r` is for libraries. You can specify the names of libraries.
|
67
|
+
|
68
|
+
```
|
69
|
+
$ ruby-signature -r set list
|
70
|
+
```
|
71
|
+
|
72
|
+
`-I` is for application signatures. You can specify the name of directory.
|
73
|
+
|
74
|
+
```
|
75
|
+
$ ruby-signature -I sig list
|
76
|
+
```
|
77
|
+
|
78
|
+
## Guides
|
79
|
+
|
80
|
+
- [Standard library signature contribution guide](docs/CONTRIBUTING.md)
|
81
|
+
- [Writing signatures guide](docs/sigs.md)
|
82
|
+
- [Stdlib signatures guide](docs/stdlib.md)
|
83
|
+
- [Syntax](docs/syntax.md)
|
84
|
+
|
85
|
+
## Development
|
86
|
+
|
87
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
88
|
+
|
89
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby-signature.
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"].reject do |path|
|
8
|
+
path =~ %r{test/stdlib/}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => [:test, :stdlib_test, :rubocop, :validate]
|
13
|
+
|
14
|
+
task :validate do
|
15
|
+
sh "rbs validate"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :stdlib_test do
|
19
|
+
FileList["test/stdlib/*_test.rb"].each do |test|
|
20
|
+
sh "ruby bin/test_runner.rb #{test}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :rubocop do
|
25
|
+
sh "rubocop --parallel"
|
26
|
+
end
|
27
|
+
|
28
|
+
rule ".rb" => ".y" do |t|
|
29
|
+
sh "racc -v -o #{t.name} #{t.source}"
|
30
|
+
end
|
31
|
+
|
32
|
+
task :parser => "lib/ruby/signature/parser.rb"
|
33
|
+
task :test => :parser
|
34
|
+
task :stdlib_test => :parser
|
35
|
+
task :build => :parser
|
36
|
+
|
37
|
+
namespace :generate do
|
38
|
+
task :stdlib_test, [:class] do |_task, args|
|
39
|
+
klass = args.fetch(:class) do
|
40
|
+
raise "Class name is necessary. e.g. rake 'generate:stdlib_test[String]'"
|
41
|
+
end
|
42
|
+
|
43
|
+
path = Pathname("test/stdlib/#{klass}_test.rb")
|
44
|
+
raise "#{path} already exists!" if path.exist?
|
45
|
+
|
46
|
+
path.write <<~RUBY
|
47
|
+
require_relative "test_helper"
|
48
|
+
|
49
|
+
class #{klass}Test < StdlibTest
|
50
|
+
target #{klass}
|
51
|
+
# library "pathname", "set", "securerandom" # Declare library signatures to load
|
52
|
+
using hook.refinement
|
53
|
+
|
54
|
+
# def test_method_name
|
55
|
+
# # Call the method
|
56
|
+
# method_name(arg)
|
57
|
+
# method_name(arg, arg2)
|
58
|
+
# end
|
59
|
+
end
|
60
|
+
RUBY
|
61
|
+
|
62
|
+
puts "Created: #{path}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
CLEAN.include("lib/ruby/signature/parser.rb")
|