Repository navigation
Fix require_relative paths when renaming classes - #4227
Open
efegokdemir wants to merge 2 commits into
Open
efegokdemir wants to merge 2 commits into
efegokdemir wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #4226. Renaming a class can also rename its matching Ruby file, but static
require_relativecalls that point to that file currently keep the old path.Implementation
Collect the old and new file paths before building the workspace edit. When the client supports file renames, inspect Ruby documents for static, bare
require_relativecalls and update only arguments that resolve to a renamed file. Preserve whether the original path included the.rbsuffix, and return text edits before file rename operations.Automated Tests
Added a regression test covering the updated path, renamed constant reference, and an unrelated string literal.
bundle exec bin/test test/requests/rename_test.rb— 4 runs, 8 assertions, passed.bundle exec srb tc— passed.bundle exec rake test— 3,557 runs, 12 failures, 18 errors, 6 skips. Reported failures were in server, integration, and setup-bundler tests, outside the changed request code; I have not verified these against a pristine checkout.Manual Tests
Not run. The regression is covered by the automated rename request test.