steep 1.4.0.dev.3 → 1.4.0.dev.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,10 @@
1
+ use RBS::Environment, RBS::TypeName
2
+ use Steep::TypeInference::MethodCall
3
+
1
4
  module Steep
2
5
  module Services
3
6
  class CompletionProvider
7
+ # Cursor position
4
8
  class Position
5
9
  attr_reader line: Integer
6
10
 
@@ -40,7 +44,7 @@ module Steep
40
44
  end
41
45
 
42
46
  class ConstantItem
43
- attr_reader env: RBS::Environment
47
+ attr_reader env: Environment
44
48
 
45
49
  attr_reader identifier: Symbol
46
50
 
@@ -48,36 +52,107 @@ module Steep
48
52
 
49
53
  attr_reader type: AST::Types::t
50
54
 
51
- attr_reader full_name: RBS::TypeName
55
+ attr_reader full_name: TypeName
52
56
 
53
- def initialize: (env: RBS::Environment, identifier: Symbol, range: Range, type: AST::Types::t, full_name: RBS::TypeName) -> void
57
+ def initialize: (env: Environment, identifier: Symbol, range: Range, type: AST::Types::t, full_name: TypeName) -> void
54
58
 
55
59
  def class?: () -> bool
56
60
 
57
61
  def module?: () -> bool
58
62
 
59
- def comments: () -> Array[RBS::AST::Comment]
63
+ def comments: () -> Array[RBS::AST::Comment?]
64
+
65
+ type const_decl = RBS::AST::Declarations::Constant
66
+ | RBS::AST::Declarations::Class
67
+ | RBS::AST::Declarations::Module
68
+ | RBS::AST::Declarations::ClassAlias
69
+ | RBS::AST::Declarations::ModuleAlias
70
+
71
+ def decl: () -> const_decl
72
+ end
73
+
74
+ # Method name completion item with *simple* receiver type
75
+ #
76
+ # Instance type, Singleton type, Interface type is simple.
77
+ # The item may have multiple overloads, but must have single method definition source.
78
+ #
79
+ class SimpleMethodNameItem
80
+ attr_reader identifier: Symbol
81
+
82
+ attr_reader range: Range
83
+
84
+ attr_reader receiver_type: AST::Types::Name::Instance | AST::Types::Name::Interface | AST::Types::Name::Singleton
85
+
86
+ attr_reader method_types: Array[RBS::MethodType]
87
+
88
+ attr_reader method_name: method_name
89
+
90
+ attr_reader method_member: RBS::Definition::Method::method_member
91
+
92
+ def initialize: (
93
+ identifier: Symbol,
94
+ range: Range,
95
+ receiver_type: AST::Types::Name::Instance | AST::Types::Name::Interface | AST::Types::Name::Singleton,
96
+ method_name: method_name,
97
+ method_types: Array[RBS::MethodType],
98
+ method_member: RBS::Definition::Method::method_member
99
+ ) -> void
100
+
101
+ %a{pure} def comment: () -> RBS::AST::Comment?
60
102
  end
61
103
 
62
- class MethodNameItem
104
+ # Method name completion item with *complex* receiver type
105
+ #
106
+ # The item may have multiple overloads and multiple method declarations.
107
+ #
108
+ class ComplexMethodNameItem
63
109
  attr_reader identifier: Symbol
64
110
 
65
111
  attr_reader range: Range
66
112
 
67
- attr_reader receiver_type: AST::Types::t
113
+ attr_reader reeiver_type: AST::Types::t
114
+
115
+ attr_reader method_types: Array[RBS::MethodType]
116
+
117
+ attr_reader method_decls: Array[MethodCall::MethodDecl]
118
+
119
+ def initialize: (
120
+ identifier: Symbol,
121
+ range: Range,
122
+ method_types: Array[RBS::MethodType],
123
+ method_decls: Array[MethodCall::MethodDecl],
124
+ receiver_type: AST::Types::t
125
+ ) -> void
126
+
127
+ def method_names: () -> Array[method_name]
68
128
 
