@@ -207,22 +207,25 @@ class RenameRangeCollector : public IndexDataConsumer {
207207 bool finishDependency (bool isClangModule) override { return true ; }
208208
209209 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?" );
226229 }
227230 return IndexDataConsumer::Continue;
228231 }
@@ -241,37 +244,19 @@ RenameRangeCollector::indexSymbolToRenameLoc(const index::IndexSymbol &symbol) {
241244 return llvm::None;
242245 }
243246
244- NameUsage usage = NameUsage ::Unknown;
247+ RenameLocUsage usage = RenameLocUsage ::Unknown;
245248 if (symbol.roles & (unsigned )index::SymbolRole::Call) {
246- usage = NameUsage ::Call;
249+ usage = RenameLocUsage ::Call;
247250 } else if (symbol.roles & (unsigned )index::SymbolRole::Definition) {
248- usage = NameUsage ::Definition;
251+ usage = RenameLocUsage ::Definition;
249252 } else if (symbol.roles & (unsigned )index::SymbolRole::Reference) {
250- usage = NameUsage ::Reference;
253+ usage = RenameLocUsage ::Reference;
251254 } else {
252255 llvm_unreachable (" unexpected role" );
253256 }
254257
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- }
273258 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};
275260}
276261
277262// / Get the decl context that we need to walk when renaming \p VD.
0 commit comments