forked from qt-creator/qt-creator
ClangCodeModel: Force clangd restart on external changes
Neither we nor clangd can afford to watch all source files, which means that after e.g. a branch switch we can easily end up in an inconsistent state. We alleviate this problem by restarting clangd if at least one open file was changed externally. Change-Id: I7e0d14835e3afbd7a64c3233614f2161282dddc0 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "locatorfilter.h"
|
||||
#include "lspinspector.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <languageserverprotocol/diagnostics.h>
|
||||
@@ -86,6 +87,7 @@ public:
|
||||
static Client *clientForFilePath(const Utils::FilePath &filePath);
|
||||
static Client *clientForUri(const LanguageServerProtocol::DocumentUri &uri);
|
||||
static const QList<Client *> clientsForProject(const ProjectExplorer::Project *project);
|
||||
template<typename T> static bool hasClients();
|
||||
|
||||
///
|
||||
/// \brief openDocumentWithClient
|
||||
@@ -130,4 +132,12 @@ private:
|
||||
WorkspaceMethodLocatorFilter m_workspaceMethodLocatorFilter;
|
||||
LspInspector m_inspector;
|
||||
};
|
||||
|
||||
template<typename T> bool LanguageClientManager::hasClients()
|
||||
{
|
||||
return Utils::contains(instance()->m_clients, [](const Client *c) {
|
||||
return qobject_cast<const T* >(c);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
Reference in New Issue
Block a user