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