QmlDesigner: Improve support for project storage aliases

Change-Id: I074aa01e2fc68dea01bece63d13e2688eadbea67
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2024-10-01 17:17:31 +02:00
parent 469194a082
commit e64f3c2703
9 changed files with 26 additions and 23 deletions

View File

@@ -375,6 +375,11 @@ extend_qtc_library(QmlDesignerCore
DEFINES QML_DOM_MSVC2019_COMPAT
)
extend_qtc_library(QmlDesignerCore
CONDITION WITH_TESTS
PUBLIC_DEFINES QDS_MODEL_USE_PROJECTSTORAGEINTERFACE
)
extend_qtc_library(QmlDesignerCore
SOURCES_PREFIX projectstorage
PUBLIC_INCLUDES projectstorage

View File

@@ -39,6 +39,8 @@ constexpr bool useProjectStorage()
return false;
#endif
}
class SourcePathStorage;
using PathCache = SourcePathCache<SourcePathStorage, NonLockingMutex>;
#ifdef QDS_MODEL_USE_PROJECTSTORAGEINTERFACE
using ProjectStorageType = ProjectStorageInterface;
@@ -46,7 +48,6 @@ class SourcePathCacheInterface;
using PathCacheType = SourcePathCacheInterface;
#else
using ProjectStorageType = ProjectStorage;
class SourcePathStorage;
using PathCacheType = SourcePathCache<SourcePathStorage, NonLockingMutex>;
#endif

View File

@@ -7,6 +7,8 @@
#include "filesysteminterface.h"
#include "sourcepathstorage/nonlockingmutex.h"
#include <modelfwd.h>
namespace QmlDesigner {
class SourcePathStorage;
@@ -16,10 +18,9 @@ class SourcePathCache;
class QMLDESIGNERCORE_EXPORT FileSystem : public FileSystemInterface
{
using PathCache = SourcePathCache<SourcePathStorage, NonLockingMutex>;
public:
FileSystem(PathCache &sourcePathCache)
FileSystem(PathCacheType &sourcePathCache)
: m_sourcePathCache(sourcePathCache)
{}
@@ -33,7 +34,7 @@ public:
void remove(const SourceIds &sourceIds) override;
private:
PathCache &m_sourcePathCache;
PathCacheType &m_sourcePathCache;
};
} // namespace QmlDesigner

View File

