Skip to content

Support cross-language rename between Swift and clang languages #1038

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 5 commits into from
Feb 2, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 26, 2024

This adds support for name translation between Swift anc clang languages to allow renaming across those language boundaries.

Rename is always initiated at the symbol’s definition, so when renaming an Objective-C symbol from Swift, the user is prompeted to enter the new Objective-C method name.

rdar://118996461

@ahoppen ahoppen requested a review from bnbarham January 26, 2024 02:46
@ahoppen ahoppen requested a review from benlangmuir as a code owner January 26, 2024 02:46
@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2024

swiftlang/indexstore-db#177

@swift-ci Please test

@ahoppen ahoppen force-pushed the ahoppen/clang-global-rename branch from 530443b to 7a39019 Compare January 26, 2024 22:45
@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2024

@swift-ci Please test Windows

Comment on lines +299 to +314
case malformedSwiftToClangTranslateNameResponse(SKDResponseDictionary)
case malformedClangToSwiftTranslateNameResponse(SKDResponseDictionary)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the response useful other than for the description? If not, maybe just pass in the description directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just thought that we pass in the SKDResponseDictionary because that gives us more type safety about what the associated type is than when it’s String. But I don’t have strong opinions either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer String, only so that we don't keep the SKDResponseDictionary around. But 🤷 doesn't really matter either way.

Copy link
Member Author

Choose a reason for hiding this comment

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

It won’t stay around for long anyway, let’s just keep it.

/// All properties refer to the definition symbol. For example, an Objective-C method named `performAction:with:` that
/// is imported to Swift as `perform(action:with:)` will always have its definition in an Objective-C source file and
/// the definition name will always be `performAction:with:`, even if rename is invoked from Swift.
public actor TranslatableName {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do wonder if this is worth it, or if we should just do a quick iteration over the index results and pick a location for the swiftName case up front. Lazy is nice and all, but I'm not sure it matters that much here? Seems like it would avoid a lot of complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the lazy name translation in TranslatableName to an up-front translation in 0336bf4. What do you think?

@ahoppen
Copy link
Member Author

ahoppen commented Jan 31, 2024

swiftlang/indexstore-db#177

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jan 31, 2024

swiftlang/indexstore-db#177

@swift-ci Please test Windows

We didn’t have any test coverage for Objective-C packages. Let’s add some.
This adds support for name translation between Swift anc clang languages to allow renaming across those language boundaries.

Rename is always initiated at the symbol’s definition, so when renaming an Objective-C symbol from Swift, the user is prompeted to enter the new Objective-C method name.

rdar://118996461
@ahoppen ahoppen force-pushed the ahoppen/clang-global-rename branch 2 times, most recently from 6a539ff to 7748f37 Compare January 31, 2024 18:52
@ahoppen
Copy link
Member Author

ahoppen commented Jan 31, 2024

swiftlang/indexstore-db#177

@swift-ci Please test

@ahoppen ahoppen force-pushed the ahoppen/clang-global-rename branch from 7748f37 to b9ccf57 Compare January 31, 2024 23:51
@ahoppen
Copy link
Member Author

ahoppen commented Jan 31, 2024

swiftlang/indexstore-db#177

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Feb 1, 2024

swiftlang/indexstore-db#177

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Feb 1, 2024

swiftlang/indexstore-db#177

@swift-ci Please test Windows

@ahoppen ahoppen merged commit d784537 into swiftlang:main Feb 2, 2024
@ahoppen ahoppen deleted the ahoppen/clang-global-rename branch February 2, 2024 21:52
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