69
- attr_reader method_type: untyped
129
+ def method_definitions: () -> Hash[method_name, RBS::Definition::Method::method_member]
70
130
 
71
- attr_reader method_decls: Array[TypeInference::MethodCall::MethodDecl]
131
+ def defining_method_name: (TypeName, Symbol name, RBS::Definition::Method::method_member) -> method_name
132
+ end
133
+
134
+ # Method name completion item for generated methods, like `#first` in tuple types
135
+ #
136
+ # The generated methods doesn't have associated `MethodDecl`.
137
+ #
138
+ class GeneratedMethodNameItem
139
+ attr_reader identifier: Symbol
72
140
 
73
- def initialize: (identifier: Symbol, range: Range, method_type: untyped, method_decls: Array[TypeInference::MethodCall::MethodDecl]) -> void
141
+ attr_reader range: Range
142
+
143
+ attr_reader reeiver_type: AST::Types::t
74
144
 
75
- def comment: () -> RBS::AST::Comment?
145
+ attr_reader method_types: Array[RBS::MethodType]
76
146
 
77
- def inherited?: () -> bool
147
+ def initialize: (
148
+ identifier: Symbol,
149
+ range: Range,
150
+ receiver_type: AST::Types::t,
151
+ method_types: Array[RBS::MethodType]
152
+ ) -> void
78
153
  end
79
154
 
80
- type item = InstanceVariableItem | LocalVariableItem | ConstantItem | MethodNameItem
155
+ type item = InstanceVariableItem | LocalVariableItem | ConstantItem | SimpleMethodNameItem | ComplexMethodNameItem | GeneratedMethodNameItem
81
156
 
82
157
  attr_reader source_text: String
83
158
 
@@ -91,41 +166,42 @@ module Steep
91
166
 
92
167
  attr_reader typing: Typing
93
168
 
94
- def initialize: (source_text: untyped, path: untyped, subtyping: untyped) -> void
169
+ def initialize: (source_text: String, path: Pathname, subtyping: Subtyping::Check) -> void
95
170
 
96
- def type_check!: (untyped text, line: untyped, column: untyped) -> untyped
171
+ def type_check!: (String text, line: Integer, column: Integer) -> void
97
172
 
98
- def env: () -> untyped
173
+ def env: () -> Environment
99
174
 
100
- def run: (line: untyped, column: untyped) -> untyped
175
+ def run: (line: Integer, column: Integer) -> Array[item]
101
176
 
102
- def range_from_loc: (untyped loc) -> untyped
177
+ def range_from_loc: (Parser::Source::Range loc) -> Range
103
178
 
104
- def at_end?: (untyped pos, of: untyped) -> (untyped | nil)
179
+ def at_end?: (Position pos, of: Parser::Source::Map | Parser::Source::Range | nil) -> boolish
105
180
 
106
- def range_for: (untyped position, ?prefix: ::String) -> untyped
181
+ def range_for: (Position position, ?prefix: ::String) -> Range
107
182
 
108
- def items_for_trigger: (position: untyped) -> (::Array[untyped] | untyped)
183
+ def items_for_trigger: (position: Position) -> Array[item]
109
184
 
110
- def items_for_dot: (position: Position) -> ::Array[MethodNameItem]
185
+ def items_for_dot: (position: Position) -> Array[item]
111
186
 
112
- def items_for_colon2: (position: untyped) -> untyped
187
+ def items_for_colon2: (position: Position) -> Array[item]
113
188
 
114
- def items_for_atmark: (position: untyped) -> (::Array[untyped] | untyped)
189
+ def items_for_atmark: (position: Position) -> Array[item]
115
190
 
