rbi 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/rbi/parser.rb +19 -10
  4. data/lib/rbi/version.rb +1 -1
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 570f1035fa8bb56861eabd49590fbf2374f428c053f0fc189e27958feedf0c4b
4
- data.tar.gz: 0dbb944e45b675851de18089c22a23c4c527f03dfca281426db8fb3cff94372e
3
+ metadata.gz: a98dd77d2fde6771b24b8ab87d585b94b944beea38a2d60a2ba38f7738deb67b
4
+ data.tar.gz: 56eb299a37b8755b57ebd72ffc4dcf6179a739e4146f6903c3d63450a586307b
5
5
  SHA512:
6
- metadata.gz: 45e5f53144cc46f1cd2c86b55c1d490ab5bd4b2d3bf5e593b3f6405e6b4583645c13130cdc6762f0e5eb18f5f74bfa1dfe990d108f6db21da394ba4d30a7b810
7
- data.tar.gz: 603617b73fc3e4e862f897bf0b10b165efd4ac608c07b71e3ef43e1190e4d1fff2f26484a65d8f4d9e5965eafa99435d02bf668fef756abe5a24f1fa3e41f52b
6
+ metadata.gz: 7e2a8e48b3210f41a3b38bf2844d895a0d232c8296b7122ecb64705ec9b77d56dd88ca0e1dd3b2fa15755ce90e63ee3ef17ccbc1174b3034b4d825bb4444c357
7
+ data.tar.gz: df19f77e6e4dd24e9309b03d4a1cd3008386bc3a48fe6998782008459fac78f9f97c52f603db2f65b1c68d42c3fe49f1145a7d40fcc845473c667ec4287127af
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))
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.15"
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.15
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-06-28 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