@@ -17,7 +17,7 @@ namespace QmlDesigner {
class ProjectStorageInterface
{
friend Storage::Info::CommonTypeCache<ProjectStorageInterface>;
friend Storage::Info::CommonTypeCache<ProjectStorageType>;
public:
ProjectStorageInterface(const ProjectStorageInterface &) = delete;

View File

@@ -41,12 +41,10 @@ class QMLDESIGNERCORE_EXPORT ProjectStorageUpdater final
: public ProjectStoragePathWatcherNotifierInterface
{
public:
using PathCache = SourcePathCache<SourcePathStorage, NonLockingMutex>;
ProjectStorageUpdater(FileSystemInterface &fileSystem,
ProjectStorageType &projectStorage,
FileStatusCache &fileStatusCache,
PathCache &pathCache,
PathCacheType &pathCache,
QmlDocumentParserInterface &qmlDocumentParser,
QmlTypesParserInterface &qmlTypesParser,
class ProjectStoragePathWatcherInterface &pathWatcher,
@@ -243,7 +241,7 @@ private:
FileSystemInterface &m_fileSystem;
ProjectStorageType &m_projectStorage;
FileStatusCache &m_fileStatusCache;
PathCache &m_pathCache;
PathCacheType &m_pathCache;
QmlDocumentParserInterface &m_qmlDocumentParser;
QmlTypesParserInterface &m_qmlTypesParser;
ProjectStoragePathWatcherInterface &m_pathWatcher;

View File

@@ -66,7 +66,7 @@ Utils::PathString createNormalizedPath(Utils::SmallStringView directoryPath,
Storage::Import createImport(const QmlDom::Import &qmlImport,
SourceId sourceId,
Utils::SmallStringView directoryPath,
QmlDocumentParser::ProjectStorage &storage)
ProjectStorageType &storage)
{
using Storage::ModuleKind;
using QmlUriKind = QQmlJS::Dom::QmlUri::Kind;
@@ -99,7 +99,7 @@ Storage::Import createImport(const QmlDom::Import &qmlImport,
QualifiedImports createQualifiedImports(const QList<QmlDom::Import> &qmlImports,
SourceId sourceId,
Utils::SmallStringView directoryPath,
QmlDocumentParser::ProjectStorage &storage)
ProjectStorageType &storage)
{
NanotraceHR::Tracer tracer{"create qualified imports"_t,
category(),
@@ -123,7 +123,7 @@ void addImports(Storage::Imports &imports,
const QList<QmlDom::Import> &qmlImports,
SourceId sourceId,
Utils::SmallStringView directoryPath,
QmlDocumentParser::ProjectStorage &storage)
ProjectStorageType &storage)
{
int importCount = 0;
for (const QmlDom::Import &qmlImport : qmlImports) {

View File

@@ -7,8 +7,8 @@
#include "qmldocumentparserinterface.h"
#include "sourcepathstorage/nonlockingmutex.h"
#include <modelfwd.h>
#include <qmldesignercorelib_exports.h>
namespace QmlDesigner {
template<typename Storage, typename Mutex>
@@ -18,11 +18,9 @@ class SourcePathStorage;
class QMLDESIGNERCORE_EXPORT QmlDocumentParser final : public QmlDocumentParserInterface
{
public:
using ProjectStorage = QmlDesigner::ProjectStorage;
using PathCache = QmlDesigner::SourcePathCache<SourcePathStorage, NonLockingMutex>;
#ifdef QDS_BUILD_QMLPARSER
QmlDocumentParser(ProjectStorage &storage, PathCache &pathCache)
QmlDocumentParser(ProjectStorageType &storage, PathCacheType &pathCache)
: m_storage{storage}
, m_pathCache{pathCache}
{}
@@ -39,8 +37,8 @@ public:
private:
// m_pathCache and m_storage are only used when compiled for QDS
#ifdef QDS_BUILD_QMLPARSER
ProjectStorage &m_storage;
PathCache &m_pathCache;
ProjectStorageType &m_storage;
PathCacheType &m_pathCache;
#endif
};
} // namespace QmlDesigner

View File

@@ -202,7 +202,7 @@ public:
FileStatusCache fileStatusCache{fileSystem};
QmlDocumentParser qmlDocumentParser;
QmlTypesParser qmlTypesParser{storage};
ProjectStoragePathWatcher<QFileSystemWatcher, QTimer, ProjectStorageUpdater::PathCache> pathWatcher;
ProjectStoragePathWatcher<QFileSystemWatcher, QTimer, PathCacheType> pathWatcher;
ProjectPartId projectPartId;
ProjectStorageUpdater updater;
};
@@ -265,7 +265,7 @@ public:
Sqlite::LockingMode::Normal};
QmlDesigner::SourcePathStorage sourcePathStorage{sourcePathDatabase,
sourcePathDatabase.isInitialized()};
PathCacheType pathCache{sourcePathStorage};
PathCache pathCache{sourcePathStorage};
};
QmlDesignerProjectManager::QmlDesignerProjectManager(ExternalDependenciesInterface &externalDependencies)
@@ -322,12 +322,12 @@ AsynchronousImageCache &QmlDesignerProjectManager::asynchronousImageCache()
}
namespace {
[[maybe_unused]] ProjectStorage *dummyProjectStorage()
[[maybe_unused]] ProjectStorageType *dummyProjectStorage()
{
return nullptr;
}
[[maybe_unused]] ProjectStorageUpdater::PathCache *dummyPathCache()
[[maybe_unused]] PathCacheType *dummyPathCache()
{
return nullptr;
}

View File

@@ -1041,7 +1041,7 @@ TEST_F(Model_MetaInfo, get_meta_info_by_module)
ASSERT_THAT(metaInfo, model.qmlQtObjectMetaInfo());
}
TEST_F(Model_MetaInfo, get_invalid_meta_info_by_module_for_wrong_name)
TEST_F(Model_MetaInfo, get_invalid_meta_info_by_module_and_name_for_wrong_name)
{
auto module = model.module("QML", ModuleKind::QmlLibrary);