Skip to content

Commit f39c433

Browse files
authored
Merge pull request #73524 from ahoppen/6.0/related-idents-of-invalid-decls-with-same-base-name
2 parents 5b17a5e + 43f5fd5 commit f39c433

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

include/swift/Index/Index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace index {
2525
void indexDeclContext(DeclContext *DC, IndexDataConsumer &consumer);
2626
void indexSourceFile(SourceFile *SF, IndexDataConsumer &consumer);
2727
void indexModule(ModuleDecl *module, IndexDataConsumer &consumer);
28+
bool printDisplayName(const swift::ValueDecl *D, llvm::raw_ostream &OS);
2829

2930
} // end namespace index
3031
} // end namespace swift

lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ printArtificialName(const swift::AbstractStorageDecl *ASD, AccessorKind AK, llvm
7373
llvm_unreachable("Unhandled AccessorKind in switch.");
7474
}
7575

76-
static bool printDisplayName(const swift::ValueDecl *D, llvm::raw_ostream &OS) {
76+
bool index::printDisplayName(const swift::ValueDecl *D, llvm::raw_ostream &OS) {
7777
if (!D->hasName() && !isa<ParamDecl>(D)) {
7878
auto *FD = dyn_cast<AccessorDecl>(D);
7979
if (!FD)

lib/Refactoring/LocalRename.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,13 @@ swift::ide::getRenameInfo(ResolvedCursorInfoPtr cursorInfo) {
194194
}
195195

196196
class RenameRangeCollector : public IndexDataConsumer {
197-
StringRef usr;
197+
const ValueDecl *declToRename;
198198
std::unique_ptr<StringScratchSpace> stringStorage;
199199
std::vector<RenameLoc> locations;
200200

201201
public:
202-
RenameRangeCollector(StringRef usr)
203-
: usr(usr), stringStorage(new StringScratchSpace()) {}
204-
205-
RenameRangeCollector(const ValueDecl *D)
206-
: stringStorage(new StringScratchSpace()) {
207-
SmallString<64> SS;
208-
llvm::raw_svector_ostream OS(SS);
209-
printValueDeclUSR(D, OS);
210-
usr = stringStorage->copyString(SS.str());
211-
}
202+
RenameRangeCollector(const ValueDecl *declToRename)
203+
: declToRename(declToRename), stringStorage(new StringScratchSpace()) {}
212204

213205
RenameRangeCollector(RenameRangeCollector &&collector) = default;
214206

@@ -228,7 +220,7 @@ class RenameRangeCollector : public IndexDataConsumer {
228220
bool finishDependency(bool isClangModule) override { return true; }
229221

230222
Action startSourceEntity(const IndexSymbol &symbol) override {
231-
if (symbol.USR != usr) {
223+
if (symbol.decl != declToRename) {
232224
return IndexDataConsumer::Continue;
233225
}
234226
auto loc = indexSymbolToRenameLoc(symbol);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
struct Foo {
2+
func bar(body: Invalid) {}
3+
4+
// RUN: %sourcekitd-test -req=related-idents -pos=%(line + 1):8 %s -- %s
5+
func bar(ignoreCase: Bool, body: Invalid) {}
6+
}

0 commit comments

Comments
 (0)