rbi 0.0.8 → 0.0.9

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: 37be6daaf86810c60a865b98ac94ff089184e990e168bc405a0d167c641477ed
4
- data.tar.gz: 95de3a3ffb035c40d9dd8da3055d808b1b0ae365add26bbc0754ae997c1c09c9
3
+ metadata.gz: e263b24187c9a9f490f5c29a249d22d2ee564a2a59aaea3f79eb62cbff8ac24f
4
+ data.tar.gz: c5bd9aed9462d42b8dddef6b6c8bfe001224747b49ee1ad187721daf9ac946d3
5
5
  SHA512:
6
- metadata.gz: 3b794985ed143c257080ed69ab6ac8458e0cfcad5e988bfe412566dd2146ea009a8ceabfb274759089e3a687eb42e15b27c31a884c04e78a6b413b424d97d0b1
7
- data.tar.gz: bc41f792fd147ceb04dee6852e046a68e5f90f886ce4b2937ceaa642ef4d9d46996f1560067177acfedc52b73b60878aeb03cd64deda17be516d04516e37ed63
6
+ metadata.gz: 1174676242d2ed3cfdebc28bc6eb70789d249cf10c4e5d8fceab47c58024b8db4a3f4bad9609c7543e510e6d85b6f321fc0ee65ce8d4204fee417bafb1e44510
7
+ data.tar.gz: 29f7a0b48aa474e3f970bba94e85fc6621ed9449f99c7249c2056a79ae5418b0c9b0e5e6ee97b37c5244e83c1514851a59a998a932e3c4ef36ef308b61036662
@@ -83,12 +83,12 @@ module RBI
83
83
  when RBI::Scope
84
84
  visit_all(node.nodes)
85
85
  previous = previous_definition_for(node)
86
- delete_node(node, previous) if previous && node.empty?
86
+ delete_node(node, previous) if previous && can_delete_node?(node, previous)
87
87
  when RBI::Tree
88
88
  visit_all(node.nodes)
89
89
  when RBI::Indexable
90
90
  previous = previous_definition_for(node)
91
- delete_node(node, previous) if previous
91
+ delete_node(node, previous) if previous && can_delete_node?(node, previous)
92
92
  end
93
93
  end
94
94
 
@@ -103,6 +103,24 @@ module RBI
103
103
  nil
104
104
  end
105
105
 
106
+ sig { params(node: Node, previous: Node).returns(T::Boolean) }
107
+ def can_delete_node?(node, previous)
108
+ return false unless node.class == previous.class
109
+
110
+ case node
111
+ when Scope
112
+ node.empty?
113
+ when Attr
114
+ previous = T.cast(previous, Attr)
115
+ node.names == previous.names && node.sigs == previous.sigs
116
+ when Method
117
+ previous = T.cast(previous, Method)
118
+ node.params == previous.params && node.sigs == previous.sigs
119
+ else
120
+ true
121
+ end
122
+ end
123
+
106
124
  sig { params(node: RBI::Node, previous: RBI::Node).void }
107
125
  def delete_node(node, previous)
108
126
  node.detach
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.8"
5
+ VERSION = "0.0.9"
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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2021-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast