rbs 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "0.19.0"
2
+ VERSION = "0.20.0"
3
3
  end
@@ -285,7 +285,15 @@ module RBS
285
285
  else
286
286
  "(#{attr.ivar_name})"
287
287
  end
288
- "attr_#{kind} #{attr.name}#{var}: #{attr.type}"
288
+
289
+ receiver = case attr.kind
290
+ when :singleton
291
+ "self."
292
+ when :instance
293
+ ""
294
+ end
295
+
296
+ "attr_#{kind} #{receiver}#{attr.name}#{var}: #{attr.type}"
289
297
  end
290
298
 
291
299
  def preserve_empty_line(prev, decl)
@@ -165,6 +165,10 @@
165
165
  "name": {
166
166
  "type": "string"
167
167
  },
168
+ "kind": {
169
+ "type": "string",
170
+ "enum": ["instance", "singleton"]
171
+ },
168
172
  "type": {
169
173
  "$ref": "types.json"
170
174
  },
@@ -194,7 +198,7 @@
194
198
  "$ref": "location.json"
195
199
  }
196
200
  },
197
- "required": ["member", "name", "ivar_name", "type", "annotations", "comment", "location"]
201
+ "required": ["member", "name", "ivar_name", "type", "annotations", "kind", "comment", "location"]
198
202
  },
199
203
  "visibility": {
200
204
  "title": "Visibility specifier",
@@ -93,5 +93,8 @@ module RBS
93
93
  def validate_parameter_variance: (decl: AST::Declarations::Class | AST::Declarations::Module | AST::Declarations::Interface, methods: Hash[Symbol, Definition::Method]) -> void
94
94
 
95
95
  def expand_alias: (TypeName) -> Types::t
96
+
97
+ type attributes = AST::Members::AttrReader | AST::Members::AttrWriter | AST::Members::AttrAccessor
98
+ def build_attribute: (type_name: TypeName, definition: Definition, member: attributes, accessibility: Definition::accessibility) -> void
96
99
  end
97
100
  end
@@ -91,14 +91,17 @@ module RBS
91
91
  end
92
92
 
93
93
  module Attribute
94
+ type kind = :instance | :singleton
95
+
94
96
  attr_reader name: Symbol
95
97
  attr_reader type: Types::t
98
+ attr_reader kind: kind
96
99
  attr_reader ivar_name: Symbol | false | nil
97
100
  attr_reader annotations: Array[Annotation]
98
101
  attr_reader location: Location?
99
102
  attr_reader comment: Comment?
100
103
 
101
- def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
104
+ def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, kind: kind, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
102
105
 
103
106
  include _HashEqual
104
107
  end
@@ -1,24 +1,11 @@
1
1
  module RBS
2
2
  class MethodType
3
- class Block
4
- attr_reader type: Types::Function
5
- attr_reader required: bool
6
-
7
- def initialize: (type: Types::Function, required: boolish) -> void
8
-
9
- def ==: (untyped other) -> bool
10
-
11
- def to_json: (*untyped) -> String
12
-
13
- def sub: (Substitution) -> Block
14
- end
15
-
16
3
  attr_reader type_params: Array[Symbol]
17
4
  attr_reader type: Types::Function
18
- attr_reader block: Block?
5
+ attr_reader block: Types::Block?
19
6
  attr_reader location: Location?
20
7
 
21
- def initialize: (type_params: Array[Symbol], type: Types::Function, block: Block?, location: Location?) -> void
8
+ def initialize: (type_params: Array[Symbol], type: Types::Function, block: Types::Block?, location: Location?) -> void
22
9
 
23
10
  def ==: (untyped other) -> bool
24
11
 
@@ -26,7 +13,7 @@ module RBS
26
13
 
27
14
  def sub: (Substitution) -> MethodType
28
15
 
29
- def update: (?type_params: Array[Symbol], ?type: Types::Function, ?block: Block?, ?location: Location?) -> MethodType
16
+ def update: (?type_params: Array[Symbol], ?type: Types::Function, ?block: Types::Block?, ?location: Location?) -> MethodType
30
17
 
31
18
  def free_variables: (?Set[Symbol] set) -> Set[Symbol]
32
19
 
@@ -334,11 +334,27 @@ module RBS
334
334
  def has_keyword?: () -> bool
335
335
  end
336
336
 
337
+ class Block
338
+ attr_reader type: Types::Function
339
+ attr_reader required: boolish
340
+
341
+ def initialize: (type: Types::Function, required: boolish) -> void
342
+
343
+ def ==: (untyped other) -> bool
344
+
345
+ def to_json: (*untyped) -> String
346
+
347
+ def sub: (Substitution) -> Block
348
+
349
+ def map_type: () { (Types::t) -> Types::t } -> Block
350
+ end
351
+
337
352
  class Proc
338
353
  attr_reader type: Function
354
+ attr_reader block: Block?
339
355
  attr_reader location: Location?
340
356
 
341
- def initialize: (location: Location?, type: Function) -> void
357
+ def initialize: (location: Location?, type: Function, block: Block?) -> void
342
358
 
343
359
  include _TypeBase
344
360
  end
@@ -138,8 +138,6 @@ class DBM
138
138
  #
139
139
  def include?: (String) -> bool
140
140
 
141
- def index: (untyped) -> (String | NilClass)
142
-
143
141
  # Returns a Hash (not a DBM database) created by using each value in the
144
142
  # database as a key, with the corresponding key as its value.
145
143
  #
@@ -142,6 +142,8 @@ module TSort[Node] : TSort::_Sortable[Node]
142
142
  #
143
143
  def self.each_strongly_connected_component: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (Array[T]) -> void } -> void
