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 +4 -4
- data/Gemfile +1 -1
- data/lib/rbi/parser.rb +19 -10
- data/lib/rbi/rewriters/sort_nodes.rb +3 -1
- data/lib/rbi/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bda85d642d83b25177d24ab2bc789631861302ebc31c862ea40bcd56b034ec68
|
4
|
+
data.tar.gz: 23071846fc0c1edaa681ab3cbb4c2663fc27a00666ef890fcdb404546128307d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7678a81e3e9e66a858c72c5093ebc0fdc0bec4d0e4d08ac662341959f1e82dfa5ef5898a5c166442c718907faef2ad826e979dd7dd98a48c5496969209ffdc8
|
7
|
+
data.tar.gz: c4616ce80159a71fea63a23ce90d6eaf7527fabda7200224ea213aedf0926610a974d1a428c569d0f2bfe0b3efa84fd73b7476bd29312189dd3df2e3ef321c56
|
data/Gemfile
CHANGED
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
|
-
|
212
|
-
if
|
213
|
-
@last_sigs <<
|
214
|
-
|
215
|
-
|
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,
|
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
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.
|
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-
|
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.
|
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.
|
117
|
+
rubygems_version: 3.3.3
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: RBI generation framework
|