rbs-inline 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -7
  3. data/Rakefile +12 -0
  4. data/lib/rbs/inline/annotation_parser/tokenizer.rb +361 -0
  5. data/lib/rbs/inline/annotation_parser.rb +548 -326
  6. data/lib/rbs/inline/ast/annotations.rb +446 -136
  7. data/lib/rbs/inline/ast/comment_lines.rb +32 -18
  8. data/lib/rbs/inline/ast/declarations.rb +67 -28
  9. data/lib/rbs/inline/ast/members.rb +137 -140
  10. data/lib/rbs/inline/ast/tree.rb +104 -5
  11. data/lib/rbs/inline/cli.rb +12 -12
  12. data/lib/rbs/inline/node_utils.rb +4 -0
  13. data/lib/rbs/inline/parser.rb +140 -59
  14. data/lib/rbs/inline/version.rb +1 -1
  15. data/lib/rbs/inline/writer.rb +243 -94
  16. data/lib/rbs/inline.rb +4 -0
  17. data/rbs_collection.lock.yaml +3 -7
  18. data/rbs_collection.yaml +2 -0
  19. data/sig/generated/rbs/inline/annotation_parser/tokenizer.rbs +221 -0
  20. data/sig/generated/rbs/inline/annotation_parser.rbs +148 -92
  21. data/sig/generated/rbs/inline/ast/annotations.rbs +142 -36
  22. data/sig/generated/rbs/inline/ast/comment_lines.rbs +35 -0
  23. data/sig/generated/rbs/inline/ast/declarations.rbs +29 -10
  24. data/sig/generated/rbs/inline/ast/members.rbs +33 -24
  25. data/sig/generated/rbs/inline/ast/tree.rbs +132 -0
  26. data/sig/generated/rbs/inline/cli.rbs +3 -3
  27. data/sig/generated/rbs/inline/node_utils.rbs +11 -0
  28. data/sig/generated/rbs/inline/parser.rbs +38 -18
  29. data/sig/generated/rbs/inline/version.rbs +7 -0
  30. data/sig/generated/rbs/inline/writer.rbs +104 -0
  31. data/sig/generated/rbs/inline.rbs +7 -0
  32. metadata +14 -14
  33. data/sig/rbs/inline/annotation_parser.rbs +0 -0
  34. data/sig/rbs/inline/ast/comment_lines.rbs +0 -27
  35. data/sig/rbs/inline/ast/tree.rbs +0 -98
  36. data/sig/rbs/inline/node_utils.rbs +0 -7
  37. data/sig/rbs/inline/writer.rbs +0 -27
  38. data/sig/rbs/inline.rbs +0 -41
  39. data/yard-samples/hello.rb +0 -6
  40. data/yard-samples/sample1.rb +0 -26
@@ -4,13 +4,116 @@ module RBS
4
4
  module Inline
5
5
  module AST
6
6
  module Annotations
