Skip to content

Commit

Permalink
[TODO: squash] Move replace_with_multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Jun 10, 2024
1 parent d321f86 commit 7cfe690
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 0 additions & 10 deletions lib/rbi/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 9 additions & 1 deletion lib/rbi/rewriters/replace_attributes_with_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7cfe690

Please sign in to comment.