mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Revert "Merge pull request #32628 from benlangmuir/sema-repeat"
This reverts commit35eab3e3a8, reversing changes made tod5a549a9e4. This caused an unexpected regression. rdar://65554791
This commit is contained in:
@@ -659,7 +659,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<SwiftSemanticToken> getSemanticTokens(
|
||||
std::vector<SwiftSemanticToken> takeSemanticTokens(
|
||||
ImmutableTextSnapshotRef NewSnapshot);
|
||||
|
||||
Optional<std::vector<DiagnosticEntryInfo>> getSemanticDiagnostics(
|
||||
@@ -760,12 +760,12 @@ void SwiftDocumentSemanticInfo::readSemanticInfo(
|
||||
|
||||
llvm::sys::ScopedLock L(Mtx);
|
||||
|
||||
Tokens = getSemanticTokens(NewSnapshot);
|
||||
Tokens = takeSemanticTokens(NewSnapshot);
|
||||
Diags = getSemanticDiagnostics(NewSnapshot, ParserDiags);
|
||||
}
|
||||
|
||||
std::vector<SwiftSemanticToken>
|
||||
SwiftDocumentSemanticInfo::getSemanticTokens(
|
||||
SwiftDocumentSemanticInfo::takeSemanticTokens(
|
||||
ImmutableTextSnapshotRef NewSnapshot) {
|
||||
|
||||
llvm::sys::ScopedLock L(Mtx);
|
||||
@@ -773,15 +773,13 @@ SwiftDocumentSemanticInfo::getSemanticTokens(
|
||||
if (SemaToks.empty())
|
||||
return {};
|
||||
|
||||
auto result = SemaToks;
|
||||
|
||||
// Adjust the position of the tokens.
|
||||
TokSnapshot->foreachReplaceUntil(NewSnapshot,
|
||||
[&](ReplaceImmutableTextUpdateRef Upd) -> bool {
|
||||
if (result.empty())
|
||||
if (SemaToks.empty())
|
||||
return false;
|
||||
|
||||
auto ReplaceBegin = std::lower_bound(result.begin(), result.end(),
|
||||
auto ReplaceBegin = std::lower_bound(SemaToks.begin(), SemaToks.end(),
|
||||
Upd->getByteOffset(),
|
||||
[&](const SwiftSemanticToken &Tok, unsigned StartOffset) -> bool {
|
||||
return Tok.ByteOffset+Tok.Length < StartOffset;
|
||||
@@ -791,7 +789,7 @@ SwiftDocumentSemanticInfo::getSemanticTokens(
|
||||
if (Upd->getLength() == 0) {
|
||||
ReplaceEnd = ReplaceBegin;
|
||||
} else {
|
||||
ReplaceEnd = std::upper_bound(ReplaceBegin, result.end(),
|
||||
ReplaceEnd = std::upper_bound(ReplaceBegin, SemaToks.end(),
|
||||
Upd->getByteOffset() + Upd->getLength(),
|
||||
[&](unsigned EndOffset, const SwiftSemanticToken &Tok) -> bool {
|
||||
return EndOffset < Tok.ByteOffset;
|
||||
@@ -802,14 +800,14 @@ SwiftDocumentSemanticInfo::getSemanticTokens(
|
||||
int Delta = InsertLen - Upd->getLength();
|
||||
if (Delta != 0) {
|
||||
for (std::vector<SwiftSemanticToken>::iterator
|
||||
I = ReplaceEnd, E = result.end(); I != E; ++I)
|
||||
I = ReplaceEnd, E = SemaToks.end(); I != E; ++I)
|
||||
I->ByteOffset += Delta;
|
||||
}
|
||||
result.erase(ReplaceBegin, ReplaceEnd);
|
||||
SemaToks.erase(ReplaceBegin, ReplaceEnd);
|
||||
return true;
|
||||
});
|
||||
|
||||
return result;
|
||||
return std::move(SemaToks);
|
||||
}
|
||||
|
||||
Optional<std::vector<DiagnosticEntryInfo>>
|
||||
|
||||
Reference in New Issue
Block a user