Skip to content

Support cross-file rename for clang languages #1031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 23, 2024

This uses the indexed rename request I added to clangd to perform global rename in clang’s language using SourceKit-LSP’s index: SourceKit-LSP’s index is used to find the locations to rename and the indexed rename request to clangd is used to translate the rename locations to edits.

rdar://118996369

@ahoppen ahoppen requested a review from bnbarham January 23, 2024 03:48
@ahoppen ahoppen requested a review from benlangmuir as a code owner January 23, 2024 03:48
@ahoppen
Copy link
Member Author

ahoppen commented Jan 23, 2024

@swift-ci Please test

/// Rename all occurrences of a symbol named `oldName` to `newName` at the
/// given `positions`.
///
/// The use case of this method is the positions to rename are already known
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The use case of this method is the positions to rename are already known
/// The use case of this method is for when the positions to rename are already known

Looks like a copy paste of the clangd comment, so you could update it from there (assuming you fixed that).

""",
]
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a cross-language test? Or multiple even, eg. swift <-> objc, swift <-> c, and swift <-> c++?

Copy link
Member Author

@ahoppen ahoppen Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, no. This PR is about adding global rename for clang languages, not doing cross-language rename yet. For that we need name translation, which I’ll add in a follow-up PR (and which is currently blocked by rdar://120066209).

rdar://118996461 is tracking the addition of cross-language rename.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC only ObjC is blocked by that right 😅? But cool, didn't realize we didn't have name translation yet, thanks 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but ObjC is really the interesting candidate for name translation. And it’s easiest to design it with all name translations in mind. There will be a follow-up PR soon-ish.

This uses the indexed rename request I added to clangd to perform global rename in clang’s language using SourceKit-LSP’s index: SourceKit-LSP’s index is used to find the locations to rename and the indexed rename request to clangd is used to translate the rename locations to edits.

rdar://118996369
@ahoppen ahoppen force-pushed the ahoppen/clang-rename branch from efc7914 to bfb9040 Compare January 24, 2024 05:56
@ahoppen
Copy link
Member Author

ahoppen commented Jan 24, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge January 24, 2024 05:56
@ahoppen
Copy link
Member Author

ahoppen commented Jan 24, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 441a369 into swiftlang:main Jan 24, 2024
@ahoppen ahoppen deleted the ahoppen/clang-rename branch January 24, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants