steep 1.3.0 → 1.4.0.dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-windows.yml +1 -0
  3. data/.github/workflows/ruby.yml +1 -5
  4. data/Gemfile +3 -1
  5. data/Gemfile.lock +22 -19
  6. data/Gemfile.steep +2 -1
  7. data/Gemfile.steep.lock +18 -14
  8. data/Steepfile +16 -0
  9. data/bin/rbs +21 -0
  10. data/bin/setup +1 -1
  11. data/lib/steep/annotation_parser.rb +40 -20
  12. data/lib/steep/ast/types/factory.rb +56 -10
  13. data/lib/steep/ast/types/name.rb +10 -0
  14. data/lib/steep/diagnostic/ruby.rb +1 -1
  15. data/lib/steep/diagnostic/signature.rb +40 -0
  16. data/lib/steep/index/rbs_index.rb +25 -9
  17. data/lib/steep/index/signature_symbol_provider.rb +1 -1
  18. data/lib/steep/project/dsl.rb +12 -4
  19. data/lib/steep/project/options.rb +3 -1
  20. data/lib/steep/project/target.rb +1 -3
  21. data/lib/steep/server/interaction_worker.rb +37 -20
  22. data/lib/steep/server/lsp_formatter.rb +14 -5
  23. data/lib/steep/services/completion_provider.rb +10 -12
  24. data/lib/steep/services/goto_service.rb +15 -14
  25. data/lib/steep/services/hover_provider/rbs.rb +29 -9
  26. data/lib/steep/services/hover_provider/ruby.rb +16 -10
  27. data/lib/steep/services/signature_service.rb +36 -39
  28. data/lib/steep/signature/validator.rb +28 -6
  29. data/lib/steep/subtyping/check.rb +1 -1
  30. data/lib/steep/type_construction.rb +16 -14
  31. data/lib/steep/type_inference/constant_env.rb +7 -3
  32. data/lib/steep/version.rb +1 -1
  33. data/rbs_collection.steep.lock.yaml +48 -51
  34. data/rbs_collection.steep.yaml +3 -1
  35. data/sample/lib/conference.rb +10 -0
  36. data/sample/sig/conference.rbs +23 -0
  37. data/sig/steep/annotation_parser.rbs +3 -2
  38. data/sig/steep/ast/annotation/collection.rbs +1 -1
  39. data/sig/steep/ast/types/factory.rbs +2 -0
  40. data/sig/steep/ast/types/name.rbs +4 -0
  41. data/sig/steep/diagnostic/signature.rbs +18 -14
  42. data/sig/steep/index/rbs_index.rbs +92 -42
  43. data/sig/steep/project/dsl.rbs +35 -30
  44. data/sig/steep/project/options.rbs +16 -4
  45. data/sig/steep/project/target.rbs +7 -7
  46. data/sig/steep/server/interaction_worker.rbs +2 -2
  47. data/sig/steep/server/lsp_formatter.rbs +4 -2
  48. data/sig/steep/services/completion_provider.rbs +6 -0
  49. data/sig/steep/services/hover_provider/rbs.rbs +6 -4
  50. data/sig/steep/services/hover_provider/ruby.rbs +8 -4
  51. data/sig/steep/services/signature_service.rbs +27 -3
  52. data/sig/steep/signature/validator.rbs +9 -5
  53. data/sig/steep/type_construction.rbs +1 -1
  54. data/sig/steep/type_inference/constant_env.rbs +2 -0
  55. data/smoke/diagnostics-rbs/test_expectations.yml +1 -1
  56. data/smoke/regexp/a.rb +2 -2
  57. data/steep.gemspec +2 -1
  58. metadata +21 -6
@@ -18,7 +18,9 @@ module Steep
18
18
  declarations << decl
19
19
  when RBS::AST::Declarations::Interface
20
20
  declarations << decl
21
- when RBS::AST::Declarations::Alias
21
+ when RBS::AST::Declarations::TypeAlias
22
+ declarations << decl
23
+ when RBS::AST::Declarations::ClassAlias, RBS::AST::Declarations::ModuleAlias
22
24
  declarations << decl
23
25
  else
24
26
  raise "Unexpected type declaration: #{decl}"
@@ -41,7 +43,9 @@ module Steep
41
43
  references << ref
42
44
  when RBS::AST::Declarations::Constant, RBS::AST::Declarations::Global
43
45
  references << ref
44
- when RBS::AST::Declarations::Alias
46
+ when RBS::AST::Declarations::TypeAlias
47
+ references << ref
48
+ when RBS::AST::Declarations::ClassAlias, RBS::AST::Declarations::ModuleAlias
45
49
  references << ref
46
50
  else
