rbs_protobuf 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 563169bcedcc8c4392d8ad6c428c8fd4f31b5ca3373705439fa94a0e3f05b138
4
- data.tar.gz: a55dd8d55cc9b866b101e51bb90ba88aa5e138251c3083b010671b03346d9db8
3
+ metadata.gz: 36689cc81f238ec33c07f1485ab4ff50f73fe365c1e84fcb925d34b0159859d3
4
+ data.tar.gz: a149120654ab2387721383d723bf3c54923385a66feff3a755ebce1056bf014c
5
5
  SHA512:
6
- metadata.gz: d0ea93fd55f7b9efb4a864156e428033da4116499c99ef8f222949ae301b16fe302cd00c022ce2ad91ac9216dca508a084a9c59fb5b296dbd5e41d4d8dd6b205
7
- data.tar.gz: c143b93fce43ede0ff094a26f2e51d3d72e6b35853852cc11e1b571f74abbe68ec7f579af206bec8213c908bb34d1421986f57a6f14417d316d7b666491c04ce
6
+ metadata.gz: f2bc3a51198e70d9617edf6df9c40e9fbfbac8061d3b849d6cf2ec21b839bd379bea6bf94d5a63dc134af173c773338f7b937b53597906e1bb3e85dd6c965c3c
7
+ data.tar.gz: 349c294046f6c7665dad74a0461311bf4c7edb58d9c8f804bd70b6c6ed11442d295086a59b9990465d478195c87c96e54180237e8fdd1a73c202e48ffde73b60
@@ -12,12 +12,13 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  container_tag:
15
- - 2.7-bionic
16
- - 3.0-focal
17
- - 3.1-focal
15
+ - 3.0-dev-focal
16
+ - 3.1-dev-jammy
17
+ - 3.2-dev-jammy
18
18
  protoc_version:
19
- - 3.18.2
20
- - 3.19.4
19
+ - "3.18.2"
20
+ - "3.19.4"
21
+ - "24.0"
21
22
  container:
22
23
  image: rubylang/ruby:${{ matrix.container_tag }}
23
24
  steps:
@@ -31,8 +32,9 @@ jobs:
31
32
  mv bin/protoc /usr/local/bin/protoc
32
33
  protoc --version
33
34
  - uses: actions/checkout@v3
34
- with:
35
- submodules: true
35
+ - name: Set up git safe.directory
36
+ run: |
37
+ git config --global --add safe.directory /__w/rbs_protobuf/rbs_protobuf
36
38
  - name: Run test
37
39
  run: |
38
40
  ruby -v