7
+ # @rbs!
8
+ # type t = VarType
9
+ # | ReturnType
10
+ # | Use
11
+ # | Inherits
12
+ # | Generic
13
+ # | ModuleSelf
14
+ # | Skip
15
+ # | MethodTypeAssertion | TypeAssertion | SyntaxErrorAssertion | Dot3Assertion
16
+ # | Application
17
+ # | RBSAnnotation
18
+ # | Override
19
+ # | IvarType
20
+ # | Embedded
21
+ # | Method
22
+ # | SplatParamType
23
+ # | DoubleSplatParamType
24
+ # | BlockType
25
+ # | ModuleDecl
26
+ # | ClassDecl
27
+ # # | Def
28
+ # # | AttrReader | AttrWriter | AttrAccessor
29
+ # # | Include | Extend | Prepend
30
+ # # | Alias
31
+
32
+ module Utils
33
+ # @rbs (Tree) -> RBS::AST::TypeParam?
34
+ def translate_type_param(tree)
35
+ unchecked = tree.nth_token?(0) != nil
36
+ inout =
37
+ case tree.nth_token?(1)&.[](0)
38
+ when nil
39
+ :invariant
40
+ when :kIN
41
+ :contravariant
42
+ when :kOUT
43
+ :covariant
44
+ end #: RBS::AST::TypeParam::variance
45
+
46
+ name = tree.nth_token?(2)&.last
47
+
48
+ if bound = tree.nth_tree?(3)
49
+ if type = bound.nth_type?(1)
50
+ case type
51
+ when Types::ClassSingleton, Types::ClassInstance, Types::Interface
52
+ upper_bound = type
53
+ end
54
+ end
55
+ end
56
+
57
+ if name
58
+ RBS::AST::TypeParam.new(
59
+ name: name.to_sym,
60
+ variance: inout,
61
+ upper_bound: upper_bound,
62
+ location: nil
63
+ ).unchecked!(unchecked)
64
+ end
65
+ end
66
+
67
+ # @rbs (Types::t) -> RBS::AST::Declarations::Class::Super?
68
+ def translate_super_class(type)
69
+ case type
70
+ when Types::ClassInstance
71
+ RBS::AST::Declarations::Class::Super.new(
72
+ name: type.name,
73
+ args: type.args,
74
+ location: nil
75
+ )
76
+ end
77
+ end
78
+
79
+ # Assumes the tree is generated through `#parse_module_name`
80
+ #
81
+ # Returns a type name, or `nil` if the tree is something invalid.
82
+ #
83
+ # @param tree -- A tree object that is generated through `#parse_module_name`
84
+ #
85
+ # @rbs (AST::Tree) -> TypeName?
86
+ def translate_type_name(tree)
87
+ tokens = tree.non_trivia_trees
88
+
89
+ absolute = tokens.shift
90
+ path = [] #: Array[Symbol]
91
+
92
+ tokens.each_slice(2) do |name, colon2|
93
+ if colon2
94
+ name or return nil
95
+ name.is_a?(Array) or return nil
96
+
97
+ path << name[1].to_sym
98
+ end
99
+ end
100
+
101
+ last_token = tokens.pop
102
+ last_token.is_a?(Array) or return nil
103
+ name = last_token[1].to_sym
104
+
105
+ namespace = Namespace.new(path: path, absolute: absolute ? true : false)
106
+ TypeName.new(namespace: namespace, name: name)
107
+ end
108
+ end
109
+
7
110
  class Base
8
- attr_reader :source #:: CommentLines
9
- attr_reader :tree #:: Tree
111
+ attr_reader :source #: CommentLines
112
+ attr_reader :tree #: Tree
10
113
 
11
114
  # @rbs tree: Tree
12
115
  # @rbs source: CommentLines
13
- # @rbs returns void
116
+ # @rbs return: void
14
117
  def initialize(tree, source)
15
118
  @tree = tree
16
119
  @source = source
@@ -18,11 +121,11 @@ module RBS
18
121
  end
19
122
 
20
123
  class VarType < Base
21
- attr_reader :name #:: Symbol
124
+ attr_reader :name #: Symbol
22
125
 
23
- attr_reader :type #:: Types::t?
126
+ attr_reader :type #: Types::t?
24
127
 
25
- attr_reader :comment #:: String?
128
+ attr_reader :comment #: String?
26
129
 
27
130
  # @rbs override
28
131
  def initialize(tree, source)
@@ -44,7 +147,7 @@ module RBS
44
147
  end
45
148
  end
46
149
 
47
- #:: () -> bool
150
+ #: () -> bool
48
151
  def complete?
49
152
  if name && type
50
153
  true
@@ -54,11 +157,100 @@ module RBS
54
157
  end
55
158
  end
56
159
 
