steep 1.4.0.dev.1 → 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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +12 -12
  4. data/Gemfile.steep +1 -1
  5. data/Gemfile.steep.lock +15 -12
  6. data/Steepfile +16 -0
  7. data/lib/steep/annotation_parser.rb +40 -20
  8. data/lib/steep/ast/types/factory.rb +56 -10
  9. data/lib/steep/ast/types/name.rb +10 -0
  10. data/lib/steep/diagnostic/ruby.rb +1 -1
  11. data/lib/steep/diagnostic/signature.rb +40 -0
  12. data/lib/steep/index/rbs_index.rb +12 -3
  13. data/lib/steep/index/signature_symbol_provider.rb +1 -1
  14. data/lib/steep/project/target.rb +1 -3
  15. data/lib/steep/server/interaction_worker.rb +37 -20
  16. data/lib/steep/server/lsp_formatter.rb +14 -5
  17. data/lib/steep/services/completion_provider.rb +10 -12
  18. data/lib/steep/services/goto_service.rb +15 -14
  19. data/lib/steep/services/hover_provider/rbs.rb +29 -9
  20. data/lib/steep/services/hover_provider/ruby.rb +16 -10
  21. data/lib/steep/services/signature_service.rb +36 -39
  22. data/lib/steep/signature/validator.rb +28 -6
  23. data/lib/steep/subtyping/check.rb +1 -1
  24. data/lib/steep/type_construction.rb +16 -14
  25. data/lib/steep/type_inference/constant_env.rb +7 -3
  26. data/lib/steep/version.rb +1 -1
  27. data/rbs_collection.steep.lock.yaml +16 -20
  28. data/rbs_collection.steep.yaml +3 -1
  29. data/sample/lib/conference.rb +10 -0
  30. data/sample/sig/conference.rbs +23 -0
  31. data/sig/steep/annotation_parser.rbs +3 -2
  32. data/sig/steep/ast/annotation/collection.rbs +1 -1
  33. data/sig/steep/ast/types/factory.rbs +2 -0
  34. data/sig/steep/ast/types/name.rbs +4 -0
  35. data/sig/steep/diagnostic/signature.rbs +18 -14
  36. data/sig/steep/index/rbs_index.rbs +6 -2
  37. data/sig/steep/project/target.rbs +7 -7
  38. data/sig/steep/server/interaction_worker.rbs +2 -2
  39. data/sig/steep/server/lsp_formatter.rbs +4 -2
  40. data/sig/steep/services/completion_provider.rbs +6 -0
  41. data/sig/steep/services/hover_provider/rbs.rbs +6 -4
  42. data/sig/steep/services/hover_provider/ruby.rbs +8 -4
  43. data/sig/steep/services/signature_service.rbs +27 -3
  44. data/sig/steep/signature/validator.rbs +9 -5
  45. data/sig/steep/type_construction.rbs +1 -1
  46. data/sig/steep/type_inference/constant_env.rbs +2 -0
  47. data/smoke/regexp/a.rb +2 -2
  48. metadata +3 -3
@@ -135,8 +135,8 @@ module Steep
135
135
  checker.check(
136
136
  relation,
137
137
  self_type: self_type,
138
- instance_type: module_context.instance_type,
139
- class_type: module_context.module_type,
138
+ instance_type: module_context!.instance_type,
139
+ class_type: module_context!.module_type,
140
140
  constraints: constraints
141
141
  )
142
142
  end
@@ -295,10 +295,12 @@ module Steep
295
295
  else
296
296
  name = module_name || super_name
297
297
 
298
- if name && entry = checker.factory.env.class_decls[name]
298
+ if name && checker.factory.env.module_name?(name)
299
+ definition = checker.factory.definition_builder.build_instance(name)
300
+
299
301
  AST::Annotation::Implements::Module.new(
300
302
  name: name,
301
- args: entry.type_params.each.map(&:name)
303
+ args: definition.type_params
302
304
  )
303
305
  end
304
306
  end