116
- def method_items_for_receiver_type: (untyped `type`, include_private: untyped, prefix: untyped, position: untyped, items: untyped) -> untyped
191
+ def method_items_for_receiver_type: (AST::Types::t, include_private: bool, prefix: String, position: Position, items: Array[item]) -> void
117
192
 
118
- def word_name?: (String name) -> void
193
+ def word_name?: (String name) -> bool
119
194
 
120
- def local_variable_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[LocalVariableItem]) -> void
195
+ def local_variable_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[item]) -> void
121
196
 
122
- def constant_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[ConstantItem], ?parent: Parser::AST::Node?) -> void
197
+ def constant_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[item], ?parent: Parser::AST::Node?) -> void
123
198
 
124
- def instance_variable_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[InstanceVariableItem]) -> void
199
+ def instance_variable_items_for_context: (TypeInference::Context context, position: Position, prefix: String, items: Array[item]) -> void
125
200
 
126
- def index_for: (untyped string, line: untyped, column: untyped) -> untyped
201
+ def index_for: (String, line: Integer, column: Integer) -> Integer
127
202
 
128
203
  def disallowed_method?: (Symbol name) -> bool
204
+
129
205
  end
130
206
  end
131
207
  end
@@ -1,31 +1,33 @@
1
+ use RBS::Location, RBS::AST::Declarations, RBS::AST::Directives, RBS::TypeName, RBS::Environment
2
+
1
3
  module Steep
2
4
  module Services
3
5
  module HoverProvider
4
6
  class RBS
5
7
  class TypeAliasContent
6
- attr_reader location: ::RBS::Location[untyped, untyped]
8
+ attr_reader location: Location[untyped, untyped]
7
9
 
8
- attr_reader decl: ::RBS::AST::Declarations::TypeAlias
10
+ attr_reader decl: Declarations::TypeAlias
9
11
 
10
- def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::TypeAlias) -> void
12
+ def initialize: (location: Location[untyped, untyped], decl: Declarations::TypeAlias) -> void
11
13
  end
12
14
 
13
15
  class ClassContent
14
- attr_reader location: ::RBS::Location[untyped, untyped]
16
+ attr_reader location: Location[untyped, untyped]
15
17
 
16
- type decl = ::RBS::AST::Declarations::Class | ::RBS::AST::Declarations::Module | ::RBS::AST::Declarations::ClassAlias | ::RBS::AST::Declarations::ModuleAlias
18
+ type decl = Declarations::Class | Declarations::Module | Declarations::ClassAlias | Declarations::ModuleAlias
17
19
 
18
20
  attr_reader decl: decl
19
21
 
20
- def initialize: (location: ::RBS::Location[untyped, untyped], decl: decl) -> void
22
+ def initialize: (location: Location[untyped, untyped], decl: decl) -> void
21
23
  end
22
24
 
23
25
  class InterfaceContent
24
- attr_reader location: ::RBS::Location[untyped, untyped]
26
+ attr_reader location: Location[untyped, untyped]
25
27
 
26
- attr_reader decl: ::RBS::AST::Declarations::Interface
28
+ attr_reader decl: Declarations::Interface
27
29
 
28
- def initialize: (location: ::RBS::Location[untyped, untyped], decl: ::RBS::AST::Declarations::Interface) -> void
30
+ def initialize: (location: Location[untyped, untyped], decl: Declarations::Interface) -> void
29
31
  end
30
32
 
31
33
  type content = TypeAliasContent | ClassContent | InterfaceContent
@@ -37,6 +39,8 @@ module Steep
37
39
  def project: () -> Project
38
40
 
39
41
  def content_for: (target: Project::Target, path: Pathname, line: Integer, column: Integer) -> content?
42
+
43
+ def content_for_type_name: (TypeName, env: Environment, location: Location[untyped, untyped]) -> content?
40
44
  end
41
45
  end
42
46
  end
