diff --git a/lib/ruby_lsp/addon.rb b/lib/ruby_lsp/addon.rb index c346d6ea6..0fffbfe1c 100644 --- a/lib/ruby_lsp/addon.rb +++ b/lib/ruby_lsp/addon.rb @@ -273,5 +273,12 @@ def create_discover_tests_listener(response_builder, dispatcher, uri); end def resolve_test_commands(items) [] end + + # Allows add-ons to add additional file rename operations during a rename request. This is invoked after the + # standard file rename logic and allows add-ons to handle cases where file naming conventions differ from the + # default (e.g., Rails migration files with timestamp prefixes) + # @overridable + #: (String fully_qualified_name, String new_name, Array[(Interface::RenameFile | Interface::TextDocumentEdit)] document_changes) -> void + def collect_file_renames(fully_qualified_name, new_name, document_changes); end end end diff --git a/lib/ruby_lsp/requests/rename.rb b/lib/ruby_lsp/requests/rename.rb index a8e827641..1eb534bc0 100644 --- a/lib/ruby_lsp/requests/rename.rb +++ b/lib/ruby_lsp/requests/rename.rb @@ -84,6 +84,11 @@ def perform end collect_file_renames(fully_qualified_name, document_changes) + + Addon.addons.each do |addon| + addon.collect_file_renames(fully_qualified_name, @new_name, document_changes) + end + Interface::WorkspaceEdit.new(document_changes: document_changes) end