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/lib/steep/ast/types/name.rb
CHANGED
@@ -48,7 +48,7 @@ module Steep
|
|
48
48
|
if args.empty?
|
49
49
|
"#{name}"
|
50
50
|
else
|
51
|
-
"#{name}
|
51
|
+
"#{name}[#{args.join(", ")}]"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -105,7 +105,7 @@ module Steep
|
|
105
105
|
when nil
|
106
106
|
""
|
107
107
|
end
|
108
|
-
"#{name.to_s}
|
108
|
+
"singleton(#{name.to_s})"
|
109
109
|
end
|
110
110
|
|
111
111
|
def with_location(new_location)
|
@@ -140,7 +140,7 @@ module Steep
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def to_s
|
143
|
-
"#{name.to_s}
|
143
|
+
"singleton(#{name.to_s})"
|
144
144
|
end
|
145
145
|
|
146
146
|
def with_location(new_location)
|
data/lib/steep/ast/types/var.rb
CHANGED
data/lib/steep/cli.rb
CHANGED
@@ -2,122 +2,6 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module Steep
|
4
4
|
class CLI
|
5
|
-
BUILTIN_PATH = Pathname(__dir__).join("../../stdlib").realpath
|
6
|
-
|
7
|
-
class SignatureOptions
|
8
|
-
class MissingGemError < StandardError
|
9
|
-
attr_reader :name
|
10
|
-
attr_reader :version
|
11
|
-
|
12
|
-
def initialize(name:, version:)
|
13
|
-
@name = name
|
14
|
-
@version = version
|
15
|
-
super "Requested gem not found: name=#{name}, version=#{version}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class NoTypeDefinitionFromGemError < StandardError
|
20
|
-
attr_reader :gemspec
|
21
|
-
|
22
|
-
def initialize(gemspec:)
|
23
|
-
@gemspec = gemspec
|
24
|
-
super "Gem does not provide Steep type: gem=#{gemspec.name}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :no_builtin
|
29
|
-
attr_reader :no_bundler
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
@options = []
|
33
|
-
end
|
34
|
-
|
35
|
-
def no_builtin!
|
36
|
-
@no_builtin = true
|
37
|
-
end
|
38
|
-
|
39
|
-
def no_bundler!
|
40
|
-
@no_bundler = true
|
41
|
-
end
|
42
|
-
|
43
|
-
def <<(option)
|
44
|
-
@options << option
|
45
|
-
end
|
46
|
-
|
47
|
-
def find_gem_dir(gem)
|
48
|
-
name, version = gem.split(/:/)
|
49
|
-
spec =
|
50
|
-
begin
|
51
|
-
Gem::Specification.find_by_name(name, version)
|
52
|
-
rescue Gem::MissingSpecError
|
53
|
-
raise MissingGemError.new(name: name, version: version)
|
54
|
-
end
|
55
|
-
|
56
|
-
dirs_from_spec(spec).tap do |dirs|
|
57
|
-
if dirs.empty?
|
58
|
-
raise NoTypeDefinitionFromGemError.new(gemspec: spec)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def dirs_from_spec(spec)
|
64
|
-
type_dirs = spec.metadata["steep_types"].yield_self do |types|
|
65
|
-
case types
|
66
|
-
when nil
|
67
|
-
[]
|
68
|
-
when String
|
69
|
-
types.split(/:/).map do |type|
|
70
|
-
Pathname(type)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
base_dir = Pathname(spec.gem_dir)
|
76
|
-
type_dirs.map do |dir|
|
77
|
-
base_dir + dir
|
78
|
-
end.select(&:directory?)
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_bundler_gems(options)
|
82
|
-
if defined?(Bundler)
|
83
|
-
Steep.logger.info "Bundler detected!"
|
84
|
-
Bundler.load.gems.each do |spec|
|
85
|
-
dirs = dirs_from_spec(spec)
|
86
|
-
options.unshift *dirs
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def paths
|
92
|
-
options = if @options.none? {|option| option.is_a?(Pathname) } && Pathname("sig").directory?
|
93
|
-
@options + [Pathname("sig")]
|
94
|
-
else
|
95
|
-
@options
|
96
|
-
end
|
97
|
-
|
98
|
-
unless no_bundler
|
99
|
-
add_bundler_gems(options)
|
100
|
-
end
|
101
|
-
|
102
|
-
paths = options.flat_map do |option|
|
103
|
-
case option
|
104
|
-
when Pathname
|
105
|
-
# Dir
|
106
|
-
[option]
|
107
|
-
when String
|
108
|
-
# gem name
|
109
|
-
find_gem_dir(option)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
unless no_builtin
|
114
|
-
paths.unshift BUILTIN_PATH
|
115
|
-
end
|
116
|
-
|
117
|
-
paths.reverse.uniq(&:realpath).reverse
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
5
|
attr_reader :argv
|
122
6
|
attr_reader :stdout
|
123
7
|
attr_reader :stdin
|
@@ -132,7 +16,7 @@ module Steep
|
|
132
16
|
end
|
133
17
|
|
134
18
|
def self.available_commands
|
135
|
-
[:check, :validate, :annotations, :
|
19
|
+
[:init, :check, :validate, :annotations, :version, :project, :watch, :langserver, :vendor]
|
136
20
|
end
|
137
21
|
|
138
22
|
def process_global_options
|
@@ -167,181 +51,113 @@ module Steep
|
|
167
51
|
end
|
168
52
|
|
169
53
|
def handle_logging_options(opts)
|
170
|
-
opts.on("--verbose") do
|
171
|
-
Steep.logger.level = Logger::DEBUG
|
172
|
-
end
|
173
|
-
|
174
54
|
opts.on("--log-level=[debug,info,warn,error,fatal]") do |level|
|
175
|
-
|
176
|
-
"debug" => Logger::DEBUG,
|
177
|
-
"info" => Logger::INFO,
|
178
|
-
"warn" => Logger::WARN,
|
179
|
-
"error" => Logger::ERROR,
|
180
|
-
"fatal" => Logger::FATAL
|
181
|
-
}[level.downcase] or raise "Unknown error level: #{level}"
|
182
|
-
|
183
|
-
Steep.logger.level = lv
|
55
|
+
Steep.logger.level = level
|
184
56
|
end
|
185
57
|
|
186
58
|
opts.on("--log-output=[PATH]") do |file|
|
187
59
|
Steep.log_output = file
|
188
60
|
end
|
189
|
-
end
|
190
61
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
opts.on("--no-builtin") { options.no_builtin! }
|
195
|
-
opts.on("--no-bundler") { options.no_bundler! }
|
62
|
+
opts.on("--verbose") do
|
63
|
+
Steep.logger.level = Logger::DEBUG
|
64
|
+
end
|
196
65
|
end
|
197
66
|
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
67
|
+
def process_init
|
68
|
+
Drivers::Init.new(stdout: stdout, stderr: stderr).tap do |command|
|
69
|
+
OptionParser.new do |opts|
|
70
|
+
opts.banner = "Usage: steep init [options]"
|
71
|
+
|
72
|
+
opts.on("--steepfile=PATH") {|path| command.steepfile = Pathname(path) }
|
73
|
+
opts.on("--force") { command.force_write = true }
|
74
|
+
|
75
|
+
handle_logging_options opts
|
76
|
+
end.parse!(argv)
|
77
|
+
end.run()
|
206
78
|
end
|
207
79
|
|
208
80
|
def process_check
|
209
|
-
|
210
|
-
dump_all_types = false
|
211
|
-
fallback_any_is_error = false
|
212
|
-
strict = false
|
213
|
-
|
81
|
+
Drivers::Check.new(stdout: stdout, stderr: stderr).tap do |check|
|
214
82
|
OptionParser.new do |opts|
|
83
|
+
opts.banner = "Usage: steep check [options] [sources]"
|
84
|
+
|
85
|
+
opts.on("--steepfile=PATH") {|path| check.steepfile = Pathname(path) }
|
86
|
+
opts.on("--dump-all-types") { check.dump_all_types = true }
|
215
87
|
handle_logging_options opts
|
216
|
-
handle_dir_options opts, signature_options
|
217
|
-
opts.on("--dump-all-types") { dump_all_types = true }
|
218
|
-
opts.on("--strict") { strict = true }
|
219
|
-
opts.on("--fallback-any-is-error") { fallback_any_is_error = true }
|
220
88
|
end.parse!(argv)
|
221
89
|
|
222
|
-
|
223
|
-
|
224
|
-
source_paths << Pathname(".")
|
225
|
-
end
|
226
|
-
|
227
|
-
Drivers::Check.new(source_paths: source_paths, signature_dirs: signature_options.paths, stdout: stdout, stderr: stderr).tap do |check|
|
228
|
-
check.dump_all_types = dump_all_types
|
229
|
-
check.fallback_any_is_error = fallback_any_is_error || strict
|
230
|
-
check.allow_missing_definitions = false if strict
|
231
|
-
end.run
|
232
|
-
end
|
90
|
+
check.command_line_patterns.push *argv
|
91
|
+
end.run
|
233
92
|
end
|
234
93
|
|
235
94
|
def process_validate
|
236
|
-
|
95
|
+
Drivers::Validate.new(stdout: stdout, stderr: stderr).tap do |command|
|
237
96
|
OptionParser.new do |opts|
|
238
97
|
handle_logging_options opts
|
239
|
-
handle_dir_options opts, signature_options
|
240
98
|
end.parse!(argv)
|
241
|
-
|
242
|
-
Drivers::Validate.new(signature_dirs: signature_options.paths, stdout: stdout, stderr: stderr).run
|
243
|
-
end
|
99
|
+
end.run
|
244
100
|
end
|
245
101
|
|
246
102
|
def process_annotations
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
Drivers::Annotations.new(source_paths: source_paths, stdout: stdout, stderr: stderr).run
|
253
|
-
end
|
254
|
-
|
255
|
-
def process_scaffold
|
256
|
-
OptionParser.new do |opts|
|
257
|
-
handle_logging_options opts
|
258
|
-
end.parse!(argv)
|
103
|
+
Drivers::Annotations.new(stdout: stdout, stderr: stderr).tap do |command|
|
104
|
+
OptionParser.new do |opts|
|
105
|
+
opts.banner = "Usage: steep annotations [options] [sources]"
|
106
|
+
handle_logging_options opts
|
107
|
+
end.parse!(argv)
|
259
108
|
|
260
|
-
|
261
|
-
|
109
|
+
command.command_line_patterns.push *argv
|
110
|
+
end.run
|
262
111
|
end
|
263
112
|
|
264
|
-
def
|
265
|
-
|
113
|
+
def process_project
|
114
|
+
Drivers::PrintProject.new(stdout: stdout, stderr: stderr).tap do |command|
|
266
115
|
OptionParser.new do |opts|
|
116
|
+
opts.banner = "Usage: steep project [options]"
|
117
|
+
opts.on("--steepfile=PATH") {|path| command.steepfile = Pathname(path) }
|
267
118
|
handle_logging_options opts
|
268
|
-
handle_dir_options opts, signature_options
|
269
119
|
end.parse!(argv)
|
270
|
-
|
271
|
-
Drivers::PrintInterface.new(type_name: argv.first, signature_dirs: signature_options.paths, stdout: stdout, stderr: stderr).run
|
272
|
-
end
|
120
|
+
end.run
|
273
121
|
end
|
274
122
|
|
275
123
|
def process_watch
|
276
|
-
|
277
|
-
strict = false
|
278
|
-
fallback_any_is_error = false
|
279
|
-
|
124
|
+
Drivers::Watch.new(stdout: stdout, stderr: stderr).tap do |command|
|
280
125
|
OptionParser.new do |opts|
|
126
|
+
opts.banner = "Usage: steep watch [options] [dirs]"
|
281
127
|
handle_logging_options opts
|
282
|
-
handle_dir_options opts, signature_options
|
283
|
-
opts.on("--strict") { strict = true }
|
284
|
-
opts.on("--fallback-any-is-error") { fallback_any_is_error = true }
|
285
128
|
end.parse!(argv)
|
286
129
|
|
287
|
-
|
288
|
-
|
289
|
-
source_dirs << Pathname(".")
|
290
|
-
end
|
291
|
-
|
292
|
-
Drivers::Watch.new(source_dirs: source_dirs, signature_dirs: signature_options.paths, stdout: stdout, stderr: stderr).tap do |driver|
|
293
|
-
driver.options.fallback_any_is_error = fallback_any_is_error || strict
|
294
|
-
driver.options.allow_missing_definitions = false if strict
|
295
|
-
end.run
|
296
|
-
|
297
|
-
0
|
298
|
-
end
|
130
|
+
command.dirs.push *argv
|
131
|
+
end.run
|
299
132
|
end
|
300
133
|
|
301
134
|
def process_langserver
|
302
|
-
|
303
|
-
strict = false
|
304
|
-
fallback_any_is_error = false
|
305
|
-
|
135
|
+
Drivers::Langserver.new(stdout: stdout, stderr: stderr, stdin: stdin).tap do |command|
|
306
136
|
OptionParser.new do |opts|
|
137
|
+
opts.on("--steepfile=PATH") {|path| command.steepfile = Pathname(path) }
|
307
138
|
handle_logging_options opts
|
308
|
-
handle_dir_options opts, signature_options
|
309
|
-
opts.on("--strict") { strict = true }
|
310
|
-
opts.on("--fallback-any-is-error") { fallback_any_is_error = true }
|
311
139
|
end.parse!(argv)
|
140
|
+
end.run
|
141
|
+
end
|
312
142
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
143
|
+
def process_vendor
|
144
|
+
Drivers::Vendor.new(stdout: stdout, stderr: stderr, stdin: stdin).tap do |command|
|
145
|
+
OptionParser.new do |opts|
|
146
|
+
opts.banner = "Usage: steep vendor [options] [dir]"
|
147
|
+
handle_logging_options opts
|
317
148
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
end.
|
149
|
+
opts.on("--[no-]clean") do |v|
|
150
|
+
command.clean_before = v
|
151
|
+
end
|
152
|
+
end.parse!(argv)
|
322
153
|
|
323
|
-
0
|
324
|
-
end
|
154
|
+
command.vendor_dir = Pathname(argv[0] || "vendor/sigs")
|
155
|
+
end.run
|
325
156
|
end
|
326
157
|
|
327
158
|
def process_version
|
328
159
|
stdout.puts Steep::VERSION
|
329
160
|
0
|
330
161
|
end
|
331
|
-
|
332
|
-
def process_paths
|
333
|
-
with_signature_options do |signature_options|
|
334
|
-
OptionParser.new do |opts|
|
335
|
-
handle_logging_options opts
|
336
|
-
handle_dir_options opts, signature_options
|
337
|
-
end.parse!(argv)
|
338
|
-
|
339
|
-
signature_options.paths.each do |path|
|
340
|
-
stdout.puts path
|
341
|
-
end
|
342
|
-
|
343
|
-
0
|
344
|
-
end
|
345
|
-
end
|
346
162
|
end
|
347
163
|
end
|
@@ -1,44 +1,61 @@
|
|
1
1
|
module Steep
|
2
2
|
module Drivers
|
3
3
|
class Annotations
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :command_line_patterns
|
5
5
|
attr_reader :stdout
|
6
6
|
attr_reader :stderr
|
7
7
|
attr_reader :labeling
|
8
8
|
|
9
|
-
include Utils::
|
9
|
+
include Utils::DriverHelper
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@source_paths = source_paths
|
11
|
+
def initialize(stdout:, stderr:)
|
13
12
|
@stdout = stdout
|
14
13
|
@stderr = stderr
|
15
14
|
|
15
|
+
@command_line_patterns = []
|
16
16
|
@labeling = ASTUtils::Labeling.new
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
project =
|
20
|
+
project = load_config()
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
loader = Project::FileLoader.new(project: project)
|
23
|
+
loader.load_sources(command_line_patterns)
|
24
|
+
loader.load_signatures()
|
25
|
+
|
26
|
+
project.targets.each do |target|
|
27
|
+
Steep.logger.tagged "target=#{target.name}" do
|
28
|
+
target.load_signatures do |_, subtyping, _|
|
29
|
+
case (status = target.status)
|
30
|
+
when nil # status set on error cases
|
31
|
+
target.source_files.each_value do |file|
|
32
|
+
file.parse(subtyping.factory) do |source|
|
33
|
+
source.each_annotation.sort_by {|node, _| [node.loc.expression.begin_pos, node.loc.expression.end_pos] }.each do |node, annotations|
|
34
|
+
loc = node.loc
|
35
|
+
stdout.puts "#{file.path}:#{loc.line}:#{loc.column}:#{node.type}:\t#{node.loc.expression.source.lines.first}"
|
36
|
+
annotations.each do |annotation|
|
37
|
+
stdout.puts " #{annotation.location.source}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
when Project::Target::SignatureSyntaxErrorStatus
|
43
|
+
printer = SignatureErrorPrinter.new(stdout: stdout, stderr: stderr)
|
44
|
+
printer.print_syntax_errors(status.errors)
|
45
|
+
when Project::Target::SignatureValidationErrorStatus
|
46
|
+
printer = SignatureErrorPrinter.new(stdout: stdout, stderr: stderr)
|
47
|
+
printer.print_semantic_errors(status.errors)
|
48
|
+
end
|
49
|
+
end
|
27
50
|
end
|
28
51
|
end
|
29
52
|
|
30
|
-
project.
|
31
|
-
|
32
|
-
file.source.each_annotation.sort_by {|node, _| [node.loc.expression.begin_pos, node.loc.expression.end_pos] }.each do |node, annotations|
|
33
|
-
loc = node.loc
|
34
|
-
stdout.puts "#{file.path}:#{loc.line}:#{loc.column}:#{node.type}:\t#{node.loc.expression.source.lines.first}"
|
35
|
-
annotations.each do |annotation|
|
36
|
-
stdout.puts " #{annotation.location.source}"
|
37
|
-
end
|
53
|
+
project.targets.each do |target|
|
54
|
+
Steep.logger.tagged "target=#{target.name}" do
|
38
55
|
end
|
39
56
|
end
|
40
57
|
|
41
|
-
0
|
58
|
+
project.targets.all? {|target| !target.status } ? 0 : 1
|
42
59
|
end
|
43
60
|
end
|
44
61
|
end
|