144
144
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[Array[T], void]
145
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (Array[T]) -> void } -> void
146
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[Array[T], void]
145
147
 
146
148
  # Iterates over strongly connected components in a graph. The graph is
147
149
  # represented by *node* and *each_child*.
@@ -165,6 +167,8 @@ module TSort[Node] : TSort::_Sortable[Node]
165
167
  #
166
168
  def self.each_strongly_connected_component_from: [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
167
169
  | [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
170
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
171
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
168
172
 
169
173
  # Returns strongly connected components as an array of arrays of nodes. The
170
174
  # array is sorted from children to parents. Each elements of the array
@@ -188,6 +192,7 @@ module TSort[Node] : TSort::_Sortable[Node]
188
192
  # #=> [[4], [2, 3], [1]]
189
193
  #
190
194
  def self.strongly_connected_components: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[Array[T]]
195
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[Array[T]]
191
196
 
192
197
  # Returns a topologically sorted array of nodes. The array is sorted from
193
198
  # children to parents, i.e. the first element has no child and the last node has
@@ -211,6 +216,7 @@ module TSort[Node] : TSort::_Sortable[Node]
211
216
  # p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
212
217
  #
213
218
  def self.tsort: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[T]
219
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[T]
214
220
 
215
221
  # The iterator version of the TSort.tsort method.
216
222
  #
@@ -230,6 +236,8 @@ module TSort[Node] : TSort::_Sortable[Node]
230
236
  #
231
237
  def self.tsort_each: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (T) -> void } -> void
232
238
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[T, void]
239
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (T) -> void } -> void
240
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[T, void]
233
241
 
234
242
  # The iterator version of the #strongly_connected_components method.
235
243
  # *`obj*.each_strongly_connected_component` is similar to
@@ -16,7 +16,7 @@ GEM
16
16
  i18n (1.8.5)
17
17
  concurrent-ruby (~> 1.0)
18
18
  language_server-protocol (3.15.0.1)
19
- listen (3.2.1)
19
+ listen (3.3.3)
20
20
  rb-fsevent (~> 0.10, >= 0.10.3)
21
21
  rb-inotify (~> 0.9, >= 0.9.10)
22
22
  minitest (5.14.2)
@@ -26,20 +26,20 @@ GEM
26
26
  rb-fsevent (0.10.4)
27
27
  rb-inotify (0.10.1)
28
28
  ffi (~> 1.0)
29
- rbs (0.14.0)
30
- steep (0.34.0)
29
+ rbs (0.17.0)
30
+ steep (0.36.0)
31
31
  activesupport (>= 5.1)
32
32
  ast_utils (~> 0.3.0)
33
33
  language_server-protocol (~> 3.15.0.1)
34
34
  listen (~> 3.0)
35
35
  parser (~> 2.7.0)
36
36
  rainbow (>= 2.2.2, < 4.0)
37
- rbs (~> 0.14.0)
37
+ rbs (~> 0.17.0)
38
38
  thor (1.0.1)
39
39
  thread_safe (0.3.6)
40
- tzinfo (1.2.7)
40
+ tzinfo (1.2.8)
41
41
  thread_safe (~> 0.1)
42
- zeitwerk (2.4.1)
42
+ zeitwerk (2.4.2)
43
43
 
44
44
  PLATFORMS
45
45
  ruby
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  steep
49
49
 
50
50
  BUNDLED WITH
51
- 2.1.4
51
+ 2.2.0.rc.2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2020-12-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  - !ruby/object:Gem::Version
255
255
  version: '0'
256
256
  requirements: []
257
- rubygems_version: 3.1.2
257
+ rubygems_version: 3.2.0.rc.2
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: Type signature for Ruby.