steep 1.2.1 → 1.3.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile.lock +4 -4
  4. data/Gemfile.steep +1 -1
  5. data/Gemfile.steep.lock +13 -3
  6. data/Steepfile +0 -1
  7. data/lib/steep/annotation_parser.rb +34 -28
  8. data/lib/steep/ast/annotation.rb +16 -5
  9. data/lib/steep/ast/node/type_application.rb +74 -0
  10. data/lib/steep/ast/node/type_assertion.rb +56 -0
  11. data/lib/steep/ast/types/factory.rb +5 -1
  12. data/lib/steep/diagnostic/helper.rb +2 -1
  13. data/lib/steep/diagnostic/lsp_formatter.rb +3 -1
  14. data/lib/steep/diagnostic/ruby.rb +70 -5
  15. data/lib/steep/diagnostic/signature.rb +21 -8
  16. data/lib/steep/drivers/check.rb +1 -1
  17. data/lib/steep/drivers/checkfile.rb +1 -1
  18. data/lib/steep/drivers/langserver.rb +2 -2
  19. data/lib/steep/drivers/stats.rb +1 -1
  20. data/lib/steep/drivers/watch.rb +1 -1
  21. data/lib/steep/drivers/worker.rb +0 -1
  22. data/lib/steep/server/lsp_formatter.rb +13 -3
  23. data/lib/steep/server/master.rb +4 -1
  24. data/lib/steep/server/worker_process.rb +86 -14
  25. data/lib/steep/services/hover_provider/rbs.rb +7 -7
  26. data/lib/steep/services/hover_provider/ruby.rb +19 -4
  27. data/lib/steep/services/signature_service.rb +7 -4
  28. data/lib/steep/signature/validator.rb +36 -13
  29. data/lib/steep/source.rb +189 -71
  30. data/lib/steep/type_construction.rb +232 -126
  31. data/lib/steep/type_inference/logic_type_interpreter.rb +3 -1
  32. data/lib/steep/version.rb +1 -1
  33. data/lib/steep.rb +2 -0
  34. data/rbs_collection.steep.lock.yaml +27 -10
  35. data/rbs_collection.steep.yaml +0 -1
  36. data/sig/shims/exception.rbs +4 -0
  37. data/sig/shims/parser/comment.rbs +33 -0
  38. data/sig/shims/parser.rbs +30 -2
  39. data/sig/steep/annotation_parser.rbs +59 -0
  40. data/sig/steep/ast/annotation.rbs +21 -26
  41. data/sig/steep/ast/node/type_application.rbs +31 -0
  42. data/sig/steep/ast/node/type_assertion.rbs +26 -0
  43. data/sig/steep/ast/types/factory.rbs +0 -2
  44. data/sig/steep/diagnostic/helper.rbs +9 -3
  45. data/sig/steep/diagnostic/lsp_formatter.rbs +12 -8
  46. data/sig/steep/diagnostic/ruby.rbs +62 -8
  47. data/sig/steep/diagnostic/signature.rbs +118 -85
  48. data/sig/steep/drivers/worker.rbs +11 -13
  49. data/sig/steep/range_extension.rbs +7 -0
  50. data/sig/steep/server/lsp_formatter.rbs +14 -7
  51. data/sig/steep/server/worker_process.rbs +74 -12
  52. data/sig/steep/services/hover_provider/rbs.rbs +27 -7
  53. data/sig/steep/services/hover_provider/ruby.rbs +18 -4
  54. data/sig/steep/services/hover_provider/singleton_methods.rbs +1 -1
  55. data/sig/steep/signature/validator.rbs +76 -0
  56. data/sig/steep/source.rbs +54 -30
  57. data/sig/steep/type_construction.rbs +85 -27
  58. data/sig/steep/type_inference/method_call.rbs +1 -1
  59. data/smoke/diagnostics-rbs/inherit-module.rbs +2 -0
  60. data/smoke/diagnostics-rbs/test_expectations.yml +12 -0
  61. data/steep.gemspec +1 -1
  62. metadata +16 -6
@@ -1,215 +1,248 @@
1
1
  module Steep
2
2
  module Diagnostic
3
3
  module Signature