57
- # `@rbs returns T`
160
+ class SpecialVarTypeAnnotation < Base
161
+ attr_reader :name #: Symbol?
162
+
163
+ attr_reader :type #: Types::t?
164
+
165
+ attr_reader :comment #: String?
166
+
167
+ attr_reader :type_source #: String
168
+
169
+ # @rbs override
170
+ def initialize(tree, source)
171
+ @tree = tree
172
+ @source = source
173
+
174
+ annotation = tree.nth_tree!(1)
175
+
176
+ if name = annotation.nth_token?(1)
177
+ @name = name[1].to_sym
178
+ end
179
+
180
+ if type = annotation.nth_type?(3)
181
+ @type = type
182
+ @type_source = type.location&.source || raise
183
+ else
184
+ @type = nil
185
+ @type_source = annotation.nth_tree!(3)&.to_s || raise
186
+ end
187
+
188
+ if comment = annotation.nth_tree(4)
189
+ @comment = comment.to_s
190
+ end
191
+ end
192
+ end
193
+
194
+ # `@rbs *x: T`
195
+ class SplatParamType < SpecialVarTypeAnnotation
196
+ end
197
+
198
+ # `@rbs` **x: T
199
+ class DoubleSplatParamType < SpecialVarTypeAnnotation
200
+ end
201
+
202
+ # `@rbs &block: METHOD-TYPE` or `@rbs &block: ? METHOD-TYPE`
203
+ class BlockType < Base
204
+ attr_reader :name #: Symbol?
205
+
206
+ attr_reader :type #: Types::Block?
207
+
208
+ attr_reader :comment #: String?
209
+
210
+ attr_reader :type_source #: String
211
+
212
+ # @rbs override
213
+ def initialize(tree, source)
214
+ @tree = tree
215
+ @source = source
216
+
217
+ annotation = tree.nth_tree!(1)
218
+
219
+ if name = annotation.nth_token?(1)
220
+ @name = name[1].to_sym
221
+ end
222
+
223
+ optional = annotation.nth_token?(3)
224
+
225
+ if type_token = annotation.nth_token?(4)
226
+ block_src = type_token[1]
227
+
228
+ proc_type = ::RBS::Parser.parse_type("^" + block_src, require_eof: true) rescue RBS::ParsingError
229
+ if proc_type.is_a?(Types::Proc)
230
+ @type = Types::Block.new(
231
+ type: proc_type.type,
232
+ required: !optional,
233
+ self_type: proc_type.self_type
234
+ )
235
+ end
236
+
237
+ @type_source = block_src
238
+ else
239
+ @type = nil
240
+ @type_source = ""
241
+ end
242
+
243
+ if comment = annotation.nth_tree(5)
244
+ @comment = comment.to_s
245
+ end
246
+ end
247
+ end
248
+
249
+ # `@rbs return: T`
58
250
  class ReturnType < Base
59
- attr_reader :type #:: Types::t?
251
+ attr_reader :type #: Types::t?
60
252
 
61
- attr_reader :comment #:: String?
253
+ attr_reader :comment #: String?
62
254
 
63
255
  # @rbs override
64
256
  def initialize(tree, source)
@@ -67,16 +259,16 @@ module RBS
67
259
 
68
260
  return_type_decl = tree.nth_tree!(1)
69
261
 
70
- if type = return_type_decl.nth_type?(1)
262
+ if type = return_type_decl.nth_type?(2)
71
263
  @type = type
72
264
  end
73
265
 
74
- if comment = return_type_decl.nth_tree(2)
266
+ if comment = return_type_decl.nth_tree(3)
75
267
  @comment = comment.to_s
76
268
  end
77
269
  end
78
270
 
79
- # @rbs returns bool
271
+ # @rbs return: bool
80
272
  def complete?
81
273
  if type
82
274
  true
@@ -89,13 +281,13 @@ module RBS
89
281
  # `@rbs @foo: T` or `@rbs self.@foo: T`
90
282
  #
91
283
  class IvarType < Base
92
- attr_reader :name #:: Symbol
284
+ attr_reader :name #: Symbol
93
285
 
94
- attr_reader :type #:: Types::t?
286
+ attr_reader :type #: Types::t?
95
287
 
96
- attr_reader :class_instance #:: bool
288
+ attr_reader :class_instance #: bool
97
289
 
98
- attr_reader :comment #:: String?
290
+ attr_reader :comment #: String?
99
291
 
100
292
  # @rbs override
101
293
  def initialize(tree, source)
@@ -113,54 +305,62 @@ module RBS
113
305
  end
114
306
  end
115
307
 
116
- # `#:: TYPE`
117
- #
118
- class Assertion < Base
119
- attr_reader :type #:: Types::t | MethodType | nil
308
+ class MethodTypeAssertion < Base
309
+ attr_reader :method_type #: MethodType
120
310
 
311
+ # @rbs override
121
312
  def initialize(tree, source)
122
313
  @source = source
123
314
  @tree = tree
124
315
 
125
- @type = tree.nth_method_type?(1) || tree.nth_type?(1)
316
+ @method_type = tree.nth_method_type!(1)
126
317
  end
127
318
 
128
- # @rbs returns bool
129
- def complete?
130
- if type
131
- true
132
- else
133
- false
134
- end
319
+ def type_source #: String
320
+ method_type.location&.source || raise
135
321
  end
322
+ end
136
323
 
