[5.3][IDE][SourceKit] Support escaped identifiers for the syntactic rename and related idents requests. #31598
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.
Cherry-pick of #31431
Explanation:
Sourcekitd's SyntacticRename and RelatedIdents requests would previously not account for the extra two backtick characters in escaped identifiers, e.g. giving a range covering
[`fo]o`
rather than[`foo`]
.This updates their ranges to include the backticks, and for syntactic rename, to account for them when comparing base names and argument labels with expected values. It also updates Swift -> ObjC name translation (used for cross-language rename) to account for them too.
Scope of issue: The rename refactoring would fail if any occurrence of the symbol being renamed was escaped. The RelatedIdents request returning the incorrect ranges caused editor features based on it (like Xcode's edit-all-in-scope) to behave incorrectly.
Origination: This has been an issue since the SyntacticRename and RelatedIdents requests were fist introduced.
Risk: Low. This only affects the rename refactoring, and RelatedIdents requests. It has no impact on the compiler.
Testing: Added regression tests covering escaped identifiers and all existing tests passed. Also checked Xcode behaves correctly with these changes when renaming in cross-language projects.
Reviewer: Ben Langmuir (@benlangmuir) on the master branch PR.
Resolves rdar://problem/46409010