4
+ type location = RBS::Location[untyped, untyped]
5
+
4
6
  class Base
5
7
  include Helper
6
8
 
7
- attr_reader location: untyped
9
+ attr_reader location: location?
8
10
 
9
- def initialize: (location: untyped) -> void
11
+ def initialize: (location: location?) -> void
10
12
 
11
- def header_line: () -> untyped
13
+ def header_line: () -> String
12
14
 
13
- def detail_lines: () -> nil
15
+ def detail_lines: () -> String?
14
16
 
15
- def diagnostic_code: () -> ::String
17
+ def diagnostic_code: () -> String
16
18
 
17
- def path: () -> untyped
19
+ def path: () -> Pathname?
18
20
  end
19
21
 
20
22
  class SyntaxError < Base
21
- attr_reader exception: untyped
23
+ attr_reader exception: RBS::ParsingError
22
24
 
23
- def initialize: (untyped exception, location: untyped) -> void
25
+ def initialize: (RBS::ParsingError exception, location: location?) -> void
24
26
 
25
- def self.parser_syntax_error_message: (untyped exception) -> ::String
27
+ def self.parser_syntax_error_message: (RBS::ParsingError exception) -> String
26
28
 
27
- def header_line: () -> untyped
29
+ def header_line: () -> String
28
30
  end
29
31
 
30
32
  class DuplicatedDeclaration < Base
31
- attr_reader type_name: untyped
33
+ attr_reader type_name: RBS::TypeName | Symbol
32
34
 
33
- def initialize: (type_name: untyped, location: untyped) -> void
35
+ def initialize: (type_name: RBS::TypeName | Symbol, location: location?) -> void
34
36
 
35
- def header_line: () -> ::String
37
+ def header_line: () -> String
36
38
  end
37
39
 
38
40
  class UnknownTypeName < Base
39
- attr_reader name: untyped
41
+ attr_reader name: RBS::TypeName
40
42
 
41
- def initialize: (name: untyped, location: untyped) -> void
43
+ def initialize: (name: RBS::TypeName, location: location?) -> void
42
44
 
43
- def header_line: () -> ::String
45
+ def header_line: () -> String
44
46
  end
45
47
 
46
48
  class InvalidTypeApplication < Base
47
- attr_reader name: untyped
49
+ attr_reader name: RBS::TypeName
48
50
 
49
- attr_reader args: untyped
51
+ attr_reader args: Array[AST::Types::t]
50
52
 
51
- attr_reader params: untyped
53
+ attr_reader params: Array[Symbol]
52
54
 
53
- def initialize: (name: untyped, args: untyped, params: untyped, location: untyped) -> void
55
+ def initialize: (name: RBS::TypeName, args: Array[AST::Types::t], params: Array[Symbol], location: location?) -> void
54
56
 
55
- def header_line: () -> untyped
57
+ def header_line: () -> String
56
58
  end
57
59
 
58
60
  class UnsatisfiableTypeApplication < Base
59
- attr_reader type_name: untyped
61
+ attr_reader type_name: RBS::TypeName
60
62
 
61
- attr_reader type_arg: untyped
63
+ attr_reader type_arg: AST::Types::t
62
64
 
63
- attr_reader type_param: untyped
65
+ attr_reader type_param: Interface::TypeParam
64
66
 
65
- def initialize: (type_name: untyped, type_arg: untyped, type_param: untyped, location: untyped) -> void
67
+ def initialize: (type_name: RBS::TypeName, type_arg: AST::Types::t, type_param: Interface::TypeParam, location: location?) -> void
66
68
 
67
- def header_line: () -> ::String
69
+ def header_line: () -> String
68
70
  end
69
71
 
70
72
  class InvalidMethodOverload < Base
71
- attr_reader class_name: untyped
73
+ attr_reader class_name: RBS::TypeName
72
74
 
73
- attr_reader method_name: untyped
75
+ attr_reader method_name: Symbol
74
76
 
75
- def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
77
+ def initialize: (class_name: RBS::TypeName, method_name: Symbol, location: location?) -> void
76
78
 
77
- def header_line: () -> ::String
79
+ def header_line: () -> String
78
80
  end
79
81
 
80
82
  class UnknownMethodAlias < Base