47
51
  raise "Unexpected type reference: #{ref}"
@@ -148,7 +152,7 @@ module Steep
148
152
  end
149
153
 
150
154
  def each_entry(&block)
151
- if block_given?
155
+ if block
152
156
  type_index.each_value(&block)
153
157
  method_index.each_value(&block)
154
158
  const_index.each_value(&block)
@@ -176,7 +180,7 @@ module Steep
176
180
 
177
181
  def each_declaration(type_name: nil, method_name: nil, const_name: nil, global_name: nil, &block)
178
182
  if block
179
- entry = entry(type_name: type_name, method_name: method_name, const_name: const_name, global_name: global_name)
183
+ entry = __skip__ = entry(type_name: type_name, method_name: method_name, const_name: const_name, global_name: global_name)
180
184
  entry.declarations.each(&block)
181
185
  else
182
186
  enum_for(:each_declaration, type_name: type_name, method_name: method_name, const_name: const_name, global_name: global_name)
@@ -187,9 +191,12 @@ module Steep
187
191
  entry(type_name: type_name).add_reference(ref)
188
192
  end
189
193
 
190
- def each_reference(type_name: nil, &block)
194
+ def each_reference(type_name:, &block)
191
195
  if block
192
- entry(type_name: type_name).references.each(&block)
196
+ case
197
+ when type_name
198
+ entry(type_name: type_name).references.each(&block)
199
+ end
193
200
  else
194
201
  enum_for(:each_reference, type_name: type_name)
195
202
  end
@@ -205,8 +212,8 @@ module Steep
205
212
  def member(type_name, member)
206
213
  case member
207
214
  when RBS::AST::Members::MethodDefinition
208
- member.types.each do |method_type|
209
- method_type.each_type do |type|
215
+ member.overloads.each do |overload|
216
+ overload.method_type.each_type do |type|
210
217
  type_reference type, from: member
211
218
  end
212
219
  end
@@ -230,6 +237,8 @@ module Steep
230
237
  InstanceMethodName.new(type_name: type_name, method_name: member.name)
231
238
  when :singleton
232
239
  SingletonMethodName.new(type_name: type_name, method_name: member.name)
240
+ else
241
+ raise
233
242
  end
234
243
  index.add_method_declaration(method_name, member)
235
244
  end
@@ -240,6 +249,8 @@ module Steep
240
249
  InstanceMethodName.new(type_name: type_name, method_name: "#{member.name}=".to_sym)
241
250
  when :singleton
242
251
  SingletonMethodName.new(type_name: type_name, method_name: "#{member.name}=".to_sym)
252
+ else
253
+ raise
243
254
  end
244
255
  index.add_method_declaration(method_name, member)
245
256
  end
@@ -305,6 +316,11 @@ module Steep
305
316
  end
306
317
  end
307
318
 
319
+ env.class_alias_decls.each do |name, entry|
320
+ index.add_type_declaration(name, entry.decl)
321
+ index.add_type_reference(entry.decl.old_name, entry.decl)
322
+ end
323
+
308
324
  env.interface_decls.each do |name, decl|
309
325
  index.add_type_declaration(name, decl.decl)
310
326
 
@@ -313,7 +329,7 @@ module Steep
313
329
  end
314
330
  end
315
331
 
316
- env.alias_decls.each do |name, decl|
332
+ env.type_alias_decls.each do |name, decl|
317
333
  index.add_type_declaration(name, decl.decl)
318
334
  type_reference decl.decl.type, from: decl.decl
319
335
  end
@@ -84,7 +84,7 @@ module Steep
84
84
  kind: LSP::Constant::SymbolKind::INTERFACE,
85
85
  container_name: container_name
86
86
  )
