QmlDesigner: Integrate ProjectStoragePathWatcher

Task-number: QDS-9170
Change-Id: Iedbb07e41232beeb73cd12c89f892eec7968d084
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Marco Bubke
2023-02-16 13:53:28 +01:00
parent 44d61b3e66
commit ba6c1344b6
5 changed files with 20 additions and 6 deletions

View File

@@ -32,7 +32,6 @@ void set_greedy_intersection_call(
} }
} }
template<typename FileSystemWatcher, typename Timer, class SourcePathCache> template<typename FileSystemWatcher, typename Timer, class SourcePathCache>
class ProjectStoragePathWatcher : public ProjectStoragePathWatcherInterface class ProjectStoragePathWatcher : public ProjectStoragePathWatcherInterface
{ {

View File

@@ -41,13 +41,15 @@ public:
FileStatusCache &fileStatusCache, FileStatusCache &fileStatusCache,
PathCache &pathCache, PathCache &pathCache,
QmlDocumentParserInterface &qmlDocumentParser, QmlDocumentParserInterface &qmlDocumentParser,
QmlTypesParserInterface &qmlTypesParser) QmlTypesParserInterface &qmlTypesParser,
class ProjectStoragePathWatcherInterface &pathWatcher)
: m_fileSystem{fileSystem} : m_fileSystem{fileSystem}
, m_projectStorage{projectStorage} , m_projectStorage{projectStorage}
, m_fileStatusCache{fileStatusCache} , m_fileStatusCache{fileStatusCache}
, m_pathCache{pathCache} , m_pathCache{pathCache}
, m_qmlDocumentParser{qmlDocumentParser} , m_qmlDocumentParser{qmlDocumentParser}
, m_qmlTypesParser{qmlTypesParser} , m_qmlTypesParser{qmlTypesParser}
, m_pathWatcher{pathWatcher}
{} {}
void update(QStringList directories, QStringList qmlTypesPaths); void update(QStringList directories, QStringList qmlTypesPaths);
@@ -151,6 +153,7 @@ private:
PathCache &m_pathCache; PathCache &m_pathCache;
QmlDocumentParserInterface &m_qmlDocumentParser; QmlDocumentParserInterface &m_qmlDocumentParser;
QmlTypesParserInterface &m_qmlTypesParser; QmlTypesParserInterface &m_qmlTypesParser;
ProjectStoragePathWatcherInterface &m_pathWatcher;
}; };
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -12,6 +12,7 @@
#include <projectstorage/filesystem.h> #include <projectstorage/filesystem.h>
#include <projectstorage/nonlockingmutex.h> #include <projectstorage/nonlockingmutex.h>
#include <projectstorage/projectstorage.h> #include <projectstorage/projectstorage.h>
#include <projectstorage/projectstoragepathwatcher.h>
#include <projectstorage/projectstorageupdater.h> #include <projectstorage/projectstorageupdater.h>
#include <projectstorage/qmldocumentparser.h> #include <projectstorage/qmldocumentparser.h>
#include <projectstorage/qmltypesparser.h> #include <projectstorage/qmltypesparser.h>
@@ -38,6 +39,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QFileSystemWatcher>
#include <QQmlEngine> #include <QQmlEngine>
namespace QmlDesigner { namespace QmlDesigner {
@@ -179,8 +181,15 @@ public:
FileStatusCache fileStatusCache{fileSystem}; FileStatusCache fileStatusCache{fileSystem};
QmlDocumentParser qmlDocumentParser{storage, pathCache}; QmlDocumentParser qmlDocumentParser{storage, pathCache};
QmlTypesParser qmlTypesParser{pathCache, storage}; QmlTypesParser qmlTypesParser{pathCache, storage};
ProjectStorageUpdater updater{ ProjectStoragePathWatcher<QFileSystemWatcher, QTimer, ProjectStorageUpdater::PathCache>
fileSystem, storage, fileStatusCache, pathCache, qmlDocumentParser, qmlTypesParser}; pathWatcher{pathCache, fileSystem, &updater};
ProjectStorageUpdater updater{fileSystem,
storage,
fileStatusCache,
pathCache,
qmlDocumentParser,
qmlTypesParser,
pathWatcher};
}; };
std::unique_ptr<ProjectStorageData> createProjectStorageData(::ProjectExplorer::Project *project) std::unique_ptr<ProjectStorageData> createProjectStorageData(::ProjectExplorer::Project *project)

View File

@@ -7,7 +7,7 @@
#include "projectstorage/projectstoragepathwatcherinterface.h" #include "projectstorage/projectstoragepathwatcherinterface.h"
class MockProjectStoragePathWatcher : public QmlDesigner::ProjectStoragePathWatcherInterface class ProjectStoragePathWatcherMock : public QmlDesigner::ProjectStoragePathWatcherInterface
{ {
public: public:
MOCK_METHOD(void, updateIdPaths, (const std::vector<QmlDesigner::IdPaths> &idPaths), ()); MOCK_METHOD(void, updateIdPaths, (const std::vector<QmlDesigner::IdPaths> &idPaths), ());

View File

@@ -5,6 +5,7 @@
#include "filesystemmock.h" #include "filesystemmock.h"
#include "projectstoragemock.h" #include "projectstoragemock.h"
#include "projectstoragepathwatchermock.h"
#include "qmldocumentparsermock.h" #include "qmldocumentparsermock.h"
#include "qmltypesparsermock.h" #include "qmltypesparsermock.h"
@@ -218,12 +219,14 @@ protected:
QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()}; QmlDesigner::ProjectStorage<Sqlite::Database> storage{database, database.isInitialized()};
QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{ QmlDesigner::SourcePathCache<QmlDesigner::ProjectStorage<Sqlite::Database>> sourcePathCache{
storage}; storage};
NiceMock<ProjectStoragePathWatcherMock> patchWatcherMock;
QmlDesigner::ProjectStorageUpdater updater{fileSystemMock, QmlDesigner::ProjectStorageUpdater updater{fileSystemMock,
projectStorageMock, projectStorageMock,
fileStatusCache, fileStatusCache,
sourcePathCache, sourcePathCache,
qmlDocumentParserMock, qmlDocumentParserMock,
qmlTypesParserMock}; qmlTypesParserMock,
patchWatcherMock};
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes"); SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/types/example2.qmltypes"); SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/types/example2.qmltypes");
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir"); SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");