@@ -338,7 +340,7 @@ module Steep
338
340
  end
339
341
 
340
342
  def for_module(node, new_module_name)
341
- new_nesting = [nesting, new_module_name || false]
343
+ new_nesting = [nesting, new_module_name || false] #: RBS::Resolver::context
342
344
 
343
345
  annots = source.annotations(block: node, factory: checker.factory, context: new_nesting)
344
346
 
@@ -353,9 +355,7 @@ module Steep
353
355
  end
354
356
 
355
357
  if implement_module_name
356
- module_entry = checker.factory.definition_builder.env.class_decls[implement_module_name.name]
357
-
358
- raise unless module_entry.is_a?(RBS::Environment::ModuleEntry)
358
+ module_entry = checker.factory.definition_builder.env.normalized_module_entry(implement_module_name.name) or raise
359
359
 
360
360
  module_context = module_context.update(
361
361
  instance_type: AST::Types::Intersection.build(
@@ -566,10 +566,10 @@ module Steep
566
566
  when AST::Types::Name::Singleton
567
567
  type_name = instance_type.name
568
568
 
569
- case checker.factory.env.class_decls[type_name]
570
- when RBS::Environment::ModuleEntry
569
+ case checker.factory.env.constant_entry(type_name)
570
+ when RBS::Environment::ModuleEntry, RBS::Environment::ModuleAliasEntry
571
571
  AST::Builtin::Module.instance_type
572
- when RBS::Environment::ClassEntry
572
+ when RBS::Environment::ClassEntry, RBS::Environment::ClassAliasEntry
573
573
  AST::Builtin::Class.instance_type
574
574
  else
575
575
  raise
@@ -2399,7 +2399,7 @@ module Steep
2399
2399
  if type = as_type.type?(module_context!.nesting, checker.factory, [])
2400
2400
  actual_type, constr = synthesize(asserted_node, hint: type)
2401
2401
 
2402
- if result = no_subtyping?(sub_type: type, super_type: actual_type)
2402
+ if no_subtyping?(sub_type: type, super_type: actual_type) && no_subtyping?(sub_type: actual_type, super_type: type)
2403
2403
  typing.add_error(
2404
2404
  Diagnostic::Ruby::FalseAssertion.new(
2405
2405
  node: node,
@@ -4098,7 +4098,8 @@ module Steep
4098
4098
 
4099
4099
  def validate_method_definitions(node, module_name)
4100
4100
  module_name_1 = module_name.name
4101
- member_decl_count = checker.factory.env.class_decls[module_name_1].decls.count {|d| d.decl.each_member.count > 0 }
4101
+ module_entry = checker.factory.env.normalized_module_class_entry(module_name_1) or raise
4102
+ member_decl_count = module_entry.decls.count {|d| d.decl.each_member.count > 0 }
4102
4103
 
4103
4104
  return unless member_decl_count == 1
4104
4105
 
@@ -4267,7 +4268,8 @@ module Steep
4267
4268
  def to_instance_type(type, args: nil)
4268
4269
  args = args || case type
4269
4270
  when AST::Types::Name::Singleton
4270
- checker.factory.env.class_decls[type.name].type_params.each.map { AST::Builtin.any_type }
4271
+ decl = checker.factory.env.normalized_module_class_entry(type.name) or raise
4272
+ decl.type_params.each.map { AST::Builtin.any_type }
4271
4273
  else
4272
4274
  raise "unexpected type to to_instance_type: #{type}"
4273
4275
  end
@@ -6,7 +6,6 @@ module Steep
6
6
  attr_reader :resolver
7
7
 
8
8
  def initialize(factory:, context:, resolver:)
9
- @cache = {}
10
9
  @factory = factory
11
10
  @context = context
12
11
  @resolver = resolver
@@ -25,7 +24,8 @@ module Steep
25
24
  end
26
25
 
27
26
  def constants
28
- resolver.constants(context).transform_values {|c| decompose_constant(c) }
27
+ cs = resolver.constants(context) or raise
28
+ cs.transform_values {|c| decompose_constant!(c) }
29
29
  end
30
30
 
31
31
  def resolve_child(module_name, constant_name)
@@ -35,7 +35,11 @@ module Steep
35
35
  end
36
36
 
37
37
  def children(module_name)
38
- resolver.children(module_name).transform_values {|c| decompose_constant(c) }
38
+ resolver.children(module_name).transform_values {|c| decompose_constant!(c) }
39
+ end
40
+
41
+ def decompose_constant!(constant)
42
+ decompose_constant(constant) || raise
39
43
  end
40
44
 
41
45
  def decompose_constant(constant)
data/lib/steep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "1.4.0.dev.1"
2
+ VERSION = "1.4.0.dev.2"
3
3
  end
@@ -2,17 +2,17 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
5
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
6
6
  remote: https://github.com/ruby/gem_rbs_collection.git
7
7
  repo_dir: gems
8
8
  path: ".gem_rbs_collection"
9
9
  gems:
10
10
  - name: activesupport
11
- version: '6.0'
11
+ version: '7.0'
12
12
  source:
13
13
  type: git
14
14
  name: ruby/gem_rbs_collection
15
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
15
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
16
16
  remote: https://github.com/ruby/gem_rbs_collection.git
17
17
  repo_dir: gems
18
18
  - name: ast
@@ -20,7 +20,15 @@ gems:
20
20
  source:
21
21
  type: git
22
22
  name: ruby/gem_rbs_collection
23
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
23
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
24
+ remote: https://github.com/ruby/gem_rbs_collection.git
25
+ repo_dir: gems
26
+ - name: concurrent-ruby
27
+ version: '1.1'
28
+ source:
29
+ type: git
30
+ name: ruby/gem_rbs_collection
31
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
24
32
  remote: https://github.com/ruby/gem_rbs_collection.git
25
33
  repo_dir: gems
26
34
  - name: csv
@@ -48,7 +56,7 @@ gems:
48
56
  source:
49
57
  type: git
50
58
  name: ruby/gem_rbs_collection
51
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
59
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
52
60
  remote: https://github.com/ruby/gem_rbs_collection.git
53
61
  repo_dir: gems
54
62
  - name: json
@@ -60,7 +68,7 @@ gems:
60
68
  source:
61
69
  type: git
62
70
  name: ruby/gem_rbs_collection
63
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
71
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
64
72
  remote: https://github.com/ruby/gem_rbs_collection.git
65
73
  repo_dir: gems
66
74
  - name: logger
@@ -88,7 +96,7 @@ gems:
88
96
  source:
89
97
  type: git
90
98
  name: ruby/gem_rbs_collection
91
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
99
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
92
100
  remote: https://github.com/ruby/gem_rbs_collection.git
93
101
  repo_dir: gems
94
102
  - name: pathname
@@ -100,17 +108,9 @@ gems:
100
108
  source:
101
109
  type: git
102
110
  name: ruby/gem_rbs_collection
103
- revision: 6f9f54a753a78c505e63e7f31a48b3f71f1b510d
111
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
104
112
  remote: https://github.com/ruby/gem_rbs_collection.git
105
113
  repo_dir: gems
106
- - name: rbs
107
- version: 3.0.0.dev.1
108
- source:
109
- type: rubygems
110
- - name: rdoc
111
- version: '0'
112
- source:
113
- type: stdlib
114
114
  - name: securerandom
115
115
  version: '0'
116
116
  source:
@@ -131,8 +131,4 @@ gems:
131
131
  version: '0'
132
132
  source:
133
133
  type: stdlib
134
- - name: tsort
135
- version: '0'
136
- source:
137
- type: stdlib
138
134
  gemfile_lock_path: Gemfile.steep.lock
@@ -2,7 +2,7 @@
2
2
  sources:
3
3
  - name: ruby/gem_rbs_collection
4
4
  remote: https://github.com/ruby/gem_rbs_collection.git
5
- revision: main
5
+ revision: c42c09528dd99252db98f0744181a6de54ec2f55
6
6
  repo_dir: gems
7
7
 
8
8
  # A directory to install the downloaded RBSs
@@ -15,6 +15,8 @@ gems:
15
15
  ignore: true
16
16
  - name: set
17
17
  - name: rbs
18
+ ignore: true
18
19
  - name: with_steep_types
19
20
  ignore: true
20
21
  - name: dbm
22
+ - name: optparse
@@ -10,3 +10,13 @@ class Conference
10
10
  end
11
11
 
12
12
  Conference.new()
13
+
14
+
15
+ Konference
16
+
17
+ Konference.new()
18
+
19
+
20
+ # @type var foo: Konference
21
+
22
+ foo = Conference.new
@@ -1,3 +1,5 @@
1
+ use Object as Foo
2
+
1
3
  class Conference
2
4
  attr_reader title: String
3
5
  attr_reader year: Integer
@@ -12,3 +14,24 @@ end
12
14
  class Object
13
15
  def must: () -> self
14
16
  end
17
+
18
+ # Test data
19
+ class Konference = Conference
20
+
21
+ class Allay = ::Array
22
+
23
+ module Hoge = Bazzz
24
+
25
+ module Bazzz = Hoge
26
+
27
+ class Foo < Konference
28
+ class OBH = String
29
+
30
+ type a = Integer
31
+ end
32
+
33
+ type foo = [Conference, Konference]
34
+
35
+
36
+ type b = ::Foo::OBH
37
+
@@ -19,7 +19,8 @@ module Steep
19
19
 
20
20
  attr_reader location: RBS::Location[untyped, untyped]
21
21
 
22
- def initialize: (source: String, location: RBS::Location[untyped, untyped], ?exn: Exception?) -> void
22
+ def initialize: (source: String, location: RBS::Location[untyped, untyped], exn: Exception) -> void
23
+ | (source: String, location: RBS::Location[untyped, untyped], message: String) -> void
23
24
  end
24
25
 
25
26
  TYPE: Regexp
@@ -30,7 +31,7 @@ module Steep
30
31
 
31
32
  TYPE_PARAMS: Regexp
32
33
 
33
- def parse_type: (String) -> AST::Types::t
34
+ def parse_type: (MatchData, ?Symbol, location: RBS::Location[untyped, untyped]) -> AST::Types::t
34
35
 
35
36
  # ```
36
37
  # @type ${keyword} ${name}: ${type}
@@ -26,7 +26,7 @@ module Steep
26
26
 
27
27
  attr_reader module_type_annotation: untyped
28
28
 
29
- attr_reader implement_module_annotation: untyped
29
+ attr_reader implement_module_annotation: Implements?
30
30
 
31
31
  attr_reader dynamic_annotations: untyped
32
32
 
@@ -74,6 +74,8 @@ module Steep
74
74
  def try_singleton_type: (t) -> t?
75
75
 
76
76
  def try_instance_type: (t) -> t?
77
+
78
+ def normalize_type: (t) -> t
77
79
  end
78
80
  end
79
81
  end
@@ -16,6 +16,8 @@ module Steep
16
16
  def subst: (Steep::Interface::Substitution s) -> self
17
17
 
18
18
  def level: () -> Array[Integer]
19
+
20
+ def map_type: () { (t) -> t } -> self
19
21
  end
20
22
 
21
23
  class Applying < Base
@@ -45,6 +47,8 @@ module Steep
45
47
  include Helper::ChildrenLevel
46
48
 
47
49
  def level: () -> Array[Integer]
50
+
51
+ def map_type: () { (t) -> t } -> self
48
52
  end
49
53
 
50
54
  class Singleton < Base
@@ -146,23 +146,11 @@ module Steep
146
146
  class ModuleSelfTypeError < Base
147
147
  attr_reader name: RBS::TypeName
148
148
 
149
- attr_reader ancestor: RBS::DefinitionBuilder::AncestorBuilder::OneAncestors
149
+ attr_reader ancestor: RBS::Definition::Ancestor::Instance
150
150
 
151
151
  attr_reader relation: Subtyping::Relation[AST::Types::t]
152
152
 
153
- def initialize: (name: RBS::TypeName, ancestor: RBS::DefinitionBuilder::AncestorBuilder::OneAncestors, relation: Subtyping::Relation[AST::Types::t], location: location?) -> void
154
-
155
- def header_line: () -> String
156
- end
157
-
158
- class ClassVariableDuplicationError < Base
159
- attr_reader class_name: RBS::TypeName
160
-
161
- attr_reader other_class_name: RBS::TypeName
162
-
163
- attr_reader variable_name: Symbol
164
-
165
- def initialize: (class_name: RBS::TypeName, other_class_name: RBS::TypeName, variable_name: Symbol, location: RBS::Location[untyped, untyped]) -> void
153
+ def initialize: (name: RBS::TypeName, ancestor: RBS::Definition::Ancestor::Instance, relation: Subtyping::Relation[AST::Types::t], location: location?) -> void
166
154
 
167
155
  def header_line: () -> String
168
156
  end
@@ -242,6 +230,22 @@ module Steep
242
230
  def header_line: () -> String
243
231
  end
244
232
 
233
+ class InconsistentClassModuleAliasError < Base
234
+ attr_reader decl: RBS::AST::Declarations::ModuleAlias | RBS::AST::Declarations::ClassAlias
235
+
236
+ def initialize: (decl: RBS::AST::Declarations::ModuleAlias | RBS::AST::Declarations::ClassAlias) -> void
237
+
238
+ def header_line: () -> String
239
+ end
240
+
241
+ class CyclicClassAliasDefinitionError < Base
242
+ attr_reader decl: RBS::AST::Declarations::ModuleAlias | RBS::AST::Declarations::ClassAlias
243
+
244
+ def initialize: (decl: RBS::AST::Declarations::ModuleAlias | RBS::AST::Declarations::ClassAlias) -> void
245
+
246
+ def header_line: () -> String
247
+ end
248
+
245
249
  def self.from_rbs_error: (RBS::BaseError error, factory: AST::Types::Factory) -> Base
246
250
  end
247
251
  end
@@ -7,7 +7,9 @@ module Steep
7
7
  type decl = RBS::AST::Declarations::Class
8
8
  | RBS::AST::Declarations::Module
9
9
  | RBS::AST::Declarations::Interface
10
- | RBS::AST::Declarations::Alias
10
+ | RBS::AST::Declarations::TypeAlias
11
+ | RBS::AST::Declarations::ClassAlias
12
+ | RBS::AST::Declarations::ModuleAlias
11
13
 
12
14
  type ref = RBS::AST::Members::MethodDefinition
13
15
  | RBS::AST::Members::AttrWriter
@@ -22,7 +24,9 @@ module Steep
22
24
  | RBS::AST::Declarations::Class
23
25
  | RBS::AST::Declarations::Constant
24
26
  | RBS::AST::Declarations::Global
25
- | RBS::AST::Declarations::Alias
27
+ | RBS::AST::Declarations::TypeAlias
28
+ | RBS::AST::Declarations::ClassAlias
29
+ | RBS::AST::Declarations::ModuleAlias
26
30
 
27
31
  attr_reader declarations: Set[decl]
28
32
 
@@ -1,9 +1,9 @@
1
1
  module Steep
2
2
  class Project
3
3
  class Target
4
- attr_reader name: untyped
4
+ attr_reader name: Symbol
5
5
 
6
- attr_reader options: untyped
6
+ attr_reader options: Options
7
7
 
8
8
  attr_reader source_pattern: Pattern
9
9
 
@@ -11,15 +11,15 @@ module Steep
11
11
 
12
12
  attr_reader code_diagnostics_config: untyped
13
13
 
14
- def initialize: (name: untyped, options: untyped, source_pattern: untyped, signature_pattern: untyped, code_diagnostics_config: untyped) -> void
14
+ def initialize: (name: Symbol, options: Options, source_pattern: Pattern, signature_pattern: Pattern, code_diagnostics_config: untyped) -> void
15
15
 
16
- def possible_source_file?: (untyped path) -> untyped
16
+ def possible_source_file?: (Pathname path) -> bool
17
17
 
18
- def possible_signature_file?: (untyped path) -> untyped
18
+ def possible_signature_file?: (Pathname path) -> bool
19
19
 
20
- def new_env_loader: (project: untyped) -> untyped
20
+ def new_env_loader: (project: Project) -> RBS::EnvironmentLoader
21
21
 
22
- def self.construct_env_loader: (options: untyped, project: untyped) -> untyped
22
+ def self.construct_env_loader: (options: Options, project: Project) -> RBS::EnvironmentLoader
23
23
  end
24
24
  end
25
25
  end
@@ -23,11 +23,11 @@ module Steep
23
23
 
24
24
  def process_completion: (untyped job) -> untyped
25
25
 
26
- def format_completion_item_for_rbs: (untyped sig_service, untyped type_name, untyped context, untyped job, untyped prefix) -> (nil | untyped)
26
+ def format_completion_item_for_rbs: (Services::SignatureService sig_service, untyped type_name, untyped context, untyped job, untyped prefix) -> (nil | untyped)
27
27
 
28
28
  def format_comment: (untyped comment) -> (untyped | nil)
29
29
 
30
- def format_comments: (untyped comments) -> (untyped | nil)
30
+ def format_comments: (Array[RBS::AST::Comment] comments) -> untyped?
31
31
 
32
32
  def format_completion_item: (untyped item) -> untyped
33
33
 
@@ -28,8 +28,10 @@ module Steep
28
28
  type summarizable_decl = ::RBS::AST::Declarations::Class
29
29
  | ::RBS::AST::Declarations::Module
30
30
  | ::RBS::AST::Declarations::Interface
31
- | ::RBS::AST::Declarations::Alias
32
-
31
+ | ::RBS::AST::Declarations::TypeAlias
32
+ | ::RBS::AST::Declarations::ClassAlias
33
+ | ::RBS::AST::Declarations::ModuleAlias
34
+
33
35
  def self?.declaration_summary: (summarizable_decl) -> String
34
36
  end
35
37
  end
@@ -51,6 +51,12 @@ module Steep
51
51
  attr_reader full_name: RBS::TypeName
52
52
 
53
53
  def initialize: (env: RBS::Environment, identifier: Symbol, range: Range, type: AST::Types::t, full_name: RBS::TypeName) -> void
54
+
55
+ def class?: () -> bool
56
+
57
+ def module?: () -> bool
58
+
59
+ def comments: () -> Array[RBS::AST::Comment]
54
60
  end
55
61
 
56
62
  class MethodNameItem
@@ -5,17 +5,19 @@ module Steep
5
5
  class TypeAliasContent
6
6
  attr_reader location: ::RBS::Location[untyped, untyped]
7
7
 
8
- attr_reader decl: ::RBS::AST::Declarations::Alias
8
+ attr_reader decl: ::RBS::AST::Declarations::TypeAlias
9
9
 
10
- def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Alias) -> void
10
+ def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::TypeAlias) -> void
11
11
  end
12
12
 
13
13
  class ClassContent
14
14
  attr_reader location: ::RBS::Location[untyped, untyped]
15
15
 
16
- attr_reader decl: ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module
16
+ type decl = ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module | ::RBS::AST::Declarations::ClassAlias | ::RBS::AST::Declarations::ModuleAlias
17
17
 
18
- def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module) -> void
18
+ attr_reader decl: decl
19
+
20
+ def initialize: (location: ::RBS::Location[untyped, untyped], decl: decl) -> void
19
21
  end
20
22
 
21
23
  class InterfaceContent
@@ -82,23 +82,27 @@ module Steep
82
82
 
83
83
  type decl = ::RBS::Environment::ClassEntry
84
84
  | ::RBS::Environment::ModuleEntry
85
- | ::RBS::Environment::SingleEntry[::RBS::TypeName, ::RBS::AST::Declarations::Constant]
85
+ | ::RBS::Environment::ClassAliasEntry
86
+ | ::RBS::Environment::ModuleAliasEntry
87
+ | ::RBS::Environment::ConstantEntry
86
88
 
87
89
  attr_reader decl: decl
88
90
 
89
91
  attr_reader class_decl(): ::RBS::Environment::ClassEntry | ::RBS::Environment::ModuleEntry | nil
90
92
 
91
- attr_reader constant_decl(): ::RBS::Environment::SingleEntry[::RBS::TypeName, ::RBS::AST::Declarations::Constant]?
93
+ attr_reader class_alias(): ::RBS::Environment::ClassAliasEntry | ::RBS::Environment::ModuleAliasEntry | nil
94
+
95
+ attr_reader constant_decl(): ::RBS::Environment::ConstantEntry?
92
96
 
93
97
  def initialize: (location: Parser::Source::Range, full_name: ::RBS::TypeName, type: AST::Types::t, decl: decl) -> void
94
98
 
95
99
  def comments: () -> Array[::RBS::AST::Comment]
96
100
 
97
101
  # Returns true if `decl` is a class/module definition
98
- def class_or_module?: () -> (::RBS::Environment::ClassEntry | ::RBS::Environment::ModuleEntry | nil)
102
+ def class_or_module?: () -> bool
99
103
 
100
104
  # Returns true if `decl` is a constant definition
101
- def constant?: () -> ::RBS::Environment::SingleEntry[::RBS::TypeName, ::RBS::AST::Declarations::Constant]?
105
+ def constant?: () -> bool
102
106
  end
103
107
 
104
108
  type content = TypeContent | VariableContent | MethodCallContent | DefinitionContent | ConstantContent | TypeAssertionContent
@@ -1,5 +1,12 @@
1
1
  module Steep
2
2
  module Services
3
+ # SignatureService takes care of two sets of RBS files.
4
+ #
5
+ # 1. RBS files loaded from `EnvironmentLoader` -- usually type signatures of libraries
6
+ # 2. RBS files managed in editors -- usually type signatures of the development target (app or gem)
7
+ #
8
+ # The files in #2 are managed throuth `#status` and the changes are tracked.
9
+ #
3
10
  class SignatureService
4
11
  type status = SyntaxErrorStatus | AncestorErrorStatus | LoadedStatus
5
12
 
@@ -65,17 +72,25 @@ module Steep
65
72
  def constant_resolver: () -> RBS::Resolver::ConstantResolver
66
73
  end
67
74
 
75
+ # A file has one of the three states:
76
+ #
77
+ # 1. The parsing succeeded and loaded a list of declarations
78
+ # 2. The content has a syntax error and parsing failed
79
+ # 3. Other unexpected error
80
+ #
68
81
  class FileStatus
69
82
  attr_reader path: Pathname
70
83
 
71
84
  attr_reader content: String
72
85
 
73
- attr_reader decls: Array[RBS::AST::Declarations::t] | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
86
+ type signature = [RBS::Buffer, Array[RBS::AST::Directives::t], Array[RBS::AST::Declarations::t]]
87
+
88
+ attr_reader signature: signature | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
74
89
 
75
90
  def initialize: (
76
91
  path: Pathname,
77
92
  content: String,
78
- decls: Array[RBS::AST::Declarations::t] | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
93
+ signature: signature | Diagnostic::Signature::UnexpectedError | RBS::ParsingError
79
94
  ) -> void
80
95
  end
81
96
 
@@ -85,11 +100,17 @@ module Steep
85
100
 
86
101
  @env_rbs_paths: Set[Pathname]?
87
102
 
103
+ # All RBS paths in environment, both dependency RBS and target RBS
104
+ #
88
105
  def env_rbs_paths: () -> Set[Pathname]
89
106
 
107
+ # Yield all RBS paths in the environment, both dependency RBS and target RBS
108
+ #
90
109
  def each_rbs_path: () { (Pathname) -> void } -> void
91
110
  | () -> Enumerator[Pathname, void]
92
111
 
112
+ # The Target files
113
+ #
93
114
  def files: () -> Hash[Pathname, FileStatus]
94
115
 
95
116
  def pending_changed_paths: () -> Set[Pathname]
@@ -106,10 +127,13 @@ module Steep
106
127
 
107
128
  def apply_changes: (Hash[Pathname, FileStatus] files, Server::ChangeBuffer::changes changes) -> Hash[Pathname, FileStatus]
108
129
 
130
+ # The entry point to apply the edit to the signatures
131
+ #
109
132
  def update: (Server::ChangeBuffer::changes changes) -> void
110
133
 
111
134
  def update_env: (
112
- Hash[Pathname, FileStatus] updated_files, paths: Set[Pathname]
135
+ Hash[Pathname, FileStatus] updated_files,
136
+ paths: Set[Pathname]
113
137
  ) -> (RBS::DefinitionBuilder::AncestorBuilder | Array[Diagnostic::Signature::Base])
114
138
 
115
139
  def rescue_rbs_error: (Array[RBS::BaseError] errors) { () -> void } -> void
@@ -9,7 +9,7 @@ module Steep
9
9
 
10
10
  @errors: Array[Diagnostic::Signature::Base]
11
11
 
12
- @type_name_resolver: RBS::TypeNameResolver?
12
+ @type_name_resolver: RBS::Resolver::TypeNameResolver?
13
13
 
14
14
  @validator: RBS::Validator?
15
15
 
@@ -26,7 +26,7 @@ module Steep
26
26
 
27
27
  def builder: () -> RBS::DefinitionBuilder
28
28
 
29
- def type_name_resolver: () -> RBS::TypeNameResolver
29
+ def type_name_resolver: () -> RBS::Resolver::TypeNameResolver
30
30
 
31
31
  def validator: () -> RBS::Validator
32
32
 
@@ -60,13 +60,17 @@ module Steep
60
60
 
61
61
  def validate_const: () -> void
62
62
 
63
- def validate_one_constant: (RBS::TypeName name, RBS::Environment::SingleEntry[RBS::TypeName, RBS::AST::Declarations::Constant] entry) -> void
63
+ def validate_one_constant: (RBS::TypeName name, RBS::Environment::ConstantEntry entry) -> void
64
64
 
65
65
  def validate_global: () -> void
66
66
 
67
- def validate_one_global: (Symbol name, RBS::Environment::SingleEntry[Symbol, RBS::AST::Declarations::Global]) -> void
67
+ def validate_one_global: (Symbol name, RBS::Environment::GlobalEntry) -> void
68
68
 
69
- def validate_one_alias: (RBS::TypeName name, ?RBS::Environment::SingleEntry[RBS::TypeName, RBS::AST::Declarations::Alias] entry) -> void
69
+ def validate_one_alias: (RBS::TypeName name, ?RBS::Environment::TypeAliasEntry entry) -> void
70
+
71
+ def validate_one_class_decl: (RBS::TypeName) -> void
72
+
73
+ def validate_one_class_alias: (RBS::TypeName, RBS::Environment::ClassAliasEntry | RBS::Environment::ModuleAliasEntry) -> void
70
74
 
71
75
  def validate_alias: () -> void
72
76
 
@@ -80,7 +80,7 @@ module Steep
80
80
 
81
81
  def with_method_constr: (untyped method_name, untyped node, args: untyped, self_type: untyped, definition: untyped) { (untyped) -> untyped } -> untyped
82
82
 
83
- def implement_module: (module_name: untyped, annotations: untyped, ?super_name: untyped?) -> untyped
83
+ def implement_module: (module_name: RBS::TypeName, annotations: AST::Annotation::Collection, ?super_name: RBS::TypeName?) -> AST::Annotation::Implements::Module?
84
84
 
85
85
  def default_module_context: (untyped implement_module_name, nesting: untyped) -> untyped
86
86