steep 1.7.0.dev.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/README.md +18 -0
- data/doc/narrowing.md +1 -1
- data/doc/shape.md +176 -0
- data/guides/src/gem-rbs-collection/gem-rbs-collection.md +7 -24
- data/lib/steep/ast/types/factory.rb +27 -18
- data/lib/steep/ast/types/proc.rb +14 -9
- data/lib/steep/interface/block.rb +1 -1
- data/lib/steep/interface/builder.rb +1 -0
- data/lib/steep/interface/function.rb +14 -6
- data/lib/steep/interface/method_type.rb +15 -7
- data/lib/steep/project/pattern.rb +1 -2
- data/lib/steep/rake_task.rb +132 -0
- data/lib/steep/server/interaction_worker.rb +6 -0
- data/lib/steep/server/lsp_formatter.rb +2 -0
- data/lib/steep/services/completion_provider.rb +1 -1
- data/lib/steep/services/file_loader.rb +15 -20
- data/lib/steep/services/signature_help_provider.rb +11 -9
- data/lib/steep/signature/validator.rb +1 -1
- data/lib/steep/subtyping/check.rb +15 -6
- data/lib/steep/subtyping/variable_variance.rb +3 -3
- data/lib/steep/type_construction.rb +186 -149
- data/lib/steep/type_inference/block_params.rb +1 -1
- data/lib/steep/type_inference/logic_type_interpreter.rb +2 -1
- data/lib/steep/type_inference/method_params.rb +16 -0
- data/lib/steep/type_inference/send_args.rb +5 -2
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +5 -2
- metadata +7 -145
- data/.github/dependabot.yml +0 -28
- data/.github/workflows/ruby-windows.yml +0 -35
- data/.github/workflows/ruby.yml +0 -32
- data/.vscode/steep-shared.code-snippets +0 -41
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -104
- data/Gemfile.steep +0 -0
- data/gemfile_steep/Gemfile +0 -3
- data/gemfile_steep/Gemfile.lock +0 -77
- data/rbs_collection.steep.lock.yaml +0 -108
- data/rbs_collection.steep.yaml +0 -23
- data/sig/shims/bundler.rbs +0 -3
- data/sig/shims/concurrent-ruby.rbs +0 -39
- data/sig/shims/exception.rbs +0 -4
- data/sig/shims/language-server_protocol.rbs +0 -450
- data/sig/shims/parser/comment.rbs +0 -33
- data/sig/shims/parser/nodes.rbs +0 -252
- data/sig/shims/parser/source/map.rbs +0 -146
- data/sig/shims/parser/source/range.rbs +0 -237
- data/sig/shims/parser.rbs +0 -69
- data/sig/shims/string.rbs +0 -4
- data/sig/shims/tagged_logging.rbs +0 -6
- data/sig/shims/yaml.rbs +0 -4
- data/sig/steep/annotation_parser.rbs +0 -60
- data/sig/steep/ast/annotation/collection.rbs +0 -78
- data/sig/steep/ast/annotation.rbs +0 -121
- data/sig/steep/ast/builtin.rbs +0 -69
- data/sig/steep/ast/ignore.rbs +0 -66
- data/sig/steep/ast/node/type_application.rbs +0 -31
- data/sig/steep/ast/node/type_assertion.rbs +0 -32
- data/sig/steep/ast/types/any.rbs +0 -29
- data/sig/steep/ast/types/boolean.rbs +0 -31
- data/sig/steep/ast/types/bot.rbs +0 -29
- data/sig/steep/ast/types/class.rbs +0 -33
- data/sig/steep/ast/types/factory.rbs +0 -110
- data/sig/steep/ast/types/helper.rbs +0 -24
- data/sig/steep/ast/types/instance.rbs +0 -33
- data/sig/steep/ast/types/intersection.rbs +0 -40
- data/sig/steep/ast/types/literal.rbs +0 -35
- data/sig/steep/ast/types/logic.rbs +0 -83
- data/sig/steep/ast/types/name.rbs +0 -84
- data/sig/steep/ast/types/nil.rbs +0 -31
- data/sig/steep/ast/types/proc.rbs +0 -53
- data/sig/steep/ast/types/record.rbs +0 -39
- data/sig/steep/ast/types/self.rbs +0 -33
- data/sig/steep/ast/types/top.rbs +0 -29
- data/sig/steep/ast/types/tuple.rbs +0 -37
- data/sig/steep/ast/types/union.rbs +0 -40
- data/sig/steep/ast/types/var.rbs +0 -42
- data/sig/steep/ast/types/void.rbs +0 -29
- data/sig/steep/ast/types.rbs +0 -16
- data/sig/steep/cli.rbs +0 -55
- data/sig/steep/diagnostic/deprecated/else_on_exhaustive_case.rbs +0 -13
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +0 -15
- data/sig/steep/diagnostic/helper.rbs +0 -15
- data/sig/steep/diagnostic/lsp_formatter.rbs +0 -36
- data/sig/steep/diagnostic/ruby.rbs +0 -703
- data/sig/steep/diagnostic/signature.rbs +0 -252
- data/sig/steep/drivers/annotations.rbs +0 -17
- data/sig/steep/drivers/check.rbs +0 -33
- data/sig/steep/drivers/checkfile.rbs +0 -27
- data/sig/steep/drivers/diagnostic_printer.rbs +0 -25
- data/sig/steep/drivers/init.rbs +0 -19
- data/sig/steep/drivers/langserver.rbs +0 -36
- data/sig/steep/drivers/print_project.rbs +0 -15
- data/sig/steep/drivers/stats.rbs +0 -47
- data/sig/steep/drivers/utils/driver_helper.rbs +0 -25
- data/sig/steep/drivers/utils/jobs_option.rbs +0 -19
- data/sig/steep/drivers/validate.rbs +0 -15
- data/sig/steep/drivers/vendor.rbs +0 -19
- data/sig/steep/drivers/watch.rbs +0 -27
- data/sig/steep/drivers/worker.rbs +0 -29
- data/sig/steep/equatable.rbs +0 -11
- data/sig/steep/expectations.rbs +0 -72
- data/sig/steep/index/rbs_index.rbs +0 -141
- data/sig/steep/index/signature_symbol_provider.rbs +0 -41
- data/sig/steep/index/source_index.rbs +0 -63
- data/sig/steep/interface/block.rbs +0 -41
- data/sig/steep/interface/builder.rbs +0 -152
- data/sig/steep/interface/function.rbs +0 -270
- data/sig/steep/interface/method_type.rbs +0 -105
- data/sig/steep/interface/shape.rbs +0 -80
- data/sig/steep/interface/substitution.rbs +0 -51
- data/sig/steep/interface/type_param.rbs +0 -43
- data/sig/steep/method_name.rbs +0 -30
- data/sig/steep/module_helper.rbs +0 -16
- data/sig/steep/node_helper.rbs +0 -91
- data/sig/steep/path_helper.rbs +0 -15
- data/sig/steep/project/dsl.rbs +0 -108
- data/sig/steep/project/options.rbs +0 -47
- data/sig/steep/project/pattern.rbs +0 -47
- data/sig/steep/project/target.rbs +0 -25
- data/sig/steep/project.rbs +0 -26
- data/sig/steep/range_extension.rbs +0 -7
- data/sig/steep/server/base_worker.rbs +0 -49
- data/sig/steep/server/change_buffer.rbs +0 -38
- data/sig/steep/server/delay_queue.rbs +0 -37
- data/sig/steep/server/interaction_worker.rbs +0 -90
- data/sig/steep/server/lsp_formatter.rbs +0 -63
- data/sig/steep/server/master.rbs +0 -299
- data/sig/steep/server/type_check_worker.rbs +0 -141
- data/sig/steep/server/worker_process.rbs +0 -97
- data/sig/steep/services/completion_provider.rbs +0 -264
- data/sig/steep/services/content_change.rbs +0 -37
- data/sig/steep/services/file_loader.rbs +0 -21
- data/sig/steep/services/goto_service.rbs +0 -106
- data/sig/steep/services/hover_provider/rbs.rbs +0 -47
- data/sig/steep/services/hover_provider/ruby.rbs +0 -127
- data/sig/steep/services/hover_provider/singleton_methods.rbs +0 -11
- data/sig/steep/services/path_assignment.rbs +0 -21
- data/sig/steep/services/signature_help_provider.rbs +0 -51
- data/sig/steep/services/signature_service.rbs +0 -156
- data/sig/steep/services/stats_calculator.rbs +0 -41
- data/sig/steep/services/type_check_service.rbs +0 -112
- data/sig/steep/services/type_name_completion.rbs +0 -135
- data/sig/steep/signature/validator.rbs +0 -85
- data/sig/steep/source/ignore_ranges.rbs +0 -38
- data/sig/steep/source.rbs +0 -105
- data/sig/steep/subtyping/cache.rbs +0 -17
- data/sig/steep/subtyping/check.rbs +0 -131
- data/sig/steep/subtyping/constraints.rbs +0 -111
- data/sig/steep/subtyping/relation.rbs +0 -63
- data/sig/steep/subtyping/result.rbs +0 -179
- data/sig/steep/subtyping/variable_variance.rbs +0 -25
- data/sig/steep/thread_waiter.rbs +0 -13
- data/sig/steep/type_construction.rbs +0 -542
- data/sig/steep/type_inference/block_params.rbs +0 -170
- data/sig/steep/type_inference/case_when.rbs +0 -130
- data/sig/steep/type_inference/constant_env.rbs +0 -29
- data/sig/steep/type_inference/context.rbs +0 -216
- data/sig/steep/type_inference/context_array.rbs +0 -38
- data/sig/steep/type_inference/logic_type_interpreter.rbs +0 -108
- data/sig/steep/type_inference/method_call.rbs +0 -124
- data/sig/steep/type_inference/method_params.rbs +0 -127
- data/sig/steep/type_inference/multiple_assignment.rbs +0 -76
- data/sig/steep/type_inference/send_args.rbs +0 -243
- data/sig/steep/type_inference/type_env.rbs +0 -160
- data/sig/steep/type_inference/type_env_builder.rbs +0 -81
- data/sig/steep/typing.rbs +0 -75
- data/sig/steep.rbs +0 -45
@@ -0,0 +1,132 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/tasklib"
|
3
|
+
require "steep/cli"
|
4
|
+
|
5
|
+
module Steep
|
6
|
+
# Provides Rake tasks for running Steep commands.
|
7
|
+
#
|
8
|
+
# require "steep/rake_task"
|
9
|
+
# Steep::RakeTask.new do |t|
|
10
|
+
# t.check.severity_level = :error
|
11
|
+
# t.watch.verbose
|
12
|
+
# t.stats << "--format=table"
|
13
|
+
# end
|
14
|
+
class RakeTask < Rake::TaskLib # steep:ignore UnknownConstant
|
15
|
+
attr_accessor :name
|
16
|
+
|
17
|
+
def self.available_commands
|
18
|
+
%i(init check stats binstub project watch)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(name = :steep, cli_runner = default_cli_runner)
|
22
|
+
super()
|
23
|
+
|
24
|
+
@name = name
|
25
|
+
|
26
|
+
configuration = TaskConfiguration.new
|
27
|
+
|
28
|
+
yield configuration if block_given?
|
29
|
+
|
30
|
+
define_tasks(configuration, cli_runner)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# :nodoc:
|
36
|
+
class TaskConfiguration
|
37
|
+
def initialize
|
38
|
+
@commands = {}
|
39
|
+
end
|
40
|
+
|
41
|
+
def method_missing(command)
|
42
|
+
if respond_to?(command)
|
43
|
+
@commands[command] ||= CommandConfiguration.new
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def respond_to_missing?(name, include_private = false)
|
50
|
+
RakeTask.available_commands.include?(name) || super
|
51
|
+
end
|
52
|
+
|
53
|
+
def options(command)
|
54
|
+
@commands[command]&.to_a || []
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# :nodoc:
|
59
|
+
class CommandConfiguration
|
60
|
+
def initialize
|
61
|
+
@options = []
|
62
|
+
end
|
63
|
+
|
64
|
+
def method_missing(name, value = nil)
|
65
|
+
option = "--#{name.to_s.gsub(/_/, '-').gsub(/=/, '')}"
|
66
|
+
option << "=#{value}" if value
|
67
|
+
|
68
|
+
self << option
|
69
|
+
end
|
70
|
+
|
71
|
+
def respond_to_missing?(_name)
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def <<(value)
|
76
|
+
@options << value
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_a
|
81
|
+
@options
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def default_cli_runner
|
86
|
+
lambda do |arguments|
|
87
|
+
require "steep"
|
88
|
+
|
89
|
+
cli = Steep::CLI.new(
|
90
|
+
stdout: $stdout,
|
91
|
+
stdin: $stdin,
|
92
|
+
stderr: $stderr,
|
93
|
+
argv: arguments
|
94
|
+
)
|
95
|
+
|
96
|
+
cli.run
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def define_tasks(configuration, cli_runner)
|
101
|
+
namespace name do
|
102
|
+
RakeTask.available_commands.each do |command|
|
103
|
+
desc "Run steep #{command}"
|
104
|
+
task command do |_, args|
|
105
|
+
configured_options = configuration.options(command)
|
106
|
+
|
107
|
+
argv = [
|
108
|
+
command.to_s,
|
109
|
+
*configured_options,
|
110
|
+
*args.extras
|
111
|
+
]
|
112
|
+
|
113
|
+
result = cli_runner[argv]
|
114
|
+
|
115
|
+
raise "Steep failed" if result.nonzero?
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
desc "Run steep help"
|
120
|
+
task "help" do
|
121
|
+
arguments = ["--help"]
|
122
|
+
|
123
|
+
cli_runner[arguments]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Default steep task to steep:check
|
128
|
+
desc "Run steep check" unless ::Rake.application.last_description # steep:ignore UnknownConstant
|
129
|
+
task name => ["#{name}:check"]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -90,6 +90,12 @@ module Steep
|
|
90
90
|
collect_changes(request)
|
91
91
|
queue_job ApplyChangeJob.new
|
92
92
|
|
93
|
+
when "$/file/reset"
|
94
|
+
uri = request[:params][:uri]
|
95
|
+
text = request[:params][:content]
|
96
|
+
reset_change(uri: uri, text: text)
|
97
|
+
queue_job ApplyChangeJob.new
|
98
|
+
|
93
99
|
when "textDocument/hover"
|
94
100
|
id = request[:id]
|
95
101
|
|
@@ -740,7 +740,7 @@ module Steep
|
|
740
740
|
if method = shape.methods[call.method_name]
|
741
741
|
method.method_types.each.with_index do |method_type, i|
|
742
742
|
defn = method_type.method_decls.to_a[0]&.method_def
|
743
|
-
if defn
|
743
|
+
if defn && defn.type.type
|
744
744
|
range = range_for(position, prefix: prefix)
|
745
745
|
kwargs = argument_nodes.find { |arg| arg.type == :kwargs }&.children || []
|
746
746
|
used_kwargs = kwargs.filter_map { |arg| arg.type == :pair && arg.children.first.children.first }
|
@@ -12,30 +12,25 @@ module Steep
|
|
12
12
|
pats = commandline_patterns.empty? ? pattern.patterns : commandline_patterns
|
13
13
|
|
14
14
|
pats.each do |path|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if source_path.file?
|
31
|
-
relative_path = source_path.relative_path_from(base_dir)
|
32
|
-
unless pattern.ignore?(relative_path)
|
33
|
-
yield relative_path
|
15
|
+
Pathname.glob((base_dir + path).to_s).each do |absolute_path|
|
16
|
+
if absolute_path.file?
|
17
|
+
relative_path = absolute_path.relative_path_from(base_dir)
|
18
|
+
if pattern =~ relative_path
|
19
|
+
yield relative_path
|
20
|
+
end
|
21
|
+
else
|
22
|
+
files = Pathname.glob("#{absolute_path}/**/*#{pattern.ext}")
|
23
|
+
|
24
|
+
files.sort.each do |source_path|
|
25
|
+
if source_path.file?
|
26
|
+
relative_path = source_path.relative_path_from(base_dir)
|
27
|
+
unless pattern.ignore?(relative_path)
|
28
|
+
yield relative_path
|
29
|
+
end
|
34
30
|
end
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
38
|
-
|
39
34
|
end
|
40
35
|
else
|
41
36
|
enum_for :each_path_in_patterns, pattern, commandline_patterns
|
@@ -7,15 +7,17 @@ module Steep
|
|
7
7
|
# @implements Item
|
8
8
|
|
9
9
|
def parameters
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
if method_type.type.is_a?(RBS::Types::Function)
|
11
|
+
arguments = [] #: Array[String]
|
12
|
+
arguments.push(*method_type.type.required_positionals.map(&:to_s))
|
13
|
+
arguments.push(*method_type.type.optional_positionals.map {|p| "?#{p}"})
|
14
|
+
arguments.push("*#{self.method_type.type.rest_positionals}") if method_type.type.rest_positionals
|
15
|
+
arguments.push(*method_type.type.trailing_positionals.map(&:to_s))
|
16
|
+
arguments.push(*method_type.type.required_keywords.map {|name, param| "#{name}: #{param}" })
|
17
|
+
arguments.push(*method_type.type.optional_keywords.map {|name, param| "?#{name}: #{param}" })
|
18
|
+
arguments.push("**#{method_type.type.rest_keywords}") if method_type.type.rest_keywords
|
19
|
+
arguments
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -134,7 +134,7 @@ module Steep
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def validate_type(type)
|
137
|
-
Steep.logger.debug "#{Location.to_string type.location}: Validating #{type}..."
|
137
|
+
Steep.logger.debug { "#{Location.to_string type.location}: Validating #{type}..." }
|
138
138
|
|
139
139
|
validator.validate_type(type, context: nil)
|
140
140
|
validate_type_application(type)
|
@@ -850,8 +850,10 @@ module Steep
|
|
850
850
|
relation.function!
|
851
851
|
|
852
852
|
All(relation) do |result|
|
853
|
-
|
854
|
-
|
853
|
+
if relation.sub_type.params && relation.super_type.params
|
854
|
+
result.add(relation.map {|fun| _ = fun.params }) do |rel|
|
855
|
+
check_method_params(name, rel)
|
856
|
+
end
|
855
857
|
end
|
856
858
|
|
857
859
|
result.add(relation.map {|fun| fun.return_type }) do |rel|
|
@@ -906,16 +908,23 @@ module Steep
|
|
906
908
|
end
|
907
909
|
|
908
910
|
def match_method_type_fails?(name, type1, type2)
|
909
|
-
|
910
|
-
|
911
|
+
if type1.type.params && type2.type.params
|
912
|
+
match_params(name, Relation(type1.type.params, type2.type.params)).tap do |param_pairs|
|
913
|
+
return param_pairs unless param_pairs.is_a?(Array)
|
914
|
+
end
|
911
915
|
end
|
912
916
|
|
913
917
|
case result = expand_block_given(name, Relation(type1.block, type2.block))
|
914
918
|
when Result::Base
|
915
919
|
return result
|
916
920
|
when Relation
|
917
|
-
|
918
|
-
|
921
|
+
type1.block or raise
|
922
|
+
type2.block or raise
|
923
|
+
|
924
|
+
if type1.block.type.params && type2.block.type.params
|
925
|
+
match_params(name, result.map {|m| _ = m.type.params }).tap do |param_pairs|
|
926
|
+
return param_pairs unless param_pairs.is_a?(Array)
|
927
|
+
end
|
919
928
|
end
|
920
929
|
end
|
921
930
|
|
@@ -46,7 +46,7 @@ module Steep
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.add_params(params, block:, covariants:, contravariants:)
|
49
|
-
params
|
49
|
+
params&.each_type do |type|
|
50
50
|
add_type(type, variance: block ? :contravariant : :covariant, covariants: covariants, contravariants: contravariants)
|
51
51
|
end
|
52
52
|
end
|
@@ -64,12 +64,12 @@ module Steep
|
|
64
64
|
contravariants << type.name
|
65
65
|
end
|
66
66
|
when AST::Types::Proc
|
67
|
-
type.type.params
|
67
|
+
type.type.params&.each_type do |type|
|
68
68
|
add_type(type, variance: variance, covariants: contravariants, contravariants: covariants)
|
69
69
|
end
|
70
70
|
add_type(type.type.return_type, variance: variance, covariants: covariants, contravariants: contravariants)
|
71
71
|
if type.block
|
72
|
-
type.block.type.params
|
72
|
+
type.block.type.params&.each_type do |type|
|
73
73
|
add_type(type, variance: variance, covariants: covariants, contravariants: contravariants)
|
74
74
|
end
|
75
75
|
add_type(type.type.return_type, variance: variance, covariants: contravariants, contravariants: covariants)
|