-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Update related identifiers request to serve local rename #70287
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
[SourceKit] Update related identifiers request to serve local rename #70287
Conversation
@swift-ci Please smoke test |
This will allow us to get syntactic rename ranges from the locations returned by related identifiers.
0f45f21
to
9a8e9b7
Compare
RenameLocs Locs = localRenameLocs(SrcFile, Info->VD); | ||
|
||
std::string OldName = Locs.getLocations().front().OldName.str(); | ||
for (auto loc : Locs.getLocations()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably optimized out, but I'd surround in #ifndef NDEBUG
if you want this. This would be the main case for a separate request I suppose, since ideally we wouldn't need OldName
on every single returned location.
9a8e9b7
to
bdd51c3
Compare
@swift-ci Please smoke test |
for (size_t index = 0; index < ResolvedLocs.size(); ++index) { | ||
auto RenameLoc = Locs.getLocations()[index]; | ||
auto ResolvedLoc = ResolvedLocs[index]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM has a zip
in STLExtras.h
. Could use llvm::zip_equal
which assumes they're the same size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sweet.
…d by the related identifiers request While we don't want to return non-editable base names for Edit-All-In-Scope, we do want to return them if the related identifiers response is used as the input for find-syntactic-rename-ranges.
This allows us to at least rename the base of operators. The labels don’t matter too much since they only occur on the function definition.
bdd51c3
to
516836c
Compare
@swift-ci Please smoke test |
for (auto [RenameLoc, ResolvedLoc] : | ||
llvm::zip_equal(Locs.getLocations(), ResolvedLocs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about structured bindings, neat!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only found them by searching for zip_equal
in the LLVM repo as well
@swift-ci Please smoke test macOS |
Some of the tests now depend on features provided by Swift Syntax, and will fail to pass if building without Swift Syntax support. This commits marks all the tests I know fail to pass when Swift Syntax is disabled. - swiftlang#70281 modified `ASTGen/verify-parse.swift` - swiftlang#70287 created `refactoring/SyntacticRename/operator.swift` and `SourceKit/RelatedIdents/operator.swift` - swiftlang#70389 modified `SourceKit/Refactoring/basic.swift` and indirectly modified all `refactoring/ExtractFunction/*` tests.
Some of the tests now depend on features provided by Swift Syntax, and will fail to pass if building without Swift Syntax support. This commits marks all the tests I know fail to pass when Swift Syntax is disabled. - swiftlang#70281 modified `ASTGen/verify-parse.swift` - swiftlang#70287 created `refactoring/SyntacticRename/operator.swift` and `SourceKit/RelatedIdents/operator.swift` - swiftlang#70389 modified `SourceKit/Refactoring/basic.swift` and indirectly modified all `refactoring/ExtractFunction/*` tests.
Some of the tests now depend on features provided by Swift Syntax, and will fail to pass if building without Swift Syntax support. This commits marks all the tests I know fail to pass when Swift Syntax is disabled. - #70281 modified `ASTGen/verify-parse.swift` - #70287 created `refactoring/SyntacticRename/operator.swift` and `SourceKit/RelatedIdents/operator.swift` - #70389 modified `SourceKit/Refactoring/basic.swift` and indirectly modified all `refactoring/ExtractFunction/*` tests.
Some of the tests now depend on features provided by Swift Syntax, and will fail to pass if building without Swift Syntax support. This commits marks all the tests I know fail to pass when Swift Syntax is disabled. - swiftlang#70281 modified `ASTGen/verify-parse.swift` - swiftlang#70287 created `refactoring/SyntacticRename/operator.swift` and `SourceKit/RelatedIdents/operator.swift` - swiftlang#70389 modified `SourceKit/Refactoring/basic.swift` and indirectly modified all `refactoring/ExtractFunction/*` tests.
Some of the tests now depend on features provided by Swift Syntax, and will fail to pass if building without Swift Syntax support. This commits marks all the tests I know fail to pass when Swift Syntax is disabled. - swiftlang#70281 modified `ASTGen/verify-parse.swift` - swiftlang#70287 created `refactoring/SyntacticRename/operator.swift` and `SourceKit/RelatedIdents/operator.swift` - swiftlang#70389 modified `SourceKit/Refactoring/basic.swift` and indirectly modified all `refactoring/ExtractFunction/*` tests.
This augments the related identifiers request to return more information that’s needed for local rename.
In particular this is:
foo(a:)
). This is needed so we can pass it tofind-syntactic-rename-ranges
, which will verify that the name at any given location matches this old nameinit
. While we don't want to return non-editable base names for Edit-All-In-Scope, we do want to return them if the related identifiers response is used as the input forfind-syntactic-rename-ranges
to rename initializer argument labels.rdar://118994821