137
- # Returns a type if it's type
138
- #
139
- def type? #:: Types::t?
140
- case type
141
- when MethodType, nil
142
- nil
143
- else
144
- type
145
- end
324
+ class TypeAssertion < Base
325
+ attr_reader :type #: Types::t
326
+
327
+ # @rbs override
328
+ def initialize(tree, source)
329
+ @source = source
330
+ @tree = tree
331
+
332
+ @type = tree.nth_type!(1)
146
333
  end
147
334
 
148
- # Returns a method type if it's a method type
149
- #
150
- def method_type? #:: MethodType?
151
- case type
152
- when MethodType
153
- type
154
- else
155
- nil
156
- end
335
+ def type_source #: String
336
+ type.location&.source || raise
337
+ end
338
+ end
339
+
340
+ class SyntaxErrorAssertion < Base
341
+ attr_reader :error_string #: String
342
+
343
+ # @rbs override
344
+ def initialize(tree, source)
345
+ @tree = tree
346
+ @source = source
347
+
348
+ @error_string = tree.nth_tree(1).to_s
349
+ end
350
+ end
351
+
352
+ class Dot3Assertion < Base
353
+ # @rbs override
354
+ def initialize(tree, source)
355
+ @tree = tree
356
+ @source = source
157
357
  end
158
358
  end
159
359
 
160
360
  # `#[TYPE, ..., TYPE]`
161
361
  #
162
362
  class Application < Base
163
- attr_reader :types #:: Array[Types::t]?
363
+ attr_reader :types #: Array[Types::t]?
164
364
 
165
365
  # @rbs override
166
366
  def initialize(tree, source)
@@ -183,63 +383,15 @@ module RBS
183
383
  end
184
384
  end
185
385
 
186
- # @rbs returns bool
386
+ # @rbs return: bool
187
387
  def complete?
188
388
  types ? true : false
189
389
  end
190
390
  end
191
391
 
192
- # `# @rbs yields () -> void -- Comment`
193
- #
194
- class Yields < Base
195
- # The type of block
196
- #
197
- # * Types::Block when syntactically correct input is given
198
- # * String when syntax error is reported
199
- # * `nil` when nothing is given
200
- #
201
- attr_reader :block_type #:: Types::Block | String | nil
202
-
203
- # The content of the comment or `nil`
204
- #
205
- attr_reader :comment #:: String?
206
-
207
- # If `[optional]` token is inserted just after `yields` token
208
- #
209
- # The Types::Block instance has correct `required` attribute based on the `[optional]` token.
210
- # This is for the other cases, syntax error or omitted.
211
- #
212
- attr_reader :optional #:: bool
213
-
214
- # @rbs override
215
- def initialize(tree, comments)
216
- @tree = tree
217
- @source = comments
218
-
219
- yields_tree = tree.nth_tree!(1)
220
- @optional = yields_tree.nth_token?(1).is_a?(Array)
221
- if block_token = yields_tree.nth_token(2)
222
- block_src = block_token[1]
223
- proc_src = "^" + block_src
224
- proc_type = ::RBS::Parser.parse_type(proc_src, require_eof: true) rescue RBS::ParsingError
225
- if proc_type.is_a?(Types::Proc)
226
- @block_type = Types::Block.new(
227
- type: proc_type.type,
228
- required: !optional,
229
- self_type: proc_type.self_type
230
- )
231
- else
232
- @block_type = block_src
233
- end
234
- end
235
-
236
- @comment = yields_tree.nth_tree?(3)&.to_s
237
- end
238
- end
239
-
240
392
  # `# @rbs %a{a} %a{a} ...`
241
393
  class RBSAnnotation < Base
242
- attr_reader :contents #:: Array[String]
394
+ attr_reader :contents #: Array[String]
243
395
 
244
396
  # @rbs override
245
397
  def initialize(tree, comments)
@@ -267,8 +419,8 @@ module RBS
267
419
  # `# @rbs inherits T`
268
420
  #
269
421
  class Inherits < Base
270
- attr_reader :super_name #:: TypeName?
271
- attr_reader :args #:: Array[Types::t]?
422
+ attr_reader :super_name #: TypeName?
423
+ attr_reader :args #: Array[Types::t]?
272
424
 
273
425
  # @rbs override
274
426
  def initialize(tree, source)
@@ -299,7 +451,7 @@ module RBS
299
451
 
