[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:
Argyrios Kyrtzidis
2017-06-20 12:26:32 -07:00
committed by GitHub
parent 531c2e8868
commit 0cfc56ec04
12 changed files with 337 additions and 191 deletions

View File

@@ -35,7 +35,8 @@ class Context {
public:
Context(StringRef RuntimeLibPath,
llvm::function_ref<
std::unique_ptr<LangSupport>(Context &)> LangSupportFactoryFn);
std::unique_ptr<LangSupport>(Context &)> LangSupportFactoryFn,
bool shouldDispatchNotificationsOnMain = true);
~Context();
StringRef getRuntimeLibPath() const { return RuntimeLibPath; }

View File

@@ -14,6 +14,7 @@
#define LLVM_SOURCEKIT_CORE_NOTIFICATIONCENTER_H
#include "SourceKit/Core/LLVM.h"
#include "llvm/Support/Mutex.h"
#include <functional>
#include <vector>
@@ -23,9 +24,14 @@ typedef std::function<void(StringRef DocumentName)>
DocumentUpdateNotificationReceiver;
class NotificationCenter {
bool DispatchToMain;
std::vector<DocumentUpdateNotificationReceiver> DocUpdReceivers;
mutable llvm::sys::Mutex Mtx;
public:
explicit NotificationCenter(bool dispatchToMain);
~NotificationCenter();
void addDocumentUpdateNotificationReceiver(
DocumentUpdateNotificationReceiver Receiver);