rbi 0.0.14 → 0.0.16

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: 570f1035fa8bb56861eabd49590fbf2374f428c053f0fc189e27958feedf0c4b
4
- data.tar.gz: 0dbb944e45b675851de18089c22a23c4c527f03dfca281426db8fb3cff94372e
3
+ metadata.gz: bda85d642d83b25177d24ab2bc789631861302ebc31c862ea40bcd56b034ec68
4
+ data.tar.gz: 23071846fc0c1edaa681ab3cbb4c2663fc27a00666ef890fcdb404546128307d
5
5
  SHA512:
6
- metadata.gz: 45e5f53144cc46f1cd2c86b55c1d490ab5bd4b2d3bf5e593b3f6405e6b4583645c13130cdc6762f0e5eb18f5f74bfa1dfe990d108f6db21da394ba4d30a7b810
7
- data.tar.gz: 603617b73fc3e4e862f897bf0b10b165efd4ac608c07b71e3ef43e1190e4d1fff2f26484a65d8f4d9e5965eafa99435d02bf668fef756abe5a24f1fa3e41f52b
6
+ metadata.gz: f7678a81e3e9e66a858c72c5093ebc0fdc0bec4d0e4d08ac662341959f1e82dfa5ef5898a5c166442c718907faef2ad826e979dd7dd98a48c5496969209ffdc8
7
+ data.tar.gz: c4616ce80159a71fea63a23ce90d6eaf7527fabda7200224ea213aedf0926610a974d1a428c569d0f2bfe0b3efa84fd73b7476bd29312189dd3df2e3ef321c56
data/Gemfile CHANGED
@@ -14,5 +14,5 @@ group(:development, :test) do
14
14
  gem("rubocop-shopify", require: false)
15
15
  gem("rubocop-sorbet", require: false)
16
16
  gem("sorbet", ">= 0.5.9204", require: false)
17
- gem("tapioca", "0.5.2", require: false)
17
+ gem("tapioca", require: false)
18
18
  end
data/lib/rbi/parser.rb CHANGED
@@ -178,6 +178,7 @@ module RBI
178
178
  @scopes_stack = T.let([@tree], T::Array[Tree])
179
179
  @last_node = T.let(nil, T.nilable(::AST::Node))
180
180
  @last_sigs = T.let([], T::Array[RBI::Sig])
181
+ @last_sigs_comments = T.let([], T::Array[Comment])
181
182
 
182
183
  separate_header_comments
183
184
  end
@@ -208,11 +209,12 @@ module RBI
208
209
  node = parse_send(node)
209
210
  current_scope << node if node
210
211
  when :block
211
- node = parse_block(node)
212
- if node.is_a?(Sig)
213
- @last_sigs << node
214
- elsif node
215
- current_scope << node
212
+ rbi_node = parse_block(node)
213
+ if rbi_node.is_a?(Sig)
214
+ @last_sigs << rbi_node
215
+ @last_sigs_comments.concat(node_comments(node))
216
+ elsif rbi_node
217
+ current_scope << rbi_node
216
218
  end
217
219
  else
218
220
  visit_all(node.children)
@@ -268,7 +270,7 @@ module RBI
268
270
  params: node.children[1].children.map { |child| parse_param(child) },
269
271
  sigs: current_sigs,
270
272
  loc: loc,
271
- comments: node_comments(node)
273
+ comments: current_sigs_comments + node_comments(node)
272
274
  )
273
275
  when :defs
274
276
  Method.new(
@@ -277,7 +279,7 @@ module RBI
277
279
  is_singleton: true,
278
280
  sigs: current_sigs,
279
281
  loc: loc,
280
- comments: node_comments(node)
282
+ comments: current_sigs_comments + node_comments(node)
281
283
  )
282
284
  else
283
285
  raise ParseError.new("Unsupported def node type `#{node.type}`", loc)
@@ -324,13 +326,13 @@ module RBI
324
326
  case method_name
325
327
  when :attr_reader
326
328
  symbols = node.children[2..-1].map { |child| child.children[0] }
327
- AttrReader.new(*symbols, sigs: current_sigs, loc: loc, comments: comments)
329
+ AttrReader.new(*symbols, sigs: current_sigs, loc: loc, comments: current_sigs_comments + comments)
328
330
  when :attr_writer
329
331
  symbols = node.children[2..-1].map { |child| child.children[0] }
330
- AttrWriter.new(*symbols, sigs: current_sigs, loc: loc, comments: comments)
332
+ AttrWriter.new(*symbols, sigs: current_sigs, loc: loc, comments: current_sigs_comments + comments)
331
333
  when :attr_accessor
332
334
  symbols = node.children[2..-1].map { |child| child.children[0] }
333
- AttrAccessor.new(*symbols, sigs: current_sigs, loc: loc, comments: comments)
335
+ AttrAccessor.new(*symbols, sigs: current_sigs, loc: loc, comments: current_sigs_comments + comments)
334
336
  when :include
335
337
  names = node.children[2..-1].map { |child| parse_expr(child) }
336
338
  Include.new(*names, loc: loc, comments: comments)
@@ -533,6 +535,13 @@ module RBI
533
535
  sigs
534
536
  end
535
537
 
538
+ sig { returns(T::Array[Comment]) }
539
+ def current_sigs_comments
540
+ comments = @last_sigs_comments.dup
541
+ @last_sigs_comments.clear
542
+ comments
543
+ end
544
+
536
545
  sig { void }
537
546
  def assoc_dangling_comments
538
547
  last_line = T.let(nil, T.nilable(Integer))
@@ -81,10 +81,12 @@ module RBI
81
81
  sig { params(node: Node).returns(T.nilable(String)) }
82
82
  def node_name(node)
83
83
  case node
84
- when Module, Class, Struct, Const, Method, Helper, TStructField, RequiresAncestor
84
+ when Module, Class, Struct, Const, Method, Helper, RequiresAncestor
85
85
  node.name
86
86
  when Attr
87
87
  node.names.first.to_s
88
+ when TStructField, Mixin
89
+ nil # we never want to sort these nodes by their name
88
90
  end
89
91
  end
90
92
 
data/lib/rbi/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module RBI
5
- VERSION = "0.0.14"
5
+ VERSION = "0.0.16"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -107,14 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 2.4.0
110
+ version: 2.7.0
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.2.20
117
+ rubygems_version: 3.3.3
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: RBI generation framework