rbi 0.1.13 → 0.1.14
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/formatter.rb +0 -12
- data/lib/rbi/index.rb +1 -1
- data/lib/rbi/model.rb +4 -2
- data/lib/rbi/parser.rb +3 -3
- data/lib/rbi/printer.rb +512 -610
- data/lib/rbi/rewriters/attr_to_methods.rb +169 -0
- data/lib/rbi/rewriters/group_nodes.rb +46 -47
- data/lib/rbi/rewriters/merge_trees.rb +9 -31
- data/lib/rbi/version.rb +1 -1
- data/lib/rbi/visitor.rb +228 -2
- data/lib/rbi.rb +8 -0
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3705c571d4b2685e60fec1c0dc54435caed79ba988239006be0bf14757790c51
|
4
|
+
data.tar.gz: 4560dc122385781dd604cdc4ca57835caa22e3f29b2cafa5b7e2e468032c5923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f70d57182bed826c64ca53ed2d62a1da0aeb0dee1badbe774ed00c8bd505b8e40f00363c4ca069efef457649cff19ce6b2be595e6dca453e56456eb4580ca38
|
7
|
+
data.tar.gz: 5c60fedeeb8995f9e6ed4ef926f68870ed88021de20e60294e1aec97029c728f24d098a8d297ec967dbfc23c31788dbb30d82b8f925f1c95962df7772580c294
|
data/Gemfile
CHANGED
@@ -10,7 +10,7 @@ group(:development, :test) do
|
|
10
10
|
gem("minitest")
|
11
11
|
gem("minitest-reporters")
|
12
12
|
gem("rake", "~> 13.2")
|
13
|
-
gem("rubocop", "~> 1.
|
13
|
+
gem("rubocop", "~> 1.65", require: false)
|
14
14
|
gem("rubocop-shopify", require: false)
|
15
15
|
gem("rubocop-sorbet", require: false)
|
16
16
|
gem("sorbet", ">= 0.5.9204", require: false)
|
data/lib/rbi/formatter.rb
CHANGED
@@ -8,18 +8,6 @@ module RBI
|
|
8
8
|
sig { params(sort_nodes: T::Boolean).returns(T::Boolean) }
|
9
9
|
attr_writer :sort_nodes
|
10
10
|
|
11
|
-
sig { params(nest_singleton_methods: T::Boolean).returns(T::Boolean) }
|
12
|
-
attr_writer :nest_singleton_methods
|
13
|
-
|
14
|
-
sig { params(add_sig_templates: T::Boolean).returns(T::Boolean) }
|
15
|
-
attr_writer :add_sig_templates
|
16
|
-
|
17
|
-
sig { params(group_nodes: T::Boolean).returns(T::Boolean) }
|
18
|
-
attr_writer :group_nodes
|
19
|
-
|
20
|
-
sig { params(nest_non_public_methods: T::Boolean).returns(T::Boolean) }
|
21
|
-
attr_writer :nest_non_public_methods
|
22
|
-
|
23
11
|
sig { returns(T.nilable(Integer)) }
|
24
12
|
attr_accessor :max_line_length
|
25
13
|
|
data/lib/rbi/index.rb
CHANGED
data/lib/rbi/model.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module RBI
|
5
|
+
class ReplaceNodeError < Error; end
|
6
|
+
|
5
7
|
class Node
|
6
8
|
extend T::Sig
|
7
9
|
extend T::Helpers
|
@@ -32,10 +34,10 @@ module RBI
|
|
32
34
|
sig { params(node: Node).void }
|
33
35
|
def replace(node)
|
34
36
|
tree = parent_tree
|
35
|
-
raise unless tree
|
37
|
+
raise ReplaceNodeError, "Can't replace #{self} without a parent tree" unless tree
|
36
38
|
|
37
39
|
index = tree.nodes.index(self)
|
38
|
-
raise unless index
|
40
|
+
raise ReplaceNodeError, "Can't find #{self} in #{tree} child nodes" unless index
|
39
41
|
|
40
42
|
tree.nodes[index] = node
|
41
43
|
node.parent_tree = tree
|
data/lib/rbi/parser.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
require "prism"
|
5
5
|
|
6
6
|
module RBI
|
7
|
-
class ParseError <
|
7
|
+
class ParseError < Error
|
8
8
|
extend T::Sig
|
9
9
|
|
10
10
|
sig { returns(Loc) }
|
@@ -17,7 +17,7 @@ module RBI
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
class UnexpectedParserError <
|
20
|
+
class UnexpectedParserError < Error
|
21
21
|
extend T::Sig
|
22
22
|
|
23
23
|
sig { returns(Loc) }
|
@@ -719,7 +719,7 @@ module RBI
|
|
719
719
|
comments = node_comments(send)
|
720
720
|
default_value = T.let(nil, T.nilable(String))
|
721
721
|
|
722
|
-
rest
|
722
|
+
rest.each do |arg|
|
723
723
|
next unless arg.is_a?(Prism::KeywordHashNode)
|
724
724
|
|
725
725
|
arg.elements.each do |assoc|
|