rbs-inline 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbs/inline/annotation_parser.rb +8 -1
- data/lib/rbs/inline/ast/annotations.rb +24 -10
- data/lib/rbs/inline/ast/declarations.rb +15 -0
- data/lib/rbs/inline/version.rb +1 -1
- data/lib/rbs/inline/writer.rb +59 -5
- data/rbs_collection.lock.yaml +2 -2
- data/sig/generated/rbs/inline/ast/annotations.rbs +1 -1
- data/sig/generated/rbs/inline/ast/declarations.rbs +2 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5a68634b62b49714735e0b84f748c4e2a646dc1f785644202b76dcbcb7a3937
|
4
|
+
data.tar.gz: 19d106b8ff48e0eab47f30751764611437fb13a1cf54bb382738e849217fb2fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8f197fbd6ed4bbb17f3715aa314320405561ee2dd8fe61c7a1d61279e8f1c7d2ba166308cee7282114f004a195853f0bb1f736a932466e58000ced915f844d7
|
7
|
+
data.tar.gz: 7ae9e4c5a8ecbdc3c9935c698ed5964454c5d1b152e3f637457b96220f959e3489df7906c674f88a99f346879d9cd66768dd4ec7b4a39206030e41c880493344
|
@@ -754,7 +754,14 @@ module RBS
|
|
754
754
|
tree = AST::Tree.new(:module_self)
|
755
755
|
|
756
756
|
tokenizer.consume_token!(K_MODULE_SELF, tree: tree)
|
757
|
-
|
757
|
+
while true
|
758
|
+
tree << parse_type(tokenizer, tree)
|
759
|
+
if tokenizer.type?(K_COMMA)
|
760
|
+
tokenizer.advance(tree, eat: true)
|
761
|
+
else
|
762
|
+
break
|
763
|
+
end
|
764
|
+
end
|
758
765
|
|
759
766
|
tree << parse_optional(tokenizer, K_MINUS2, tree: tree) do
|
760
767
|
parse_comment(tokenizer)
|
@@ -509,7 +509,7 @@ module RBS
|
|
509
509
|
|
510
510
|
# `# @rbs module-self [MODULE_SELF]`
|
511
511
|
class ModuleSelf < Base
|
512
|
-
attr_reader :
|
512
|
+
attr_reader :self_types #: Array[RBS::AST::Declarations::Module::Self]
|
513
513
|
|
514
514
|
attr_reader :comment #: String?
|
515
515
|
|
@@ -517,20 +517,34 @@ module RBS
|
|
517
517
|
def initialize(tree, source)
|
518
518
|
@tree = tree
|
519
519
|
@source = source
|
520
|
+
@self_types = []
|
520
521
|
|
521
522
|
module_self = tree.nth_tree!(1)
|
522
|
-
|
523
|
+
self_trees = module_self.non_trivia_trees
|
524
|
+
self_trees.shift
|
523
525
|
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
526
|
+
while true
|
527
|
+
type = self_trees.shift
|
528
|
+
case type
|
529
|
+
when Types::ClassInstance, Types::Interface
|
530
|
+
@self_types << RBS::AST::Declarations::Module::Self.new(
|
531
|
+
name: type.name,
|
532
|
+
args: type.args,
|
533
|
+
location: nil
|
534
|
+
)
|
535
|
+
end
|
536
|
+
|
537
|
+
break if self_trees.empty?
|
538
|
+
|
539
|
+
next_tree = self_trees.first
|
540
|
+
if next_tree.is_a?(Array) && next_tree[0] == :kCOMMA
|
541
|
+
self_trees.shift
|
542
|
+
else
|
543
|
+
break
|
544
|
+
end
|
531
545
|
end
|
532
546
|
|
533
|
-
if comment =
|
547
|
+
if comment = self_trees.first
|
534
548
|
@comment = comment.to_s
|
535
549
|
end
|
536
550
|
end
|
@@ -241,6 +241,21 @@ module RBS
|
|
241
241
|
end
|
242
242
|
|
243
243
|
class SingletonClassDecl < ModuleOrClass #[Prism::SingletonClassNode]
|
244
|
+
# @rbs (AST::Members::RubyDef) -> (:private | nil)
|
245
|
+
def visibility(def_member)
|
246
|
+
current_visibility = nil
|
247
|
+
members.each do |member|
|
248
|
+
case member
|
249
|
+
when AST::Members::RubyPublic
|
250
|
+
current_visibility = nil
|
251
|
+
when AST::Members::RubyPrivate
|
252
|
+
current_visibility = :private
|
253
|
+
end
|
254
|
+
|
255
|
+
break if member == def_member
|
256
|
+
end
|
257
|
+
current_visibility
|
258
|
+
end
|
244
259
|
end
|
245
260
|
|
246
261
|
class BlockDecl < Base
|
data/lib/rbs/inline/version.rb
CHANGED
data/lib/rbs/inline/writer.rb
CHANGED
@@ -155,7 +155,7 @@ module RBS
|
|
155
155
|
|
156
156
|
translate_members(decl.members, nil, members)
|
157
157
|
|
158
|
-
self_types = decl.module_selfs.
|
158
|
+
self_types = decl.module_selfs.flat_map { _1.self_types }.compact
|
159
159
|
|
160
160
|
rbs << RBS::AST::Declarations::Module.new(
|
161
161
|
name: decl.module_name,
|
@@ -257,10 +257,40 @@ module RBS
|
|
257
257
|
visibility: nil
|
258
258
|
)
|
259
259
|
|
260
|
+
members = [:singleton, :instance].map do |kind|
|
261
|
+
RBS::AST::Members::MethodDefinition.new(
|
262
|
+
name: :members,
|
263
|
+
kind: kind, #: RBS::AST::MethodDefinition::Kind
|
264
|
+
overloads: [
|
265
|
+
RBS::AST::Members::MethodDefinition::Overload.new(
|
266
|
+
method_type: RBS::MethodType.new(
|
267
|
+
type_params: [],
|
268
|
+
type: Types::Function.empty(
|
269
|
+
Types::Tuple.new(
|
270
|
+
types: decl.each_attribute.map do |name, _|
|
271
|
+
Types::Literal.new(literal: name, location: nil)
|
272
|
+
end,
|
273
|
+
location: nil
|
274
|
+
)
|
275
|
+
),
|
276
|
+
block: nil,
|
277
|
+
location: nil
|
278
|
+
),
|
279
|
+
annotations: []
|
280
|
+
)
|
281
|
+
],
|
282
|
+
annotations: [],
|
283
|
+
location: nil,
|
284
|
+
comment: nil,
|
285
|
+
overloading: false,
|
286
|
+
visibility: nil
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
260
290
|
rbs << RBS::AST::Declarations::Class.new(
|
261
291
|
name: decl.constant_name,
|
262
292
|
type_params: [],
|
263
|
-
members: [*attributes, new],
|
293
|
+
members: [*attributes, new, *members],
|
264
294
|
super_class: RBS::AST::Declarations::Class::Super.new(
|
265
295
|
name: RBS::TypeName.new(name: :Data, namespace: RBS::Namespace.empty),
|
266
296
|
args: [],
|
@@ -365,6 +395,29 @@ module RBS
|
|
365
395
|
method_type: RBS::MethodType.new(type_params: [], type: method_type, block: nil, location: nil),
|
366
396
|
annotations: []
|
367
397
|
)
|
398
|
+
|
399
|
+
unless decl.positional_init?
|
400
|
+
new.overloads <<
|
401
|
+
RBS::AST::Members::MethodDefinition::Overload.new(
|
402
|
+
method_type: RBS::MethodType.new(
|
403
|
+
type_params: [],
|
404
|
+
type: Types::Function.empty(Types::Bases::Instance.new(location: nil)).then do |t|
|
405
|
+
t.update(required_positionals: [
|
406
|
+
RBS::Types::Function::Param.new(
|
407
|
+
type: RBS::Types::Record.new(all_fields: decl.each_attribute.map do |name, attr|
|
408
|
+
[name, attr&.type || Types::Bases::Any.new(location: nil)]
|
409
|
+
end.to_h, location: nil),
|
410
|
+
name: nil,
|
411
|
+
location: nil
|
412
|
+
)
|
413
|
+
])
|
414
|
+
end,
|
415
|
+
block: nil,
|
416
|
+
location: nil
|
417
|
+
),
|
418
|
+
annotations:[]
|
419
|
+
)
|
420
|
+
end
|
368
421
|
end
|
369
422
|
|
370
423
|
rbs << RBS::AST::Declarations::Class.new(
|
@@ -421,6 +474,7 @@ module RBS
|
|
421
474
|
return
|
422
475
|
end
|
423
476
|
|
477
|
+
visibility = member.visibility || decl&.visibility(member)
|
424
478
|
rbs << RBS::AST::Members::MethodDefinition.new(
|
425
479
|
name: member.method_name,
|
426
480
|
kind: kind,
|
@@ -429,7 +483,7 @@ module RBS
|
|
429
483
|
location: nil,
|
430
484
|
comment: comment,
|
431
485
|
overloading: member.overloading?,
|
432
|
-
visibility:
|
486
|
+
visibility: visibility
|
433
487
|
)
|
434
488
|
when AST::Members::RubyAlias
|
435
489
|
if member.comments
|
@@ -453,9 +507,9 @@ module RBS
|
|
453
507
|
rbs.concat m
|
454
508
|
end
|
455
509
|
when AST::Members::RubyPrivate
|
456
|
-
rbs << RBS::AST::Members::Private.new(location: nil)
|
510
|
+
rbs << RBS::AST::Members::Private.new(location: nil) unless decl
|
457
511
|
when AST::Members::RubyPublic
|
458
|
-
rbs << RBS::AST::Members::Public.new(location: nil)
|
512
|
+
rbs << RBS::AST::Members::Public.new(location: nil) unless decl
|
459
513
|
when AST::Members::RBSIvar
|
460
514
|
if m = member.rbs
|
461
515
|
rbs << m
|
data/rbs_collection.lock.yaml
CHANGED
@@ -42,11 +42,11 @@ gems:
|
|
42
42
|
source:
|
43
43
|
type: git
|
44
44
|
name: ruby/gem_rbs_collection
|
45
|
-
revision:
|
45
|
+
revision: 03121e6bbf2340e3b179edcc351deac45476f4d0
|
46
46
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
47
47
|
repo_dir: gems
|
48
48
|
- name: rbs
|
49
|
-
version: 3.5.
|
49
|
+
version: 3.5.3
|
50
50
|
source:
|
51
51
|
type: rubygems
|
52
52
|
- name: rdoc
|
@@ -195,7 +195,7 @@ module RBS
|
|
195
195
|
|
196
196
|
# `# @rbs module-self [MODULE_SELF]`
|
197
197
|
class ModuleSelf < Base
|
198
|
-
attr_reader
|
198
|
+
attr_reader self_types: Array[RBS::AST::Declarations::Module::Self]
|
199
199
|
|
200
200
|
attr_reader comment: String?
|
201
201
|
|
@@ -115,6 +115,8 @@ module RBS
|
|
115
115
|
end
|
116
116
|
|
117
117
|
class SingletonClassDecl < ModuleOrClass[Prism::SingletonClassNode]
|
118
|
+
# @rbs (AST::Members::RubyDef) -> (:private | nil)
|
119
|
+
def visibility: (AST::Members::RubyDef) -> (:private | nil)
|
118
120
|
end
|
119
121
|
|
120
122
|
class BlockDecl < Base
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs-inline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prism
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.29'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '1.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '0.29'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '1.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rbs
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 3.
|
106
|
+
version: 3.1.0
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ">="
|