data/.gitmodules CHANGED
@@ -1,3 +0,0 @@
1
- [submodule "vendor/gem_rbs_collection"]
2
- path = vendor/gem_rbs_collection
3
- url = git@github.com:ruby/gem_rbs_collection.git
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.0 (2023-08-16)
4
+
5
+ * Support optional fields in proto3 ([\#32](https://github.com/square/rbs_protobuf/pull/32))
6
+ * Update Steep to 1.5 and RBS to 3.1 ([\#30](https://github.com/square/rbs_protobuf/pull/30))
7
+
3
8
  ## 1.0.0 (2022-04-25)
4
9
 
5
10
  This is version 1.0.0. 🎉
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
- gem "steep"
9
- gem "rbs"
8
+ gem "steep", require: false
9
+ gem "rbs", "~> 3.1"
10
10
 
11
11
  gem "protobuf", "~> 3.10"
data/Gemfile.lock CHANGED
@@ -1,59 +1,72 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_protobuf (1.0.0)
4
+ rbs_protobuf (1.1.0)
5
5
  activesupport (>= 4.0)
6
6
  rbs (>= 2.2.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.0.2.3)
11
+ activesupport (7.0.7)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
16
  ast (2.4.2)
17
- concurrent-ruby (1.1.10)
17
+ concurrent-ruby (1.2.2)
18
+ csv (3.2.7)
18
19
  ffi (1.15.5)
19
- i18n (1.10.0)
20
+ fileutils (1.7.1)
21
+ i18n (1.14.1)
20
22
  concurrent-ruby (~> 1.0)
21
- language_server-protocol (3.16.0.3)
22
- listen (3.7.1)
23
+ json (2.6.3)
24
+ language_server-protocol (3.17.0.3)
25
+ listen (3.8.0)
23
26
  rb-fsevent (~> 0.10, >= 0.10.3)
24
27
  rb-inotify (~> 0.9, >= 0.9.10)
28
+ logger (1.5.3)
25
29
  middleware (0.1.0)
26
- minitest (5.15.0)
27
- parallel (1.22.1)
28
- parser (3.1.2.0)
30
+ minitest (5.19.0)
31
+ parser (3.2.2.3)
29
32
  ast (~> 2.4.1)
33
+ racc
30
34
  protobuf (3.10.5)
31
35
  activesupport (>= 3.2)
32
36
  middleware
33
37
  thor
34
38
  thread_safe
39
+ racc (1.7.1)
35
40
  rainbow (3.1.1)
36
41
  rake (12.3.3)
37
- rb-fsevent (0.11.1)
42
+ rb-fsevent (0.11.2)
38
43
  rb-inotify (0.10.1)
39
44
  ffi (~> 1.0)
40
- rbs (2.3.2)
41
- steep (0.52.1)
45
+ rbs (3.1.3)
46
+ securerandom (0.2.2)
47
+ steep (1.5.3)
42
48
  activesupport (>= 5.1)
49
+ concurrent-ruby (>= 1.1.10)
50
+ csv (>= 3.0.9)
51
+ fileutils (>= 1.1.0)
52
+ json (>= 2.1.0)
43
53
  language_server-protocol (>= 3.15, < 4.0)
44
54
  listen (~> 3.0)
45
- parallel (>= 1.0.0)
46
- parser (>= 3.0)
55
+ logger (>= 1.3.0)
56
+ parser (>= 3.1)
47
57
  rainbow (>= 2.2.2, < 4.0)
48
- rbs (>= 2.3.2)
58
+ rbs (>= 3.1.0)
59
+ securerandom (>= 0.1)
60
+ strscan (>= 1.0.0)
49
61
  terminal-table (>= 2, < 4)
62
+ strscan (3.0.6)
50
63
  terminal-table (3.0.2)
51
64
  unicode-display_width (>= 1.1.1, < 3)
52
65
  thor (1.2.1)
53
66
  thread_safe (0.3.6)
54
- tzinfo (2.0.4)
67
+ tzinfo (2.0.6)
55
68
  concurrent-ruby (~> 1.0)
56
- unicode-display_width (2.1.0)
69
+ unicode-display_width (2.4.2)
57
70
 
58
71
  PLATFORMS
59
72
  ruby
@@ -62,7 +75,7 @@ DEPENDENCIES
62
75
  minitest (~> 5.0)
63
76
  protobuf (~> 3.10)
64
77
  rake (~> 12.0)
65
- rbs
78
+ rbs (~> 3.1)
66
79
  rbs_protobuf!
67
80
  steep
68
81
 
data/Rakefile CHANGED
@@ -27,7 +27,8 @@ namespace :example do
27
27
  "-I#{proto_path}",
28
28
  "example/a.proto",
29
29
  "example/b.proto",
30
- "example/c.proto"
30
+ "example/c.proto",
31
+ "example/d.proto"
31
32
  )
32
33
  sh(
33
34
  { "RBS_PROTOBUF_BACKEND" => "protobuf", "RBS_PROTOBUF_EXTENSION" => "true" },
@@ -35,7 +36,8 @@ namespace :example do
35
36
  "--rbs_out=example/protobuf-gem",
36
37
  "-Iexample",
37
38
  "example/a.proto",
38
- "example/b.proto"
39
+ "example/b.proto",
40
+ "example/d.proto"
39
41
  )
40
42
  sh(
41
43
  { "RBS_PROTOBUF_BACKEND" => "protobuf", "RBS_PROTOBUF_EXTENSION" => "true", "RUBYOPT" => "-rbundler/setup -Iexample/protobuf-gem -rc.pb" },
data/Steepfile CHANGED
@@ -2,7 +2,6 @@ D = Steep::Diagnostic
2
2
 
3
3
  target :lib do
4
4
  signature "sig"
5
- signature "vendor/gem_rbs_collection/gems/protobuf"
6
5
  check "lib"
7
6
 
8
7
  configure_code_diagnostics do |hash|
@@ -7,5 +7,7 @@ require "rbs_protobuf"
7
7
  input = STDIN.read()
8
8
  File.write(ENV["PROTOC_DUMPER_OUT"] || "a.pb.out", input)
9
9
 
10
- response = Google::Protobuf::Compiler::CodeGeneratorResponse.new
10
+ response = Google::Protobuf::Compiler::CodeGeneratorResponse.new(
11
+ :supported_features => ::Google::Protobuf::Compiler::CodeGeneratorResponse::Feature::FEATURE_PROTO3_OPTIONAL.to_i
12
+ )
11
13
  print Google::Protobuf::Compiler::CodeGeneratorResponse.encode(response)
data/example/d.proto ADDED
@@ -0,0 +1,6 @@
1
+ syntax = "proto3";
2
+
3
+ message Foo {
4
+ string bar = 2;
5
+ optional string baz = 1;
6
+ }
@@ -14,7 +14,7 @@ module RBSProtobuf
14
14
  end
15
15
 
16
16
  def response
17
- @response ||= Google::Protobuf::Compiler::CodeGeneratorResponse.new
17
+ @response ||= Google::Protobuf::Compiler::CodeGeneratorResponse.new(:supported_features => ::Google::Protobuf::Compiler::CodeGeneratorResponse::Feature::FEATURE_PROTO3_OPTIONAL.to_i)
18
18
  end
19
19
 
20
20
  def generate_rbs!
@@ -188,96 +188,114 @@ module RBSProtobuf
188
188
 
189
189
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
190
190
  name: :initialize,
191
- types: [
192
- factory.method_type(
193
- type: factory.function().update(
194
- optional_keywords: field_types.transform_values {|pair|
195
- _, _, init_type = pair
196
- factory.param(init_type)
197
- }
198
- )
199
- )
191
+ overloads: [
192
+ RBS::AST::Members::MethodDefinition::Overload.new(
193
+ method_type: factory.method_type(
194
+ type: factory.function().update(
195
+ optional_keywords: field_types.transform_values {|pair|
196
+ _, _, init_type = pair
197
+ factory.param(init_type)
198
+ }
199
+ )
200
+ ),
201
+ annotations: []
202
+ ),
200
203
  ],
201
204
  annotations: [],
202
205
  comment: nil,
203
206
  location: nil,
204
- overload: false,
207
+ overloading: false,
208
+ visibility: nil,
205
209
  kind: :instance
206
210
  )
207
211
 
208
212
  unless field_types.empty?
209
213
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
210
214
  name: :[],
211
- types:
215
+ overloads:
212
216
  field_types.map do |field_name, pair|
213
217
  read_type, _ = pair
214
218
 
215
- factory.method_type(
216
- type: factory.function(read_type).update(
217
- required_positionals: [
218
- factory.param(factory.literal_type(field_name))
219
- ]
220
- )
221
- )
222
- end +
223
- [
224
- factory.method_type(
225
- type: factory.function(factory.untyped).update(
219
+ RBS::AST::Members::MethodDefinition::Overload.new(
220
+ method_type: factory.method_type(
221
+ type: factory.function(read_type).update(
226
222
  required_positionals: [
227
- factory.param(RBS::BuiltinNames::Symbol.instance_type)
223
+ factory.param(factory.literal_type(field_name))
228
224
  ]
229
225
  )
226
+ ),
227
+ annotations: []
228
+ )
229
+ end +
230
+ [
231
+ RBS::AST::Members::MethodDefinition::Overload.new(
232
+ method_type: factory.method_type(
233
+ type: factory.function(factory.untyped).update(
234
+ required_positionals: [
235
+ factory.param(RBS::BuiltinNames::Symbol.instance_type)
236
+ ]
237
+ )
238
+ ),
239
+ annotations: []
230
240
  )
231
241
  ],
232
242
  annotations: [],
233
243
  comment: nil,
234
244
  location: nil,
235
- overload: false,
245
+ overloading: false,
246
+ visibility: nil,
236
247
  kind: :instance
237
248
  )
238
249
 
239
250
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
240
251
  name: :[]=,
241
- types:
252
+ overloads:
242
253
  field_types.flat_map do |field_name, pair|
243
254
  read_type, write_types = pair
244
255
 
245
256
  [read_type, *write_types].map do |type|
246
- if (type_param, type_var = interface_type?(type))
247
- factory.method_type(
248
- type: factory.function(type_var).update(
249
- required_positionals: [
250
- factory.literal_type(field_name),
251
- type_var
252
- ].map {|t| factory.param(t) }
257
+ method_type =
258
+ if (type_param, type_var = interface_type?(type))
259
+ factory.method_type(
260
+ type: factory.function(type_var).update(
261
+ required_positionals: [
262
+ factory.literal_type(field_name),
263
+ type_var
264
+ ].map {|t| factory.param(t) }
265
+ )
266
+ ).update(type_params: [type_param])
267
+ else
268
+ factory.method_type(
269
+ type: factory.function(type).update(
270
+ required_positionals: [
271
+ factory.literal_type(field_name),
272
+ type
273
+ ].map {|t| factory.param(t) }
274
+ )
253
275
  )
254
- ).update(type_params: [type_param])
255
- else
256
- factory.method_type(
257
- type: factory.function(type).update(
258
- required_positionals: [
259
- factory.literal_type(field_name),
260
- type
261
- ].map {|t| factory.param(t) }
262
- )
263
- )
264
- end
276
+ end
277
+
278
+ RBS::AST::Members::MethodDefinition::Overload.new(method_type: method_type, annotations: [])
265
279
  end
266
280
  end +
267
281
  [
268
- factory.method_type(
269
- type: factory.function(factory.untyped).update(
270
- required_positionals: [
271
- RBS::BuiltinNames::Symbol.instance_type,
272
- factory.untyped
273
- ].map {|t| factory.param(t) }
274
- )
282
+ RBS::AST::Members::MethodDefinition::Overload.new(
283
+ method_type: factory.method_type(
284
+ type: factory.function(factory.untyped).update(
285
+ required_positionals: [
286
+ RBS::BuiltinNames::Symbol.instance_type,
287
+ factory.untyped
288
+ ].map {|t| factory.param(t) }
289
+ )
290
+ ),
291
+ annotations: []
275
292
  )
276
293
  ],
277
294
  annotations: [],
278
295
  comment: nil,
279
296
  location: nil,
280
- overload: false,
297
+ overloading: false,
298
+ visibility: nil,
281
299
  kind: :instance
282
300
  )
283
301
  end
@@ -286,15 +304,19 @@ module RBSProtobuf
286
304
  if field.type == FieldDescriptorProto::Type::TYPE_BOOL
287
305
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
288
306
  name: :"#{field.name}?",
289
- types: [
290
- factory.method_type(
291
- type: factory.function(factory.bool_type)
307
+ overloads: [
308
+ RBS::AST::Members::MethodDefinition::Overload.new(
309
+ method_type: factory.method_type(
310
+ type: factory.function(factory.bool_type)
311
+ ),
312
+ annotations: []
292
313
  )
293
314
  ],
294
315
  annotations: [],
295
316
  comment: nil,
296
317
  location: nil,
297
- overload: false,
318
+ overloading: false,
319
+ visibility: nil,
298
320
  kind: :instance
299
321
  )
300
322
  end
@@ -310,20 +332,24 @@ module RBSProtobuf
310
332
  ).tap do |interface_decl|
311
333
  interface_decl.members << RBS::AST::Members::MethodDefinition.new(
312
334
  name: :to_proto,
313
- types: [
314
- factory.method_type(
315
- type: factory.function(class_instance_type)
335
+ overloads: [
336
+ RBS::AST::Members::MethodDefinition::Overload.new(
337
+ method_type: factory.method_type(
338
+ type: factory.function(class_instance_type)
339
+ ),
340
+ annotations: []
316
341
  )
317
342
  ],
318
343
  annotations: [],
319
344
  comment: nil,
320
345
  location: nil,
321
- overload: false,
346
+ overloading: false,
347
+ visibility: nil,
322
348
  kind: :instance
323
349
  )
324
350
  end
325
351
 
326
- class_decl.members << RBS::AST::Declarations::Alias.new(
352
+ class_decl.members << RBS::AST::Declarations::TypeAlias.new(
327
353
  name: TypeName("init"),
328
354
  type_params: [],
329
355
  type: factory.union_type(class_instance_type, TO_PROTO[]),
@@ -332,7 +358,7 @@ module RBSProtobuf
332
358
  location: nil
333
359
  )
334
360
 
335
- class_decl.members << RBS::AST::Declarations::Alias.new(
361
+ class_decl.members << RBS::AST::Declarations::TypeAlias.new(
336
362
  name: TypeName("field_array"),
337
363
  type_params: [],
338
364
  type: FIELD_ARRAY[
@@ -344,7 +370,7 @@ module RBSProtobuf
344
370
  location: nil
345
371
  )
346
372
 
347
- class_decl.members << RBS::AST::Declarations::Alias.new(
373
+ class_decl.members << RBS::AST::Declarations::TypeAlias.new(
348
374
  name: TypeName("field_hash"),
349
375
  type_params: [RBS::AST::TypeParam.new(name: :KEY, variance: :invariant, upper_bound: nil, location: nil)],
350
376
  type: FIELD_HASH[
@@ -357,7 +383,7 @@ module RBSProtobuf
357
383
  location: nil
358
384
  )
359
385
 
360
- class_decl.members << RBS::AST::Declarations::Alias.new(
386
+ class_decl.members << RBS::AST::Declarations::TypeAlias.new(
361
387
  name: TypeName("array"),
362
388
  type_params: [],
363
389
  type: RBS::BuiltinNames::Array.instance_type(factory.union_type(class_instance_type, TO_PROTO[])),
@@ -366,7 +392,7 @@ module RBSProtobuf
366
392
  location: nil
367
393
  )
368
394
 
369
- class_decl.members << RBS::AST::Declarations::Alias.new(
395
+ class_decl.members << RBS::AST::Declarations::TypeAlias.new(
370
396
  name: TypeName("hash"),
371
397
  type_params: [RBS::AST::TypeParam.new(name: :KEY, variance: :invariant, upper_bound: nil, location: nil)],
372
398
  type: RBS::BuiltinNames::Hash.instance_type(
@@ -567,41 +593,52 @@ module RBSProtobuf
567
593
  unless write_types.empty?
568
594
  members << RBS::AST::Members::MethodDefinition.new(
569
595
  name: :"#{name}=",
570
- types:
596
+ overloads:
571
597
  write_types.map do |write_type|
572
- if (type_param, type = interface_type?(write_type))
573
- factory.method_type(
574
- type: factory.function(type).update(
575
- required_positionals:[factory.param(type)]
576
- )
577
- ).update(type_params: [type_param])
578
- else
579
- factory.method_type(
580
- type: factory.function(write_type).update(
581
- required_positionals:[factory.param(write_type)]
598
+ method_type =
599
+ if (type_param, type = interface_type?(write_type))
600
+ factory.method_type(
601
+ type: factory.function(type).update(
602
+ required_positionals:[factory.param(type)]
603
+ )
604
+ ).update(type_params: [type_param])
605
+ else
606
+ factory.method_type(
607
+ type: factory.function(write_type).update(
608
+ required_positionals:[factory.param(write_type)]
609
+ )
582
610
  )
583
- )
584
- end
611
+ end
612
+
613
+ RBS::AST::Members::MethodDefinition::Overload.new(
614
+ method_type: method_type,
615
+ annotations: []
616
+ )
585
617
  end,
586
618
  annotations: [],
587
619
  comment: comment,
588
620
  location: nil,
589
- overload: true,
621
+ overloading: true,
622
+ visibility: nil,
590
623
  kind: :instance
591
624
  )
592
625
  end
593
626
 
594
627
  members << RBS::AST::Members::MethodDefinition.new(
595
628
  name: :"#{name}!",
596
- types: [
597
- factory.method_type(
598
- type: factory.function(factory.optional_type(read_type))
629
+ overloads: [
630
+ RBS::AST::Members::MethodDefinition::Overload.new(
631
+ method_type: factory.method_type(
632
+ type: factory.function(factory.optional_type(read_type))
633
+ ),
634
+ annotations: []
599
635
  )
600
636
  ],
601
637
  annotations: [],
602
638
  comment: nil,
603
639
  location: nil,
604
- overload: false,
640
+ overloading: false,
641
+ visibility: nil,
605
642
  kind: :instance
606
643
  )
607
644
  end
@@ -638,7 +675,7 @@ module RBSProtobuf
638
675
  factory.literal_type(v.number)
639
676
  end.uniq
640
677
 
641
- enum_decl.members << RBS::AST::Declarations::Alias.new(
678
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
642
679
  name: factory.type_name("names"),
643
680
  type_params: [],
644
681
  type: factory.union_type(*names),
@@ -647,7 +684,7 @@ module RBSProtobuf
647
684
  annotations: []
648
685
  )
649
686
 
650
- enum_decl.members << RBS::AST::Declarations::Alias.new(
687
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
651
688
  name: factory.type_name("strings"),
652
689
  type_params: [],
653
690
  type: factory.union_type(*strings),
@@ -656,7 +693,7 @@ module RBSProtobuf
656
693
  annotations: []
657
694
  )
658
695
 
659
- enum_decl.members << RBS::AST::Declarations::Alias.new(
696
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
660
697
  name: factory.type_name("tags"),
661
698
  type_params: [],
662
699
  type: factory.union_type(*tags),
@@ -665,7 +702,7 @@ module RBSProtobuf
665
702
  annotations: []
666
703
  )
667
704
 
668
- enum_decl.members << RBS::AST::Declarations::Alias.new(
705
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
669
706
  name: factory.type_name("values"),
670
707
  type_params: [],
671
708
  type: factory.union_type(
@@ -712,7 +749,7 @@ module RBSProtobuf
712
749
  enum_instance_type = factory.instance_type(RBS::TypeName.new(name: enum_name.to_sym, namespace: RBS::Namespace.empty))
713
750
  values_type = factory.alias_type(RBS::TypeName.new(name: :values, namespace: RBS::Namespace.empty))
714
751
 
715
- enum_decl.members << RBS::AST::Declarations::Alias.new(
752
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
716
753
  name: TypeName("init"),
717
754
  type_params: [],
718
755
  type: factory.union_type(enum_instance_type, values_type),
@@ -721,7 +758,7 @@ module RBSProtobuf
721
758
  location: nil
722
759
  )
723
760
 
724
- enum_decl.members << RBS::AST::Declarations::Alias.new(
761
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
725
762
  name: TypeName("field_array"),
726
763
  type_params: [],
727
764
  type: FIELD_ARRAY[
@@ -733,7 +770,7 @@ module RBSProtobuf
733
770
  location: nil
734
771
  )
735
772
 
736
- enum_decl.members << RBS::AST::Declarations::Alias.new(
773
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
737
774
  name: TypeName("field_hash"),
738
775
  type_params: [RBS::AST::TypeParam.new(name: :KEY, variance: :invariant, upper_bound: nil, location: nil)],
739
776
  type: FIELD_HASH[
@@ -746,7 +783,7 @@ module RBSProtobuf
746
783
  location: nil
747
784
  )
748
785
 
749
- enum_decl.members << RBS::AST::Declarations::Alias.new(
786
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
750
787
  name: TypeName("array"),
751
788
  type_params: [],
752
789
  type: RBS::BuiltinNames::Array.instance_type(factory.union_type(enum_instance_type, values_type)),
@@ -755,7 +792,7 @@ module RBSProtobuf
755
792
  location: nil
756
793
  )
757
794
 
758
- enum_decl.members << RBS::AST::Declarations::Alias.new(
795
+ enum_decl.members << RBS::AST::Declarations::TypeAlias.new(
759
796
  name: TypeName("hash"),
760
797
  type_params: [RBS::AST::TypeParam.new(name: :KEY, variance: :invariant, upper_bound: nil, location: nil)],
761
798
  type: RBS::BuiltinNames::Hash.instance_type(
@@ -790,49 +827,59 @@ module RBSProtobuf
790
827
 
791
828
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
792
829
  name: :[],
793
- types: [
794
- factory.method_type(
795
- type: factory.function(read_type).update(
796
- required_positionals: [
797
- factory.param(factory.literal_type(field_name))
798
- ]
799
- )
830
+ overloads: [
831
+ RBS::AST::Members::MethodDefinition::Overload.new(
832
+ method_type: factory.method_type(
833
+ type: factory.function(read_type).update(
834
+ required_positionals: [
835
+ factory.param(factory.literal_type(field_name))
836
+ ]
837
+ )
838
+ ),
839
+ annotations: []
800
840
  )
801
841
  ],
802
842
  annotations: [],
803
843
  comment: nil,
804
844
  location: nil,
805
- overload: true,
845
+ overloading: true,
846
+ visibility: nil,
806
847
  kind: :instance
807
848
  )
808
849
 
809
850
  class_decl.members << RBS::AST::Members::MethodDefinition.new(
810
851
  name: :[]=,
811
- types: [read_type, *write_types].map do |write_type|
812
- if (type_param, type_var = interface_type?(write_type))
813
- factory.method_type(
814
- type: factory.function(type_var).update(
815
- required_positionals: [
816
- factory.param(factory.literal_type(field_name)),
817
- factory.param(type_var)
818
- ]
819
- )
820
- ).update(type_params: [type_param])
821
- else
822
- factory.method_type(
823
- type: factory.function(write_type).update(
824
- required_positionals: [
825
- factory.param(factory.literal_type(field_name)),
826
- factory.param(write_type)
827
- ]
852
+ overloads: [read_type, *write_types].map do |write_type|
853
+ method_type =
854
+ if (type_param, type_var = interface_type?(write_type))
855
+ factory.method_type(
856
+ type: factory.function(type_var).update(
857
+ required_positionals: [
858
+ factory.param(factory.literal_type(field_name)),
859
+ factory.param(type_var)
860
+ ]
861
+ )
862
+ ).update(type_params: [type_param])
863
+ else
864
+ factory.method_type(
865
+ type: factory.function(write_type).update(
866
+ required_positionals: [
867
+ factory.param(factory.literal_type(field_name)),
868
+ factory.param(write_type)
869
+ ]
870
+ )
828
871
  )
829
- )
830
- end
872
+ end
873
+ RBS::AST::Members::MethodDefinition::Overload.new(
874
+ method_type: method_type,
875
+ annotations: []
876
+ )
831
877
  end,
832
878
  annotations: [],
833
879
  comment: nil,
834
880
  location: nil,
835
- overload: true,
881
+ overloading: true,
882
+ visibility: nil,
836
883
  kind: :instance
837
884
  )
838
885
  end
@@ -1,3 +1,3 @@
1
1
  module RBSProtobuf
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,76 +1,61 @@
1
1
  ---
2
2
  sources:
3
- - name: ruby/gem_rbs_collection
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ revision: 8a678b2ec20e9d594055f53745399814e3a887dc
4
6
  remote: https://github.com/ruby/gem_rbs_collection.git
5
- revision: main
6
7
  repo_dir: gems
7
8
  path: ".gem_rbs_collection"
8
9
  gems:
9
- - name: rbs
10
- version: 2.3.2
10
+ - name: abbrev
11
+ version: '0'
11
12
  source:
12
- type: rubygems
13
+ type: stdlib
13
14
  - name: activesupport
14
- version: '6.0'
15
+ version: '7.0'
15
16
  source:
16
17
  type: git
17
18
  name: ruby/gem_rbs_collection
18
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
19
+ revision: 8a678b2ec20e9d594055f53745399814e3a887dc
19
20
  remote: https://github.com/ruby/gem_rbs_collection.git
20
21
  repo_dir: gems
21
- - name: ast
22
- version: '2.4'
22
+ - name: concurrent-ruby
23
+ version: '1.1'
23
24
  source:
24
25
  type: git
25
26
  name: ruby/gem_rbs_collection
26
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
27
+ revision: 8a678b2ec20e9d594055f53745399814e3a887dc
27
28
  remote: https://github.com/ruby/gem_rbs_collection.git
28
29
  repo_dir: gems
30
+ - name: date
31
+ version: '0'
32
+ source:
33
+ type: stdlib
29
34
  - name: i18n
30
35
  version: '1.10'
31
36
  source:
32
37
  type: git
33
38
  name: ruby/gem_rbs_collection
34
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
39
+ revision: 8a678b2ec20e9d594055f53745399814e3a887dc
35
40
  remote: https://github.com/ruby/gem_rbs_collection.git
36
41
  repo_dir: gems
37
- - name: listen
38
- version: '3.2'
39
- source:
40
- type: git
41
- name: ruby/gem_rbs_collection
42
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
43
- remote: https://github.com/ruby/gem_rbs_collection.git
44
- repo_dir: gems
45
- - name: parallel
46
- version: '1.20'
47
- source:
48
- type: git
49
- name: ruby/gem_rbs_collection
50
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
51
- remote: https://github.com/ruby/gem_rbs_collection.git
52
- repo_dir: gems
53
- - name: rainbow
54
- version: '3.0'
42
+ - name: json
43
+ version: '0'
55
44
  source:
56
- type: git
57
- name: ruby/gem_rbs_collection
58
- revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
59
- remote: https://github.com/ruby/gem_rbs_collection.git
60
- repo_dir: gems
45
+ type: stdlib
61
46
  - name: logger
62
47
  version: '0'
63
48
  source:
64
49
  type: stdlib
65
- - name: set
50
+ - name: minitest
66
51
  version: '0'
67
52
  source:
68
53
  type: stdlib
69
- - name: pathname
54
+ - name: monitor
70
55
  version: '0'
71
56
  source:
72
57
  type: stdlib
73
- - name: json
58
+ - name: mutex_m
74
59
  version: '0'
75
60
  source:
76
61
  type: stdlib
@@ -78,19 +63,27 @@ gems:
78
63
  version: '0'
79
64
  source:
80
65
  type: stdlib
81
- - name: rubygems
66
+ - name: pathname
82
67
  version: '0'
83
68
  source:
84
69
  type: stdlib
85
- - name: tsort
86
- version: '0'
70
+ - name: protobuf
71
+ version: 3.10.3
87
72
  source:
88
- type: stdlib
89
- - name: monitor
73
+ type: git
74
+ name: ruby/gem_rbs_collection
75
+ revision: 8a678b2ec20e9d594055f53745399814e3a887dc
76
+ remote: https://github.com/ruby/gem_rbs_collection.git
77
+ repo_dir: gems
78
+ - name: rbs
79
+ version: 3.1.3
80
+ source:
81
+ type: rubygems
82
+ - name: rdoc
90
83
  version: '0'
91
84
  source:
92
85
  type: stdlib
93
- - name: date
86
+ - name: securerandom
94
87
  version: '0'
95
88
  source:
96
89
  type: stdlib
@@ -98,11 +91,12 @@ gems:
98
91
  version: '0'
99
92
  source:
100
93
  type: stdlib
101
- - name: mutex_m
94
+ - name: time
102
95
  version: '0'
103
96
  source:
104
97
  type: stdlib
105
- - name: time
98
+ - name: tsort
106
99
  version: '0'
107
100
  source:
108
101
  type: stdlib
102
+ gemfile_lock_path: Gemfile.lock
data/rbs_collection.yaml CHANGED
@@ -8,12 +8,4 @@ sources:
8
8
  # A directory to install the downloaded RBSs
9
9
  path: .gem_rbs_collection
10
10
 
11
- gems:
12
- # Skip loading rbs gem's RBS.
13
- # It's unnecessary if you don't use rbs as a library.
14
- - name: rbs
15
- - name: activesupport
16
- - name: protobuf
17
- ignore: true
18
- - name: rbs_protobuf
19
- ignore: true
11
+ gems: []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -49,7 +49,6 @@ files:
49
49
  - ".github/workflows/test.yml"
50
50
  - ".gitignore"
51
51
  - ".gitmodules"
52
- - ".protoc-version"
53
52
  - ".rakeTasks"
54
53
  - ".travis.yml"
55
54
  - CHANGELOG.md
@@ -69,6 +68,7 @@ files:
69
68
  - example/a.proto
70
69
  - example/b.proto
71
70
  - example/c.proto
71
+ - example/d.proto
72
72
  - example/protobuf_gem_example.rb
73
73
  - exe/protoc-gen-rbs
74
74
  - lib/rbs_protobuf.rb
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.3.7
111
+ rubygems_version: 3.4.10
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Generate RBS files from .proto files
data/.protoc-version DELETED
@@ -1 +0,0 @@
1
- 3.9.0-square-1.0