steep 1.4.0.dev.1 → 1.4.0.dev.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +12 -12
- data/Gemfile.steep +1 -1
- data/Gemfile.steep.lock +15 -12
- data/Steepfile +16 -0
- data/lib/steep/annotation_parser.rb +40 -20
- data/lib/steep/ast/types/factory.rb +56 -10
- data/lib/steep/ast/types/name.rb +10 -0
- data/lib/steep/diagnostic/ruby.rb +1 -1
- data/lib/steep/diagnostic/signature.rb +40 -0
- data/lib/steep/index/rbs_index.rb +12 -3
- data/lib/steep/index/signature_symbol_provider.rb +1 -1
- data/lib/steep/project/target.rb +1 -3
- data/lib/steep/server/interaction_worker.rb +37 -20
- data/lib/steep/server/lsp_formatter.rb +14 -5
- data/lib/steep/services/completion_provider.rb +10 -12
- data/lib/steep/services/goto_service.rb +15 -14
- data/lib/steep/services/hover_provider/rbs.rb +29 -9
- data/lib/steep/services/hover_provider/ruby.rb +16 -10
- data/lib/steep/services/signature_service.rb +36 -39
- data/lib/steep/signature/validator.rb +28 -6
- data/lib/steep/subtyping/check.rb +1 -1
- data/lib/steep/type_construction.rb +16 -14
- data/lib/steep/type_inference/constant_env.rb +7 -3
- data/lib/steep/version.rb +1 -1
- data/rbs_collection.steep.lock.yaml +16 -20
- data/rbs_collection.steep.yaml +3 -1
- data/sample/lib/conference.rb +10 -0
- data/sample/sig/conference.rbs +23 -0
- data/sig/steep/annotation_parser.rbs +3 -2
- data/sig/steep/ast/annotation/collection.rbs +1 -1
- data/sig/steep/ast/types/factory.rbs +2 -0
- data/sig/steep/ast/types/name.rbs +4 -0
- data/sig/steep/diagnostic/signature.rbs +18 -14
- data/sig/steep/index/rbs_index.rbs +6 -2
- data/sig/steep/project/target.rbs +7 -7
- data/sig/steep/server/interaction_worker.rbs +2 -2
- data/sig/steep/server/lsp_formatter.rbs +4 -2
- data/sig/steep/services/completion_provider.rbs +6 -0
- data/sig/steep/services/hover_provider/rbs.rbs +6 -4
- data/sig/steep/services/hover_provider/ruby.rbs +8 -4
- data/sig/steep/services/signature_service.rbs +27 -3
- data/sig/steep/signature/validator.rbs +9 -5
- data/sig/steep/type_construction.rbs +1 -1
- data/sig/steep/type_inference/constant_env.rbs +2 -0
- data/smoke/regexp/a.rb +2 -2
- metadata +3 -3
@@ -128,7 +128,7 @@ module Steep
|
|
128
128
|
)
|
129
129
|
when (targets = project.targets_for_path(job.path)).is_a?(Array)
|
130
130
|
target = targets[0] or return
|
131
|
-
sig_service = service.signature_services[target.name]
|
131
|
+
sig_service = service.signature_services[target.name] #: Services::SignatureService
|
132
132
|
relative_path = job.path
|
133
133
|
buffer = RBS::Buffer.new(name: relative_path, content: sig_service.files[relative_path].content)
|
134
134
|
pos = buffer.loc_to_pos([job.line, job.column])
|
@@ -139,10 +139,12 @@ module Steep
|
|
139
139
|
return
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
142
|
+
sig = sig_service.files[relative_path].signature
|
143
|
+
sig.is_a?(Array) or raise
|
144
|
+
decls = sig[2]
|
145
|
+
locator = RBS::Locator.new(buffer: sig[0], dirs: sig[1], decls: decls)
|
144
146
|
|
145
|
-
_hd, tail = locator.find2(line: job.line, column: job.column)
|
147
|
+
(_hd, tail = locator.find2(line: job.line, column: job.column)) or return []
|
146
148
|
|
147
149
|
namespace = []
|
148
150
|
tail.each do |t|
|
@@ -160,11 +162,12 @@ module Steep
|
|
160
162
|
|
161
163
|
context.map!(&:absolute!)
|
162
164
|
|
163
|
-
|
165
|
+
class_names = sig_service.latest_env.class_decls.keys + sig_service.latest_env.class_alias_decls.keys
|
166
|
+
class_items = class_names.map { |type_name|
|
164
167
|
format_completion_item_for_rbs(sig_service, type_name, context, job, prefix)
|
165
168
|
}.compact
|
166
169
|
|
167
|
-
alias_items = sig_service.latest_env.
|
170
|
+
alias_items = sig_service.latest_env.type_alias_decls.keys.map { |type_name|
|
168
171
|
format_completion_item_for_rbs(sig_service, type_name, context, job, prefix)
|
169
172
|
}.compact
|
170
173
|
|
@@ -201,21 +204,35 @@ module Steep
|
|
201
204
|
|
202
205
|
case type_name.kind
|
203
206
|
when :class
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
207
|
+
env = sig_service.latest_env #: RBS::Environment
|
208
|
+
class_entry = env.module_class_entry(type_name) or raise
|
209
|
+
|
210
|
+
case class_entry
|
211
|
+
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
212
|
+
LanguageServer::Protocol::Interface::CompletionItem.new(
|
213
|
+
label: "#{name}",
|
214
|
+
documentation: format_comment(class_entry.primary.decl.comment),
|
215
|
+
text_edit: LanguageServer::Protocol::Interface::TextEdit.new(
|
216
|
+
range: range,
|
217
|
+
new_text: name
|
218
|
+
),
|
219
|
+
kind: LSP::Constant::CompletionItemKind::CLASS,
|
220
|
+
insert_text_format: LSP::Constant::InsertTextFormat::SNIPPET
|
221
|
+
)
|
222
|
+
when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
|
223
|
+
LanguageServer::Protocol::Interface::CompletionItem.new(
|
224
|
+
label: "#{name}",
|
225
|
+
documentation: format_comment(class_entry.decl.comment),
|
226
|
+
text_edit: LanguageServer::Protocol::Interface::TextEdit.new(
|
227
|
+
range: range,
|
228
|
+
new_text: name
|
229
|
+
),
|
230
|
+
kind: LSP::Constant::CompletionItemKind::CLASS,
|
231
|
+
insert_text_format: LSP::Constant::InsertTextFormat::SNIPPET
|
232
|
+
)
|
233
|
+
end
|
217
234
|
when :alias
|
218
|
-
alias_decl = sig_service.latest_env.
|
235
|
+
alias_decl = sig_service.latest_env.type_alias_decls[type_name]&.decl or raise
|
219
236
|
LanguageServer::Protocol::Interface::CompletionItem.new(
|
220
237
|
label: "#{name}",
|
221
238
|
text_edit: LanguageServer::Protocol::Interface::TextEdit.new(
|
@@ -110,19 +110,24 @@ EOM
|
|
110
110
|
end
|
111
111
|
when HoverProvider::Ruby::ConstantContent
|
112
112
|
CommentBuilder.build do |builder|
|
113
|
-
|
113
|
+
case
|
114
|
+
when decl = content.class_decl
|
114
115
|
builder << <<EOM
|
115
116
|
```rbs
|
116
117
|
#{declaration_summary(decl.primary.decl)}
|
117
118
|
```
|
118
119
|
EOM
|
119
|
-
|
120
|
-
|
121
|
-
if content.constant?
|
120
|
+
when decl = content.constant_decl
|
122
121
|
builder << <<EOM
|
123
122
|
```rbs
|
124
123
|
#{content.full_name}: #{content.type}
|
125
124
|
```
|
125
|
+
EOM
|
126
|
+
when decl = content.class_alias
|
127
|
+
builder << <<EOM
|
128
|
+
```rbs
|
129
|
+
#{decl.is_a?(::RBS::Environment::ClassAliasEntry) ? "class" : "module"} #{decl.decl.new_name} = #{decl.decl.old_name}
|
130
|
+
```
|
126
131
|
EOM
|
127
132
|
end
|
128
133
|
|
@@ -245,10 +250,14 @@ EOM
|
|
245
250
|
" : #{decl.self_types.map {|s| name_and_args(s.name, s.args) }.join(", ")}"
|
246
251
|
end
|
247
252
|
"module #{name_and_params(decl.name, decl.type_params)}#{self_type}"
|
248
|
-
when RBS::AST::Declarations::
|
253
|
+
when RBS::AST::Declarations::TypeAlias
|
249
254
|
"type #{decl.name} = #{decl.type}"
|
250
255
|
when RBS::AST::Declarations::Interface
|
251
256
|
"interface #{name_and_params(decl.name, decl.type_params)}"
|
257
|
+
when RBS::AST::Declarations::ClassAlias
|
258
|
+
"class #{decl.new_name} = #{decl.old_name}"
|
259
|
+
when RBS::AST::Declarations::ModuleAlias
|
260
|
+
"module #{decl.new_name} = #{decl.old_name}"
|
252
261
|
end
|
253
262
|
end
|
254
263
|
end
|
@@ -16,25 +16,23 @@ module Steep
|
|
16
16
|
# @implements ConstantItem
|
17
17
|
|
18
18
|
def class?
|
19
|
-
|
20
|
-
decl.primary.decl.is_a?(RBS::AST::Declarations::Class)
|
21
|
-
end
|
19
|
+
env.class_entry(full_name) ? true : false
|
22
20
|
end
|
23
21
|
|
24
22
|
def module?
|
25
|
-
|
26
|
-
decl.primary.decl.is_a?(RBS::AST::Declarations::Module)
|
27
|
-
end
|
23
|
+
env.module_entry(full_name) ? true : false
|
28
24
|
end
|
29
25
|
|
30
26
|
def comments
|
31
|
-
case
|
32
|
-
when
|
33
|
-
|
34
|
-
when
|
35
|
-
|
27
|
+
case entry = env.constant_entry(full_name)
|
28
|
+
when RBS::Environment::ConstantEntry
|
29
|
+
[entry.decl.comment].compact
|
30
|
+
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
31
|
+
entry.decls.filter_map {|d| d.decl.comment }
|
32
|
+
when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
|
33
|
+
[entry.decl.comment].compact
|
36
34
|
else
|
37
|
-
|
35
|
+
raise
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -151,15 +151,15 @@ module Steep
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
|
-
when target_names = type_check.signature_file?(path)
|
154
|
+
when target_names = type_check.signature_file?(path) #: Array[Symbol]
|
155
155
|
target_names.each do |target_name|
|
156
|
-
signature_service = type_check.signature_services[target_name]
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
signature_service = type_check.signature_services[target_name] #: SignatureService
|
157
|
+
|
158
|
+
env = signature_service.latest_env
|
159
|
+
buffer = env.buffers.find {|buf| buf.name.to_s == relative_path.to_s } or raise
|
160
|
+
(dirs, decls = env.signatures[buffer]) or raise
|
161
161
|
|
162
|
-
locator = RBS::Locator.new(decls: decls)
|
162
|
+
locator = RBS::Locator.new(buffer: buffer, dirs: dirs, decls: decls)
|
163
163
|
last, nodes = locator.find2(line: line, column: column)
|
164
164
|
case nodes[0]
|
165
165
|
when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
|
@@ -222,16 +222,17 @@ module Steep
|
|
222
222
|
|
223
223
|
def constant_definition_in_rbs(name, locations:)
|
224
224
|
type_check.signature_services.each_value do |signature|
|
225
|
-
env = signature.latest_env
|
225
|
+
env = signature.latest_env #: RBS::Environment
|
226
226
|
|
227
|
-
|
227
|
+
case entry = env.constant_entry(name)
|
228
|
+
when RBS::Environment::ConstantEntry
|
229
|
+
locations << entry.decl.location&.[](:name)
|
230
|
+
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
228
231
|
entry.decls.each do |d|
|
229
|
-
locations << d.decl.location[:name
|
232
|
+
locations << d.decl.location&.[](:name)
|
230
233
|
end
|
231
|
-
|
232
|
-
|
233
|
-
if entry = env.constant_decls[name]
|
234
|
-
locations << entry.decl.location[:name]
|
234
|
+
when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
|
235
|
+
locations << entry.decl.location&.[](:new_name)
|
235
236
|
end
|
236
237
|
end
|
237
238
|
|
@@ -19,18 +19,17 @@ module Steep
|
|
19
19
|
def content_for(target:, path:, line:, column:)
|
20
20
|
service = self.service.signature_services[target.name]
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
return if decls.nil?
|
22
|
+
env = service.latest_env
|
23
|
+
buffer = env.buffers.find {|buf| buf.name.to_s == path.to_s } or return
|
24
|
+
(dirs, decls = env.signatures[buffer]) or raise
|
27
25
|
|
28
|
-
|
26
|
+
locator = ::RBS::Locator.new(buffer: buffer, dirs: dirs, decls: decls)
|
27
|
+
loc_key, path = locator.find2(line: line, column: column) || return
|
29
28
|
head, *_tail = path
|
30
29
|
|
31
30
|
case head
|
32
31
|
when ::RBS::Types::Alias
|
33
|
-
alias_decl = service.latest_env.
|
32
|
+
alias_decl = service.latest_env.type_alias_decls[head.name]&.decl or raise
|
34
33
|
|
35
34
|
TypeAliasContent.new(
|
36
35
|
location: head.location || raise,
|
@@ -38,9 +37,16 @@ module Steep
|
|
38
37
|
)
|
39
38
|
when ::RBS::Types::ClassInstance, ::RBS::Types::ClassSingleton
|
40
39
|
if loc_key == :name
|
41
|
-
env = service.latest_env
|
42
|
-
class_decl = env.class_decls[head.name]&.decls&.[](0)&.decl or raise
|
43
40
|
location = head.location&.[](:name) or raise
|
41
|
+
|
42
|
+
class_entry = service.latest_env.module_class_entry(head.name) or raise
|
43
|
+
case class_entry
|
44
|
+
when ::RBS::Environment::ClassEntry, ::RBS::Environment::ModuleEntry
|
45
|
+
class_decl = class_entry.primary.decl
|
46
|
+
when ::RBS::Environment::ClassAliasEntry, ::RBS::Environment::ModuleAliasEntry
|
47
|
+
class_decl = class_entry.decl
|
48
|
+
end
|
49
|
+
|
44
50
|
ClassContent.new(
|
45
51
|
location: location,
|
46
52
|
decl: class_decl
|
@@ -55,6 +61,20 @@ module Steep
|
|
55
61
|
location: location,
|
56
62
|
decl: interface_decl
|
57
63
|
)
|
64
|
+
when ::RBS::AST::Declarations::ClassAlias, ::RBS::AST::Declarations::ModuleAlias
|
65
|
+
if loc_key == :old_name
|
66
|
+
location = head.location&.[](:old_name) or raise
|
67
|
+
|
68
|
+
class_entry = service.latest_env.module_class_entry(head.old_name) or raise
|
69
|
+
case class_entry
|
70
|
+
when ::RBS::Environment::ClassEntry, ::RBS::Environment::ModuleEntry
|
71
|
+
class_decl = class_entry.primary.decl
|
72
|
+
when ::RBS::Environment::ClassAliasEntry, ::RBS::Environment::ModuleAliasEntry
|
73
|
+
class_decl = class_entry.decl
|
74
|
+
end
|
75
|
+
|
76
|
+
ClassContent.new(location: location, decl: class_decl)
|
77
|
+
end
|
58
78
|
end
|
59
79
|
end
|
60
80
|
end
|
@@ -14,6 +14,8 @@ module Steep
|
|
14
14
|
case
|
15
15
|
when decl = class_decl
|
16
16
|
decl.decls.map {|d| d.decl.comment }
|
17
|
+
when decl = class_alias
|
18
|
+
[decl.decl.comment]
|
17
19
|
when decl = constant_decl
|
18
20
|
[decl.decl.comment]
|
19
21
|
else
|
@@ -22,27 +24,31 @@ module Steep
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def class_decl
|
25
|
-
|
27
|
+
case decl
|
28
|
+
when ::RBS::Environment::ClassEntry, ::RBS::Environment::ModuleEntry
|
26
29
|
decl
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
30
|
-
def
|
31
|
-
|
33
|
+
def class_alias
|
34
|
+
case decl
|
35
|
+
when ::RBS::Environment::ClassAliasEntry, ::RBS::Environment::ModuleAliasEntry
|
32
36
|
decl
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
|
-
def
|
37
|
-
if decl.is_a?(::RBS::Environment::
|
40
|
+
def constant_decl
|
41
|
+
if decl.is_a?(::RBS::Environment::ConstantEntry)
|
38
42
|
decl
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
46
|
+
def constant?
|
47
|
+
constant_decl ? true : false
|
48
|
+
end
|
49
|
+
|
42
50
|
def class_or_module?
|
43
|
-
|
44
|
-
decl
|
45
|
-
end
|
51
|
+
(class_decl || class_alias) ? true : false
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
@@ -169,13 +175,13 @@ module Steep
|
|
169
175
|
const_name = typing.source_index.reference(constant_node: node)
|
170
176
|
|
171
177
|
if const_name
|
172
|
-
|
178
|
+
entry = context.env.constant_entry(const_name) or return
|
173
179
|
|
174
180
|
return ConstantContent.new(
|
175
181
|
location: node.location.name,
|
176
182
|
full_name: const_name,
|
177
183
|
type: type,
|
178
|
-
decl:
|
184
|
+
decl: entry
|
179
185
|
)
|
180
186
|
end
|
181
187
|
when :assertion
|
@@ -75,7 +75,7 @@ module Steep
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
FileStatus = _ = Struct.new(:path, :content, :
|
78
|
+
FileStatus = _ = Struct.new(:path, :content, :signature, keyword_init: true)
|
79
79
|
|
80
80
|
def initialize(env:)
|
81
81
|
builder = RBS::DefinitionBuilder.new(env: env)
|
@@ -150,7 +150,7 @@ module Steep
|
|
150
150
|
def apply_changes(files, changes)
|
151
151
|
Steep.logger.tagged "#apply_changes" do
|
152
152
|
Steep.measure2 "Applying change" do |sampler|
|
153
|
-
changes.each.with_object({}) do |pair, update|
|
153
|
+
changes.each.with_object({}) do |pair, update| # $ Hash[Pathname, FileStatus]
|
154
154
|
path, cs = pair
|
155
155
|
sampler.sample "#{path}" do
|
156
156
|
old_text = files[path]&.content
|
@@ -158,17 +158,18 @@ module Steep
|
|
158
158
|
|
159
159
|
buffer = RBS::Buffer.new(name: path, content: content)
|
160
160
|
|
161
|
-
update[path] =
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
161
|
+
update[path] =
|
162
|
+
begin
|
163
|
+
FileStatus.new(path: path, content: content, signature: RBS::Parser.parse_signature(buffer))
|
164
|
+
rescue ArgumentError => exn
|
165
|
+
error = Diagnostic::Signature::UnexpectedError.new(
|
166
|
+
message: exn.message,
|
167
|
+
location: RBS::Location.new(buffer: buffer, start_pos: 0, end_pos: content.size)
|
168
|
+
)
|
169
|
+
FileStatus.new(path: path, content: content, signature: error)
|
170
|
+
rescue RBS::ParsingError => exn
|
171
|
+
FileStatus.new(path: path, content: content, signature: exn)
|
172
|
+
end
|
172
173
|
end
|
173
174
|
end
|
174
175
|
end
|
@@ -181,16 +182,16 @@ module Steep
|
|
181
182
|
paths = Set.new(updates.each_key)
|
182
183
|
paths.merge(pending_changed_paths)
|
183
184
|
|
184
|
-
if updates.each_value.any? {|file| !file.
|
185
|
-
diagnostics = []
|
185
|
+
if updates.each_value.any? {|file| !file.signature.is_a?(Array) }
|
186
|
+
diagnostics = [] #: Array[Diagnostic::Signature::Base]
|
186
187
|
|
187
188
|
updates.each_value do |file|
|
188
|
-
unless file.
|
189
|
-
diagnostic = if file.
|
190
|
-
file.
|
189
|
+
unless file.signature.is_a?(Array)
|
190
|
+
diagnostic = if file.signature.is_a?(Diagnostic::Signature::Base)
|
191
|
+
file.signature
|
191
192
|
else
|
192
193
|
# factory is not used here because the error is a syntax error.
|
193
|
-
Diagnostic::Signature.from_rbs_error(file.
|
194
|
+
Diagnostic::Signature.from_rbs_error(file.signature, factory: _ = nil)
|
194
195
|
end
|
195
196
|
diagnostics << diagnostic
|
196
197
|
end
|
@@ -204,9 +205,7 @@ module Steep
|
|
204
205
|
)
|
205
206
|
else
|
206
207
|
files = self.files.merge(updates)
|
207
|
-
updated_files = paths.
|
208
|
-
hash[path] = files[path]
|
209
|
-
end
|
208
|
+
updated_files = files.slice(*paths.to_a)
|
210
209
|
result =
|
211
210
|
Steep.measure "#update_env with updated #{paths.size} files" do
|
212
211
|
update_env(updated_files, paths: paths)
|
@@ -229,33 +228,29 @@ module Steep
|
|
229
228
|
end
|
230
229
|
|
231
230
|
def update_env(updated_files, paths:)
|
231
|
+
|
232
232
|
Steep.logger.tagged "#update_env" do
|
233
|
-
|
234
|
-
|
235
|
-
new_decls = Set[].compare_by_identity
|
233
|
+
errors = [] #: Array[RBS::BaseError]
|
234
|
+
new_decls = Set[].compare_by_identity #: Set[RBS::AST::Declarations::t]
|
236
235
|
|
237
236
|
env =
|
238
237
|
Steep.measure "Deleting out of date decls" do
|
239
|
-
latest_env.
|
240
|
-
|
241
|
-
paths.include?(decl.location.buffer.name)
|
242
|
-
end
|
243
|
-
end
|
238
|
+
bufs = latest_env.buffers.select {|buf| paths.include?(buf.name) }
|
239
|
+
latest_env.unload(Set.new(bufs))
|
244
240
|
end
|
245
241
|
|
246
242
|
Steep.measure "Loading new decls" do
|
247
243
|
updated_files.each_value do |content|
|
248
|
-
case
|
249
|
-
when RBS::
|
250
|
-
errors <<
|
244
|
+
case content.signature
|
245
|
+
when RBS::ParsingError
|
246
|
+
errors << content.signature
|
251
247
|
when Diagnostic::Signature::UnexpectedError
|
252
|
-
return [
|
248
|
+
return [content.signature]
|
253
249
|
else
|
254
250
|
begin
|
255
|
-
decls
|
256
|
-
|
257
|
-
|
258
|
-
end
|
251
|
+
buffer, dirs, decls = content.signature
|
252
|
+
env.add_signature(buffer: buffer, directives: dirs, decls: decls)
|
253
|
+
new_decls.merge(decls)
|
259
254
|
rescue RBS::LoadingError => exn
|
260
255
|
errors << exn
|
261
256
|
end
|
@@ -375,8 +370,10 @@ module Steep
|
|
375
370
|
type_name_from_decl(member, set: set)
|
376
371
|
end
|
377
372
|
end
|
378
|
-
when RBS::AST::Declarations::
|
373
|
+
when RBS::AST::Declarations::TypeAlias
|
379
374
|
set << decl.name
|
375
|
+
when RBS::AST::Declarations::ClassAlias, RBS::AST::Declarations::ModuleAlias
|
376
|
+
set << decl.new_name
|
380
377
|
end
|
381
378
|
end
|
382
379
|
|
@@ -36,7 +36,7 @@ module Steep
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def type_name_resolver
|
39
|
-
@type_name_resolver ||= RBS::TypeNameResolver.
|
39
|
+
@type_name_resolver ||= RBS::Resolver::TypeNameResolver.new(env)
|
40
40
|
end
|
41
41
|
|
42
42
|
def validator
|
@@ -112,7 +112,7 @@ module Steep
|
|
112
112
|
type.args
|
113
113
|
]
|
114
114
|
when RBS::Types::Alias
|
115
|
-
entry = env.
|
115
|
+
entry = env.type_alias_decls[type.name]
|
116
116
|
|
117
117
|
[
|
118
118
|
type.name,
|
@@ -135,7 +135,7 @@ module Steep
|
|
135
135
|
def validate_type(type)
|
136
136
|
Steep.logger.debug "#{Location.to_string type.location}: Validating #{type}..."
|
137
137
|
|
138
|
-
validator.validate_type
|
138
|
+
validator.validate_type(type, context: nil)
|
139
139
|
validate_type_application(type)
|
140
140
|
end
|
141
141
|
|
@@ -235,7 +235,7 @@ module Steep
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
def
|
238
|
+
def validate_one_class_decl(name)
|
239
239
|
rescue_validation_errors(name) do
|
240
240
|
Steep.logger.debug { "Validating class definition `#{name}`..." }
|
241
241
|
|
@@ -390,6 +390,17 @@ module Steep
|
|
390
390
|
end
|
391
391
|
end
|
392
392
|
|
393
|
+
def validate_one_class(name)
|
394
|
+
entry = env.constant_entry(name)
|
395
|
+
|
396
|
+
case entry
|
397
|
+
when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry
|
398
|
+
validate_one_class_decl(name)
|
399
|
+
when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry
|
400
|
+
validate_one_class_alias(name, entry)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
393
404
|
def validate_ancestor_application(name, ancestor)
|
394
405
|
unless ancestor.args.empty?
|
395
406
|
definition =
|
@@ -465,6 +476,10 @@ module Steep
|
|
465
476
|
validate_one_class(name)
|
466
477
|
end
|
467
478
|
|
479
|
+
env.class_alias_decls.each do |name, entry|
|
480
|
+
validate_one_class_alias(name, entry)
|
481
|
+
end
|
482
|
+
|
468
483
|
env.interface_decls.each_key do |name|
|
469
484
|
validate_one_interface(name)
|
470
485
|
end
|
@@ -497,7 +512,7 @@ module Steep
|
|
497
512
|
end
|
498
513
|
end
|
499
514
|
|
500
|
-
def validate_one_alias(name, entry = env.
|
515
|
+
def validate_one_alias(name, entry = env.type_alias_decls[name])
|
501
516
|
rescue_validation_errors(name) do
|
502
517
|
Steep.logger.debug "Validating alias `#{name}`..."
|
503
518
|
upper_bounds = entry.decl.type_params.each.with_object({}) do |param, bounds|
|
@@ -512,8 +527,15 @@ module Steep
|
|
512
527
|
end
|
513
528
|
end
|
514
529
|
|
530
|
+
def validate_one_class_alias(name, entry)
|
531
|
+
rescue_validation_errors(name) do
|
532
|
+
Steep.logger.debug "Validating class/module alias `#{name}`..."
|
533
|
+
validator.validate_class_alias(entry: entry)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
515
537
|
def validate_alias
|
516
|
-
env.
|
538
|
+
env.type_alias_decls.each do |name, entry|
|
517
539
|
validate_one_alias(name, entry)
|
518
540
|
end
|
519
541
|
end
|