300
452
  # `# @rbs use [USES]`
301
453
  class Use < Base
302
- attr_reader :clauses #:: Array[RBS::AST::Directives::Use::clause]
454
+ attr_reader :clauses #: Array[RBS::AST::Directives::Use::clause]
303
455
 
304
456
  # @rbs override
305
457
  def initialize(tree, source)
@@ -351,9 +503,9 @@ module RBS
351
503
 
352
504
  # `# @rbs module-self [MODULE_SELF]`
353
505
  class ModuleSelf < Base
354
- attr_reader :constraint #:: RBS::AST::Declarations::Module::Self?
506
+ attr_reader :constraint #: RBS::AST::Declarations::Module::Self?
355
507
 
356
- attr_reader :comment #:: String?
508
+ attr_reader :comment #: String?
357
509
 
358
510
  # @rbs override
359
511
  def initialize(tree, source)
@@ -389,9 +541,11 @@ module RBS
389
541
  class Generic < Base
390
542
  # TypeParam object or `nil` if syntax error
391
543
  #
392
- attr_reader :type_param #:: RBS::AST::TypeParam?
544
+ attr_reader :type_param #: RBS::AST::TypeParam?
545
+
546
+ attr_reader :comment #: String?
393
547
 
394
- attr_reader :comment #:: String?
548
+ include Utils
395
549
 
396
550
  # @rbs override
397
551
  def initialize(tree, source)
@@ -399,38 +553,10 @@ module RBS
399
553
  @source = source
400
554
 
401
555
  generic_tree = tree.nth_tree!(1)
402
- unchecked = generic_tree.nth_token?(1) != nil
403
- inout =
404
- case generic_tree.nth_token?(2)&.[](0)
405
- when nil
406
- :invariant
407
- when :kIN
408
- :contravariant
409
- when :kOUT
410
- :covariant
411
- end #: RBS::AST::TypeParam::variance
412
-
413
- name = generic_tree.nth_token?(3)&.last
414
556
 
415
- if bound = generic_tree.nth_tree?(4)
416
- if type = bound.nth_type?(1)
417
- case type
418
- when Types::ClassSingleton, Types::ClassInstance, Types::Interface
419
- upper_bound = type
420
- end
421
- end
422
- end
557
+ @type_param = translate_type_param(generic_tree.nth_tree!(1))
423
558
 
424
- if name
425
- @type_param = RBS::AST::TypeParam.new(
426
- name: name.to_sym,
427
- variance: inout,
428
- upper_bound: upper_bound,
429
- location: nil
430
- ).unchecked!(unchecked)
431
- end
432
-
433
- if comment = generic_tree.nth_tree?(5)
559
+ if comment = generic_tree.nth_tree?(2)
434
560
  @comment = comment.to_s
435
561
  end
436
562
  end
@@ -438,7 +564,7 @@ module RBS
438
564
 
439
565
  # `# @rbs!` annotation
440
566
  class Embedded < Base
441
- attr_reader :content #:: String
567
+ attr_reader :content #: String
442
568
 
443
569
  # @rbs override
444
570
  def initialize(tree, source)
@@ -448,6 +574,190 @@ module RBS
448
574
  @content = tree.nth_token!(1)[1]
449
575
  end
450
576
  end