81
- attr_reader class_name: untyped
83
+ attr_reader class_name: RBS::TypeName
82
84
 
83
- attr_reader method_name: untyped
85
+ attr_reader method_name: Symbol
84
86
 
85
- def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
87
+ def initialize: (class_name: RBS::TypeName, method_name: Symbol, location: location?) -> void
86
88
 
87
- def header_line: () -> ::String
89
+ def header_line: () -> String
88
90
  end
89
91
 
90
92
  class DuplicatedMethodDefinition < Base
91
- attr_reader class_name: untyped
93
+ attr_reader class_name: RBS::TypeName
92
94
 
93
- attr_reader method_name: untyped
95
+ attr_reader method_name: Symbol
94
96
 
95
- def initialize: (class_name: untyped, method_name: untyped, location: untyped) -> void
97
+ def initialize: (class_name: RBS::TypeName, method_name: Symbol, location: location?) -> void
96
98
 
97
- def header_line: () -> ::String
99
+ def header_line: () -> String
98
100
  end
99
101
 
100
102
  class RecursiveAlias < Base
101
- attr_reader class_name: untyped
102
-
103
- attr_reader names: untyped
103
+ attr_reader class_name: RBS::TypeName
104
104
 
105
- attr_reader location: untyped
105
+ attr_reader names: Array[Symbol]
106
106
 
107
- def initialize: (class_name: untyped, names: untyped, location: untyped) -> void
107
+ def initialize: (class_name: RBS::TypeName, names: Array[Symbol], location: location?) -> void
108
108
 
109
- def header_line: () -> ::String
109
+ def header_line: () -> String
110
110
  end
111
111
 
112
112
  class RecursiveAncestor < Base
113
- attr_reader ancestors: untyped
113
+ attr_reader ancestors: Array[RBS::Definition::Ancestor::t]
114
114
 
115
- def initialize: (ancestors: untyped, location: untyped) -> void
115
+ def initialize: (ancestors: Array[RBS::Definition::Ancestor::t], location: location?) -> void
116
116
 
117
- def header_line: () -> ::String
117
+ def header_line: () -> String
118
118
  end
119
119
 
120
120
  class SuperclassMismatch < Base
121
- attr_reader name: untyped
121
+ attr_reader name: RBS::TypeName
122
122
 
123
- def initialize: (name: untyped, location: untyped) -> void
123
+ def initialize: (name: RBS::TypeName, location: location?) -> void
124
124
 
125
- def header_line: () -> ::String
125
+ def header_line: () -> String
126
126
  end
127
127
 
128
128
  class GenericParameterMismatch < Base
129
- attr_reader name: untyped
129
+ attr_reader name: RBS::TypeName
130
130
 
131
- def initialize: (name: untyped, location: untyped) -> void
131
+ def initialize: (name: RBS::TypeName, location: location?) -> void
132
132
 
133
- def header_line: () -> ::String
133
+ def header_line: () -> String
134
134
  end
135
135
 
136
136
  class InvalidVarianceAnnotation < Base
137
- attr_reader name: untyped
137
+ attr_reader name: RBS::TypeName
138
138
 
139
- attr_reader param: untyped
139
+ attr_reader param: RBS::AST::TypeParam
140
140
 
141
- def initialize: (name: untyped, param: untyped, location: untyped) -> void
141
+ def initialize: (name: RBS::TypeName, param: RBS::AST::TypeParam, location: location?) -> void
142
142
 
143
- def header_line: () -> ::String
143
+ def header_line: () -> String
144
144
  end
145
145
 
146
146
  class ModuleSelfTypeError < Base
147
- attr_reader name: untyped
147
+ attr_reader name: RBS::TypeName
148
148
 
149
- attr_reader ancestor: untyped
149
+ attr_reader ancestor: RBS::DefinitionBuilder::AncestorBuilder::OneAncestors
150
150
 
151
- attr_reader relation: untyped
151
+ attr_reader relation: Subtyping::Relation[AST::Types::t]
152
152
 
153
- def initialize: (name: untyped, ancestor: untyped, relation: untyped, location: untyped) -> void
153
+ def initialize: (name: RBS::TypeName, ancestor: RBS::DefinitionBuilder::AncestorBuilder::OneAncestors, relation: Subtyping::Relation[AST::Types::t], location: location?) -> void
154
154
 
