mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] If diagnostics are 'stale' for a particular snapshot then ignore them and only return the syntactic parser diagnostics (#10388)
This makes sure that diagnostics returned for a particular state of source buffer are consistent and accurate. rdar://32769873
This commit is contained in:
committed by
GitHub
parent
531c2e8868
commit
0cfc56ec04
@@ -15,20 +15,33 @@
|
||||
|
||||
using namespace SourceKit;
|
||||
|
||||
NotificationCenter::NotificationCenter(bool dispatchToMain)
|
||||
: DispatchToMain(dispatchToMain) {
|
||||
}
|
||||
NotificationCenter::~NotificationCenter() {}
|
||||
|
||||
void NotificationCenter::addDocumentUpdateNotificationReceiver(
|
||||
DocumentUpdateNotificationReceiver Receiver) {
|
||||
|
||||
WorkQueue::dispatchOnMain([this, Receiver]{
|
||||
DocUpdReceivers.push_back(Receiver);
|
||||
});
|
||||
llvm::sys::ScopedLock L(Mtx);
|
||||
DocUpdReceivers.push_back(Receiver);
|
||||
}
|
||||
|
||||
void NotificationCenter::postDocumentUpdateNotification(
|
||||
StringRef DocumentName) const {
|
||||
|
||||
std::string DocName = DocumentName;
|
||||
WorkQueue::dispatchOnMain([this, DocName]{
|
||||
for (auto &Fn : DocUpdReceivers)
|
||||
Fn(DocName);
|
||||
});
|
||||
|
||||
std::vector<DocumentUpdateNotificationReceiver> recvs;
|
||||
{
|
||||
llvm::sys::ScopedLock L(Mtx);
|
||||
recvs = DocUpdReceivers;
|
||||
}
|
||||
std::string docName = DocumentName;
|
||||
auto sendNote = [recvs, docName]{
|
||||
for (auto &Fn : recvs)
|
||||
Fn(docName);
|
||||
};
|
||||
if (DispatchToMain)
|
||||
WorkQueue::dispatchOnMain(sendNote);
|
||||
else
|
||||
sendNote();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user