diff --git a/lib/rbi/model.rb b/lib/rbi/model.rb index 91672606..f6849858 100644 --- a/lib/rbi/model.rb +++ b/lib/rbi/model.rb @@ -42,16 +42,6 @@ def replace(node) self.parent_tree = nil end - sig { params(nodes: T::Enumerable[Node]).void } - def replace_with_multiple(nodes) - tree = parent_tree - raise unless tree - - # Does this work? - nodes.each { |node| tree << node } - detach - end - sig { returns(T.nilable(Scope)) } def parent_scope parent = T.let(parent_tree, T.nilable(Tree)) diff --git a/lib/rbi/rewriters/replace_attributes_with_methods.rb b/lib/rbi/rewriters/replace_attributes_with_methods.rb index b875346e..eff270cb 100644 --- a/lib/rbi/rewriters/replace_attributes_with_methods.rb +++ b/lib/rbi/rewriters/replace_attributes_with_methods.rb @@ -23,7 +23,7 @@ def visit(node) new_methods = convert_to_methods(attr) - child.replace_with_multiple(new_methods) + replace(child, with: new_methods) end end end @@ -131,6 +131,14 @@ def create_setter_method(name, sig, attribute_type, visibility, loc, comments) # comments: comments, ) end + + def replace(node, with:) + tree = node.parent_tree + raise unless tree + + with.each { |node| tree << node } + node.detach + end end end