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