Skip to content

[SourceKit] Merge local refactoring implementations #64298

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
Mar 14, 2023

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Mar 11, 2023

Retrieving local rename ranges and the local rename refactoring both had almost identical methods, except for the addition of retrieving the outermost shadowed decl that was added a couple months back. Merge them.

Resolves rdar://106529370.
Resolves #64264

@bnbarham
Copy link
Contributor Author

@swift-ci please test

Comment on lines +9097 to +9101
Optional<RenameRangeCollector> RangeCollector =
localRenames(SF, StartLoc, StringRef(), Diags);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

findLocalRenameRanges and the rename refactoring itself were both doing this. Back when I added shorthand shadow handling, I updated one and not the other (didn't see this one).

The two refactorings here are just merging those + changing collectRenameAvailabilityInfo to just give back the availability info since it was always just a single value, never both.

_ = toRename
}
// RUN: %refactor -rename -dump-text -source-filename %s -pos=%(line+2):29 -new-name=renamed | %FileCheck %s --check-prefix=OPTIONAL
// OPTIONAL: shorthand_shadow.swift [[# @LINE+1]]:29 -> [[# @LINE+1]]:32
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be worth keeping a version of this test that is inside a closure. At least in solver-based land they still behave differently than top-level code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved that to the sourcekitd-test. This one now just checks we handle shorthand shadow correctly from refactor as well.

Copy link
Contributor Author

@bnbarham bnbarham Mar 11, 2023

Choose a reason for hiding this comment

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

...oh I forgot to add that file :). Fixed.

@bnbarham bnbarham force-pushed the fix-shorthand-rename branch from 178293c to c903c88 Compare March 11, 2023 01:00
@bnbarham
Copy link
Contributor Author

@swift-ci please test

Retrieving local rename ranges and the local rename refactoring both had
almost identical methods, except for the addition of retrieving the
outermost shadowed decl that was added a couple months back. Merge them.

Resolves rdar://106529370.
@bnbarham bnbarham force-pushed the fix-shorthand-rename branch from c903c88 to d2de8ed Compare March 13, 2023 22:36
@bnbarham
Copy link
Contributor Author

@swift-ci please test

@bnbarham bnbarham merged commit 277674a into swiftlang:main Mar 14, 2023
@bnbarham bnbarham deleted the fix-shorthand-rename branch March 14, 2023 17:36
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.

Local rename fails if refactoring if let file when file is not declared
3 participants