Clang: Improve updating

If project parts are up to date we send them directly to the indexer, so
the indexer can decide we something needs an update.

Change-Id: I7d4f32794c6b3a861cdefb3653a6dfd4e711f619
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2019-05-22 12:26:58 +02:00
parent 912cb9278f
commit b213dee013
27 changed files with 154 additions and 283 deletions

View File

@@ -43,11 +43,8 @@ void PchManagerClient::alive()
void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message)
{
for (ClangBackEnd::ProjectPartPch &projectPartPch : message.takeProjectPartPchs()) {
const QString pchPath{projectPartPch.pchPath};
addProjectPartPch(std::move(projectPartPch));
precompiledHeaderUpdated(projectPartPch.projectPartId, pchPath, projectPartPch.lastModified);
}
for (ClangBackEnd::ProjectPartId &projectPartId : message.takeProjectPartIds())
precompiledHeaderUpdated(projectPartId);
}
void PchManagerClient::progress(ClangBackEnd::ProgressMessage &&message)
@@ -66,10 +63,8 @@ void PchManagerClient::progress(ClangBackEnd::ProgressMessage &&message)
void PchManagerClient::precompiledHeaderRemoved(ClangBackEnd::ProjectPartId projectPartId)
{
for (auto notifier : m_notifiers) {
removeProjectPartPch(projectPartId);
for (auto notifier : m_notifiers)
notifier->precompiledHeaderRemoved(projectPartId);
}
}
void PchManagerClient::setConnectionClient(PchManagerConnectionClient *connectionClient)
@@ -77,22 +72,6 @@ void PchManagerClient::setConnectionClient(PchManagerConnectionClient *connectio
m_connectionClient = connectionClient;
}
Utils::optional<ClangBackEnd::ProjectPartPch> PchManagerClient::projectPartPch(
ClangBackEnd::ProjectPartId projectPartId) const
{
auto found = std::lower_bound(m_projectPartPchs.cbegin(),
m_projectPartPchs.cend(),
projectPartId,
[] (const auto &projectPartPch, auto projectPartId) {
return projectPartId < projectPartPch.projectPartId;
});
if (found != m_projectPartPchs.end() && found->projectPartId == projectPartId)
return *found;
return Utils::nullopt;
}
void PchManagerClient::attach(PchManagerNotifierInterface *notifier)
{
m_notifiers.push_back(notifier);
@@ -109,47 +88,15 @@ void PchManagerClient::detach(PchManagerNotifierInterface *notifierToBeDeleted)
m_notifiers.erase(newEnd, m_notifiers.end());
}
void PchManagerClient::removeProjectPartPch(ClangBackEnd::ProjectPartId projectPartId)
{
auto found = std::lower_bound(m_projectPartPchs.begin(),
m_projectPartPchs.end(),
projectPartId,
[] (const auto &projectPartPch, auto projectPartId) {
return projectPartId < projectPartPch.projectPartId;
});
if (found != m_projectPartPchs.end() && found->projectPartId == projectPartId) {
*found = std::move(m_projectPartPchs.back());
m_projectPartPchs.pop_back();
}
}
void PchManagerClient::addProjectPartPch(ClangBackEnd::ProjectPartPch &&projectPartPch)
{
auto found = std::lower_bound(m_projectPartPchs.begin(),
m_projectPartPchs.end(),
projectPartPch.projectPartId,
[] (const auto &projectPartPch, auto projectPartId) {
return projectPartId < projectPartPch.projectPartId;
});
if (found != m_projectPartPchs.end() && found->projectPartId == projectPartPch.projectPartId)
*found = std::move(projectPartPch);
else
m_projectPartPchs.insert(found, std::move(projectPartPch));
}
const std::vector<PchManagerNotifierInterface *> &PchManagerClient::notifiers() const
{
return m_notifiers;
}
void PchManagerClient::precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId,
const QString &pchFilePath,
long long lastModified)
void PchManagerClient::precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId)
{
for (auto notifier : m_notifiers)
notifier->precompiledHeaderUpdated(projectPartId, pchFilePath, lastModified);
notifier->precompiledHeaderUpdated(projectPartId);
}
} // namespace ClangPchManager

View File

@@ -28,7 +28,7 @@
#include "clangpchmanager_global.h"
#include <pchmanagerclientinterface.h>
#include <projectpartpchproviderinterface.h>
#include <projectpartid.h>
#include <vector>
@@ -37,8 +37,7 @@ class PchManagerConnectionClient;
class ProgressManagerInterface;
class PchManagerNotifierInterface;
class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchManagerClientInterface,
public ClangBackEnd::ProjectPartPchProviderInterface
class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchManagerClientInterface
{
friend class PchManagerNotifierInterface;
public:
@@ -56,27 +55,13 @@ public:
void setConnectionClient(PchManagerConnectionClient *connectionClient);
Utils::optional<ClangBackEnd::ProjectPartPch> projectPartPch(
ClangBackEnd::ProjectPartId projectPartId) const override;
const ClangBackEnd::ProjectPartPchs &projectPartPchs() const override
{
return m_projectPartPchs;
}
unittest_public : const std::vector<PchManagerNotifierInterface *> &notifiers() const;
void precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId,
const QString &pchFilePath,
long long lastModified);
void precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId);
void attach(PchManagerNotifierInterface *notifier);
void detach(PchManagerNotifierInterface *notifier);
void addProjectPartPch(ClangBackEnd::ProjectPartPch &&projectPartPch);
void removeProjectPartPch(ClangBackEnd::ProjectPartId projectPartId);
private:
ClangBackEnd::ProjectPartPchs m_projectPartPchs;
std::vector<PchManagerNotifierInterface*> m_notifiers;
PchManagerConnectionClient *m_connectionClient=nullptr;
ProgressManagerInterface &m_pchCreationProgressManager;

View File

@@ -42,10 +42,7 @@ public:
PchManagerNotifierInterface(const PchManagerNotifierInterface &) = delete;
PchManagerNotifierInterface &operator=(const PchManagerNotifierInterface &) = delete;
virtual void precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId,
const QString &pchFilePath,
long long lastModified)
= 0;
virtual void precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId) = 0;
virtual void precompiledHeaderRemoved(ClangBackEnd::ProjectPartId projectPartId) = 0;
PchManagerClient &m_pchManagerClient;