155
- def header_line: () -> ::String
155
+ def header_line: () -> String
156
156
  end
157
157
 
158
- class InstanceVariableTypeError < Base
159
- attr_reader name: untyped
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
166
+
167
+ def header_line: () -> String
168
+ end
169
+
170
+ # The error is raised when a class variable is defined in both `class_name` and `other_class_name`
171
+ #
172
+ class ClassVariableDuplicationError < Base
173
+ attr_reader class_name: RBS::TypeName
174
+ attr_reader other_class_name: RBS::TypeName
175
+ attr_reader variable_name: Symbol
160
176
 
161
- attr_reader variable: untyped
177
+ def initialize: (class_name: RBS::TypeName, other_class_name: RBS::TypeName, variable_name: Symbol, location: RBS::Location[untyped, untyped]) -> void
162
178
 
163
- attr_reader var_type: untyped
179
+ def header_line: () -> String
180
+ end
181
+
182
+
183
+ class InstanceVariableTypeError < Base
184
+ attr_reader name: Symbol
185
+
186
+ attr_reader var_type: AST::Types::t
164
187
 
165
- attr_reader parent_type: untyped
188
+ attr_reader parent_type: AST::Types::t
166
189
 
167
- def initialize: (name: untyped, location: untyped, var_type: untyped, parent_type: untyped) -> void
190
+ def initialize: (name: Symbol, location: location?, var_type: AST::Types::t, parent_type: AST::Types::t) -> void
168
191
 
169
- def header_line: () -> ::String
192
+ def header_line: () -> String
170
193
  end
171
194
 
172
195
  class MixinClassError < Base
173
- attr_reader member: untyped
196
+ attr_reader member: RBS::AST::Members::Include | RBS::AST::Members::Extend | RBS::AST::Members::Prepend
174
197
 
175
- attr_reader type_name: untyped
198
+ attr_reader type_name: RBS::TypeName
176
199
 
177
- def initialize: (location: untyped, member: untyped, type_name: untyped) -> void
200
+ def initialize: (location: location?, member: RBS::AST::Members::Include | RBS::AST::Members::Extend | RBS::AST::Members::Prepend, type_name: RBS::TypeName) -> void
178
201
 
179
- def header_line: () -> ::String
202
+ def header_line: () -> String
180
203
 
181
204
  private
182
205
 
183
- def mixin_name: () -> untyped
206
+ def mixin_name: () -> String
207
+ end
208
+
209
+ # A class definition has a module as its super class
210
+ #
211
+ class InheritModuleError < Base
212
+ attr_reader super_class: RBS::AST::Declarations::Class::Super
213
+
214
+ def initialize: (RBS::AST::Declarations::Class::Super) -> void
215
+
216
+ def header_line: () -> String
184
217
  end
185
218
 
186
219
  class UnexpectedError < Base
187
- attr_reader message: untyped
220
+ attr_reader message: String
188
221
 
189
- def initialize: (message: untyped, location: untyped) -> void
222
+ def initialize: (message: String, location: location?) -> void
190
223
 
191
- def header_line: () -> ::String
224
+ def header_line: () -> String
192
225
  end
193
226
 
194
227
  class RecursiveTypeAlias < Base
195
- attr_reader alias_names: untyped
228
+ attr_reader alias_names: Array[RBS::TypeName]
196
229
 
197
- def initialize: (alias_names: untyped, location: untyped) -> void
230
+ def initialize: (alias_names: Array[RBS::TypeName], location: location?) -> void
198
231
 
199
- def header_line: () -> ::String
232
+ def header_line: () -> String
200
233
  end
201
234
 
202
235
  class NonregularTypeAlias < Base
203
- attr_reader type_name: untyped
236
+ attr_reader type_name: RBS::TypeName
204
237
 
205
- attr_reader nonregular_type: untyped
238
+ attr_reader nonregular_type: AST::Types::t
206
239
 
207
- def initialize: (type_name: untyped, nonregular_type: untyped, location: untyped) -> void
240
+ def initialize: (type_name: RBS::TypeName, nonregular_type: AST::Types::t, location: location?) -> void
208
241
 
