Revert "Merge pull request #32628 from benlangmuir/sema-repeat"

This reverts commit 35eab3e3a8, reversing
changes made to d5a549a9e4.

This caused an unexpected regression.

rdar://65554791
This commit is contained in:
Ben Langmuir
2020-07-14 17:00:02 -07:00
parent 6ea2034e33
commit 209a7b3813
3 changed files with 9 additions and 87 deletions

View File

@@ -1,10 +0,0 @@
func foo() {}
foo()
// RUN: %sourcekitd-test -req=open %s -- %s \
// RUN: == -req=edit -offset=0 -replace="" -length=0 %s \
// RUN: == -req=edit -offset=0 -replace="" -length=0 %s \
// RUN: == -req=edit -pos=3:1 -replace="foo()" -length=0 %s \
// RUN: == -req=edit -offset=0 -replace="" -length=0 %s \
// RUN: == -req=edit -offset=0 -replace="" -length=0 %s > %t.response
// RUN: %diff -u %s.response %t.response

View File

@@ -1,66 +0,0 @@
{
key.annotations: [
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 14,
key.length: 3
}
],
key.diagnostic_stage: source.diagnostic.stage.swift.sema,
key.syntaxmap: [
],
key.substructure: [
]
}
{
key.annotations: [
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 14,
key.length: 3
}
],
key.diagnostic_stage: source.diagnostic.stage.swift.sema,
key.syntaxmap: [
],
key.substructure: [
]
}
{
key.annotations: [
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 14,
key.length: 3
},
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 20,
key.length: 3
}
],
key.diagnostic_stage: source.diagnostic.stage.swift.sema,
key.syntaxmap: [
],
key.substructure: [
]
}
{
key.annotations: [
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 14,
key.length: 3
},
{
key.kind: source.lang.swift.ref.function.free,
key.offset: 20,
key.length: 3
}
],
key.diagnostic_stage: source.diagnostic.stage.swift.sema,
key.syntaxmap: [
],
key.substructure: [
]
}

View File

@@ -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>>