@@ -207,22 +207,25 @@ class RenameRangeCollector : public IndexDataConsumer {
207
207
bool finishDependency (bool isClangModule) override { return true ; }
208
208
209
209
Action startSourceEntity (const IndexSymbol &symbol) override {
210
- if (symbol.USR == usr) {
211
- if (auto loc = indexSymbolToRenameLoc (symbol)) {
212
- // Inside capture lists like `{ [test] in }`, 'test' refers to both the
213
- // newly declared, captured variable and the referenced variable it is
214
- // initialized from. Make sure to only rename it once.
215
- auto existingLoc = llvm::find_if (locations, [&](RenameLoc searchLoc) {
216
- return searchLoc.Line == loc->Line && searchLoc.Column == loc->Column ;
217
- });
218
- if (existingLoc == locations.end ()) {
219
- locations.push_back (std::move (*loc));
220
- } else {
221
- assert (existingLoc->OldName == loc->OldName &&
222
- existingLoc->IsFunctionLike == loc->IsFunctionLike &&
223
- " Asked to do a different rename for the same location?" );
224
- }
225
- }
210
+ if (symbol.USR != usr) {
211
+ return IndexDataConsumer::Continue;
212
+ }
213
+ auto loc = indexSymbolToRenameLoc (symbol);
214
+ if (!loc) {
215
+ return IndexDataConsumer::Continue;
216
+ }
217
+
218
+ // Inside capture lists like `{ [test] in }`, 'test' refers to both the
219
+ // newly declared, captured variable and the referenced variable it is
220
+ // initialized from. Make sure to only rename it once.
221
+ auto existingLoc = llvm::find_if (locations, [&](RenameLoc searchLoc) {
222
+ return searchLoc.Line == loc->Line && searchLoc.Column == loc->Column ;
223
+ });
224
+ if (existingLoc == locations.end ()) {
225
+ locations.push_back (std::move (*loc));
226
+ } else {
227
+ assert (existingLoc->OldName == loc->OldName &&
228
+ " Asked to do a different rename for the same location?" );
226
229
}
227
230
return IndexDataConsumer::Continue;
228
231
}
@@ -241,37 +244,19 @@ RenameRangeCollector::indexSymbolToRenameLoc(const index::IndexSymbol &symbol) {
241
244
return llvm::None;
242
245
}
243
246
244
- NameUsage usage = NameUsage ::Unknown;
247
+ RenameLocUsage usage = RenameLocUsage ::Unknown;
245
248
if (symbol.roles & (unsigned )index::SymbolRole::Call) {
246
- usage = NameUsage ::Call;
249
+ usage = RenameLocUsage ::Call;
247
250
} else if (symbol.roles & (unsigned )index::SymbolRole::Definition) {
248
- usage = NameUsage ::Definition;
251
+ usage = RenameLocUsage ::Definition;
249
252
} else if (symbol.roles & (unsigned )index::SymbolRole::Reference) {
250
- usage = NameUsage ::Reference;
253
+ usage = RenameLocUsage ::Reference;
251
254
} else {
252
255
llvm_unreachable (" unexpected role" );
253
256
}
254
257
255
- bool isFunctionLike = false ;
256
-
257
- switch (symbol.symInfo .Kind ) {
258
- case index::SymbolKind::EnumConstant:
259
- case index::SymbolKind::Function:
260
- case index::SymbolKind::Constructor:
261
- case index::SymbolKind::ConversionFunction:
262
- case index::SymbolKind::InstanceMethod:
263
- case index::SymbolKind::ClassMethod:
264
- case index::SymbolKind::StaticMethod:
265
- isFunctionLike = true ;
266
- break ;
267
- case index::SymbolKind::Class:
268
- case index::SymbolKind::Enum:
269
- case index::SymbolKind::Struct:
270
- default :
271
- break ;
272
- }
273
258
StringRef oldName = stringStorage->copyString (symbol.name );
274
- return RenameLoc{symbol.line , symbol.column , usage, oldName, isFunctionLike };
259
+ return RenameLoc{symbol.line , symbol.column , usage, oldName};
275
260
}
276
261
277
262
// / Get the decl context that we need to walk when renaming \p VD.
0 commit comments