209
- def header_line: () -> ::String
242
+ def header_line: () -> String
210
243
  end
211
244
 
212
- def self.from_rbs_error: (untyped error, factory: untyped) -> untyped
245
+ def self.from_rbs_error: (RBS::BaseError error, factory: AST::Types::Factory) -> Base
213
246
  end
214
247
  end
215
248
  end
@@ -1,31 +1,29 @@
1
1
  module Steep
2
2
  module Drivers
3
3
  class Worker
4
- attr_reader stdout: untyped
4
+ attr_reader stdout: IO
5
5
 
6
- attr_reader stderr: untyped
6
+ attr_reader stderr: IO
7
7
 
8
- attr_reader stdin: untyped
8
+ attr_reader stdin: IO
9
9
 
10
- attr_accessor steepfile_path: untyped
10
+ attr_accessor worker_type: Symbol
11
11
 
12
- attr_accessor worker_type: untyped
12
+ attr_accessor worker_name: String
13
13
 
14
- attr_accessor worker_name: untyped
14
+ attr_accessor delay_shutdown: bool
15
15
 
16
- attr_accessor delay_shutdown: untyped
16
+ attr_accessor max_index: Integer
17
17
 
18
- attr_accessor max_index: untyped
18
+ attr_accessor index: Integer
19
19
 
20
- attr_accessor index: untyped
21
-
22
- attr_accessor commandline_args: untyped
20
+ attr_accessor commandline_args: Array[String]
23
21
 
24
22
  include Utils::DriverHelper
25
23
 
26
- def initialize: (stdout: untyped, stderr: untyped, stdin: untyped) -> void
24
+ def initialize: (stdout: IO, stderr: IO, stdin: IO) -> void
27
25
 
28
- def run: () -> 0
26
+ def run: () -> Integer
29
27
  end
30
28
  end
31
29
  end
@@ -0,0 +1,7 @@
1
+ class RBS::Location[in RK, in OK]
2
+ def as_lsp_range: () -> { start: { line: Integer, character: Integer }, end: { line: Integer, character: Integer } }
3
+ end
4
+
5
+ class Parser::Source::Range
6
+ def as_lsp_range: () -> { start: { line: Integer, character: Integer }, end: { line: Integer, character: Integer } }
7
+ end
@@ -4,26 +4,33 @@ module Steep
4
4
  include Services
5
5
 
6
6
  class CommentBuilder
7
+ @array: Array[String]
8
+
7
9
  def initialize: () -> void
8
10
 
9
- def self.build: () { (untyped) -> untyped } -> untyped
11
+ def self.build: () { (CommentBuilder) -> void } -> String
10
12
 
11
- def to_s: () -> (untyped | nil)
13
+ def to_s: () -> String
12
14
 
13
- def <<: (untyped string) -> (untyped | nil)
15
+ def <<: (String? string) -> void
14
16
 
15
- def push: () { (untyped) -> untyped } -> untyped
17
+ def push: () { (String) -> void } -> void
16
18
  end
17
19
 
18
- def self?.format_hover_content: (untyped content) -> untyped
20
+ def self?.format_hover_content: (Services::HoverProvider::Ruby::content | Services::HoverProvider::RBS::content) -> untyped
19
21
 
20
- def self?.to_list: (untyped collection) ?{ () -> untyped } -> untyped
22
+ def self?.to_list: [A < Object] (Enumerable[A] collection) ?{ (A) -> String } -> String
21
23
 
22
24
  def self?.name_and_args: (untyped name, untyped args) -> ::String
23
25
 
24
26
  def self?.name_and_params: (untyped name, untyped params) -> ::String
25
27
 
26
- def self?.declaration_summary: (untyped decl) -> untyped
28
+ type summarizable_decl = ::RBS::AST::Declarations::Class
29
+ | ::RBS::AST::Declarations::Module
30
+ | ::RBS::AST::Declarations::Interface
31
+ | ::RBS::AST::Declarations::Alias
32
+
33
+ def self?.declaration_summary: (summarizable_decl) -> String
27
34
  end
28
35
  end
29
36
  end