87
- when RBS::AST::Declarations::Alias
87
+ when RBS::AST::Declarations::TypeAlias
88
88
  symbols << SymbolInformation.new(
89
89
  name: name,
90
90
  location: decl.location,
@@ -172,8 +172,12 @@ module Steep
172
172
  yield code_diagnostics_config if block_given?
173
173
  end
174
174
 
175
+ def project!
176
+ project or raise "TargetDSL doesn't have project (#{name})"
177
+ end
178
+
175
179
  def collection_config(path)
176
- @collection_config_path = project.absolute_path(path)
180
+ @collection_config_path = project!.absolute_path(path)
177
181
  end
178
182
 
179
183
  def disable_collection
@@ -196,7 +200,6 @@ module Steep
196
200
 
197
201
  def initialize(project:)
198
202
  @project = project
199
- @global_signatures = []
200
203
  end
201
204
 
202
205
  def self.register_template(name, target)
@@ -218,13 +221,18 @@ module Steep
218
221
  end
219
222
 
220
223
  Steep.logger.tagged "target=#{name}" do
221
- target.instance_eval(&block) if block_given?
224
+ target.instance_eval(&block) if block
222
225
  end
223
226
 
224
227
  source_pattern = Pattern.new(patterns: target.sources, ignores: target.ignored_sources, ext: ".rb")
225
228
  signature_pattern = Pattern.new(patterns: target.signatures, ext: ".rbs")
226
229
 
227
- collection_lock = target.collection_config_path&.then { |p| RBS::Collection::Config.lockfile_of(p) }
230
+
231
+ if config_path = target.collection_config_path
232
+ lockfile_path = RBS::Collection::Config.to_lockfile_path(config_path)
233
+ content = YAML.load_file(lockfile_path.to_s)
234
+ collection_lock = RBS::Collection::Config::Lockfile.from_lockfile(lockfile_path: lockfile_path, data: content)
235
+ end
228
236
 
229
237
  Project::Target.new(
230
238
  name: target.name,
@@ -1,7 +1,9 @@
1
1
  module Steep
2
2
  class Project
3
3
  class Options
4
- PathOptions = Struct.new(:core_root, :stdlib_root, :repo_paths, keyword_init: true) do
4
+ PathOptions = _ = Struct.new(:core_root, :stdlib_root, :repo_paths, keyword_init: true) do
5
+ # @implements PathOptions
6
+
5
7
  def customized_stdlib?
6
8
  stdlib_root != nil
7
9
  end
@@ -14,9 +14,6 @@ module Steep
14
14
  @source_pattern = source_pattern
15
15
  @signature_pattern = signature_pattern
16
16
  @code_diagnostics_config = code_diagnostics_config
17
-
18
- @source_files = {}
19
- @signature_files = {}
20
17
  end
21
18
 
22
19
  def possible_source_file?(path)
@@ -55,6 +52,7 @@ module Steep
55
52
 
56
53
  options.libraries.each do |lib|
57
54
  name, version = lib.split(/:/, 2)
55
+ name or raise
58
56
  loader.add(library: name, version: version)
59
57
  end
60
58
  loader.add_collection(options.collection_lock) if options.collection_lock
@@ -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
- decls = sig_service.files[relative_path].decls
143
- locator = RBS::Locator.new(decls: decls)
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
- class_items = sig_service.latest_env.class_decls.keys.map { |type_name|
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.alias_decls.keys.map { |type_name|
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
- class_decl = sig_service.latest_env.class_decls[type_name]&.decls[0]&.decl or raise
205
-
206
- LanguageServer::Protocol::Interface::CompletionItem.new(
207
- label: "#{name}",
208
- documentation: format_comment(class_decl.comment),
209
- text_edit: LanguageServer::Protocol::Interface::TextEdit.new(
210
- range: range,
211
- new_text: name
212
- ),
213
- kind: LSP::Constant::CompletionItemKind::CLASS,
214
- insert_text_format: LSP::Constant::InsertTextFormat::SNIPPET
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.alias_decls[type_name]&.decl or raise
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
- if decl = content.class_or_module?
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
- end
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::Alias
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
- if decl = env.class_decls[full_name]
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
- if decl = env.class_decls[full_name]
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 decl = env.class_decls[full_name]
33
- decl.decls.filter_map {|d| d.decl.comment }
34
- when comment = env.constant_decls[full_name]&.decl&.comment
35
- [comment]
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
- decls = signature_service.latest_env.declarations.select do |decl|
158
- buffer_path = Pathname(decl.location.buffer.name)
159
- buffer_path == relative_path || buffer_path == path
160
- end
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
- if entry = env.class_decls[name]
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
- end
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
- _, decls = service.latest_env.buffers_decls.find do |buffer, _|
23
- Pathname(buffer.name) == path
24
- end
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
- loc_key, path = ::RBS::Locator.new(decls: decls).find2(line: line, column: column) || return
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.alias_decls[head.name]&.decl or raise
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
- if (decl = decl()).is_a?(::RBS::Environment::MultiEntry)
27
+ case decl
28
+ when ::RBS::Environment::ClassEntry, ::RBS::Environment::ModuleEntry
26
29
  decl
27
30
  end
28
31
  end
29
32
 
30
- def constant_decl
31
- if (decl = decl()).is_a?(::RBS::Environment::SingleEntry)
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 constant?
37
- if decl.is_a?(::RBS::Environment::SingleEntry)
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
- if decl.is_a?(::RBS::Environment::MultiEntry)
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
- decl = context.env.class_decls[const_name] || context.env.constant_decls[const_name]
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: decl
184
+ decl: entry
179
185
  )
180
186
  end
181
187
  when :assertion