@@ -474,8 +474,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
474
474
475
475
IndexSymbol Info;
476
476
std::tie (Info.line , Info.column ) = getLineCol (Loc);
477
- std::tie (Info.startOffset , Info.endOffset ) =
478
- getRangeStartAndEndOffset (Range);
477
+ Info.offset = getOffsetInBuffer (Loc);
479
478
Info.roles |= (unsigned )SymbolRole::Reference;
480
479
Info.symInfo = getSymbolInfoForModule (Mod);
481
480
getModuleNameAndUSR (Mod, Info.name , Info.USR );
@@ -593,19 +592,10 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
593
592
return SrcMgr.getLineAndColumn (Loc, BufferID);
594
593
}
595
594
596
- std::pair<unsigned , unsigned > getRangeStartAndEndOffset (CharSourceRange Range) {
597
- if (Range.isInvalid ())
598
- return std::make_pair (0 , 0 );
599
- unsigned offset = SrcMgr.getLocOffsetInBuffer (Range.getStart (), BufferID);
600
- unsigned length = SrcMgr.getByteDistance (Range.getStart (), Range.getEnd ());
601
- return std::make_pair (offset, offset + length);
602
- }
603
-
604
- std::pair<unsigned , unsigned > getLocStartAndEndOffset (SourceLoc Loc) {
595
+ unsigned getOffsetInBuffer (SourceLoc Loc) {
605
596
if (Loc.isInvalid ())
606
- return std::make_pair (0 , 0 );
607
- return getRangeStartAndEndOffset (
608
- Lexer::getCharSourceRangeFromSourceRange (SrcMgr, SourceRange (Loc)));
597
+ return 0 ;
598
+ return SrcMgr.getLocOffsetInBuffer (Loc, BufferID);
609
599
}
610
600
611
601
bool shouldIndex (ValueDecl *D, bool IsRef) const {
@@ -1243,7 +1233,7 @@ bool IndexSwiftASTWalker::initIndexSymbol(ValueDecl *D, SourceLoc Loc,
1243
1233
return true ;
1244
1234
1245
1235
std::tie (Info.line , Info.column ) = getLineCol (Loc);
1246
- std::tie ( Info.startOffset , Info. endOffset ) = getLocStartAndEndOffset (Loc);
1236
+ Info.offset = getOffsetInBuffer (Loc);
1247
1237
if (!IsRef) {
1248
1238
if (auto Group = D->getGroupName ())
1249
1239
Info.group = Group.getValue ();
@@ -1265,7 +1255,7 @@ bool IndexSwiftASTWalker::initIndexSymbol(ExtensionDecl *ExtD, ValueDecl *Extend
1265
1255
return true ;
1266
1256
1267
1257
std::tie (Info.line , Info.column ) = getLineCol (Loc);
1268
- std::tie ( Info.startOffset , Info. endOffset ) = getLocStartAndEndOffset (Loc);
1258
+ Info.offset = getOffsetInBuffer (Loc);
1269
1259
if (auto Group = ExtD->getGroupName ())
1270
1260
Info.group = Group.getValue ();
1271
1261
return false ;
@@ -1473,7 +1463,7 @@ bool IndexSwiftASTWalker::indexComment(const Decl *D) {
1473
1463
Info.USR = stringStorage.copyString (OS.str ());
1474
1464
}
1475
1465
std::tie (Info.line , Info.column ) = getLineCol (loc);
1476
- std::tie ( Info.startOffset , Info. endOffset ) = getLocStartAndEndOffset (loc);
1466
+ Info.offset = getOffsetInBuffer (loc);
1477
1467
if (!IdxConsumer.startSourceEntity (Info) || !IdxConsumer.finishSourceEntity (Info.symInfo , Info.roles )) {
1478
1468
Cancelled = true ;
1479
1469
break ;
0 commit comments