Skip to content

Commit deae3bc

Browse files
committed
Add collect_file_renames addon hook for rename requests
1 parent 8d0757d commit deae3bc

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/ruby_lsp/addon.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,5 +273,12 @@ def create_discover_tests_listener(response_builder, dispatcher, uri); end
273273
def resolve_test_commands(items)
274274
[]
275275
end
276+
277+
# Allows add-ons to add additional file rename operations during a rename request. This is invoked after the
278+
# standard file rename logic and allows add-ons to handle cases where file naming conventions differ from the
279+
# default (e.g., Rails migration files with timestamp prefixes)
280+
# @overridable
281+
#: (String fully_qualified_name, String new_name, Array[(Interface::RenameFile | Interface::TextDocumentEdit)] document_changes) -> void
282+
def collect_file_renames(fully_qualified_name, new_name, document_changes); end
276283
end
277284
end

lib/ruby_lsp/requests/rename.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ def perform
8484
end
8585

8686
collect_file_renames(fully_qualified_name, document_changes)
87+
88+
Addon.addons.each do |addon|
89+
addon.collect_file_renames(fully_qualified_name, @new_name, document_changes)
90+
end
91+
8792
Interface::WorkspaceEdit.new(document_changes: document_changes)
8893
end
8994

0 commit comments

Comments
 (0)