steep 0.37.0 → 0.42.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 +1 -1
- data/CHANGELOG.md +34 -0
- data/Rakefile +5 -2
- data/bin/output_rebaseline.rb +34 -0
- data/bin/output_test.rb +53 -0
- data/lib/steep.rb +95 -14
- data/lib/steep/ast/types/bot.rb +1 -1
- data/lib/steep/ast/types/class.rb +4 -0
- data/lib/steep/ast/types/factory.rb +10 -0
- data/lib/steep/ast/types/logic.rb +16 -3
- data/lib/steep/ast/types/top.rb +1 -1
- data/lib/steep/cli.rb +31 -7
- data/lib/steep/diagnostic/helper.rb +17 -0
- data/lib/steep/diagnostic/lsp_formatter.rb +16 -0
- data/lib/steep/diagnostic/ruby.rb +619 -0
- data/lib/steep/diagnostic/signature.rb +357 -0
- data/lib/steep/drivers/annotations.rb +19 -28
- data/lib/steep/drivers/check.rb +182 -60
- data/lib/steep/drivers/diagnostic_printer.rb +99 -0
- data/lib/steep/drivers/langserver.rb +3 -8
- data/lib/steep/drivers/print_project.rb +10 -9
- data/lib/steep/drivers/stats.rb +124 -32
- data/lib/steep/drivers/trace_printer.rb +5 -1
- data/lib/steep/drivers/utils/jobs_count.rb +9 -0
- data/lib/steep/drivers/validate.rb +31 -13
- data/lib/steep/drivers/watch.rb +69 -48
- data/lib/steep/drivers/worker.rb +16 -8
- data/lib/steep/expectations.rb +159 -0
- data/lib/steep/index/rbs_index.rb +334 -0
- data/lib/steep/index/signature_symbol_provider.rb +162 -0
- data/lib/steep/index/source_index.rb +100 -0
- data/lib/steep/project.rb +0 -30
- data/lib/steep/project/dsl.rb +5 -3
- data/lib/steep/project/options.rb +4 -4
- data/lib/steep/project/pattern.rb +56 -0
- data/lib/steep/project/target.rb +9 -214
- data/lib/steep/range_extension.rb +29 -0
- data/lib/steep/server/base_worker.rb +43 -7
- data/lib/steep/server/change_buffer.rb +63 -0
- data/lib/steep/server/interaction_worker.rb +73 -56
- data/lib/steep/server/master.rb +245 -109
- data/lib/steep/server/type_check_worker.rb +122 -0
- data/lib/steep/server/worker_process.rb +17 -15
- data/lib/steep/{project → services}/completion_provider.rb +3 -3
- data/lib/steep/services/content_change.rb +61 -0
- data/lib/steep/services/file_loader.rb +48 -0
- data/lib/steep/{project → services}/hover_content.rb +14 -16
- data/lib/steep/services/path_assignment.rb +29 -0
- data/lib/steep/services/signature_service.rb +369 -0
- data/lib/steep/services/stats_calculator.rb +69 -0
- data/lib/steep/services/type_check_service.rb +342 -0
- data/lib/steep/signature/validator.rb +174 -32
- data/lib/steep/subtyping/check.rb +248 -47
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/type_construction.rb +565 -295
- data/lib/steep/type_inference/constant_env.rb +5 -1
- data/lib/steep/type_inference/local_variable_type_env.rb +26 -12
- data/lib/steep/type_inference/logic_type_interpreter.rb +99 -26
- data/lib/steep/type_inference/type_env.rb +43 -17
- data/lib/steep/typing.rb +8 -2
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/a.rb +0 -3
- data/smoke/alias/b.rb +0 -1
- data/smoke/alias/c.rb +0 -2
- data/smoke/alias/test_expectations.yml +96 -0
- data/smoke/and/a.rb +0 -3
- data/smoke/and/test_expectations.yml +31 -0
- data/smoke/array/a.rb +0 -3
- data/smoke/array/b.rb +0 -2
- data/smoke/array/c.rb +0 -1
- data/smoke/array/test_expectations.yml +103 -0
- data/smoke/block/a.rb +0 -2
- data/smoke/block/b.rb +0 -2
- data/smoke/block/d.rb +0 -4
- data/smoke/block/test_expectations.yml +125 -0
- data/smoke/case/a.rb +0 -3
- data/smoke/case/test_expectations.yml +47 -0
- data/smoke/class/a.rb +0 -3
- data/smoke/class/c.rb +0 -1
- data/smoke/class/f.rb +0 -1
- data/smoke/class/g.rb +0 -2
- data/smoke/class/i.rb +0 -2
- data/smoke/class/test_expectations.yml +120 -0
- data/smoke/const/a.rb +0 -3
- data/smoke/const/b.rb +7 -0
- data/smoke/const/b.rbs +5 -0
- data/smoke/const/test_expectations.yml +139 -0
- data/smoke/diagnostics-rbs-duplicated/Steepfile +5 -0
- data/smoke/diagnostics-rbs-duplicated/a.rbs +5 -0
- data/smoke/diagnostics-rbs-duplicated/test_expectations.yml +13 -0
- data/smoke/diagnostics-rbs/Steepfile +8 -0
- data/smoke/diagnostics-rbs/duplicated-method-definition.rbs +20 -0
- data/smoke/diagnostics-rbs/generic-parameter-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid-method-overload.rbs +3 -0
- data/smoke/diagnostics-rbs/invalid-type-application.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid_variance_annotation.rbs +3 -0
- data/smoke/diagnostics-rbs/recursive-alias.rbs +5 -0
- data/smoke/diagnostics-rbs/recursive-class.rbs +8 -0
- data/smoke/diagnostics-rbs/superclass-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/test_expectations.yml +231 -0
- data/smoke/diagnostics-rbs/unknown-method-alias.rbs +3 -0
- data/smoke/diagnostics-rbs/unknown-type-name-2.rbs +5 -0
- data/smoke/diagnostics-rbs/unknown-type-name.rbs +13 -0
- data/smoke/diagnostics/Steepfile +5 -0
- data/smoke/diagnostics/a.rbs +26 -0
- data/smoke/diagnostics/argument_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_body_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_type_mismatch.rb +3 -0
- data/smoke/diagnostics/break_type_mismatch.rb +1 -0
- data/smoke/diagnostics/else_on_exhaustive_case.rb +12 -0
- data/smoke/diagnostics/incompatible_annotation.rb +6 -0
- data/smoke/diagnostics/incompatible_argument.rb +1 -0
- data/smoke/diagnostics/incompatible_assignment.rb +8 -0
- data/smoke/diagnostics/method_arity_mismatch.rb +11 -0
- data/smoke/diagnostics/method_body_type_mismatch.rb +6 -0
- data/smoke/diagnostics/method_definition_missing.rb +2 -0
- data/smoke/diagnostics/method_return_type_annotation_mismatch.rb +7 -0
- data/smoke/diagnostics/missing_keyword.rb +1 -0
- data/smoke/diagnostics/no_method.rb +1 -0
- data/smoke/diagnostics/required_block_missing.rb +1 -0
- data/smoke/diagnostics/return_type_mismatch.rb +6 -0
- data/smoke/diagnostics/test_expectations.yml +477 -0
- data/smoke/diagnostics/unexpected_block_given.rb +1 -0
- data/smoke/diagnostics/unexpected_dynamic_method.rb +3 -0
- data/smoke/diagnostics/unexpected_jump.rb +4 -0
- data/smoke/diagnostics/unexpected_jump_value.rb +3 -0
- data/smoke/diagnostics/unexpected_keyword.rb +1 -0
- data/smoke/diagnostics/unexpected_splat.rb +1 -0
- data/smoke/diagnostics/unexpected_yield.rb +6 -0
- data/smoke/diagnostics/unknown_constant_assigned.rb +7 -0
- data/smoke/diagnostics/unresolved_overloading.rb +1 -0
- data/smoke/diagnostics/unsatisfiable_constraint.rb +7 -0
- data/smoke/diagnostics/unsupported_syntax.rb +2 -0
- data/smoke/dstr/a.rb +0 -1
- data/smoke/dstr/test_expectations.yml +13 -0
- data/smoke/ensure/a.rb +0 -4
- data/smoke/ensure/test_expectations.yml +62 -0
- data/smoke/enumerator/a.rb +0 -6
- data/smoke/enumerator/b.rb +0 -3
- data/smoke/enumerator/test_expectations.yml +135 -0
- data/smoke/extension/a.rb +0 -1
- data/smoke/extension/b.rb +0 -2
- data/smoke/extension/c.rb +0 -1
- data/smoke/extension/f.rb +2 -0
- data/smoke/extension/f.rbs +3 -0
- data/smoke/extension/test_expectations.yml +73 -0
- data/smoke/hash/b.rb +0 -1
- data/smoke/hash/c.rb +0 -3
- data/smoke/hash/d.rb +0 -1
- data/smoke/hash/e.rb +0 -1
- data/smoke/hash/test_expectations.yml +81 -0
- data/smoke/hello/hello.rb +0 -2
- data/smoke/hello/test_expectations.yml +25 -0
- data/smoke/if/a.rb +0 -2
- data/smoke/if/test_expectations.yml +34 -0
- data/smoke/implements/a.rb +0 -2
- data/smoke/implements/test_expectations.yml +23 -0
- data/smoke/initialize/test_expectations.yml +1 -0
- data/smoke/integer/a.rb +0 -7
- data/smoke/integer/test_expectations.yml +101 -0
- data/smoke/interface/a.rb +0 -2
- data/smoke/interface/test_expectations.yml +23 -0
- data/smoke/kwbegin/a.rb +0 -1
- data/smoke/kwbegin/test_expectations.yml +17 -0
- data/smoke/lambda/a.rb +1 -4
- data/smoke/lambda/test_expectations.yml +39 -0
- data/smoke/literal/a.rb +0 -5
- data/smoke/literal/b.rb +0 -2
- data/smoke/literal/test_expectations.yml +106 -0
- data/smoke/map/test_expectations.yml +1 -0
- data/smoke/method/a.rb +0 -5
- data/smoke/method/b.rb +0 -1
- data/smoke/method/test_expectations.yml +90 -0
- data/smoke/module/a.rb +0 -2
- data/smoke/module/b.rb +0 -2
- data/smoke/module/c.rb +0 -1
- data/smoke/module/d.rb +0 -1
- data/smoke/module/f.rb +0 -2
- data/smoke/module/test_expectations.yml +75 -0
- data/smoke/regexp/a.rb +0 -38
- data/smoke/regexp/b.rb +0 -26
- data/smoke/regexp/test_expectations.yml +615 -0
- data/smoke/regression/set_divide.rb +0 -4
- data/smoke/regression/test_expectations.yml +43 -0
- data/smoke/rescue/a.rb +0 -5
- data/smoke/rescue/test_expectations.yml +79 -0
- data/smoke/self/a.rb +0 -2
- data/smoke/self/test_expectations.yml +23 -0
- data/smoke/skip/skip.rb +0 -2
- data/smoke/skip/test_expectations.yml +23 -0
- data/smoke/stdout/test_expectations.yml +1 -0
- data/smoke/super/a.rb +0 -4
- data/smoke/super/test_expectations.yml +79 -0
- data/smoke/toplevel/a.rb +0 -1
- data/smoke/toplevel/test_expectations.yml +15 -0
- data/smoke/tsort/Steepfile +2 -0
- data/smoke/tsort/a.rb +0 -3
- data/smoke/tsort/test_expectations.yml +63 -0
- data/smoke/type_case/a.rb +0 -4
- data/smoke/type_case/test_expectations.yml +48 -0
- data/smoke/unexpected/Steepfile +5 -0
- data/smoke/unexpected/test_expectations.yml +25 -0
- data/smoke/unexpected/unexpected.rb +1 -0
- data/smoke/unexpected/unexpected.rbs +3 -0
- data/smoke/yield/a.rb +0 -3
- data/smoke/yield/b.rb +6 -0
- data/smoke/yield/test_expectations.yml +68 -0
- data/steep.gemspec +4 -3
- metadata +144 -29
- data/bin/smoke_runner.rb +0 -139
- data/lib/steep/drivers/signature_error_printer.rb +0 -25
- data/lib/steep/errors.rb +0 -565
- data/lib/steep/project/file_loader.rb +0 -68
- data/lib/steep/project/signature_file.rb +0 -33
- data/lib/steep/project/source_file.rb +0 -129
- data/lib/steep/server/code_worker.rb +0 -137
- data/lib/steep/server/signature_worker.rb +0 -152
- data/lib/steep/server/utils.rb +0 -69
- data/lib/steep/signature/errors.rb +0 -82
- data/lib/steep/type_assignability.rb +0 -367
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bed885aa8ba3f60076879eb1ca1572c56ae59aae2a9ee3745affbbd1f3f93d2
|
4
|
+
data.tar.gz: 344c77c6676f8c6772d28bab9598c8fa45835100f24603985750de076ebe57f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dce04d256960ee738d029a9c66187a1ef5f11beb3fd0613cbb02dde6494eeafde8aa0bf12aadc02d07bb6a64a785444f18636df1eaa3f1be02bce1d24ad63385
|
7
|
+
data.tar.gz: df9772b46abe7c2acd10cf497ded086b3614016d74b26578d2da6720f26afa01a73a7b43c6a0170b67157e7615e2ec989597ed1081a3f6e4ac69553adc338589
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.42.0 (2021-03-08)
|
6
|
+
|
7
|
+
* Type checking performance improvement ([\#309](https://github.com/soutaro/steep/pull/309), [\#311](https://github.com/soutaro/steep/pull/311), [\#312](https://github.com/soutaro/steep/pull/312), [\#313](https://github.com/soutaro/steep/pull/313), [\#314](https://github.com/soutaro/steep/pull/314), [\#315](https://github.com/soutaro/steep/pull/315), [\#316](https://github.com/soutaro/steep/pull/316), [\#320](https://github.com/soutaro/steep/pull/320), [\#322](https://github.com/soutaro/steep/pull/322))
|
8
|
+
* Let `watch` command support files ([\#323](https://github.com/soutaro/steep/pull/323))
|
9
|
+
* Validate _module-self-type_ constraints ([\#308](https://github.com/soutaro/steep/pull/308))
|
10
|
+
* Add `-j` option to specify number of worker processes ([\#318](https://github.com/soutaro/steep/pull/318), [\#325](https://github.com/soutaro/steep/pull/325))
|
11
|
+
* Fix `code` of RBS diagnostics ([\#306](https://github.com/soutaro/steep/pull/306))
|
12
|
+
* Skip printing source code from out of date _expectations_ file ([\#305](https://github.com/soutaro/steep/pull/305))
|
13
|
+
|
14
|
+
## 0.41.0 (2021-02-07)
|
15
|
+
|
16
|
+
* Add `--with-expectations` and `--save-expectations` option ([#303](https://github.com/soutaro/steep/pull/303))
|
17
|
+
|
18
|
+
## 0.40.0 (2021-01-31)
|
19
|
+
|
20
|
+
* Report progress with dots ([#287](https://github.com/soutaro/steep/pull/287))
|
21
|
+
* Diagnostics message improvements ([#297](https://github.com/soutaro/steep/pull/297), [#301](https://github.com/soutaro/steep/pull/301))
|
22
|
+
* Fix error on implicit `to_proc` syntax when `untyped` is yielded ([#291](https://github.com/soutaro/steep/pull/291))
|
23
|
+
|
24
|
+
## 0.39.0 (2020-12-25)
|
25
|
+
|
26
|
+
* Update RBS to 1.0.0 ([#282](https://github.com/soutaro/steep/pull/282))
|
27
|
+
* Better `&&` and `||` typing ([#276](https://github.com/soutaro/steep/pull/276))
|
28
|
+
* Type case based on literals ([#277](https://github.com/soutaro/steep/pull/277))
|
29
|
+
* Type case improvements ([#279](https://github.com/soutaro/steep/pull/279), [#283](https://github.com/soutaro/steep/pull/283))
|
30
|
+
* Improvements on untyped classes/modules, unsupported syntax error handling, and argument types in untyped methods ([#280](https://github.com/soutaro/steep/pull/280))
|
31
|
+
* Fix `bot` and `top` type format ([#278](https://github.com/soutaro/steep/pull/278))
|
32
|
+
* Colorfull error messages ([#273](https://github.com/soutaro/steep/pull/273))
|
33
|
+
|
34
|
+
## 0.38.0 (2020-12-10)
|
35
|
+
|
36
|
+
* Improve `break`/`next` typing ([#271](https://github.com/soutaro/steep/pull/271))
|
37
|
+
* Add LSP `workspace/symbol` feature ([#267](https://github.com/soutaro/steep/pull/267))
|
38
|
+
|
5
39
|
## 0.37.0 (2020-12-06)
|
6
40
|
|
7
41
|
* Update to RBS 0.20.0 with _singleton attribute_ syntax and _proc types with blocks_. ([#264](https://github.com/soutaro/steep/pull/264))
|
data/Rakefile
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "yaml"
|
3
|
+
require "open3"
|
4
|
+
require "tempfile"
|
5
|
+
|
6
|
+
if ARGV.empty?
|
7
|
+
test_dirs = (Pathname(__dir__) + "../smoke").children
|
8
|
+
else
|
9
|
+
test_dirs = ARGV.map {|p| Pathname.pwd + p }
|
10
|
+
end
|
11
|
+
|
12
|
+
failed_tests = []
|
13
|
+
|
14
|
+
test_dirs.each do |dir|
|
15
|
+
puts "Rebaselining #{dir}..."
|
16
|
+
|
17
|
+
command = %w(steep check --save-expectations=test_expectations.yml)
|
18
|
+
puts " command: #{command.join(" ")}"
|
19
|
+
|
20
|
+
output, status = Open3.capture2(*command, chdir: dir.to_s)
|
21
|
+
|
22
|
+
unless status.success?
|
23
|
+
puts "Error!!! 👺"
|
24
|
+
failed_tests << dir.basename
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if failed_tests.empty?
|
29
|
+
puts "Successfully updated output expectations! 🤡"
|
30
|
+
else
|
31
|
+
puts "Failed to update the following tests! 💀"
|
32
|
+
puts " #{failed_tests.join(", ")}"
|
33
|
+
exit 1
|
34
|
+
end
|
data/bin/output_test.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "yaml"
|
3
|
+
require "open3"
|
4
|
+
require "tempfile"
|
5
|
+
require "optparse"
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.on("--verbose", "-v") { @verbose = true }
|
9
|
+
end.parse!(ARGV)
|
10
|
+
|
11
|
+
if ARGV.empty?
|
12
|
+
test_dirs = (Pathname(__dir__) + "../smoke").children
|
13
|
+
else
|
14
|
+
test_dirs = ARGV.map {|p| Pathname.pwd + p }
|
15
|
+
end
|
16
|
+
|
17
|
+
failed_tests = []
|
18
|
+
|
19
|
+
test_dirs.each do |dir|
|
20
|
+
puts "Running test #{dir}..."
|
21
|
+
|
22
|
+
unless (dir + "test_expectations.yml").file?
|
23
|
+
puts "Skipped ⛹️♀️"
|
24
|
+
next
|
25
|
+
end
|
26
|
+
|
27
|
+
command = %w(steep check --with-expectations=test_expectations.yml)
|
28
|
+
puts " command: #{command.join(" ")}"
|
29
|
+
|
30
|
+
output, status = Open3.capture2(*command, chdir: dir.to_s)
|
31
|
+
|
32
|
+
unless status.success?
|
33
|
+
failed_tests << dir.basename
|
34
|
+
puts " Failed! 🤕"
|
35
|
+
else
|
36
|
+
puts " Succeed! 👍"
|
37
|
+
end
|
38
|
+
|
39
|
+
if @verbose
|
40
|
+
puts " Raw output:"
|
41
|
+
output.split(/\n/).each do |line|
|
42
|
+
puts " > #{line.chomp}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if failed_tests.empty?
|
48
|
+
puts "All tests ok! 👏"
|
49
|
+
else
|
50
|
+
puts "Errors detected! 🤮"
|
51
|
+
puts " #{failed_tests.join(", ")}"
|
52
|
+
exit 1
|
53
|
+
end
|
data/lib/steep.rb
CHANGED
@@ -4,6 +4,7 @@ require "pathname"
|
|
4
4
|
require "parser/ruby27"
|
5
5
|
require "ast_utils"
|
6
6
|
require "active_support/core_ext/object/try"
|
7
|
+
require "active_support/core_ext/string/inflections"
|
7
8
|
require "logger"
|
8
9
|
require "active_support/tagged_logging"
|
9
10
|
require "rainbow"
|
@@ -13,6 +14,9 @@ require "etc"
|
|
13
14
|
require "open3"
|
14
15
|
require "stringio"
|
15
16
|
require 'uri'
|
17
|
+
require "yaml"
|
18
|
+
|
19
|
+
require "parallel/processor_count"
|
16
20
|
|
17
21
|
require "rbs"
|
18
22
|
|
@@ -42,6 +46,8 @@ require "steep/ast/annotation/collection"
|
|
42
46
|
require "steep/ast/builtin"
|
43
47
|
require "steep/ast/types/factory"
|
44
48
|
|
49
|
+
require "steep/range_extension"
|
50
|
+
|
45
51
|
require "steep/interface/function"
|
46
52
|
require "steep/interface/block"
|
47
53
|
require "steep/interface/method_type"
|
@@ -56,12 +62,14 @@ require "steep/subtyping/constraints"
|
|
56
62
|
require "steep/subtyping/variable_variance"
|
57
63
|
require "steep/subtyping/variable_occurrence"
|
58
64
|
|
59
|
-
require "steep/
|
65
|
+
require "steep/diagnostic/helper"
|
66
|
+
require "steep/diagnostic/ruby"
|
67
|
+
require "steep/diagnostic/signature"
|
68
|
+
require "steep/diagnostic/lsp_formatter"
|
60
69
|
require "steep/signature/validator"
|
61
70
|
require "steep/source"
|
62
71
|
require "steep/annotation_parser"
|
63
72
|
require "steep/typing"
|
64
|
-
require "steep/errors"
|
65
73
|
require "steep/module_helper"
|
66
74
|
require "steep/type_construction"
|
67
75
|
require "steep/type_inference/context"
|
@@ -76,36 +84,47 @@ require "steep/type_inference/logic_type_interpreter"
|
|
76
84
|
require "steep/type_inference/method_call"
|
77
85
|
require "steep/ast/types"
|
78
86
|
|
79
|
-
require "steep/
|
87
|
+
require "steep/index/rbs_index"
|
88
|
+
require "steep/index/signature_symbol_provider"
|
89
|
+
require "steep/index/source_index"
|
90
|
+
|
91
|
+
require "steep/server/change_buffer"
|
80
92
|
require "steep/server/base_worker"
|
81
|
-
require "steep/server/code_worker"
|
82
|
-
require "steep/server/signature_worker"
|
83
93
|
require "steep/server/worker_process"
|
84
94
|
require "steep/server/interaction_worker"
|
95
|
+
require "steep/server/type_check_worker"
|
85
96
|
require "steep/server/master"
|
86
97
|
|
98
|
+
require "steep/services/content_change"
|
99
|
+
require "steep/services/path_assignment"
|
100
|
+
require "steep/services/signature_service"
|
101
|
+
require "steep/services/type_check_service"
|
102
|
+
require "steep/services/hover_content"
|
103
|
+
require "steep/services/completion_provider"
|
104
|
+
require "steep/services/stats_calculator"
|
105
|
+
require "steep/services/file_loader"
|
106
|
+
|
87
107
|
require "steep/project"
|
88
|
-
require "steep/project/
|
89
|
-
require "steep/project/source_file"
|
108
|
+
require "steep/project/pattern"
|
90
109
|
require "steep/project/options"
|
91
110
|
require "steep/project/target"
|
92
111
|
require "steep/project/dsl"
|
93
|
-
|
94
|
-
require "steep/
|
95
|
-
require "steep/project/completion_provider"
|
112
|
+
|
113
|
+
require "steep/expectations"
|
96
114
|
require "steep/drivers/utils/driver_helper"
|
115
|
+
require "steep/drivers/utils/jobs_count"
|
97
116
|
require "steep/drivers/check"
|
98
117
|
require "steep/drivers/stats"
|
99
118
|
require "steep/drivers/validate"
|
100
119
|
require "steep/drivers/annotations"
|
101
120
|
require "steep/drivers/watch"
|
102
121
|
require "steep/drivers/langserver"
|
103
|
-
require "steep/drivers/signature_error_printer"
|
104
122
|
require "steep/drivers/trace_printer"
|
105
123
|
require "steep/drivers/print_project"
|
106
124
|
require "steep/drivers/init"
|
107
125
|
require "steep/drivers/vendor"
|
108
126
|
require "steep/drivers/worker"
|
127
|
+
require "steep/drivers/diagnostic_printer"
|
109
128
|
|
110
129
|
if ENV["NO_COLOR"]
|
111
130
|
Rainbow.enabled = false
|
@@ -121,7 +140,7 @@ module Steep
|
|
121
140
|
def self.new_logger(output, prev_level)
|
122
141
|
ActiveSupport::TaggedLogging.new(Logger.new(output)).tap do |logger|
|
123
142
|
logger.push_tags "Steep #{VERSION}"
|
124
|
-
logger.level = prev_level || Logger::
|
143
|
+
logger.level = prev_level || Logger::ERROR
|
125
144
|
end
|
126
145
|
end
|
127
146
|
|
@@ -138,11 +157,14 @@ module Steep
|
|
138
157
|
@logger = nil
|
139
158
|
self.log_output = STDERR
|
140
159
|
|
141
|
-
def self.measure(message)
|
160
|
+
def self.measure(message, level: :warn)
|
142
161
|
start = Time.now
|
143
162
|
yield.tap do
|
144
163
|
time = Time.now - start
|
145
|
-
|
164
|
+
if level.is_a?(Symbol)
|
165
|
+
level = Logger.const_get(level.to_s.upcase)
|
166
|
+
end
|
167
|
+
self.logger.log(level) { "#{message} took #{time} seconds" }
|
146
168
|
end
|
147
169
|
end
|
148
170
|
|
@@ -152,4 +174,63 @@ module Steep
|
|
152
174
|
Steep.logger.warn " #{loc}"
|
153
175
|
end
|
154
176
|
end
|
177
|
+
|
178
|
+
class Sampler
|
179
|
+
def initialize()
|
180
|
+
@samples = []
|
181
|
+
end
|
182
|
+
|
183
|
+
def sample(message)
|
184
|
+
start = Time.now
|
185
|
+
yield.tap do
|
186
|
+
time = Time.now - start
|
187
|
+
@samples << [message, time]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def count
|
192
|
+
@samples.count
|
193
|
+
end
|
194
|
+
|
195
|
+
def total
|
196
|
+
@samples.sum(&:last)
|
197
|
+
end
|
198
|
+
|
199
|
+
def slowests(num)
|
200
|
+
@samples.sort_by(&:last).reverse.take(num)
|
201
|
+
end
|
202
|
+
|
203
|
+
def average
|
204
|
+
if count > 0
|
205
|
+
total/count
|
206
|
+
else
|
207
|
+
0
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def percentile(p)
|
212
|
+
slowests(count - count * p / 100r).last&.last || 0
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def self.measure2(message, level: :warn)
|
217
|
+
sampler = Sampler.new
|
218
|
+
result = yield(sampler)
|
219
|
+
|
220
|
+
if level.is_a?(Symbol)
|
221
|
+
level = Logger.const_get(level.to_s.upcase)
|
222
|
+
end
|
223
|
+
logger.log(level) { "#{sampler.total}secs for \"#{message}\"" }
|
224
|
+
logger.log(level) { " Average: #{sampler.average}secs"}
|
225
|
+
logger.log(level) { " Median: #{sampler.percentile(50)}secs"}
|
226
|
+
logger.log(level) { " Samples: #{sampler.count}"}
|
227
|
+
logger.log(level) { " 99 percentile: #{sampler.percentile(99)}secs"}
|
228
|
+
logger.log(level) { " 90 percentile: #{sampler.percentile(90)}secs"}
|
229
|
+
logger.log(level) { " 10 Slowests:"}
|
230
|
+
sampler.slowests(10).each do |message, time|
|
231
|
+
logger.log(level) { " #{message} (#{time}secs)"}
|
232
|
+
end
|
233
|
+
|
234
|
+
result
|
235
|
+
end
|
155
236
|
end
|
data/lib/steep/ast/types/bot.rb
CHANGED
@@ -368,6 +368,8 @@ module Steep
|
|
368
368
|
]
|
369
369
|
when AST::Types::Name::Alias
|
370
370
|
unwrap_optional(expand_alias(type))
|
371
|
+
when AST::Types::Boolean
|
372
|
+
[AST::Builtin.true_type, AST::Builtin.false_type]
|
371
373
|
else
|
372
374
|
[type, nil]
|
373
375
|
end
|
@@ -421,6 +423,14 @@ module Steep
|
|
421
423
|
return_type: AST::Types::Logic::ArgIsReceiver.new(location: method_type.type.return_type.location)
|
422
424
|
)
|
423
425
|
)
|
426
|
+
when RBS::BuiltinNames::Object.name, RBS::BuiltinNames::String.name, RBS::BuiltinNames::Integer.name, RBS::BuiltinNames::Symbol.name,
|
427
|
+
RBS::BuiltinNames::TrueClass.name, RBS::BuiltinNames::FalseClass.name, TypeName("::NilClass")
|
428
|
+
# Value based type-case works on literal types which is available for String, Integer, Symbol, TrueClass, FalseClass, and NilClass
|
429
|
+
return method_type.with(
|
430
|
+
type: method_type.type.with(
|
431
|
+
return_type: AST::Types::Logic::ArgEqualsReceiver.new(location: method_type.type.return_type.location)
|
432
|
+
)
|
433
|
+
)
|
424
434
|
end
|
425
435
|
end
|
426
436
|
end
|
@@ -58,16 +58,23 @@ module Steep
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
class ArgEqualsReceiver < Base
|
62
|
+
def initialize(location: nil)
|
63
|
+
@location = location
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
61
67
|
class Env < Base
|
62
|
-
attr_reader :truthy, :falsy
|
68
|
+
attr_reader :truthy, :falsy, :type
|
63
69
|
|
64
|
-
def initialize(truthy:, falsy:, location: nil)
|
70
|
+
def initialize(truthy:, falsy:, type:, location: nil)
|
65
71
|
@truthy = truthy
|
66
72
|
@falsy = falsy
|
73
|
+
@type = type
|
67
74
|
end
|
68
75
|
|
69
76
|
def ==(other)
|
70
|
-
other.is_a?(Env) && other.truthy == truthy && other.falsy == falsy
|
77
|
+
other.is_a?(Env) && other.truthy == truthy && other.falsy == falsy && other.type == type
|
71
78
|
end
|
72
79
|
|
73
80
|
alias eql? ==
|
@@ -75,6 +82,12 @@ module Steep
|
|
75
82
|
def hash
|
76
83
|
self.class.hash ^ truthy.hash ^ falsy.hash
|
77
84
|
end
|
85
|
+
|
86
|
+
def inspect
|
87
|
+
"#<Steep::AST::Types::Env @type=#{type}, @truthy=..., @falsy=...>"
|
88
|
+
end
|
89
|
+
|
90
|
+
alias to_s inspect
|
78
91
|
end
|
79
92
|
end
|
80
93
|
end
|