@@ -1,29 +1,91 @@
1
1
  module Steep
2
2
  module Server
3
+ # WorkerProcess class represents a worker process
4
+ #
5
+ # Available operations are:
6
+ #
7
+ # 1. Sending a LSP message to the process
8
+ # 2. Receiving a LSP message from the process
9
+ # 3. Killing the process
10
+ #
11
+ # The process may be invoked by
12
+ #
13
+ # 1. `#fork` if available, or
14
+ # 2. `#spawn` otherwise
15
+ #
16
+ # `#fork` version is faster because it skips loading libraries.
17
+ #
18
+ #
3
19
  class WorkerProcess
4
- attr_reader reader: untyped
20
+ interface _ProcessWaitThread
21
+ def pid: () -> Integer
22
+ end
5
23
 
6
- attr_reader writer: untyped
24
+ attr_reader reader: LanguageServer::Protocol::Transport::Io::Reader
7
25
 
8
- attr_reader stderr: untyped
26
+ attr_reader writer: LanguageServer::Protocol::Transport::Io::Writer
9
27
 
10
- attr_reader name: untyped
28
+ attr_reader stderr: IO?
11
29
 
12
- attr_reader wait_thread: untyped
30
+ attr_reader name: String
13
31
 
14
- attr_reader index: untyped
32
+ attr_reader wait_thread: Thread & _ProcessWaitThread
15
33
 
16
- def initialize: (reader: untyped, writer: untyped, stderr: untyped, wait_thread: untyped, name: untyped, ?index: untyped?) -> void
34
+ attr_reader index: Integer?
17
35
 
18
- def self.spawn_worker: (untyped `type`, name: untyped, steepfile: untyped, ?steep_command: ::String, ?options: untyped, ?delay_shutdown: bool, ?index: untyped?) -> untyped
36
+ def initialize: (
37
+ reader: LanguageServer::Protocol::Transport::Io::Reader,
38
+ writer: LanguageServer::Protocol::Transport::Io::Writer,
39
+ stderr: IO?,
40
+ wait_thread: Thread & _ProcessWaitThread,
41
+ name: String,
42
+ ?index: Integer?
43
+ ) -> void
19
44
 
20
- def self.spawn_typecheck_workers: (steepfile: untyped, args: untyped, ?steep_command: ::String, ?count: untyped, ?delay_shutdown: bool) -> untyped
45
+ type worker_type = :interaction | :typecheck
21
46
 
22
- def <<: (untyped message) -> untyped
47
+ def self.start_worker: (
48
+ worker_type `type`,
49
+ name: String,
50
+ steepfile: Pathname,
51
+ ?steep_command: ::String,
52
+ ?patterns: Array[String],
53
+ ?delay_shutdown: bool,
54
+ ?index: [Integer, Integer]?
55
+ ) -> WorkerProcess
23
56
 
24
- def read: () ?{ () -> untyped } -> untyped
57
+ def self.fork_worker: (
58
+ worker_type `type`,
59
+ name: String,
60
+ steepfile: Pathname,
61
+ patterns: Array[String],
62
+ delay_shutdown: bool,
63
+ index: [Integer, Integer]?
64
+ ) -> WorkerProcess
25
65
 
26
- def kill: () -> untyped
66
+ def self.spawn_worker: (
67
+ worker_type `type`,
68
+ name: String,
69
+ steepfile: Pathname,
70
+ steep_command: ::String,
71
+ patterns: Array[String],
72
+ delay_shutdown: bool,
73
+ index: [Integer, Integer]?
74
+ ) -> WorkerProcess
75
+
76
+ def self.start_typecheck_workers: (
77
+ steepfile: Pathname,
78
+ args: Array[String],
79
+ ?steep_command: ::String,
80
+ ?count: Integer,
81
+ ?delay_shutdown: bool
82
+ ) -> Array[WorkerProcess]
83
+
84
+ def <<: (untyped message) -> void
85
+
86
+ def read: () { (untyped) -> void } -> void
87
+
88
+ def kill: () -> void
27
89
  end
28
90
  end
29
91
  end
@@ -2,19 +2,39 @@ module Steep
2
2
  module Services
3
3
  module HoverProvider
