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/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Alias
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :params
|
8
|
-
attr_reader :type
|
9
|
-
|
10
|
-
def initialize(location:, name:, params:, type:)
|
11
|
-
@location = location
|
12
|
-
@name = name
|
13
|
-
@params = params
|
14
|
-
@type = type
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class SuperClass
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :args
|
8
|
-
|
9
|
-
def initialize(name:, args:, location:)
|
10
|
-
@name = name
|
11
|
-
@args = args
|
12
|
-
@location = location
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Class
|
17
|
-
attr_reader :location
|
18
|
-
attr_reader :name
|
19
|
-
attr_reader :params
|
20
|
-
attr_reader :super_class
|
21
|
-
attr_reader :members
|
22
|
-
|
23
|
-
def initialize(name:, params:, super_class:, location:, members:)
|
24
|
-
@name = name
|
25
|
-
@params = params
|
26
|
-
@super_class = super_class
|
27
|
-
@location = location
|
28
|
-
@members = members
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Const
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :type
|
8
|
-
|
9
|
-
def initialize(location:, name:, type:)
|
10
|
-
@location = location
|
11
|
-
@name = name
|
12
|
-
@type = type
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Env
|
5
|
-
attr_reader :modules
|
6
|
-
attr_reader :classes
|
7
|
-
attr_reader :extensions
|
8
|
-
attr_reader :interfaces
|
9
|
-
attr_reader :constants
|
10
|
-
attr_reader :globals
|
11
|
-
attr_reader :aliases
|
12
|
-
|
13
|
-
def initialize()
|
14
|
-
@modules = {}
|
15
|
-
@classes = {}
|
16
|
-
@extensions = {}
|
17
|
-
@interfaces = {}
|
18
|
-
@constants = {}
|
19
|
-
@globals = {}
|
20
|
-
@aliases = {}
|
21
|
-
end
|
22
|
-
|
23
|
-
def assert_absolute_name(name)
|
24
|
-
name.namespace.absolute? or raise "Absolute name expected: #{name}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def add(sig)
|
28
|
-
case sig
|
29
|
-
when Signature::Class
|
30
|
-
assert_absolute_name sig.name
|
31
|
-
raise "Duplicated class: #{sig.name}" if classes.key?(sig.name) || modules.key?(sig.name)
|
32
|
-
classes[sig.name] = sig
|
33
|
-
when Signature::Module
|
34
|
-
assert_absolute_name sig.name
|
35
|
-
raise "Duplicated module: #{sig.name}" if classes.key?(sig.name) || modules.key?(sig.name)
|
36
|
-
modules[sig.name.absolute!] = sig
|
37
|
-
when Signature::Interface
|
38
|
-
assert_absolute_name sig.name
|
39
|
-
raise "Duplicated interface: #{sig.name}" if interfaces.key?(sig.name)
|
40
|
-
interfaces[sig.name] = sig
|
41
|
-
when Signature::Extension
|
42
|
-
extensions[sig.module_name.absolute!] ||= []
|
43
|
-
if extensions[sig.module_name.absolute!].any? {|ext| ext.name == sig.name }
|
44
|
-
raise "Duplicated extension: #{sig.module_name.absolute!} (#{sig.name})"
|
45
|
-
end
|
46
|
-
extensions[sig.module_name.absolute!] << sig
|
47
|
-
when Signature::Const
|
48
|
-
assert_absolute_name sig.name
|
49
|
-
constants[sig.name] = sig
|
50
|
-
when Signature::Gvar
|
51
|
-
raise "Duplicated global: #{sig.name}" if globals.key?(sig.name)
|
52
|
-
globals[sig.name] = sig
|
53
|
-
when Signature::Alias
|
54
|
-
assert_absolute_name sig.name
|
55
|
-
raise "Duplicated alias: #{sig.name}" if aliases.key?(sig.name)
|
56
|
-
aliases[sig.name] = sig
|
57
|
-
else
|
58
|
-
raise "Unknown signature:: #{sig}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def find_module(name, current_module: AST::Namespace.root)
|
63
|
-
find_name(modules, name, current_module: current_module) or raise "Unknown module: #{name}"
|
64
|
-
end
|
65
|
-
|
66
|
-
def find_class(name, current_module: AST::Namespace.root)
|
67
|
-
find_name(classes, name, current_module: current_module) or raise "Unknown class: #{name}"
|
68
|
-
end
|
69
|
-
|
70
|
-
def find_class_or_module(name, current_module: AST::Namespace.root)
|
71
|
-
sig =
|
72
|
-
find_name(modules, name, current_module: current_module) ||
|
73
|
-
find_name(classes, name, current_module: current_module)
|
74
|
-
|
75
|
-
sig or raise "Unknown class/module: #{name}}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def find_extensions(name, current_module: AST::Namespace.root)
|
79
|
-
find_name(extensions, name, current_module: current_module) || []
|
80
|
-
end
|
81
|
-
|
82
|
-
def find_const(name, current_module: Namespace.root)
|
83
|
-
find_name(constants, name, current_module: current_module)
|
84
|
-
end
|
85
|
-
|
86
|
-
def find_gvar(name)
|
87
|
-
globals[name]
|
88
|
-
end
|
89
|
-
|
90
|
-
def find_alias(name, namespace:)
|
91
|
-
find_name(aliases, name, current_module: namespace) or raise "Unknown alias: #{name}"
|
92
|
-
end
|
93
|
-
|
94
|
-
def find_name(hash, name, current_module:)
|
95
|
-
current_module.absolute? or raise "Current namespace should be absolute: #{current_module}"
|
96
|
-
|
97
|
-
if (object = hash[name.in_namespace(current_module)])
|
98
|
-
object
|
99
|
-
else
|
100
|
-
unless current_module.empty?
|
101
|
-
find_name(hash, name, current_module: current_module.parent)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def find_interface(name, namespace: Namespace.root)
|
107
|
-
find_name(interfaces, name, current_module: namespace) or raise "Unknown interface: #{name}"
|
108
|
-
end
|
109
|
-
|
110
|
-
def class_name?(name)
|
111
|
-
assert_absolute_name name
|
112
|
-
classes.key?(name)
|
113
|
-
end
|
114
|
-
|
115
|
-
def module_name?(name)
|
116
|
-
assert_absolute_name name
|
117
|
-
modules.key?(name)
|
118
|
-
end
|
119
|
-
|
120
|
-
def const_name?(name)
|
121
|
-
assert_absolute_name name
|
122
|
-
constants.key?(name)
|
123
|
-
end
|
124
|
-
|
125
|
-
def each(&block)
|
126
|
-
if block_given?
|
127
|
-
classes.each_value(&block)
|
128
|
-
modules.each_value(&block)
|
129
|
-
interfaces.each_value(&block)
|
130
|
-
constants.each_value(&block)
|
131
|
-
else
|
132
|
-
enum_for :each
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Extension
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :module_name
|
7
|
-
attr_reader :name
|
8
|
-
attr_reader :members
|
9
|
-
attr_reader :params
|
10
|
-
|
11
|
-
def initialize(location:, module_name:, params:, name:, members:)
|
12
|
-
@location = location
|
13
|
-
@module_name = module_name
|
14
|
-
@params = params
|
15
|
-
@name = name
|
16
|
-
@members = members
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Gvar
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :type
|
8
|
-
|
9
|
-
def initialize(location:, name:, type:)
|
10
|
-
@location = location
|
11
|
-
@name = name
|
12
|
-
@type = type
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Interface
|
5
|
-
class Method
|
6
|
-
attr_reader :location
|
7
|
-
attr_reader :name
|
8
|
-
attr_reader :types
|
9
|
-
|
10
|
-
def initialize(location:, name:, types:)
|
11
|
-
@location = location
|
12
|
-
@name = name
|
13
|
-
@types = types
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :location
|
18
|
-
attr_reader :name
|
19
|
-
attr_reader :params
|
20
|
-
attr_reader :methods
|
21
|
-
|
22
|
-
def initialize(location:, name:, params:, methods:)
|
23
|
-
@location = location
|
24
|
-
@name = name
|
25
|
-
@params = params
|
26
|
-
@methods = methods
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
module Members
|
5
|
-
class Include
|
6
|
-
attr_reader :location
|
7
|
-
attr_reader :name
|
8
|
-
attr_reader :args
|
9
|
-
|
10
|
-
def initialize(location:, name:, args:)
|
11
|
-
@location = location
|
12
|
-
@name = name
|
13
|
-
@args = args
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Extend
|
18
|
-
attr_reader :location
|
19
|
-
attr_reader :name
|
20
|
-
attr_reader :args
|
21
|
-
|
22
|
-
def initialize(location:, name:, args:)
|
23
|
-
@location = location
|
24
|
-
@name = name
|
25
|
-
@args = args
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class Method
|
30
|
-
attr_reader :location
|
31
|
-
attr_reader :name
|
32
|
-
attr_reader :kind
|
33
|
-
attr_reader :types
|
34
|
-
attr_reader :attributes
|
35
|
-
|
36
|
-
def initialize(location:, name:, kind:, types:, attributes:)
|
37
|
-
@location = location
|
38
|
-
@name = name
|
39
|
-
@kind = kind
|
40
|
-
@types = types
|
41
|
-
@attributes = attributes
|
42
|
-
end
|
43
|
-
|
44
|
-
def module_method?
|
45
|
-
kind == :module || kind == :module_instance
|
46
|
-
end
|
47
|
-
|
48
|
-
def instance_method?
|
49
|
-
kind == :instance || kind == :module_instance
|
50
|
-
end
|
51
|
-
|
52
|
-
def constructor?
|
53
|
-
attributes.include?(:constructor)
|
54
|
-
end
|
55
|
-
|
56
|
-
def incompatible?
|
57
|
-
attributes.include?(:incompatible)
|
58
|
-
end
|
59
|
-
|
60
|
-
def private?
|
61
|
-
attributes.include?(:private)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class Ivar
|
66
|
-
attr_reader :location
|
67
|
-
attr_reader :name
|
68
|
-
attr_reader :type
|
69
|
-
|
70
|
-
def initialize(location:, name:, type:)
|
71
|
-
@location = location
|
72
|
-
@name = name
|
73
|
-
@type = type
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Attr
|
78
|
-
attr_reader :location
|
79
|
-
attr_reader :kind
|
80
|
-
attr_reader :name
|
81
|
-
attr_reader :ivar
|
82
|
-
attr_reader :type
|
83
|
-
|
84
|
-
def initialize(location:, kind:, name:, ivar:, type:)
|
85
|
-
@location = location
|
86
|
-
@kind = kind
|
87
|
-
@name = name
|
88
|
-
@ivar = ivar
|
89
|
-
@type = type
|
90
|
-
end
|
91
|
-
|
92
|
-
def reader?
|
93
|
-
kind == :reader
|
94
|
-
end
|
95
|
-
|
96
|
-
def accessor?
|
97
|
-
kind == :accessor
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
class MethodAlias
|
102
|
-
attr_reader :location
|
103
|
-
attr_reader :new_name
|
104
|
-
attr_reader :original_name
|
105
|
-
|
106
|
-
def initialize(location:, new_name:, original_name:)
|
107
|
-
@location = location
|
108
|
-
@new_name = new_name
|
109
|
-
@original_name = original_name
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module AST
|
3
|
-
module Signature
|
4
|
-
class Module
|
5
|
-
attr_reader :location
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :params
|
8
|
-
attr_reader :self_type
|
9
|
-
attr_reader :members
|
10
|
-
|
11
|
-
def initialize(name:, location:, params:, self_type:, members:)
|
12
|
-
@name = name
|
13
|
-
@location = location
|
14
|
-
@params = params
|
15
|
-
@self_type = self_type
|
16
|
-
@members = members
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
module Steep
|
2
|
-
module Drivers
|
3
|
-
class PrintInterface
|
4
|
-
attr_reader :type_name
|
5
|
-
attr_reader :signature_dirs
|
6
|
-
attr_reader :stdout
|
7
|
-
attr_reader :stderr
|
8
|
-
|
9
|
-
include Utils::EachSignature
|
10
|
-
|
11
|
-
def initialize(type_name:, signature_dirs:, stdout:, stderr:)
|
12
|
-
@type_name = type_name
|
13
|
-
@signature_dirs = signature_dirs
|
14
|
-
@stdout = stdout
|
15
|
-
@stderr = stderr
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
if type_name
|
20
|
-
type = Parser.parse_type(type_name)
|
21
|
-
project = Project.new()
|
22
|
-
|
23
|
-
signature_dirs.each do |path|
|
24
|
-
each_file_in_path(".rbi", path) do |file_path|
|
25
|
-
file = Project::SignatureFile.new(path: file_path)
|
26
|
-
file.content = file_path.read
|
27
|
-
project.signature_files[file_path] = file
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
project.reload_signature
|
32
|
-
|
33
|
-
case sig = project.signature
|
34
|
-
when Project::SignatureLoaded
|
35
|
-
begin
|
36
|
-
check = sig.check
|
37
|
-
interface = check.resolve(type)
|
38
|
-
|
39
|
-
stdout.puts "#{type}"
|
40
|
-
stdout.puts "- Instance variables:"
|
41
|
-
interface.ivars.each do |name, type|
|
42
|
-
puts " - #{name}: #{type}"
|
43
|
-
end
|
44
|
-
stdout.puts "- Methods:"
|
45
|
-
interface.methods.each do |name, method|
|
46
|
-
puts " - #{Rainbow(name).blue}:"
|
47
|
-
method.types.each do |method_type|
|
48
|
-
loc = if method_type.location
|
49
|
-
"#{method_type.location.buffer.name}:#{method_type.location.to_s}"
|
50
|
-
else
|
51
|
-
"no location"
|
52
|
-
end
|
53
|
-
puts " - #{Rainbow(method_type.to_s).red} (#{loc})"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
0
|
57
|
-
rescue Steep::Subtyping::Check::CannotResolveError
|
58
|
-
stderr.puts "🤔 #{Rainbow(type.to_s).red} cannot be resolved to interface"
|
59
|
-
1
|
60
|
-
end
|
61
|
-
|
62
|
-
when Project::SignatureHasError
|
63
|
-
sig.errors.each do |error|
|
64
|
-
case error
|
65
|
-
when Interface::Instantiated::InvalidMethodOverrideError
|
66
|
-
stdout.puts "😱 #{error.message}"
|
67
|
-
error.result.trace.each do |s, t|
|
68
|
-
case s
|
69
|
-
when Interface::Method
|
70
|
-
stdout.puts " #{s.name}(#{s.type_name}) <: #{t.name}(#{t.type_name})"
|
71
|
-
when Interface::MethodType
|
72
|
-
stdout.puts " #{s} <: #{t} (#{s.location&.name||"?"}:#{s.location&.start_line||"?"})"
|
73
|
-
else
|
74
|
-
stdout.puts " #{s} <: #{t}"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
stdout.puts " 🚨 #{error.result.error.message}"
|
78
|
-
when Interface::Instantiated::InvalidIvarOverrideError
|
79
|
-
stdout.puts "😱 #{error.message}"
|
80
|
-
else
|
81
|
-
stdout.puts "😱 #{error.inspect}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
1
|
86
|
-
end
|
87
|
-
else
|
88
|
-
stderr.puts "Pass a type name to command line"
|
89
|
-
1
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|