@@ -659,7 +659,7 @@ class SwiftDocumentSemanticInfo :
659
659
}
660
660
661
661
private:
662
- std::vector<SwiftSemanticToken> takeSemanticTokens (
662
+ std::vector<SwiftSemanticToken> getSemanticTokens (
663
663
ImmutableTextSnapshotRef NewSnapshot);
664
664
665
665
Optional<std::vector<DiagnosticEntryInfo>> getSemanticDiagnostics (
@@ -760,26 +760,28 @@ void SwiftDocumentSemanticInfo::readSemanticInfo(
760
760
761
761
llvm::sys::ScopedLock L (Mtx);
762
762
763
- Tokens = takeSemanticTokens (NewSnapshot);
763
+ Tokens = getSemanticTokens (NewSnapshot);
764
764
Diags = getSemanticDiagnostics (NewSnapshot, ParserDiags);
765
765
}
766
766
767
767
std::vector<SwiftSemanticToken>
768
- SwiftDocumentSemanticInfo::takeSemanticTokens (
768
+ SwiftDocumentSemanticInfo::getSemanticTokens (
769
769
ImmutableTextSnapshotRef NewSnapshot) {
770
770
771
771
llvm::sys::ScopedLock L (Mtx);
772
772
773
773
if (SemaToks.empty ())
774
774
return {};
775
775
776
+ auto result = SemaToks;
777
+
776
778
// Adjust the position of the tokens.
777
779
TokSnapshot->foreachReplaceUntil (NewSnapshot,
778
780
[&](ReplaceImmutableTextUpdateRef Upd) -> bool {
779
- if (SemaToks .empty ())
781
+ if (result .empty ())
780
782
return false ;
781
783
782
- auto ReplaceBegin = std::lower_bound (SemaToks .begin (), SemaToks .end (),
784
+ auto ReplaceBegin = std::lower_bound (result .begin (), result .end (),
783
785
Upd->getByteOffset (),
784
786
[&](const SwiftSemanticToken &Tok, unsigned StartOffset) -> bool {
785
787
return Tok.ByteOffset +Tok.Length < StartOffset;
@@ -789,7 +791,7 @@ SwiftDocumentSemanticInfo::takeSemanticTokens(
789
791
if (Upd->getLength () == 0 ) {
790
792
ReplaceEnd = ReplaceBegin;
791
793
} else {
792
- ReplaceEnd = std::upper_bound (ReplaceBegin, SemaToks .end (),
794
+ ReplaceEnd = std::upper_bound (ReplaceBegin, result .end (),
793
795
Upd->getByteOffset () + Upd->getLength (),
794
796
[&](unsigned EndOffset, const SwiftSemanticToken &Tok) -> bool {
795
797
return EndOffset < Tok.ByteOffset ;
@@ -800,14 +802,14 @@ SwiftDocumentSemanticInfo::takeSemanticTokens(
800
802
int Delta = InsertLen - Upd->getLength ();
801
803
if (Delta != 0 ) {
802
804
for (std::vector<SwiftSemanticToken>::iterator
803
- I = ReplaceEnd, E = SemaToks .end (); I != E; ++I)
805
+ I = ReplaceEnd, E = result .end (); I != E; ++I)
804
806
I->ByteOffset += Delta;
805
807
}
806
- SemaToks .erase (ReplaceBegin, ReplaceEnd);
808
+ result .erase (ReplaceBegin, ReplaceEnd);
807
809
return true ;
808
810
});
809
811
810
- return std::move (SemaToks) ;
812
+ return result ;
811
813
}
812
814
813
815
Optional<std::vector<DiagnosticEntryInfo>>
0 commit comments