@@ -0,0 +1,39 @@
1
+ use RBS::Environment
2
+
3
+ module Steep
4
+ module Services
5
+ class SignatureHelpProvider
6
+ module MethodCall = TypeInference::MethodCall
7
+
8
+ class Item
9
+ attr_reader method_type: RBS::MethodType
10
+
11
+ attr_reader comment: RBS::AST::Comment?
12
+
13
+ def initialize: (RBS::MethodType, RBS::AST::Comment?) -> void
14
+ end
15
+
16
+ attr_reader source: Source
17
+
18
+ attr_reader path: Pathname
19
+
20
+ attr_reader subtyping: Subtyping::Check
21
+
22
+ attr_reader buffer: RBS::Buffer
23
+
24
+ def env: () -> Environment
25
+
26
+ def initialize: (source: Source, subtyping: Subtyping::Check) -> void
27
+
28
+ # 1-origin line, 0-origin column
29
+ #
30
+ def run: (line: Integer, column: Integer) -> [Array[Item], Integer?]?
31
+
32
+ private
33
+
34
+ def signature_help_for: (Parser::AST::Node, Typing) -> [Array[Item], Integer?]?
35
+
36
+ def type_check!: (line: Integer, column: Integer) -> Typing
37
+ end
38
+ end
39
+ end
@@ -1,6 +1,6 @@
1
1
  module Steep
2
2
  module TypeInference
3
- class MethodCall
3
+ module MethodCall
4
4
  class MethodDecl
5
5
  attr_reader method_name: method_name
6
6
 
@@ -52,7 +52,9 @@ module Steep
52
52
  include Equatable
53
53
  end
54
54
 
55
- type arg = NodeParamPair | NodeTypePair | SplatArg | UnexpectedArg | MissingArg
55
+ type arg = NodeParamPair | NodeTypePair | SplatArg | error_arg
56
+
57
+ type error_arg = UnexpectedArg | MissingArg
56
58
 
57
59
  attr_reader args: Array[Parser::AST::Node]
58
60
 
@@ -134,7 +136,9 @@ module Steep
134
136
  def initialize: (keywords: Set[Symbol]) -> void
135
137
  end
136
138
 
137
- type arg = ArgTypePairs | SplatArg | UnexpectedKeyword | MissingKeyword
139
+ type arg = ArgTypePairs | SplatArg | error_arg
140
+
141
+ type error_arg = UnexpectedKeyword | MissingKeyword
138
142
 
139
143
  attr_reader kwarg_nodes: Array[Parser::AST::Node]
140
144
 
data/sig/steep/typing.rbs CHANGED
@@ -44,7 +44,7 @@ module Steep
44
44
 
45
45
  def type_of: (node: Parser::AST::Node) -> AST::Types::t
46
46
 
47
- def call_of: (node: untyped) -> untyped
47
+ def call_of: (node: Parser::AST::Node) -> TypeInference::MethodCall::t
48
48
 
49
49
  def add_context_for_node: (untyped node, context: untyped) -> untyped
50
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steep
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0.dev.3
4
+ version: 1.4.0.dev.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -343,6 +343,7 @@ files:
343
343
  - lib/steep/services/hover_provider/ruby.rb
344
344
  - lib/steep/services/hover_provider/singleton_methods.rb
345
345
  - lib/steep/services/path_assignment.rb
346
+ - lib/steep/services/signature_help_provider.rb
346
347
  - lib/steep/services/signature_service.rb
347
348
  - lib/steep/services/stats_calculator.rb
348
349
  - lib/steep/services/type_check_service.rb
@@ -474,6 +475,7 @@ files:
474
475
  - sig/steep/services/hover_provider/ruby.rbs
475
476
  - sig/steep/services/hover_provider/singleton_methods.rbs
476
477
  - sig/steep/services/path_assignment.rbs
478
+ - sig/steep/services/signature_help_provider.rbs
477
479
  - sig/steep/services/signature_service.rbs
478
480
  - sig/steep/services/stats_calculator.rbs
479
481
  - sig/steep/services/type_check_service.rbs