4
4
  class RBS
5
- TypeAliasContent: untyped
5
+ class TypeAliasContent
6
+ attr_reader location: ::RBS::Location[untyped, untyped]
6
7
 
7
- ClassContent: untyped
8
+ attr_reader decl: ::RBS::AST::Declarations::Alias
8
9
 
9
- InterfaceContent: untyped
10
+ def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Alias) -> void
11
+ end
10
12
 
11
- attr_reader service: untyped
13
+ class ClassContent
14
+ attr_reader location: ::RBS::Location[untyped, untyped]
12
15
 
13
- def initialize: (service: untyped) -> void
16
+ attr_reader decl: ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module
14
17
 
15
- def project: () -> untyped
18
+ def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module) -> void
19
+ end
16
20
 
17
- def content_for: (target: untyped, path: untyped, line: untyped, column: untyped) -> (nil | untyped)
21
+ class InterfaceContent
22
+ attr_reader location: ::RBS::Location[untyped, untyped]
23
+
24
+ attr_reader decl: ::RBS::AST::Declarations::Interface
25
+
26
+ def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Interface) -> void
27
+ end
28
+
29
+ type content = TypeAliasContent | ClassContent | InterfaceContent
30
+
31
+ attr_reader service: TypeCheckService
32
+
33
+ def initialize: (service: TypeCheckService) -> void
34
+
35
+ def project: () -> Project
36
+
37
+ def content_for: (target: Project::Target, path: Pathname, line: Integer, column: Integer) -> content?
18
38
  end
19
39
  end
20
40
  end
@@ -35,10 +35,24 @@ module Steep
35
35
  def initialize: (node: Parser::AST::Node, name: Symbol, type: AST::Types::t, location: Parser::Source::Range) -> void
36
36
  end
37
37
 
38
+ class TypeAssertionContent
39
+ attr_reader node: Parser::AST::Node
40
+
41
+ attr_reader original_type: AST::Types::t
42
+
43
+ attr_reader asserted_type: AST::Types::t
44
+
45
+ attr_reader location: Parser::Source::Range
46
+
47
+ def initialize: (node: Parser::AST::Node, original_type: AST::Types::t, asserted_type: AST::Types::t, location: Parser::Source::Range) -> void
48
+ end
49
+
38
50
  class MethodCallContent
39
51
  attr_reader node: Parser::AST::Node
40
52
 
41
- attr_reader method_call: TypeInference::MethodCall::t
53
+ type call = TypeInference::MethodCall::Typed | TypeInference::MethodCall::Special | TypeInference::MethodCall::Error
54
+
55
+ attr_reader method_call: call
42
56
 
43
57
  attr_reader location: Parser::Source::Range
44
58
 
@@ -81,13 +95,13 @@ module Steep
81
95
  def comments: () -> Array[::RBS::AST::Comment]
82
96
 
83
97
  # Returns true if `decl` is a class/module definition
84
- def class_or_module?: () -> bool
98
+ def class_or_module?: () -> (::RBS::Environment::ClassEntry | ::RBS::Environment::ModuleEntry | nil)
85
99
 
86
100
  # Returns true if `decl` is a constant definition
87
- def constant?: () -> bool
101
+ def constant?: () -> ::RBS::Environment::SingleEntry[::RBS::TypeName, ::RBS::AST::Declarations::Constant]?
88
102
  end
89
103
 
90
- type content = TypeContent | VariableContent | MethodCallContent | DefinitionContent | ConstantContent
104
+ type content = TypeContent | VariableContent | MethodCallContent | DefinitionContent | ConstantContent | TypeAssertionContent
91
105
 
92
106
  attr_reader service: TypeCheckService
93
107
 
@@ -2,7 +2,7 @@ module Steep
2
2
  module Services
3
3
  module HoverProvider
4
4
  module SingletonMethods
5
- def content_for: (service: TypeCheckService, path: Pathname, line: Integer, column: Integer) -> (Ruby | RBS | nil)
5
+ def content_for: (service: TypeCheckService, path: Pathname, line: Integer, column: Integer) -> (Ruby::content | RBS::content | nil)
6
6
  end
7
7
 
8
8
  extend SingletonMethods