[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 5 02:39:00 PST 2024
================
@@ -53,13 +55,38 @@ struct RenameInputs {
struct RenameResult {
// The range of the symbol that the user can attempt to rename.
Range Target;
+ // Placeholder text for the rename operation, if set.
+ std::optional<std::string> Placeholder;
// Rename occurrences for the current main file.
std::vector<Range> LocalChanges;
// Complete edits for the rename, including LocalChanges.
// If the full set of changes is unknown, this field is empty.
FileEdits GlobalChanges;
};
+/// Represents a symbol range where the symbol can potentially have multiple
+/// tokens.
+struct SymbolRange {
+ /// All ranges. If multiple, corresponds to an ObjC selector.
+ std::vector<Range> Ranges;
+
+ /// Returns the first range.
+ Range range() const { return Ranges.front(); }
+
+ SymbolRange(Range R) : Ranges({R}) {}
+ SymbolRange(std::vector<Range> Ranges) : Ranges(std::move(Ranges)) {}
+
+ friend bool operator==(const SymbolRange &LHS, const SymbolRange &RHS) {
+ return LHS.Ranges == RHS.Ranges;
+ }
+ friend bool operator!=(const SymbolRange &LHS, const SymbolRange &RHS) {
+ return !(LHS == RHS);
+ }
+ friend bool operator<(const SymbolRange &LHS, const SymbolRange &RHS) {
+ return LHS.range() < RHS.range();
+ }
+};
----------------
kadircet wrote:
can you move function definitions to implementation file?
https://github.com/llvm/llvm-project/pull/76466
More information about the cfe-commits
mailing list