[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)
Alex Hoppen via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 12 16:12:28 PST 2024
https://github.com/ahoppen commented:
The outstanding comments from last review are:
- Use `SymbolName` instead of `StringRef`
- https://github.com/llvm/llvm-project/pull/76466#discussion_r1476409221
- https://github.com/llvm/llvm-project/pull/76466#discussion_r1476427027
- Don’t re-lex the source file in `collectRenameIdentifierRanges`
- https://github.com/llvm/llvm-project/pull/76466#discussion_r1476471971
- Use index or AST data to find edits in the current file. AFAICT we do use index-data for the multi-file rename case in `adjustRenameRanges` but I AFAICT no semantic information is used for the current file.
- https://github.com/llvm/llvm-project/pull/76466/files#r1479029824
- I think a good test case to add would be
```cpp
// Input
R"cpp(
@interface Foo
- (void)performA^ction:(int)action with:(int)value;
@end
@implementation Foo
- (void)performAction:(int)action with:(int)value {
[self performAction:action with:value];
}
@end
@interface Bar
- (void)performAction:(int)action with:(int)value;
@end
@implementation Bar
- (void)performAction:(int)action with:(int)value {
}
@end
)cpp",
// New name
"performNewAction:by:",
// Expected
R"cpp(
@interface Foo
- (void)performNewAction:(int)action by:(int)value;
@end
@implementation Foo
- (void)performNewAction:(int)action by:(int)value {
[self performNewAction:action by:value];
}
@end
@interface Bar
- (void)performAction:(int)action with:(int)value;
@end
@implementation Bar
- (void)performAction:(int)action with:(int)value {
}
)cpp",
```
https://github.com/llvm/llvm-project/pull/76466
More information about the cfe-commits
mailing list