577
+
578
+ # `@rbs METHOD-TYPE``
579
+ #
580
+ class Method < Base
581
+ # @rbs! type method_type = [MethodType, method_type?] | String
582
+
583
+ attr_reader :method_types #: method_type?
584
+
585
+ # `true` if the method definition is overloading something
586
+ #
587
+ attr_reader :overloading #: bool
588
+
589
+ attr_reader :type #: MethodType?
590
+
591
+ attr_reader :method_type_source #: String
592
+
593
+ # @rbs override
594
+ def initialize(tree, source)
595
+ @tree = tree
596
+ @source = source
597
+
598
+ overloads = tree.nth_tree!(1)
599
+ @method_types = construct_method_types(overloads.non_trivia_trees.dup)
600
+ @overloading = overloads.token?(:kDOT3, at: -1)
601
+ end
602
+
603
+ #: (Array[tree]) -> method_type?
604
+ def construct_method_types(children)
605
+ first = children.shift
606
+
607
+ case first
608
+ when MethodType
609
+ children.shift
610
+ [
611
+ first,
612
+ construct_method_types(children)
613
+ ]
614
+ when Array
615
+ # `...`
616
+ nil
617
+ when AST::Tree
618
+ # Syntax error
619
+ first.to_s
620
+ end
621
+ end
622
+
623
+ # @rbs () { (MethodType) -> void } -> void
624
+ # | () -> Enumerator[MethodType, void]
625
+ def each_method_type
626
+ if block_given?
627
+ type = self.method_types
628
+
629
+ while true
630
+ if type.is_a?(Array)
631
+ yield type[0]
632
+ type = type[1]
633
+ else
634
+ break
635
+ end
636
+ end
637
+ else
638
+ enum_for :each_method_type
639
+ end
640
+ end
641
+
642
+ # Returns the parsing error overload string
643
+ #
644
+ # Returns `nil` if no parsing error found.
645
+ #
646
+ def error_source #: String?
647
+ type = self.method_types
648
+
649
+ while true
650
+ if type.is_a?(Array)
651
+ type = type[1]
652
+ else
653
+ break
654
+ end
655
+ end
656
+
657
+ if type.is_a?(String)
658
+ type
659
+ end
660
+ end
661
+ end
662
+
663
+ # `@rbs module Foo`
664
+ class ModuleDecl < Base
665
+ attr_reader :name #: TypeName?
666
+
667
+ attr_reader :type_params #: Array[RBS::AST::TypeParam]
668
+
669
+ attr_reader :self_types #: Array[RBS::AST::Declarations::Module::Self]
670
+
671
+ include Utils
672
+
673
+ # @rbs override
674
+ def initialize(tree, comments)
675
+ @tree = tree
676
+ @source = comments
677
+
678
+ decl_tree = tree.nth_tree!(1)
679
+
680
+ if type_name = translate_type_name(decl_tree.nth_tree!(1))
681
+ if type_name.class?
682
+ @name = type_name
683
+ end
684
+ end
685
+
686
+ @type_params = []
687
+ if type_params = decl_tree.nth_tree(2)
688
+ params = type_params.non_trivia_trees
689
+ params.shift
690
+ params.pop
691
+ params.each_slice(2) do |param, _comma|
692
+ raise unless param.is_a?(Tree)
693
+ if type_param = translate_type_param(param)
694
+ @type_params << type_param
695
+ end
696
+ end
697
+ end
698
+
699
+ @self_types = []
700
+ if selfs_tree = decl_tree.nth_tree(3)
701
+ self_trees = selfs_tree.non_trivia_trees
702
+ self_trees.shift
703
+
704
+ self_trees.each_slice(2) do |type, _comma|
705
+ case type
706
+ when Types::ClassInstance, Types::Interface
707
+ @self_types << RBS::AST::Declarations::Module::Self.new(
708
+ name: type.name,
709
+ args: type.args,
710
+ location: type.location
711
+ )
712
+ end
713
+ end
714
+ end
715
+ end
716
+ end
717
+
718
+ # `@rbs class Foo`
719
+ class ClassDecl < Base
720
+ attr_reader :name #: TypeName?
721
+
722
+ attr_reader :type_params #: Array[RBS::AST::TypeParam]
723
+
724
+ attr_reader :super_class #: RBS::AST::Declarations::Class::Super?
725
+
726
+ include Utils
727
+
728
+ # @rbs override
729
+ def initialize(tree, comments)
730
+ @tree = tree
731
+ @source = comments
732
+
733
+ decl_tree = tree.nth_tree!(1)
734
+
735
+ if type_name = translate_type_name(decl_tree.nth_tree!(1))
736
+ if type_name.class?
737
+ @name = type_name
738
+ end
739
+ end
740
+
741
+ @type_params = []
742
+ if type_params = decl_tree.nth_tree(2)
743
+ params = type_params.non_trivia_trees
744
+ params.shift
745
+ params.pop
746
+ params.each_slice(2) do |param, _comma|
747
+ raise unless param.is_a?(Tree)
748
+ if type_param = translate_type_param(param)
749
+ @type_params << type_param
750
+ end
751
+ end
752
+ end
753
+
754
+ if super_tree = decl_tree.nth_tree(3)
755
+ if type = super_tree.nth_type?(1)
756
+ @super_class = translate_super_class(type)
757
+ end
758
+ end
759
+ end
760
+ end
451
761
  end
452
762
  end
453
763
  end