@@ -2493,27 +2493,30 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
2493
2493
StringRef PrimaryFilePath, StringRef InputBufferName, unsigned Offset,
2494
2494
bool CancelOnSubsequentRequest, ArrayRef<const char *> Args,
2495
2495
SourceKitCancellationToken CancellationToken,
2496
- std::function<void (const RequestResult<RelatedIdentsInfo> &)> Receiver) {
2496
+ std::function<void (const RequestResult<ArrayRef<RelatedIdentInfo>> &)>
2497
+ Receiver) {
2497
2498
2498
2499
std::string Error;
2499
2500
SwiftInvocationRef Invok =
2500
2501
ASTMgr->getTypecheckInvocation (Args, PrimaryFilePath, Error);
2501
2502
if (!Invok) {
2502
2503
LOG_WARN_FUNC (" failed to create an ASTInvocation: " << Error);
2503
- Receiver (RequestResult<RelatedIdentsInfo >::fromError (Error));
2504
+ Receiver (RequestResult<ArrayRef<RelatedIdentInfo> >::fromError (Error));
2504
2505
return ;
2505
2506
}
2506
2507
2507
2508
class RelatedIdConsumer : public SwiftASTConsumer {
2508
2509
std::string InputFile;
2509
2510
unsigned Offset;
2510
- std::function<void (const RequestResult<RelatedIdentsInfo> &)> Receiver;
2511
+ std::function<void (const RequestResult<ArrayRef<RelatedIdentInfo>> &)>
2512
+ Receiver;
2511
2513
SwiftInvocationRef Invok;
2512
2514
2513
2515
public:
2514
2516
RelatedIdConsumer (
2515
2517
StringRef InputFile, unsigned Offset,
2516
- std::function<void (const RequestResult<RelatedIdentsInfo> &)> Receiver,
2518
+ std::function<void (const RequestResult<ArrayRef<RelatedIdentInfo>> &)>
2519
+ Receiver,
2517
2520
SwiftInvocationRef Invok)
2518
2521
: InputFile(InputFile.str()), Offset(Offset),
2519
2522
Receiver (std::move(Receiver)), Invok(Invok) {}
@@ -2528,12 +2531,12 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
2528
2531
2529
2532
auto *SrcFile = retrieveInputFile (InputFile, CompInst);
2530
2533
if (!SrcFile) {
2531
- Receiver (RequestResult<RelatedIdentsInfo >::fromError (
2534
+ Receiver (RequestResult<ArrayRef<RelatedIdentInfo> >::fromError (
2532
2535
" Unable to find input file" ));
2533
2536
return ;
2534
2537
}
2535
2538
2536
- SmallVector<std::pair< unsigned , unsigned > , 8 > Ranges;
2539
+ SmallVector<RelatedIdentInfo , 8 > Ranges;
2537
2540
2538
2541
auto Action = [&]() {
2539
2542
unsigned BufferID = SrcFile->getBufferID ().value ();
@@ -2583,29 +2586,28 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
2583
2586
std::vector<ResolvedLoc> ResolvedLocs = resolveRenameLocations (
2584
2587
Locs.getLocations (), /* NewName=*/ StringRef (), *SrcFile, Diags);
2585
2588
2589
+ assert (ResolvedLocs.size () == Locs.getLocations ().size ());
2586
2590
for (auto ResolvedLoc : ResolvedLocs) {
2587
2591
if (ResolvedLoc.range .isInvalid ()) {
2588
2592
continue ;
2589
2593
}
2590
2594
unsigned Offset = SrcMgr.getLocOffsetInBuffer (
2591
2595
ResolvedLoc.range .getStart (), BufferID);
2592
- Ranges.emplace_back ( Offset, ResolvedLoc.range .getByteLength ());
2596
+ Ranges.push_back ({ Offset, ResolvedLoc.range .getByteLength ()} );
2593
2597
}
2594
2598
};
2595
2599
Action ();
2596
- RelatedIdentsInfo Info;
2597
- Info.Ranges = Ranges;
2598
- Receiver (RequestResult<RelatedIdentsInfo>::fromResult (Info));
2600
+ Receiver (RequestResult<ArrayRef<RelatedIdentInfo>>::fromResult (Ranges));
2599
2601
#endif
2600
2602
}
2601
2603
2602
2604
void cancelled () override {
2603
- Receiver (RequestResult<RelatedIdentsInfo >::cancelled ());
2605
+ Receiver (RequestResult<ArrayRef<RelatedIdentInfo> >::cancelled ());
2604
2606
}
2605
2607
2606
2608
void failed (StringRef Error) override {
2607
2609
LOG_WARN_FUNC (" related idents failed: " << Error);
2608
- Receiver (RequestResult<RelatedIdentsInfo >::fromError (Error));
2610
+ Receiver (RequestResult<ArrayRef<RelatedIdentInfo> >::fromError (Error));
2609
2611
}
2610
2612
2611
2613
static CaseStmt *getCaseStmtOfCanonicalVar (Decl *D) {
0 commit comments