forked from qt-creator/qt-creator
QmakeProjectManager: Restore incremental re-parsing
This was broken in commit 37aecdd112, where we overlooked that a special
type of IDocument was used that triggers a re-parse of only the affected
part of the project tree. As a result, all changes to a .pri or .pro file
would trigger a re-parse of the entire project.
Fixes: QTCREATORBUG-24572
Change-Id: I480cff4e53cf86a17e1eaac0eb9b32901bc87051
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -63,41 +63,6 @@ using namespace QmakeProjectManager::Internal;
|
||||
using namespace QMakeInternal;
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
|
||||
class QmakePriFileDocument : public Core::IDocument
|
||||
{
|
||||
public:
|
||||
QmakePriFileDocument(QmakePriFile *qmakePriFile, const Utils::FilePath &filePath) :
|
||||
IDocument(nullptr), m_priFile(qmakePriFile)
|
||||
{
|
||||
setId("Qmake.PriFile");
|
||||
setMimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE));
|
||||
setFilePath(filePath);
|
||||
}
|
||||
|
||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
Q_UNUSED(type)
|
||||
return BehaviorSilent;
|
||||
}
|
||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override
|
||||
{
|
||||
Q_UNUSED(errorString)
|
||||
Q_UNUSED(flag)
|
||||
if (type == TypePermissions)
|
||||
return true;
|
||||
m_priFile->scheduleUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
QmakePriFile *m_priFile;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
static Q_LOGGING_CATEGORY(qmakeParse, "qtc.qmake.parsing", QtWarningMsg);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "qmakeprojectmanagerconstants.h"
|
||||
#include "qmakestep.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -98,6 +99,38 @@ static Q_LOGGING_CATEGORY(qmakeBuildSystemLog, "qtc.qmake.buildsystem", QtWarnin
|
||||
<< msg; \
|
||||
}
|
||||
|
||||
class QmakePriFileDocument : public Core::IDocument
|
||||
{
|
||||
public:
|
||||
QmakePriFileDocument(QmakePriFile *qmakePriFile, const Utils::FilePath &filePath) :
|
||||
IDocument(nullptr), m_priFile(qmakePriFile)
|
||||
{
|
||||
setId("Qmake.PriFile");
|
||||
setMimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE));
|
||||
setFilePath(filePath);
|
||||
Core::DocumentManager::addDocument(this);
|
||||
}
|
||||
|
||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
Q_UNUSED(type)
|
||||
return BehaviorSilent;
|
||||
}
|
||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override
|
||||
{
|
||||
Q_UNUSED(errorString)
|
||||
Q_UNUSED(flag)
|
||||
if (type == TypePermissions)
|
||||
return true;
|
||||
m_priFile->scheduleUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
QmakePriFile *m_priFile;
|
||||
};
|
||||
|
||||
/// Watches folders for QmakePriFile nodes
|
||||
/// use one file system watcher to watch all folders
|
||||
/// such minimizing system ressouce usage
|
||||
@@ -270,8 +303,17 @@ void QmakeBuildSystem::updateDocuments()
|
||||
QSet<FilePath> projectDocuments;
|
||||
project()->rootProjectNode()->forEachProjectNode([&projectDocuments](const ProjectNode *n) {
|
||||
projectDocuments.insert(n->filePath());
|
||||
|
||||
});
|
||||
project()->setExtraProjectFiles(projectDocuments, [p = project()](const FilePath &fp)
|
||||
-> std::unique_ptr<Core::IDocument> {
|
||||
const Node * const n = p->nodeForFilePath(fp, [](const Node *n) {
|
||||
return dynamic_cast<const QmakePriFileNode *>(n); });
|
||||
QTC_ASSERT(n, return std::make_unique<Core::IDocument>());
|
||||
QmakePriFile * const priFile = static_cast<const QmakePriFileNode *>(n)->priFile();
|
||||
QTC_ASSERT(priFile, return std::make_unique<Core::IDocument>());
|
||||
return std::make_unique<QmakePriFileDocument>(priFile, fp);
|
||||
});
|
||||
project()->setExtraProjectFiles(projectDocuments);
|
||||
}
|
||||
|
||||
void QmakeBuildSystem::updateCppCodeModel()
|
||||
|
||||
Reference in New Issue
Block a user