forked from qt-creator/qt-creator
QmlDesigner: Rename SourceName and SourceContext into FileName and DirectoryPath
Change-Id: I7851b7f065498e4d21f2ea3c68fe46c135949291 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -11,8 +11,8 @@ enum class ProjectStorageIdType {
|
||||
Type,
|
||||
PropertyType,
|
||||
PropertyDeclaration,
|
||||
SourceName,
|
||||
SourceContext,
|
||||
FileName,
|
||||
DirectoryPath,
|
||||
StorageCacheIndex,
|
||||
FunctionDeclaration,
|
||||
SignalDeclaration,
|
||||
|
@@ -12,22 +12,22 @@
|
||||
namespace QmlDesigner {
|
||||
|
||||
enum class SourcePathIdType {
|
||||
SourceName,
|
||||
SourceContext,
|
||||
FileName,
|
||||
DirectoryPath,
|
||||
|
||||
};
|
||||
|
||||
using SourceContextId = Sqlite::BasicId<SourcePathIdType::SourceContext, int>;
|
||||
using SourceContextIds = std::vector<SourceContextId>;
|
||||
using DirectoryPathId = Sqlite::BasicId<SourcePathIdType::DirectoryPath, int>;
|
||||
using DirectoryPathIds = std::vector<DirectoryPathId>;
|
||||
template<std::size_t size>
|
||||
using SmallSourceContextIds = QVarLengthArray<SourceContextId, size>;
|
||||
using SmallDirectoryPathIds = QVarLengthArray<DirectoryPathId, size>;
|
||||
|
||||
using SourceNameId = Sqlite::BasicId<SourcePathIdType::SourceName, int>;
|
||||
using SourceNameIds = std::vector<SourceNameId>;
|
||||
using FileNameId = Sqlite::BasicId<SourcePathIdType::FileName, int>;
|
||||
using FileNameIds = std::vector<FileNameId>;
|
||||
template<std::size_t size>
|
||||
using SmallSourceNameIds = QVarLengthArray<SourceNameId, size>;
|
||||
using SmallFileNameIds = QVarLengthArray<FileNameId, size>;
|
||||
|
||||
using SourceId = Sqlite::CompoundBasicId<SourcePathIdType::SourceName, SourcePathIdType::SourceContext>;
|
||||
using SourceId = Sqlite::CompoundBasicId<SourcePathIdType::FileName, SourcePathIdType::DirectoryPath>;
|
||||
using SourceIds = std::vector<SourceId>;
|
||||
template<std::size_t size>
|
||||
using SmallSourceIds = QVarLengthArray<SourceId, size>;
|
||||
|
@@ -22,26 +22,26 @@ public:
|
||||
|
||||
~DirectoryPathCompressor() = default;
|
||||
|
||||
void addSourceContextId(SourceContextId sourceContextId)
|
||||
void addDirectoryPathId(DirectoryPathId directoryPathId)
|
||||
{
|
||||
auto found = std::ranges::lower_bound(m_sourceContextIds, sourceContextId);
|
||||
auto found = std::ranges::lower_bound(m_directoryPathIds, directoryPathId);
|
||||
|
||||
if (found == m_sourceContextIds.end() || *found != sourceContextId)
|
||||
m_sourceContextIds.insert(found, sourceContextId);
|
||||
if (found == m_directoryPathIds.end() || *found != directoryPathId)
|
||||
m_directoryPathIds.insert(found, directoryPathId);
|
||||
|
||||
restartTimer();
|
||||
}
|
||||
|
||||
const SourceContextIds &sourceContextIds() { return m_sourceContextIds; }
|
||||
const DirectoryPathIds &directoryPathIds() { return m_directoryPathIds; }
|
||||
|
||||
virtual void setCallback(std::function<void(const QmlDesigner::SourceContextIds &)> &&callback)
|
||||
virtual void setCallback(std::function<void(const QmlDesigner::DirectoryPathIds &)> &&callback)
|
||||
{
|
||||
if (connection)
|
||||
QObject::disconnect(connection);
|
||||
connection = QObject::connect(&m_timer, &Timer::timeout, [this, callback = std::move(callback)] {
|
||||
try {
|
||||
callback(m_sourceContextIds);
|
||||
m_sourceContextIds.clear();
|
||||
callback(m_directoryPathIds);
|
||||
m_directoryPathIds.clear();
|
||||
} catch (const std::exception &) {
|
||||
}
|
||||
});
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
SourceContextIds m_sourceContextIds;
|
||||
DirectoryPathIds m_directoryPathIds;
|
||||
QMetaObject::Connection connection;
|
||||
ConnectionGuard connectionGuard{connection};
|
||||
Timer m_timer;
|
||||
|
@@ -51,7 +51,7 @@ long long FileSystem::lastModified(SourceId sourceId) const
|
||||
FileStatus FileSystem::fileStatus(SourceId sourceId) const
|
||||
{
|
||||
auto path = sourceId.mainId() ? m_sourcePathCache.sourcePath(sourceId)
|
||||
: m_sourcePathCache.sourceContextPath(sourceId.contextId());
|
||||
: m_sourcePathCache.directoryPath(sourceId.contextId());
|
||||
QFileInfo fileInfo(QString{path});
|
||||
|
||||
fileInfo.refresh();
|
||||
|
@@ -1762,7 +1762,7 @@ Storage::Info::TypeHints ProjectStorage::typeHints(TypeId typeId) const
|
||||
return typeHints;
|
||||
}
|
||||
|
||||
SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(SourceContextId directoryId) const
|
||||
SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(DirectoryPathId directoryId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"get type annotaion source ids",
|
||||
@@ -1777,13 +1777,13 @@ SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(SourceContextId direct
|
||||
return sourceIds;
|
||||
}
|
||||
|
||||
SmallSourceContextIds<64> ProjectStorage::typeAnnotationDirectoryIds() const
|
||||
SmallDirectoryPathIds<64> ProjectStorage::typeAnnotationDirectoryIds() const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"get type annotaion source ids", projectStorageCategory()};
|
||||
|
||||
auto sourceIds = s->selectTypeAnnotationDirectoryIdsStatement
|
||||
.valuesWithTransaction<SmallSourceContextIds<64>>();
|
||||
.valuesWithTransaction<SmallDirectoryPathIds<64>>();
|
||||
|
||||
tracer.end(keyValue("source ids", sourceIds));
|
||||
|
||||
@@ -2226,7 +2226,7 @@ std::optional<Storage::Synchronization::DirectoryInfo> ProjectStorage::fetchDire
|
||||
return directoryInfo;
|
||||
}
|
||||
|
||||
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(SourceContextId directoryId) const
|
||||
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(DirectoryPathId directoryId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch directory infos by directory id",
|
||||
@@ -2243,7 +2243,7 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(Sou
|
||||
}
|
||||
|
||||
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
|
||||
SourceContextId directoryId, Storage::Synchronization::FileType fileType) const
|
||||
DirectoryPathId directoryId, Storage::Synchronization::FileType fileType) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch directory infos by source id and file type",
|
||||
@@ -2261,7 +2261,7 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
|
||||
}
|
||||
|
||||
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
|
||||
const SourceContextIds &directoryIds) const
|
||||
const DirectoryPathIds &directoryIds) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch directory infos by source ids",
|
||||
@@ -2277,7 +2277,7 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
|
||||
return directoryInfos;
|
||||
}
|
||||
|
||||
SmallSourceContextIds<32> ProjectStorage::fetchSubdirectoryIds(SourceContextId directoryId) const
|
||||
SmallDirectoryPathIds<32> ProjectStorage::fetchSubdirectoryIds(DirectoryPathId directoryId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch subdirectory source ids",
|
||||
@@ -2288,7 +2288,7 @@ SmallSourceContextIds<32> ProjectStorage::fetchSubdirectoryIds(SourceContextId d
|
||||
.rangeWithTransaction<SourceId>(directoryId,
|
||||
Storage::Synchronization::FileType::Directory);
|
||||
|
||||
SmallSourceContextIds<32> directoryIds;
|
||||
SmallDirectoryPathIds<32> directoryIds;
|
||||
for (SourceId sourceId : sourceIds)
|
||||
directoryIds.push_back(sourceId.contextId());
|
||||
|
||||
@@ -2609,7 +2609,7 @@ void ProjectStorage::synchronizeTypes(Storage::Synchronization::Types &types,
|
||||
}
|
||||
|
||||
void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::DirectoryInfos &directoryInfos,
|
||||
const SourceContextIds &updatedDirectoryInfoDirectoryIds)
|
||||
const DirectoryPathIds &updatedDirectoryInfoDirectoryIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize directory infos", projectStorageCategory()};
|
||||
|
||||
@@ -4057,13 +4057,13 @@ void ProjectStorage::addTypeIdToPropertyEditorQmlPaths(
|
||||
|
||||
void ProjectStorage::synchronizePropertyEditorPaths(
|
||||
Storage::Synchronization::PropertyEditorQmlPaths &paths,
|
||||
SourceContextIds updatedPropertyEditorQmlPathsSourceContextIds)
|
||||
DirectoryPathIds updatedPropertyEditorQmlPathsDirectoryPathIds)
|
||||
{
|
||||
using Storage::Synchronization::PropertyEditorQmlPath;
|
||||
std::ranges::sort(paths, {}, &PropertyEditorQmlPath::typeId);
|
||||
|
||||
auto range = s->selectPropertyEditorPathsForForSourceIdsStatement.range<PropertyEditorQmlPathView>(
|
||||
toIntegers(updatedPropertyEditorQmlPathsSourceContextIds));
|
||||
toIntegers(updatedPropertyEditorQmlPathsDirectoryPathIds));
|
||||
|
||||
auto compareKey = [](const PropertyEditorQmlPathView &view, const PropertyEditorQmlPath &value) {
|
||||
return view.typeId <=> value.typeId;
|
||||
@@ -4110,7 +4110,7 @@ void ProjectStorage::synchronizePropertyEditorPaths(
|
||||
|
||||
void ProjectStorage::synchronizePropertyEditorQmlPaths(
|
||||
Storage::Synchronization::PropertyEditorQmlPaths &paths,
|
||||
SourceContextIds updatedPropertyEditorQmlPathsSourceIds)
|
||||
DirectoryPathIds updatedPropertyEditorQmlPathsSourceIds)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"synchronize property editor qml paths", projectStorageCategory()};
|
||||
|
||||
|
@@ -105,9 +105,9 @@ public:
|
||||
|
||||
Storage::Info::TypeHints typeHints(TypeId typeId) const override;
|
||||
|
||||
SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const override;
|
||||
SmallSourceIds<4> typeAnnotationSourceIds(DirectoryPathId directoryId) const override;
|
||||
|
||||
SmallSourceContextIds<64> typeAnnotationDirectoryIds() const override;
|
||||
SmallDirectoryPathIds<64> typeAnnotationDirectoryIds() const override;
|
||||
|
||||
Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const override;
|
||||
Storage::Info::ItemLibraryEntries itemLibraryEntries(ImportId importId) const;
|
||||
@@ -220,11 +220,11 @@ public:
|
||||
|
||||
std::optional<Storage::Synchronization::DirectoryInfo> fetchDirectoryInfo(SourceId sourceId) const override;
|
||||
|
||||
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const override;
|
||||
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(DirectoryPathId directoryId) const override;
|
||||
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
|
||||
SourceContextId directoryId, Storage::Synchronization::FileType fileType) const override;
|
||||
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const SourceContextIds &directoryIds) const;
|
||||
SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const override;
|
||||
DirectoryPathId directoryId, Storage::Synchronization::FileType fileType) const override;
|
||||
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const DirectoryPathIds &directoryIds) const;
|
||||
SmallDirectoryPathIds<32> fetchSubdirectoryIds(DirectoryPathId directoryId) const override;
|
||||
|
||||
void setPropertyEditorPathId(TypeId typeId, SourceId pathId);
|
||||
|
||||
@@ -574,7 +574,7 @@ private:
|
||||
const SourceIds &updatedSourceIds);
|
||||
|
||||
void synchronizeDirectoryInfos(Storage::Synchronization::DirectoryInfos &directoryInfos,
|
||||
const SourceContextIds &updatedDirectoryInfoDirectoryIds);
|
||||
const DirectoryPathIds &updatedDirectoryInfoDirectoryIds);
|
||||
|
||||
void synchronizeFileStatuses(FileStatuses &fileStatuses, const SourceIds &updatedSourceIds);
|
||||
|
||||
@@ -789,7 +789,7 @@ private:
|
||||
class PropertyEditorQmlPathView
|
||||
{
|
||||
public:
|
||||
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, SourceContextId directoryId)
|
||||
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, DirectoryPathId directoryId)
|
||||
: typeId{typeId}
|
||||
, pathId{pathId}
|
||||
, directoryId{directoryId}
|
||||
@@ -811,14 +811,14 @@ private:
|
||||
public:
|
||||
TypeId typeId;
|
||||
SourceId pathId;
|
||||
SourceContextId directoryId;
|
||||
DirectoryPathId directoryId;
|
||||
};
|
||||
|
||||
void synchronizePropertyEditorPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
|
||||
SourceContextIds updatedPropertyEditorQmlPathsSourceContextIds);
|
||||
DirectoryPathIds updatedPropertyEditorQmlPathsDirectoryPathIds);
|
||||
|
||||
void synchronizePropertyEditorQmlPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
|
||||
SourceContextIds updatedPropertyEditorQmlPathsSourceIds);
|
||||
DirectoryPathIds updatedPropertyEditorQmlPathsSourceIds);
|
||||
|
||||
void synchronizeFunctionDeclarations(
|
||||
TypeId typeId, Storage::Synchronization::FunctionDeclarations &functionsDeclarations);
|
||||
|
@@ -58,8 +58,8 @@ public:
|
||||
= 0;
|
||||
virtual PropertyDeclarationId defaultPropertyDeclarationId(TypeId typeId) const = 0;
|
||||
virtual std::optional<Storage::Info::Type> type(TypeId typeId) const = 0;
|
||||
virtual SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const = 0;
|
||||
virtual SmallSourceContextIds<64> typeAnnotationDirectoryIds() const = 0;
|
||||
virtual SmallSourceIds<4> typeAnnotationSourceIds(DirectoryPathId directoryId) const = 0;
|
||||
virtual SmallDirectoryPathIds<64> typeAnnotationDirectoryIds() const = 0;
|
||||
virtual Utils::PathString typeIconPath(TypeId typeId) const = 0;
|
||||
virtual Storage::Info::TypeHints typeHints(TypeId typeId) const = 0;
|
||||
virtual Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const = 0;
|
||||
@@ -82,13 +82,13 @@ public:
|
||||
virtual bool isBasedOn(TypeId, TypeId, TypeId, TypeId, TypeId, TypeId, TypeId, TypeId) const = 0;
|
||||
|
||||
virtual FileStatus fetchFileStatus(SourceId sourceId) const = 0;
|
||||
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const = 0;
|
||||
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(DirectoryPathId directoryId) const = 0;
|
||||
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
|
||||
SourceContextId directoryId, Storage::Synchronization::FileType) const
|
||||
DirectoryPathId directoryId, Storage::Synchronization::FileType) const
|
||||
= 0;
|
||||
virtual std::optional<Storage::Synchronization::DirectoryInfo>
|
||||
fetchDirectoryInfo(SourceId sourceId) const = 0;
|
||||
virtual SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const = 0;
|
||||
virtual SmallDirectoryPathIds<32> fetchSubdirectoryIds(DirectoryPathId directoryId) const = 0;
|
||||
|
||||
virtual SourceId propertyEditorPathId(TypeId typeId) const = 0;
|
||||
virtual const Storage::Info::CommonTypeCache<ProjectStorageType> &commonTypeCache() const = 0;
|
||||
|
@@ -36,8 +36,8 @@ public:
|
||||
[&](const QString &path) { compressChangedDirectoryPath(path); });
|
||||
|
||||
m_directoryPathCompressor.setCallback(
|
||||
[&](const QmlDesigner::SourceContextIds &sourceContextIds) {
|
||||
addChangedPathForFilePath(sourceContextIds);
|
||||
[&](const QmlDesigner::DirectoryPathIds &directoryPathIds) {
|
||||
addChangedPathForFilePath(directoryPathIds);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
}
|
||||
|
||||
void updateContextIdPaths(const std::vector<IdPaths> &idPaths,
|
||||
const SourceContextIds &sourceContextIds) override
|
||||
const DirectoryPathIds &directoryPathIds) override
|
||||
{
|
||||
const auto &[entires, ids] = convertIdPathsToWatcherEntriesAndIds(idPaths);
|
||||
|
||||
@@ -62,19 +62,19 @@ public:
|
||||
|
||||
auto notContainsId = [&, &ids = ids](WatcherEntry entry) {
|
||||
return !std::ranges::binary_search(ids, entry.id)
|
||||
|| !std::ranges::binary_search(sourceContextIds, entry.sourceContextId);
|
||||
|| !std::ranges::binary_search(directoryPathIds, entry.directoryPathId);
|
||||
};
|
||||
|
||||
removeUnusedEntries(entires, notContainsId);
|
||||
}
|
||||
|
||||
void checkForChangeInDirectory(SourceContextIds sourceContextIds) override
|
||||
void checkForChangeInDirectory(DirectoryPathIds directoryPathIds) override
|
||||
{
|
||||
std::ranges::sort(sourceContextIds);
|
||||
auto removed = std::ranges::unique(sourceContextIds);
|
||||
sourceContextIds.erase(removed.begin(), removed.end());
|
||||
std::ranges::sort(directoryPathIds);
|
||||
auto removed = std::ranges::unique(directoryPathIds);
|
||||
directoryPathIds.erase(removed.begin(), removed.end());
|
||||
|
||||
addChangedPathForFilePath(sourceContextIds);
|
||||
addChangedPathForFilePath(directoryPathIds);
|
||||
}
|
||||
|
||||
void removeIds(const ProjectPartIds &ids) override
|
||||
@@ -158,23 +158,23 @@ public:
|
||||
|
||||
FileSystemWatcher &fileSystemWatcher() { return m_fileSystemWatcher; }
|
||||
|
||||
QStringList convertWatcherEntriesToDirectoryPathList(const SourceContextIds &sourceContextIds) const
|
||||
QStringList convertWatcherEntriesToDirectoryPathList(const DirectoryPathIds &directoryPathIds) const
|
||||
{
|
||||
return Utils::transform<QStringList>(sourceContextIds, [&](SourceContextId id) {
|
||||
return QString(m_pathCache.sourceContextPath(id));
|
||||
return Utils::transform<QStringList>(directoryPathIds, [&](DirectoryPathId id) {
|
||||
return QString(m_pathCache.directoryPath(id));
|
||||
});
|
||||
}
|
||||
|
||||
QStringList convertWatcherEntriesToDirectoryPathList(const WatcherEntries &watcherEntries) const
|
||||
{
|
||||
SourceContextIds sourceContextIds = Utils::transform<SourceContextIds>(
|
||||
watcherEntries, &WatcherEntry::sourceContextId);
|
||||
DirectoryPathIds directoryPathIds = Utils::transform<DirectoryPathIds>(
|
||||
watcherEntries, &WatcherEntry::directoryPathId);
|
||||
|
||||
std::ranges::sort(sourceContextIds);
|
||||
auto removed = std::ranges::unique(sourceContextIds);
|
||||
sourceContextIds.erase(removed.begin(), removed.end());
|
||||
std::ranges::sort(directoryPathIds);
|
||||
auto removed = std::ranges::unique(directoryPathIds);
|
||||
directoryPathIds.erase(removed.begin(), removed.end());
|
||||
|
||||
return convertWatcherEntriesToDirectoryPathList(sourceContextIds);
|
||||
return convertWatcherEntriesToDirectoryPathList(directoryPathIds);
|
||||
}
|
||||
|
||||
WatcherEntries notWatchedEntries(const WatcherEntries &entries) const
|
||||
@@ -187,9 +187,9 @@ public:
|
||||
return notWatchedEntries;
|
||||
}
|
||||
|
||||
SourceContextIds notWatchedPaths(const SourceContextIds &ids) const
|
||||
DirectoryPathIds notWatchedPaths(const DirectoryPathIds &ids) const
|
||||
{
|
||||
SourceContextIds notWatchedDirectoryIds;
|
||||
DirectoryPathIds notWatchedDirectoryIds;
|
||||
notWatchedDirectoryIds.reserve(ids.size());
|
||||
|
||||
std::ranges::set_difference(ids, m_watchedEntries, std::back_inserter(notWatchedDirectoryIds));
|
||||
@@ -231,20 +231,20 @@ public:
|
||||
m_watchedEntries = std::move(newWatchedEntries);
|
||||
}
|
||||
|
||||
static SourceContextIds uniquePaths(const WatcherEntries &pathEntries)
|
||||
static DirectoryPathIds uniquePaths(const WatcherEntries &pathEntries)
|
||||
{
|
||||
SourceContextIds uniqueDirectoryIds;
|
||||
DirectoryPathIds uniqueDirectoryIds;
|
||||
uniqueDirectoryIds.reserve(pathEntries.size());
|
||||
|
||||
std::ranges::unique_copy(pathEntries,
|
||||
std::back_inserter(uniqueDirectoryIds),
|
||||
{},
|
||||
&WatcherEntry::sourceContextId);
|
||||
&WatcherEntry::directoryPathId);
|
||||
|
||||
return uniqueDirectoryIds;
|
||||
}
|
||||
|
||||
SourceContextIds filterNotWatchedPaths(const WatcherEntries &entries) const
|
||||
DirectoryPathIds filterNotWatchedPaths(const WatcherEntries &entries) const
|
||||
{
|
||||
return notWatchedPaths(uniquePaths(entries));
|
||||
}
|
||||
@@ -278,18 +278,18 @@ public:
|
||||
|
||||
void compressChangedDirectoryPath(const QString &path)
|
||||
{
|
||||
m_directoryPathCompressor.addSourceContextId(
|
||||
m_pathCache.sourceContextId(Utils::PathString{path}));
|
||||
m_directoryPathCompressor.addDirectoryPathId(
|
||||
m_pathCache.directoryPathId(Utils::PathString{path}));
|
||||
}
|
||||
|
||||
WatcherEntries watchedEntriesForPaths(const QmlDesigner::SourceContextIds &sourceContextIds)
|
||||
WatcherEntries watchedEntriesForPaths(const QmlDesigner::DirectoryPathIds &directoryPathIds)
|
||||
{
|
||||
WatcherEntries foundEntries;
|
||||
foundEntries.reserve(m_watchedEntries.size());
|
||||
|
||||
Utils::set_greedy_intersection(
|
||||
m_watchedEntries,
|
||||
sourceContextIds,
|
||||
directoryPathIds,
|
||||
[&](WatcherEntry &entry) {
|
||||
m_fileStatusCache.update(entry.sourceId);
|
||||
auto fileStatus = m_fileStatusCache.find(entry.sourceId);
|
||||
@@ -300,7 +300,7 @@ public:
|
||||
}
|
||||
},
|
||||
{},
|
||||
&WatcherEntry::sourceContextId);
|
||||
&WatcherEntry::directoryPathId);
|
||||
|
||||
return foundEntries;
|
||||
}
|
||||
@@ -339,10 +339,10 @@ public:
|
||||
return idPaths;
|
||||
}
|
||||
|
||||
void addChangedPathForFilePath(const SourceContextIds &sourceContextIds)
|
||||
void addChangedPathForFilePath(const DirectoryPathIds &directoryPathIds)
|
||||
{
|
||||
if (m_notifier) {
|
||||
WatcherEntries foundEntries = watchedEntriesForPaths(sourceContextIds);
|
||||
WatcherEntries foundEntries = watchedEntriesForPaths(directoryPathIds);
|
||||
|
||||
SourceIds watchedSourceIds = watchedPaths(foundEntries);
|
||||
|
||||
|
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
virtual void updateIdPaths(const std::vector<IdPaths> &idPaths) = 0;
|
||||
virtual void updateContextIdPaths(const std::vector<IdPaths> &idPaths,
|
||||
const SourceContextIds &sourceContextIds)
|
||||
const DirectoryPathIds &directoryPathIds)
|
||||
= 0;
|
||||
virtual void removeIds(const ProjectPartIds &ids) = 0;
|
||||
|
||||
|
@@ -100,26 +100,26 @@ class WatcherEntry
|
||||
{
|
||||
public:
|
||||
ProjectChunkId id;
|
||||
SourceContextId sourceContextId;
|
||||
DirectoryPathId directoryPathId;
|
||||
SourceId sourceId;
|
||||
long long lastModified = -1;
|
||||
long long size = -1;
|
||||
|
||||
friend bool operator==(WatcherEntry first, WatcherEntry second)
|
||||
{
|
||||
return first.id == second.id && first.sourceContextId == second.sourceContextId
|
||||
return first.id == second.id && first.directoryPathId == second.directoryPathId
|
||||
&& first.sourceId == second.sourceId;
|
||||
}
|
||||
|
||||
friend std::weak_ordering operator<=>(const WatcherEntry &first, const WatcherEntry &second)
|
||||
{
|
||||
return std::tie(first.sourceContextId, first.sourceId, first.id)
|
||||
<=> std::tie(second.sourceContextId, second.sourceId, second.id);
|
||||
return std::tie(first.directoryPathId, first.sourceId, first.id)
|
||||
<=> std::tie(second.directoryPathId, second.sourceId, second.id);
|
||||
}
|
||||
|
||||
operator SourceId() const { return sourceId; }
|
||||
|
||||
operator SourceContextId() const { return sourceContextId; }
|
||||
operator DirectoryPathId() const { return directoryPathId; }
|
||||
};
|
||||
|
||||
using WatcherEntries = std::vector<WatcherEntry>;
|
||||
|
@@ -14,7 +14,7 @@ public:
|
||||
ProjectStorageTriggerUpdateInterface(const ProjectStorageTriggerUpdateInterface &) = delete;
|
||||
ProjectStorageTriggerUpdateInterface &operator=(const ProjectStorageTriggerUpdateInterface &) = delete;
|
||||
|
||||
virtual void checkForChangeInDirectory(SourceContextIds sourceContextIds) = 0;
|
||||
virtual void checkForChangeInDirectory(DirectoryPathIds directoryPathIds) = 0;
|
||||
|
||||
protected:
|
||||
~ProjectStorageTriggerUpdateInterface() = default;
|
||||
|
@@ -1154,7 +1154,7 @@ public:
|
||||
PropertyEditorQmlPath(ModuleId moduleId,
|
||||
TypeNameString typeName,
|
||||
SourceId pathId,
|
||||
SourceContextId directoryId)
|
||||
DirectoryPathId directoryId)
|
||||
: typeName{typeName}
|
||||
, pathId{pathId}
|
||||
, directoryId{directoryId}
|
||||
@@ -1179,7 +1179,7 @@ public:
|
||||
TypeNameString typeName;
|
||||
TypeId typeId;
|
||||
SourceId pathId;
|
||||
SourceContextId directoryId;
|
||||
DirectoryPathId directoryId;
|
||||
ModuleId moduleId;
|
||||
};
|
||||
|
||||
@@ -1188,7 +1188,7 @@ using PropertyEditorQmlPaths = std::vector<class PropertyEditorQmlPath>;
|
||||
class DirectoryInfo
|
||||
{
|
||||
public:
|
||||
DirectoryInfo(SourceContextId directoryId, SourceId sourceId, ModuleId moduleId, FileType fileType)
|
||||
DirectoryInfo(DirectoryPathId directoryId, SourceId sourceId, ModuleId moduleId, FileType fileType)
|
||||
: directoryId{directoryId}
|
||||
, sourceId{sourceId}
|
||||
, moduleId{moduleId}
|
||||
@@ -1216,7 +1216,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
SourceContextId directoryId;
|
||||
DirectoryPathId directoryId;
|
||||
SourceId sourceId;
|
||||
ModuleId moduleId;
|
||||
FileType fileType;
|
||||
@@ -1227,13 +1227,13 @@ using DirectoryInfos = std::vector<DirectoryInfo>;
|
||||
class TypeAnnotation
|
||||
{
|
||||
public:
|
||||
TypeAnnotation(SourceId sourceId, SourceContextId directoryId)
|
||||
TypeAnnotation(SourceId sourceId, DirectoryPathId directoryId)
|
||||
: sourceId{sourceId}
|
||||
, directoryId{directoryId}
|
||||
{}
|
||||
|
||||
TypeAnnotation(SourceId sourceId,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Utils::SmallStringView typeName,
|
||||
ModuleId moduleId,
|
||||
Utils::SmallStringView iconPath,
|
||||
@@ -1274,7 +1274,7 @@ public:
|
||||
SourceId sourceId;
|
||||
ModuleId moduleId;
|
||||
TypeTraits traits;
|
||||
SourceContextId directoryId;
|
||||
DirectoryPathId directoryId;
|
||||
};
|
||||
|
||||
using TypeAnnotations = std::vector<TypeAnnotation>;
|
||||
@@ -1314,7 +1314,7 @@ public:
|
||||
, fileStatuses(std::move(fileStatuses))
|
||||
{}
|
||||
|
||||
SynchronizationPackage(SourceContextIds updatedDirectoryInfoDirectoryIds,
|
||||
SynchronizationPackage(DirectoryPathIds updatedDirectoryInfoDirectoryIds,
|
||||
DirectoryInfos directoryInfos)
|
||||
: directoryInfos(std::move(directoryInfos))
|
||||
, updatedDirectoryInfoDirectoryIds(std::move(updatedDirectoryInfoDirectoryIds))
|
||||
@@ -1327,13 +1327,13 @@ public:
|
||||
SourceIds updatedFileStatusSourceIds;
|
||||
FileStatuses fileStatuses;
|
||||
DirectoryInfos directoryInfos;
|
||||
SourceContextIds updatedDirectoryInfoDirectoryIds;
|
||||
DirectoryPathIds updatedDirectoryInfoDirectoryIds;
|
||||
Imports moduleDependencies;
|
||||
SourceIds updatedModuleDependencySourceIds;
|
||||
ModuleExportedImports moduleExportedImports;
|
||||
ModuleIds updatedModuleIds;
|
||||
PropertyEditorQmlPaths propertyEditorQmlPaths;
|
||||
SourceContextIds updatedPropertyEditorQmlPathDirectoryIds;
|
||||
DirectoryPathIds updatedPropertyEditorQmlPathDirectoryIds;
|
||||
TypeAnnotations typeAnnotations;
|
||||
SourceIds updatedTypeAnnotationSourceIds;
|
||||
};
|
||||
|
@@ -417,8 +417,8 @@ void ProjectStorageUpdater::updateDirectoryChanged(Utils::SmallStringView direct
|
||||
FileState annotationDirectoryState,
|
||||
SourcePath qmldirSourcePath,
|
||||
SourceId qmldirSourceId,
|
||||
SourceContextId directoryId,
|
||||
SourceContextId annotationDirectoryId,
|
||||
DirectoryPathId directoryId,
|
||||
DirectoryPathId annotationDirectoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -513,9 +513,9 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
|
||||
}
|
||||
|
||||
void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &directoryPath,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
FileState directoryState,
|
||||
const SourceContextIds &subdirectoriesToIgnore,
|
||||
const DirectoryPathIds &subdirectoriesToIgnore,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -523,35 +523,35 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
|
||||
{
|
||||
struct Directory
|
||||
{
|
||||
Directory(Utils::SmallStringView path, SourceContextId sourceContextId)
|
||||
Directory(Utils::SmallStringView path, DirectoryPathId directoryPathId)
|
||||
: path{path}
|
||||
, sourceContextId{sourceContextId}
|
||||
, directoryPathId{directoryPathId}
|
||||
{}
|
||||
|
||||
Utils::PathString path;
|
||||
SourceContextId sourceContextId;
|
||||
DirectoryPathId directoryPathId;
|
||||
};
|
||||
|
||||
using Directories = QVarLengthArray<Directory, 32>;
|
||||
|
||||
auto subdirectoryIds = m_projectStorage.fetchSubdirectoryIds(directoryId);
|
||||
auto subdirectories = Utils::transform<Directories>(
|
||||
subdirectoryIds, [&](SourceContextId sourceContextId) -> Directory {
|
||||
auto subdirectoryPath = m_pathCache.sourceContextPath(sourceContextId);
|
||||
return {subdirectoryPath, sourceContextId};
|
||||
subdirectoryIds, [&](DirectoryPathId directoryPathId) -> Directory {
|
||||
auto subdirectoryPath = m_pathCache.directoryPath(directoryPathId);
|
||||
return {subdirectoryPath, directoryPathId};
|
||||
});
|
||||
|
||||
auto exisitingSubdirectoryPaths = m_fileSystem.subdirectories(directoryPath.toQString());
|
||||
Directories existingSubdirecories;
|
||||
|
||||
auto skipDirectory = [&](std::string_view subdirectoryPath, SourceContextId sourceContextId) {
|
||||
auto skipDirectory = [&](std::string_view subdirectoryPath, DirectoryPathId directoryPathId) {
|
||||
if (subdirectoryPath.ends_with("designer"))
|
||||
return true;
|
||||
|
||||
if (isInsideProject == IsInsideProject::Yes) {
|
||||
static SourceNameId ignoreInQdsSourceNameId = m_pathCache.sourceNameId("ignore-in-qds");
|
||||
static FileNameId ignoreInQdsFileNameId = m_pathCache.fileNameId("ignore-in-qds");
|
||||
|
||||
SourceId ignoreInQdsSourceId = SourceId::create(ignoreInQdsSourceNameId, sourceContextId);
|
||||
SourceId ignoreInQdsSourceId = SourceId::create(ignoreInQdsFileNameId, directoryPathId);
|
||||
|
||||
auto ignoreInQdsState = fileState(ignoreInQdsSourceId, package, notUpdatedSourceIds);
|
||||
|
||||
@@ -567,17 +567,17 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
|
||||
};
|
||||
|
||||
for (Utils::PathString subdirectoryPath : exisitingSubdirectoryPaths) {
|
||||
SourceContextId sourceContextId = m_pathCache.sourceContextId(subdirectoryPath);
|
||||
DirectoryPathId directoryPathId = m_pathCache.directoryPathId(subdirectoryPath);
|
||||
|
||||
if (skipDirectory(subdirectoryPath, sourceContextId))
|
||||
if (skipDirectory(subdirectoryPath, directoryPathId))
|
||||
continue;
|
||||
|
||||
subdirectories.emplace_back(subdirectoryPath, sourceContextId);
|
||||
existingSubdirecories.emplace_back(subdirectoryPath, sourceContextId);
|
||||
subdirectories.emplace_back(subdirectoryPath, directoryPathId);
|
||||
existingSubdirecories.emplace_back(subdirectoryPath, directoryPathId);
|
||||
}
|
||||
|
||||
std::ranges::sort(subdirectories, {}, &Directory::sourceContextId);
|
||||
auto removed = std::ranges::unique(subdirectories, {}, &Directory::sourceContextId);
|
||||
std::ranges::sort(subdirectories, {}, &Directory::directoryPathId);
|
||||
auto removed = std::ranges::unique(subdirectories, {}, &Directory::directoryPathId);
|
||||
subdirectories.erase(removed.begin(), removed.end());
|
||||
|
||||
auto updateDirectory = [&](const Directory &subdirectory) {
|
||||
@@ -593,12 +593,12 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
|
||||
subdirectoriesToIgnore,
|
||||
updateDirectory,
|
||||
{},
|
||||
&Directory::sourceContextId);
|
||||
&Directory::directoryPathId);
|
||||
|
||||
if (isChangedOrAdded(directoryState)) {
|
||||
for (const auto &[subdirectoryPath, subdirectoryId] : existingSubdirecories) {
|
||||
package.directoryInfos.emplace_back(directoryId,
|
||||
SourceId::create(SourceNameId{}, subdirectoryId),
|
||||
SourceId::create(FileNameId{}, subdirectoryId),
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::Directory);
|
||||
}
|
||||
@@ -607,8 +607,8 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
|
||||
|
||||
void ProjectStorageUpdater::annotationDirectoryChanged(
|
||||
Utils::SmallStringView directoryPath,
|
||||
SourceContextId directoryId,
|
||||
SourceContextId annotationDirectoryId,
|
||||
DirectoryPathId directoryId,
|
||||
DirectoryPathId annotationDirectoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package)
|
||||
{
|
||||
@@ -624,7 +624,7 @@ void ProjectStorageUpdater::annotationDirectoryChanged(
|
||||
|
||||
void ProjectStorageUpdater::updatePropertyEditorFiles(
|
||||
Utils::SmallStringView directoryPath,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package)
|
||||
{
|
||||
@@ -643,7 +643,7 @@ void ProjectStorageUpdater::updatePropertyEditorFiles(
|
||||
|
||||
void ProjectStorageUpdater::updatePropertyEditorFile(
|
||||
const QString &fileName,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package)
|
||||
{
|
||||
@@ -659,7 +659,7 @@ void ProjectStorageUpdater::updatePropertyEditorFile(
|
||||
}
|
||||
|
||||
void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPath,
|
||||
const SourceContextIds &subdirectoriesToIgnore,
|
||||
const DirectoryPathIds &subdirectoriesToIgnore,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -669,18 +669,18 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
|
||||
|
||||
SourcePath qmldirPath{directoryPath + "/qmldir"};
|
||||
SourceId qmldirSourceId = m_pathCache.sourceId(qmldirPath);
|
||||
SourceContextId directoryId = qmldirSourceId.contextId();
|
||||
DirectoryPathId directoryId = qmldirSourceId.contextId();
|
||||
|
||||
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
|
||||
if (isExisting(directoryState))
|
||||
WatchedSourceIds.directoryIds.push_back(SourceId::create(SourceNameId{}, directoryId));
|
||||
WatchedSourceIds.directoryIds.push_back(SourceId::create(FileNameId{}, directoryId));
|
||||
|
||||
auto qmldirState = fileState(qmldirSourceId, package, notUpdatedSourceIds);
|
||||
if (isExisting(qmldirState))
|
||||
WatchedSourceIds.qmldirSourceIds.push_back(qmldirSourceId);
|
||||
|
||||
SourcePath annotationDirectoryPath{directoryPath + "/designer"};
|
||||
auto annotationDirectoryId = m_pathCache.sourceContextId(annotationDirectoryPath);
|
||||
auto annotationDirectoryId = m_pathCache.directoryPathId(annotationDirectoryPath);
|
||||
auto annotationDirectoryState = fileState(annotationDirectoryId, package, notUpdatedSourceIds);
|
||||
|
||||
switch (combineState(directoryState, qmldirState, annotationDirectoryState)) {
|
||||
@@ -765,7 +765,7 @@ void ProjectStorageUpdater::updatePropertyEditorPaths(
|
||||
while (dirIterator.hasNext()) {
|
||||
auto pathInfo = dirIterator.nextFileInfo();
|
||||
|
||||
SourceContextId directoryId = m_pathCache.sourceContextId(
|
||||
DirectoryPathId directoryId = m_pathCache.directoryPathId(
|
||||
Utils::PathString{pathInfo.filePath()});
|
||||
|
||||
auto state = fileState(directoryId, package, notUpdatedSourceIds);
|
||||
@@ -798,9 +798,9 @@ void ProjectStorageUpdater::updateTypeAnnotations(const QStringList &directoryPa
|
||||
{
|
||||
NanotraceHR::Tracer tracer("update type annotations", category());
|
||||
|
||||
std::map<SourceContextId, SmallSourceIds<16>> updatedSourceIdsDictonary;
|
||||
std::map<DirectoryPathId, SmallSourceIds<16>> updatedSourceIdsDictonary;
|
||||
|
||||
for (SourceContextId directoryId : m_projectStorage.typeAnnotationDirectoryIds())
|
||||
for (DirectoryPathId directoryId : m_projectStorage.typeAnnotationDirectoryIds())
|
||||
updatedSourceIdsDictonary[directoryId] = {};
|
||||
|
||||
for (const auto &directoryPath : directoryPaths)
|
||||
@@ -813,7 +813,7 @@ void ProjectStorageUpdater::updateTypeAnnotations(
|
||||
const QString &rootDirectoryPath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
|
||||
std::map<DirectoryPathId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
|
||||
{
|
||||
NanotraceHR::Tracer tracer("update type annotation directory",
|
||||
category(),
|
||||
@@ -834,7 +834,7 @@ void ProjectStorageUpdater::updateTypeAnnotations(
|
||||
|
||||
auto directoryPath = fileInfo.canonicalPath();
|
||||
|
||||
SourceContextId directoryId = m_pathCache.sourceContextId(Utils::PathString{directoryPath});
|
||||
DirectoryPathId directoryId = m_pathCache.directoryPathId(Utils::PathString{directoryPath});
|
||||
|
||||
auto state = fileState(sourceId, package, notUpdatedSourceIds);
|
||||
if (isChangedOrAdded(state))
|
||||
@@ -848,7 +848,7 @@ void ProjectStorageUpdater::updateTypeAnnotations(
|
||||
void ProjectStorageUpdater::updateTypeAnnotationDirectories(
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
|
||||
std::map<DirectoryPathId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
|
||||
{
|
||||
for (auto &[directoryId, updatedSourceIds] : updatedSourceIdsDictonary) {
|
||||
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
|
||||
@@ -886,7 +886,7 @@ QString contentFromFile(const QString &path)
|
||||
void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
|
||||
const QString &filePath,
|
||||
SourceId sourceId,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"update type annotation path",
|
||||
@@ -909,7 +909,7 @@ void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
|
||||
void ProjectStorageUpdater::updatePropertyEditorPath(
|
||||
const QString &directoryPath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
long long pathOffset)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"update property editor path",
|
||||
@@ -929,7 +929,7 @@ void ProjectStorageUpdater::updatePropertyEditorPath(
|
||||
void ProjectStorageUpdater::updatePropertyEditorFilePath(
|
||||
const QString &path,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
long long pathOffset)
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"update property editor file path",
|
||||
@@ -960,15 +960,15 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
|
||||
}
|
||||
|
||||
namespace {
|
||||
SourceContextIds filterUniqueSourceContextIds(const SourceIds &sourceIds)
|
||||
DirectoryPathIds filterUniqueDirectoryPathIds(const SourceIds &sourceIds)
|
||||
{
|
||||
auto sourceContextIds = Utils::transform(sourceIds, &SourceId::contextId);
|
||||
auto directoryPathIds = Utils::transform(sourceIds, &SourceId::contextId);
|
||||
|
||||
std::sort(sourceContextIds.begin(), sourceContextIds.end());
|
||||
auto newEnd = std::unique(sourceContextIds.begin(), sourceContextIds.end());
|
||||
sourceContextIds.erase(newEnd, sourceContextIds.end());
|
||||
std::sort(directoryPathIds.begin(), directoryPathIds.end());
|
||||
auto newEnd = std::unique(directoryPathIds.begin(), directoryPathIds.end());
|
||||
directoryPathIds.erase(newEnd, directoryPathIds.end());
|
||||
|
||||
return sourceContextIds;
|
||||
return directoryPathIds;
|
||||
}
|
||||
|
||||
SourceIds filterUniqueSourceIds(SourceIds sourceIds)
|
||||
@@ -1049,9 +1049,9 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
|
||||
auto updateDirectory = [&](const SourceIds &directorySourceIds,
|
||||
WatchedSourceIds &watchedSourceIds) {
|
||||
auto directoryIds = filterUniqueSourceContextIds(directorySourceIds);
|
||||
auto directoryIds = filterUniqueDirectoryPathIds(directorySourceIds);
|
||||
for (auto directoryId : directoryIds) {
|
||||
Utils::PathString directory = m_pathCache.sourceContextPath(directoryId);
|
||||
Utils::PathString directory = m_pathCache.directoryPath(directoryId);
|
||||
this->updateDirectory(directory,
|
||||
directoryIds,
|
||||
package,
|
||||
@@ -1067,7 +1067,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
auto projectDirectoryIds = updateDirectory(project.directory, watchedProjectSourceIds);
|
||||
|
||||
auto parseQmlComponent = [&](SourceIds qmlDocumentSourceIds,
|
||||
const SourceContextIds &directoryIds,
|
||||
const DirectoryPathIds &directoryIds,
|
||||
IsInsideProject isInsideProject) {
|
||||
for (SourceId sourceId : filterUniqueSourceIds(std::move(qmlDocumentSourceIds))) {
|
||||
if (!contains(directoryIds, sourceId.contextId()))
|
||||
@@ -1079,7 +1079,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
parseQmlComponent(std::move(project.qmlDocument), projectDirectoryIds, IsInsideProject::Yes);
|
||||
|
||||
auto parseTypeInfo = [&](SourceIds qmltypesSourceIds,
|
||||
const SourceContextIds &directoryIds,
|
||||
const DirectoryPathIds &directoryIds,
|
||||
IsInsideProject isInsideProject) {
|
||||
for (SourceId sourceId : filterUniqueSourceIds(std::move(qmltypesSourceIds))) {
|
||||
if (!contains(directoryIds, sourceId.contextId())) {
|
||||
@@ -1116,7 +1116,7 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
|
||||
|
||||
auto directoryIdsSize = projectDirectoryIds.size() + qtDirectoryIds.size();
|
||||
if (directoryIdsSize > 0) {
|
||||
SourceContextIds directoryIds;
|
||||
DirectoryPathIds directoryIds;
|
||||
std::vector<IdPaths> newIdPaths;
|
||||
idPaths.reserve(8);
|
||||
appendIdPaths(std::move(watchedQtSourceIds), m_qtPartId, newIdPaths);
|
||||
@@ -1135,7 +1135,7 @@ void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
|
||||
void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
|
||||
const std::vector<Utils::PathString> &qmldirDependencies,
|
||||
const std::vector<Utils::PathString> &qmldirImports,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
const QString &directoryPath,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
@@ -1258,7 +1258,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Direct
|
||||
void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFilePath,
|
||||
Utils::SmallStringView directoryPath,
|
||||
Storage::Synchronization::ExportedTypes exportedTypes,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &watchedSourceIds,
|
||||
@@ -1426,7 +1426,7 @@ Storage::Synchronization::ExportedTypes createExportedTypes(ProjectStorageUpdate
|
||||
} // namespace
|
||||
|
||||
void ProjectStorageUpdater::parseQmlComponents(Components components,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -1442,7 +1442,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
|
||||
std::ranges::sort(components,
|
||||
[](auto &&first, auto &&second) { return first.fileName < second.fileName; });
|
||||
|
||||
auto directoryPath = m_pathCache.sourceContextPath(directoryId);
|
||||
auto directoryPath = m_pathCache.directoryPath(directoryId);
|
||||
|
||||
auto callback = [&](ComponentRange componentsWithSameFileName) {
|
||||
const auto &firstComponent = *componentsWithSameFileName.begin();
|
||||
@@ -1511,11 +1511,11 @@ ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
|
||||
}
|
||||
|
||||
ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
|
||||
SourceContextId sourceContextId,
|
||||
DirectoryPathId directoryPathId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds) const
|
||||
{
|
||||
auto sourceId = SourceId::create(SourceNameId{}, sourceContextId);
|
||||
auto sourceId = SourceId::create(FileNameId{}, directoryPathId);
|
||||
return fileState(sourceId, package, notUpdatedSourceIds);
|
||||
}
|
||||
|
||||
|
@@ -142,15 +142,15 @@ private:
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds);
|
||||
void updateDirectory(const Utils::PathString &directory,
|
||||
const SourceContextIds &subdirecoriesToIgnore,
|
||||
const DirectoryPathIds &subdirecoriesToIgnore,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
IsInsideProject isInsideProject);
|
||||
void updateSubdirectories(const Utils::PathString &directory,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
FileState directoryFileState,
|
||||
const SourceContextIds &subdirecoriesToIgnore,
|
||||
const DirectoryPathIds &subdirecoriesToIgnore,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -161,24 +161,24 @@ private:
|
||||
FileState annotationDirectoryState,
|
||||
SourcePath qmldirSourcePath,
|
||||
SourceId qmldirSourceId,
|
||||
SourceContextId directoryId,
|
||||
SourceContextId annotationDirectoryId,
|
||||
DirectoryPathId directoryId,
|
||||
DirectoryPathId annotationDirectoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
IsInsideProject isInsideProject,
|
||||
ProjectStorageTracing::Category::TracerType &tracer);
|
||||
void annotationDirectoryChanged(Utils::SmallStringView directoryPath,
|
||||
SourceContextId directoryId,
|
||||
SourceContextId annotationDirectoryId,
|
||||
DirectoryPathId directoryId,
|
||||
DirectoryPathId annotationDirectoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package);
|
||||
void updatePropertyEditorFiles(Utils::SmallStringView directyPath,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package);
|
||||
void updatePropertyEditorFile(const QString &fileName,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package);
|
||||
void updatePropertyEditorPaths(const QString &propertyEditorResourcesPath,
|
||||
@@ -187,31 +187,31 @@ private:
|
||||
void updateTypeAnnotations(const QString &directoryPath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
|
||||
std::map<DirectoryPathId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
|
||||
void updateTypeAnnotationDirectories(
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
|
||||
std::map<DirectoryPathId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
|
||||
void updateTypeAnnotations(const QStringList &directoryPath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds);
|
||||
void updateTypeAnnotation(const QString &directoryPath,
|
||||
const QString &filePath,
|
||||
SourceId sourceId,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package);
|
||||
void updatePropertyEditorPath(const QString &path,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
long long pathOffset);
|
||||
void updatePropertyEditorFilePath(const QString &filePath,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
long long pathOffset);
|
||||
void parseTypeInfos(const QStringList &typeInfos,
|
||||
const std::vector<Utils::PathString> &qmldirDependencies,
|
||||
const std::vector<Utils::PathString> &qmldirImports,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
const QString &directoryPath,
|
||||
ModuleId moduleId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
IsInsideProject isInsideProject);
|
||||
void parseQmlComponents(Components components,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -239,7 +239,7 @@ private:
|
||||
void parseQmlComponent(Utils::SmallStringView fileName,
|
||||
Utils::SmallStringView directory,
|
||||
Storage::Synchronization::ExportedTypes exportedTypes,
|
||||
SourceContextId directoryId,
|
||||
DirectoryPathId directoryId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds,
|
||||
WatchedSourceIds &WatchedSourceIds,
|
||||
@@ -254,7 +254,7 @@ private:
|
||||
FileState fileState(SourceId sourceId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds) const;
|
||||
FileState fileState(SourceContextId sourceContextId,
|
||||
FileState fileState(DirectoryPathId directoryPathId,
|
||||
Storage::Synchronization::SynchronizationPackage &package,
|
||||
NotUpdatedSourceIds ¬UpdatedSourceIds) const;
|
||||
|
||||
|
@@ -28,7 +28,7 @@ constexpr auto extraFileElementName = "ExtraFile"_L1;
|
||||
} // namespace
|
||||
|
||||
Synchronization::TypeAnnotations TypeAnnotationReader::parseTypeAnnotation(
|
||||
const QString &content, const QString &directoryPath, SourceId sourceId, SourceContextId directoryId)
|
||||
const QString &content, const QString &directoryPath, SourceId sourceId, DirectoryPathId directoryId)
|
||||
{
|
||||
m_sourceId = sourceId;
|
||||
m_directoryId = directoryId;
|
||||
|
@@ -50,7 +50,7 @@ public:
|
||||
Synchronization::TypeAnnotations parseTypeAnnotation(const QString &content,
|
||||
const QString &directoryPath,
|
||||
SourceId sourceId,
|
||||
SourceContextId directoryId);
|
||||
DirectoryPathId directoryId);
|
||||
|
||||
QStringList errors();
|
||||
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
json m_itemLibraryEntries;
|
||||
Property m_currentProperty;
|
||||
SourceId m_sourceId;
|
||||
SourceContextId m_directoryId;
|
||||
DirectoryPathId m_directoryId;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner::Storage
|
||||
|
@@ -31,8 +31,8 @@ class SourcePathCache final : public SourcePathCacheInterface
|
||||
|
||||
public:
|
||||
SourcePathCache(Storage &storage)
|
||||
: m_sourceContextStorageAdapter{storage}
|
||||
, m_sourceNameStorageAdapter{storage}
|
||||
: m_directoryPathStorageAdapter{storage}
|
||||
, m_fileNameStorageAdapter{storage}
|
||||
|
||||
{
|
||||
populateIfEmpty();
|
||||
@@ -43,44 +43,44 @@ public:
|
||||
|
||||
void populateIfEmpty() override
|
||||
{
|
||||
if (m_sourceNameCache.isEmpty()) {
|
||||
m_sourceContextPathCache.populate();
|
||||
m_sourceNameCache.populate();
|
||||
if (m_fileNameCache.isEmpty()) {
|
||||
m_directoryPathCache.populate();
|
||||
m_fileNameCache.populate();
|
||||
}
|
||||
}
|
||||
|
||||
SourceId sourceId(SourcePathView sourcePath) const override
|
||||
{
|
||||
Utils::SmallStringView sourceContextPath = sourcePath.directory();
|
||||
Utils::SmallStringView directoryPath = sourcePath.directory();
|
||||
|
||||
auto sourceContextId = m_sourceContextPathCache.id(sourceContextPath);
|
||||
auto directoryPathId = m_directoryPathCache.id(directoryPath);
|
||||
|
||||
Utils::SmallStringView sourceName = sourcePath.name();
|
||||
Utils::SmallStringView fileName = sourcePath.name();
|
||||
|
||||
auto sourceNameId = m_sourceNameCache.id(sourceName);
|
||||
auto fileNameId = m_fileNameCache.id(fileName);
|
||||
|
||||
return SourceId::create(sourceNameId, sourceContextId);
|
||||
return SourceId::create(fileNameId, directoryPathId);
|
||||
}
|
||||
|
||||
SourceNameId sourceNameId(Utils::SmallStringView sourceName) const override
|
||||
FileNameId fileNameId(Utils::SmallStringView fileName) const override
|
||||
{
|
||||
return m_sourceNameCache.id(sourceName);
|
||||
return m_fileNameCache.id(fileName);
|
||||
}
|
||||
|
||||
SourceId sourceId(SourceContextId sourceContextId, Utils::SmallStringView sourceName) const override
|
||||
SourceId sourceId(DirectoryPathId directoryPathId, Utils::SmallStringView fileName) const override
|
||||
{
|
||||
SourceNameId sourceNameId = m_sourceNameCache.id(sourceName);
|
||||
FileNameId fileNameId = m_fileNameCache.id(fileName);
|
||||
|
||||
return SourceId::create(sourceNameId, sourceContextId);
|
||||
return SourceId::create(fileNameId, directoryPathId);
|
||||
}
|
||||
|
||||
SourceContextId sourceContextId(Utils::SmallStringView sourceContextPath) const override
|
||||
DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const override
|
||||
{
|
||||
Utils::SmallStringView path = sourceContextPath.back() == '/'
|
||||
? sourceContextPath.substr(0, sourceContextPath.size() - 1)
|
||||
: sourceContextPath;
|
||||
Utils::SmallStringView path = directoryPath.back() == '/'
|
||||
? directoryPath.substr(0, directoryPath.size() - 1)
|
||||
: directoryPath;
|
||||
|
||||
return m_sourceContextPathCache.id(path);
|
||||
return m_directoryPathCache.id(path);
|
||||
}
|
||||
|
||||
SourcePath sourcePath(SourceId sourceId) const override
|
||||
@@ -88,61 +88,61 @@ public:
|
||||
if (!sourceId) [[unlikely]]
|
||||
throw NoSourcePathForInvalidSourceId();
|
||||
|
||||
auto sourceName = m_sourceNameCache.value(sourceId.mainId());
|
||||
auto fileName = m_fileNameCache.value(sourceId.mainId());
|
||||
|
||||
Utils::PathString sourceContextPath = m_sourceContextPathCache.value(sourceId.contextId());
|
||||
Utils::PathString directoryPath = m_directoryPathCache.value(sourceId.contextId());
|
||||
|
||||
return SourcePath{sourceContextPath, sourceName};
|
||||
return SourcePath{directoryPath, fileName};
|
||||
}
|
||||
|
||||
Utils::PathString sourceContextPath(SourceContextId sourceContextId) const override
|
||||
Utils::PathString directoryPath(DirectoryPathId directoryPathId) const override
|
||||
{
|
||||
if (!sourceContextId) [[unlikely]]
|
||||
throw NoSourceContextPathForInvalidSourceContextId();
|
||||
if (!directoryPathId) [[unlikely]]
|
||||
throw NoDirectoryPathForInvalidDirectoryPathId();
|
||||
|
||||
return m_sourceContextPathCache.value(sourceContextId);
|
||||
return m_directoryPathCache.value(directoryPathId);
|
||||
}
|
||||
|
||||
Utils::SmallString sourceName(SourceNameId sourceNameId) const override
|
||||
Utils::SmallString fileName(FileNameId fileNameId) const override
|
||||
{
|
||||
if (!sourceNameId) [[unlikely]]
|
||||
throw NoSourceNameForInvalidSourceNameId();
|
||||
if (!fileNameId) [[unlikely]]
|
||||
throw NoFileNameForInvalidFileNameId();
|
||||
|
||||
return m_sourceNameCache.value(sourceNameId);
|
||||
return m_fileNameCache.value(fileNameId);
|
||||
}
|
||||
|
||||
private:
|
||||
class SourceContextStorageAdapter
|
||||
class DirectoryPathStorageAdapter
|
||||
{
|
||||
public:
|
||||
auto fetchId(Utils::SmallStringView sourceContextPath)
|
||||
auto fetchId(Utils::SmallStringView directoryPath)
|
||||
{
|
||||
return storage.fetchSourceContextId(sourceContextPath);
|
||||
return storage.fetchDirectoryPathId(directoryPath);
|
||||
}
|
||||
|
||||
auto fetchValue(SourceContextId id) { return storage.fetchSourceContextPath(id); }
|
||||
auto fetchValue(DirectoryPathId id) { return storage.fetchDirectoryPath(id); }
|
||||
|
||||
auto fetchAll() { return storage.fetchAllSourceContexts(); }
|
||||
auto fetchAll() { return storage.fetchAllDirectoryPaths(); }
|
||||
|
||||
Storage &storage;
|
||||
};
|
||||
|
||||
class SourceNameStorageAdapter
|
||||
class FileNameStorageAdapter
|
||||
{
|
||||
public:
|
||||
auto fetchId(Utils::SmallStringView sourceNameView)
|
||||
auto fetchId(Utils::SmallStringView fileNameView)
|
||||
{
|
||||
return storage.fetchSourceNameId(sourceNameView);
|
||||
return storage.fetchFileNameId(fileNameView);
|
||||
}
|
||||
|
||||
auto fetchValue(SourceNameId id) { return storage.fetchSourceName(id); }
|
||||
auto fetchValue(FileNameId id) { return storage.fetchFileName(id); }
|
||||
|
||||
auto fetchAll() { return storage.fetchAllSourceNames(); }
|
||||
auto fetchAll() { return storage.fetchAllFileNames(); }
|
||||
|
||||
Storage &storage;
|
||||
};
|
||||
|
||||
struct SourceNameLess
|
||||
struct FileNameLess
|
||||
{
|
||||
bool operator()(Utils::SmallStringView first, Utils::SmallStringView second) const noexcept
|
||||
{
|
||||
@@ -150,7 +150,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
struct SourceContextLess
|
||||
struct DirectoryPathLess
|
||||
{
|
||||
bool operator()(Utils::SmallStringView first, Utils::SmallStringView second) const noexcept
|
||||
{
|
||||
@@ -161,26 +161,26 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
using SourceContextPathCache = StorageCache<Utils::PathString,
|
||||
Utils::SmallStringView,
|
||||
SourceContextId,
|
||||
SourceContextStorageAdapter,
|
||||
Mutex,
|
||||
SourceContextLess,
|
||||
Cache::SourceContext>;
|
||||
using SourceNameCache = StorageCache<Utils::SmallString,
|
||||
using DirectoryPathCache = StorageCache<Utils::PathString,
|
||||
Utils::SmallStringView,
|
||||
DirectoryPathId,
|
||||
DirectoryPathStorageAdapter,
|
||||
Mutex,
|
||||
DirectoryPathLess,
|
||||
Cache::DirectoryPath>;
|
||||
using FileNameCache = StorageCache<Utils::SmallString,
|
||||
Utils::SmallStringView,
|
||||
SourceNameId,
|
||||
SourceNameStorageAdapter,
|
||||
FileNameId,
|
||||
FileNameStorageAdapter,
|
||||
Mutex,
|
||||
SourceNameLess,
|
||||
Cache::SourceName>;
|
||||
FileNameLess,
|
||||
Cache::FileName>;
|
||||
|
||||
private:
|
||||
SourceContextStorageAdapter m_sourceContextStorageAdapter;
|
||||
SourceNameStorageAdapter m_sourceNameStorageAdapter;
|
||||
mutable SourceContextPathCache m_sourceContextPathCache{m_sourceContextStorageAdapter};
|
||||
mutable SourceNameCache m_sourceNameCache{m_sourceNameStorageAdapter};
|
||||
DirectoryPathStorageAdapter m_directoryPathStorageAdapter;
|
||||
FileNameStorageAdapter m_fileNameStorageAdapter;
|
||||
mutable DirectoryPathCache m_directoryPathCache{m_directoryPathStorageAdapter};
|
||||
mutable FileNameCache m_fileNameCache{m_fileNameStorageAdapter};
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -24,19 +24,19 @@ public:
|
||||
|
||||
virtual SourceId sourceId(SourcePathView sourcePath) const = 0;
|
||||
|
||||
virtual SourceId sourceId(SourceContextId sourceContextId,
|
||||
Utils::SmallStringView sourceName) const
|
||||
virtual SourceId sourceId(DirectoryPathId directoryPathId,
|
||||
Utils::SmallStringView fileName) const
|
||||
= 0;
|
||||
|
||||
virtual SourceNameId sourceNameId(Utils::SmallStringView sourceName) const = 0;
|
||||
virtual FileNameId fileNameId(Utils::SmallStringView fileName) const = 0;
|
||||
|
||||
virtual SourceContextId sourceContextId(Utils::SmallStringView sourceContextPath) const = 0;
|
||||
virtual DirectoryPathId directoryPathId(Utils::SmallStringView directoryPath) const = 0;
|
||||
|
||||
virtual SourcePath sourcePath(SourceId sourceId) const = 0;
|
||||
|
||||
virtual Utils::PathString sourceContextPath(SourceContextId sourceContextId) const = 0;
|
||||
virtual Utils::PathString directoryPath(DirectoryPathId directoryPathId) const = 0;
|
||||
|
||||
virtual Utils::SmallString sourceName(SourceNameId sourceNameId) const = 0;
|
||||
virtual Utils::SmallString fileName(FileNameId fileNameId) const = 0;
|
||||
|
||||
protected:
|
||||
~SourcePathCacheInterface() = default;
|
||||
|
@@ -13,35 +13,35 @@
|
||||
namespace QmlDesigner::Cache {
|
||||
|
||||
|
||||
class SourceContext
|
||||
: public StorageCacheEntry<Utils::PathString, Utils::SmallStringView, SourceContextId>
|
||||
class DirectoryPath
|
||||
: public StorageCacheEntry<Utils::PathString, Utils::SmallStringView, DirectoryPathId>
|
||||
{
|
||||
using Base = StorageCacheEntry<Utils::PathString, Utils::SmallStringView, SourceContextId>;
|
||||
using Base = StorageCacheEntry<Utils::PathString, Utils::SmallStringView, DirectoryPathId>;
|
||||
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
friend bool operator==(const SourceContext &first, const SourceContext &second)
|
||||
friend bool operator==(const DirectoryPath &first, const DirectoryPath &second)
|
||||
{
|
||||
return first.id == second.id && first.value == second.value;
|
||||
}
|
||||
};
|
||||
|
||||
using SourceContexts = std::vector<SourceContext>;
|
||||
using DirectoryPaths = std::vector<DirectoryPath>;
|
||||
|
||||
class SourceName : public StorageCacheEntry<Utils::PathString, Utils::SmallStringView, SourceNameId>
|
||||
class FileName : public StorageCacheEntry<Utils::PathString, Utils::SmallStringView, FileNameId>
|
||||
{
|
||||
using Base = StorageCacheEntry<Utils::PathString, Utils::SmallStringView, SourceNameId>;
|
||||
using Base = StorageCacheEntry<Utils::PathString, Utils::SmallStringView, FileNameId>;
|
||||
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
friend bool operator==(const SourceName &first, const SourceName &second)
|
||||
friend bool operator==(const FileName &first, const FileName &second)
|
||||
{
|
||||
return first.id == second.id && first.value == second.value;
|
||||
}
|
||||
};
|
||||
|
||||
using SourceNames = std::vector<SourceName>;
|
||||
using FileNames = std::vector<FileName>;
|
||||
|
||||
} // namespace QmlDesigner::Cache
|
||||
|
@@ -26,42 +26,42 @@ const char *NoSourcePathForInvalidSourceId::what() const noexcept
|
||||
return "You cannot get a file path for an invalid file path id!";
|
||||
}
|
||||
|
||||
NoSourceContextPathForInvalidSourceContextId::NoSourceContextPathForInvalidSourceContextId()
|
||||
NoDirectoryPathForInvalidDirectoryPathId::NoDirectoryPathForInvalidDirectoryPathId()
|
||||
{
|
||||
category().threadEvent("NoSourceContextPathForInvalidSourceContextId");
|
||||
category().threadEvent("NoDirectoryPathForInvalidDirectoryPathId");
|
||||
}
|
||||
|
||||
const char *NoSourceContextPathForInvalidSourceContextId::what() const noexcept
|
||||
const char *NoDirectoryPathForInvalidDirectoryPathId::what() const noexcept
|
||||
{
|
||||
return "You cannot get a directory path for an invalid directory path id!";
|
||||
}
|
||||
|
||||
SourceContextIdDoesNotExists::SourceContextIdDoesNotExists()
|
||||
DirectoryPathIdDoesNotExists::DirectoryPathIdDoesNotExists()
|
||||
{
|
||||
category().threadEvent("SourceContextIdDoesNotExists");
|
||||
category().threadEvent("DirectoryPathIdDoesNotExists");
|
||||
}
|
||||
|
||||
const char *SourceContextIdDoesNotExists::what() const noexcept
|
||||
const char *DirectoryPathIdDoesNotExists::what() const noexcept
|
||||
{
|
||||
return "The source context id does not exist in the database!";
|
||||
}
|
||||
|
||||
SourceNameIdDoesNotExists::SourceNameIdDoesNotExists()
|
||||
FileNameIdDoesNotExists::FileNameIdDoesNotExists()
|
||||
{
|
||||
category().threadEvent("SourceNameIdDoesNotExists");
|
||||
category().threadEvent("FileNameIdDoesNotExists");
|
||||
}
|
||||
|
||||
const char *SourceNameIdDoesNotExists::what() const noexcept
|
||||
const char *FileNameIdDoesNotExists::what() const noexcept
|
||||
{
|
||||
return "The source id does not exist in the database!";
|
||||
}
|
||||
|
||||
NoSourceNameForInvalidSourceNameId::NoSourceNameForInvalidSourceNameId()
|
||||
NoFileNameForInvalidFileNameId::NoFileNameForInvalidFileNameId()
|
||||
{
|
||||
category().threadEvent("NoSourceNameForInvalidSourceNameId");
|
||||
category().threadEvent("NoFileNameForInvalidFileNameId");
|
||||
}
|
||||
|
||||
const char *NoSourceNameForInvalidSourceNameId::what() const noexcept
|
||||
const char *NoFileNameForInvalidFileNameId::what() const noexcept
|
||||
{
|
||||
return "You cannot get a source name for an invalid source name id!";
|
||||
}
|
||||
|
@@ -27,31 +27,31 @@ public:
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT NoSourceNameForInvalidSourceNameId : public SourcePathError
|
||||
class QMLDESIGNERCORE_EXPORT NoFileNameForInvalidFileNameId : public SourcePathError
|
||||
{
|
||||
public:
|
||||
NoSourceNameForInvalidSourceNameId();
|
||||
NoFileNameForInvalidFileNameId();
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT NoSourceContextPathForInvalidSourceContextId : public SourcePathError
|
||||
class QMLDESIGNERCORE_EXPORT NoDirectoryPathForInvalidDirectoryPathId : public SourcePathError
|
||||
{
|
||||
public:
|
||||
NoSourceContextPathForInvalidSourceContextId();
|
||||
NoDirectoryPathForInvalidDirectoryPathId();
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT SourceContextIdDoesNotExists : public SourcePathError
|
||||
class QMLDESIGNERCORE_EXPORT DirectoryPathIdDoesNotExists : public SourcePathError
|
||||
{
|
||||
public:
|
||||
SourceContextIdDoesNotExists();
|
||||
DirectoryPathIdDoesNotExists();
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT SourceNameIdDoesNotExists : public SourcePathError
|
||||
class QMLDESIGNERCORE_EXPORT FileNameIdDoesNotExists : public SourcePathError
|
||||
{
|
||||
public:
|
||||
SourceNameIdDoesNotExists();
|
||||
FileNameIdDoesNotExists();
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
|
@@ -18,24 +18,24 @@ struct SourcePathStorage::Statements
|
||||
{}
|
||||
|
||||
Sqlite::Database &database;
|
||||
mutable Sqlite::ReadStatement<1, 1> selectSourceContextIdFromSourceContextsBySourceContextPathStatement{
|
||||
"SELECT sourceContextId FROM sourceContexts WHERE sourceContextPath = ?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectSourceContextPathFromSourceContextsBySourceContextIdStatement{
|
||||
"SELECT sourceContextPath FROM sourceContexts WHERE sourceContextId = ?", database};
|
||||
mutable Sqlite::ReadStatement<2> selectAllSourceContextsStatement{
|
||||
"SELECT sourceContextPath, sourceContextId FROM sourceContexts", database};
|
||||
Sqlite::WriteStatement<1> insertIntoSourceContextsStatement{
|
||||
"INSERT INTO sourceContexts(sourceContextPath) VALUES (?)", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectSourceNameIdFromSourceNamesBySourceNameStatement{
|
||||
"SELECT sourceNameId FROM sourceNames WHERE sourceName = ?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectSourceNameFromSourceNamesBySourceNameIdStatement{
|
||||
"SELECT sourceName FROM sourceNames WHERE sourceNameId = ?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectDirectoryPathIdFromDirectoryPathsByDirectoryPathStatement{
|
||||
"SELECT directoryPathId FROM directoryPaths WHERE directoryPath = ?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectDirectoryPathFromDirectoryPathsByDirectoryPathIdStatement{
|
||||
"SELECT directoryPath FROM directoryPaths WHERE directoryPathId = ?", database};
|
||||
mutable Sqlite::ReadStatement<2> selectAllDirectoryPathsStatement{
|
||||
"SELECT directoryPath, directoryPathId FROM directoryPaths", database};
|
||||
Sqlite::WriteStatement<1> insertIntoDirectoryPathsStatement{
|
||||
"INSERT INTO directoryPaths(directoryPath) VALUES (?)", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectFileNameIdFromFileNamesByFileNameStatement{
|
||||
"SELECT fileNameId FROM fileNames WHERE fileName = ?", database};
|
||||
mutable Sqlite::ReadStatement<1, 1> selectFileNameFromFileNamesByFileNameIdStatement{
|
||||
"SELECT fileName FROM fileNames WHERE fileNameId = ?", database};
|
||||
Sqlite::WriteStatement<1> insertIntoSourcesStatement{
|
||||
"INSERT INTO sourceNames(sourceName) VALUES (?)", database};
|
||||
"INSERT INTO fileNames(fileName) VALUES (?)", database};
|
||||
mutable Sqlite::ReadStatement<2> selectAllSourcesStatement{
|
||||
"SELECT sourceName, sourceNameId FROM sourceNames", database};
|
||||
Sqlite::WriteStatement<0> deleteAllSourceNamesStatement{"DELETE FROM sourceNames", database};
|
||||
Sqlite::WriteStatement<0> deleteAllSourceContextsStatement{"DELETE FROM sourceContexts", database};
|
||||
"SELECT fileName, fileNameId FROM fileNames", database};
|
||||
Sqlite::WriteStatement<0> deleteAllFileNamesStatement{"DELETE FROM fileNames", database};
|
||||
Sqlite::WriteStatement<0> deleteAllDirectoryPathsStatement{"DELETE FROM directoryPaths", database};
|
||||
};
|
||||
|
||||
class SourcePathStorage::Initializer
|
||||
@@ -44,32 +44,32 @@ public:
|
||||
Initializer(Database &database, bool isInitialized)
|
||||
{
|
||||
if (!isInitialized) {
|
||||
createSourceContextsTable(database);
|
||||
createSourceNamesTable(database);
|
||||
createDirectoryPathsTable(database);
|
||||
createFileNamesTable(database);
|
||||
}
|
||||
}
|
||||
|
||||
void createSourceContextsTable(Database &database)
|
||||
void createDirectoryPathsTable(Database &database)
|
||||
{
|
||||
Sqlite::Table table;
|
||||
table.setUseIfNotExists(true);
|
||||
table.setName("sourceContexts");
|
||||
table.addColumn("sourceContextId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||
const Sqlite::Column &sourceContextPathColumn = table.addColumn("sourceContextPath");
|
||||
table.setName("directoryPaths");
|
||||
table.addColumn("directoryPathId", Sqlite::ColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||
const Sqlite::Column &directoryPathColumn = table.addColumn("directoryPath");
|
||||
|
||||
table.addUniqueIndex({sourceContextPathColumn});
|
||||
table.addUniqueIndex({directoryPathColumn});
|
||||
|
||||
table.initialize(database);
|
||||
}
|
||||
|
||||
void createSourceNamesTable(Database &database)
|
||||
void createFileNamesTable(Database &database)
|
||||
{
|
||||
Sqlite::StrictTable table;
|
||||
table.setUseIfNotExists(true);
|
||||
table.setName("sourceNames");
|
||||
table.addColumn("sourceNameId", Sqlite::StrictColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||
const auto &sourceNameColumn = table.addColumn("sourceName", Sqlite::StrictColumnType::Text);
|
||||
table.addUniqueIndex({sourceNameColumn});
|
||||
table.setName("fileNames");
|
||||
table.addColumn("fileNameId", Sqlite::StrictColumnType::Integer, {Sqlite::PrimaryKey{}});
|
||||
const auto &fileNameColumn = table.addColumn("fileName", Sqlite::StrictColumnType::Text);
|
||||
table.addUniqueIndex({fileNameColumn});
|
||||
|
||||
table.initialize(database);
|
||||
}
|
||||
@@ -88,52 +88,52 @@ SourcePathStorage::SourcePathStorage(Database &database, bool isInitialized)
|
||||
|
||||
SourcePathStorage::~SourcePathStorage() = default;
|
||||
|
||||
SourceContextId SourcePathStorage::fetchSourceContextIdUnguarded(Utils::SmallStringView sourceContextPath)
|
||||
DirectoryPathId SourcePathStorage::fetchDirectoryPathIdUnguarded(Utils::SmallStringView directoryPath)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source context id unguarded", category()};
|
||||
|
||||
auto sourceContextId = readSourceContextId(sourceContextPath);
|
||||
auto directoryPathId = readDirectoryPathId(directoryPath);
|
||||
|
||||
return sourceContextId ? sourceContextId : writeSourceContextId(sourceContextPath);
|
||||
return directoryPathId ? directoryPathId : writeDirectoryPathId(directoryPath);
|
||||
}
|
||||
|
||||
SourceContextId SourcePathStorage::fetchSourceContextId(Utils::SmallStringView sourceContextPath)
|
||||
DirectoryPathId SourcePathStorage::fetchDirectoryPathId(Utils::SmallStringView directoryPath)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source context id",
|
||||
category(),
|
||||
keyValue("source context path", sourceContextPath)};
|
||||
keyValue("source context path", directoryPath)};
|
||||
|
||||
SourceContextId sourceContextId;
|
||||
DirectoryPathId directoryPathId;
|
||||
try {
|
||||
sourceContextId = Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchSourceContextIdUnguarded(sourceContextPath);
|
||||
directoryPathId = Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchDirectoryPathIdUnguarded(directoryPath);
|
||||
});
|
||||
} catch (const Sqlite::ConstraintPreventsModification &) {
|
||||
sourceContextId = fetchSourceContextId(sourceContextPath);
|
||||
directoryPathId = fetchDirectoryPathId(directoryPath);
|
||||
}
|
||||
|
||||
tracer.end(keyValue("source context id", sourceContextId));
|
||||
tracer.end(keyValue("source context id", directoryPathId));
|
||||
|
||||
return sourceContextId;
|
||||
return directoryPathId;
|
||||
}
|
||||
|
||||
Utils::PathString SourcePathStorage::fetchSourceContextPath(SourceContextId sourceContextId) const
|
||||
Utils::PathString SourcePathStorage::fetchDirectoryPath(DirectoryPathId directoryPathId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source context path",
|
||||
category(),
|
||||
keyValue("source context id", sourceContextId)};
|
||||
keyValue("source context id", directoryPathId)};
|
||||
|
||||
auto path = Sqlite::withDeferredTransaction(database, [&] {
|
||||
auto optionalSourceContextPath = s->selectSourceContextPathFromSourceContextsBySourceContextIdStatement
|
||||
.optionalValue<Utils::PathString>(sourceContextId);
|
||||
auto optionalDirectoryPath = s->selectDirectoryPathFromDirectoryPathsByDirectoryPathIdStatement
|
||||
.optionalValue<Utils::PathString>(directoryPathId);
|
||||
|
||||
if (!optionalSourceContextPath)
|
||||
throw SourceContextIdDoesNotExists();
|
||||
if (!optionalDirectoryPath)
|
||||
throw DirectoryPathIdDoesNotExists();
|
||||
|
||||
return std::move(*optionalSourceContextPath);
|
||||
return std::move(*optionalDirectoryPath);
|
||||
});
|
||||
|
||||
tracer.end(keyValue("source context path", path));
|
||||
@@ -141,133 +141,133 @@ Utils::PathString SourcePathStorage::fetchSourceContextPath(SourceContextId sour
|
||||
return path;
|
||||
}
|
||||
|
||||
Cache::SourceContexts SourcePathStorage::fetchAllSourceContexts() const
|
||||
Cache::DirectoryPaths SourcePathStorage::fetchAllDirectoryPaths() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all source contexts", category()};
|
||||
|
||||
return s->selectAllSourceContextsStatement.valuesWithTransaction<Cache::SourceContext, 128>();
|
||||
return s->selectAllDirectoryPathsStatement.valuesWithTransaction<Cache::DirectoryPath, 128>();
|
||||
}
|
||||
|
||||
SourceNameId SourcePathStorage::fetchSourceNameId(Utils::SmallStringView sourceName)
|
||||
FileNameId SourcePathStorage::fetchFileNameId(Utils::SmallStringView fileName)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source id", category(), keyValue("source name", sourceName)};
|
||||
NanotraceHR::Tracer tracer{"fetch source id", category(), keyValue("source name", fileName)};
|
||||
|
||||
auto sourceNameId = Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchSourceNameIdUnguarded(sourceName);
|
||||
auto fileNameId = Sqlite::withDeferredTransaction(database, [&] {
|
||||
return fetchFileNameIdUnguarded(fileName);
|
||||
});
|
||||
|
||||
tracer.end(keyValue("source name id", sourceNameId));
|
||||
tracer.end(keyValue("source name id", fileNameId));
|
||||
|
||||
return sourceNameId;
|
||||
return fileNameId;
|
||||
}
|
||||
|
||||
Utils::SmallString SourcePathStorage::fetchSourceName(SourceNameId sourceNameId) const
|
||||
Utils::SmallString SourcePathStorage::fetchFileName(FileNameId fileNameId) const
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source name and source context id",
|
||||
category(),
|
||||
keyValue("source name id", sourceNameId)};
|
||||
keyValue("source name id", fileNameId)};
|
||||
|
||||
auto sourceName = s->selectSourceNameFromSourceNamesBySourceNameIdStatement
|
||||
.valueWithTransaction<Utils::SmallString>(sourceNameId);
|
||||
auto fileName = s->selectFileNameFromFileNamesByFileNameIdStatement
|
||||
.valueWithTransaction<Utils::SmallString>(fileNameId);
|
||||
|
||||
if (sourceName.empty())
|
||||
throw SourceNameIdDoesNotExists();
|
||||
if (fileName.empty())
|
||||
throw FileNameIdDoesNotExists();
|
||||
|
||||
tracer.end(keyValue("source name", sourceName));
|
||||
tracer.end(keyValue("source name", fileName));
|
||||
|
||||
return sourceName;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
void SourcePathStorage::clearSources()
|
||||
{
|
||||
Sqlite::withImmediateTransaction(database, [&] {
|
||||
s->deleteAllSourceContextsStatement.execute();
|
||||
s->deleteAllSourceNamesStatement.execute();
|
||||
s->deleteAllDirectoryPathsStatement.execute();
|
||||
s->deleteAllFileNamesStatement.execute();
|
||||
});
|
||||
}
|
||||
|
||||
Cache::SourceNames SourcePathStorage::fetchAllSourceNames() const
|
||||
Cache::FileNames SourcePathStorage::fetchAllFileNames() const
|
||||
{
|
||||
NanotraceHR::Tracer tracer{"fetch all sources", category()};
|
||||
|
||||
return s->selectAllSourcesStatement.valuesWithTransaction<Cache::SourceName, 1024>();
|
||||
return s->selectAllSourcesStatement.valuesWithTransaction<Cache::FileName, 1024>();
|
||||
}
|
||||
|
||||
SourceNameId SourcePathStorage::fetchSourceNameIdUnguarded(Utils::SmallStringView sourceName)
|
||||
FileNameId SourcePathStorage::fetchFileNameIdUnguarded(Utils::SmallStringView fileName)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"fetch source id unguarded",
|
||||
category(),
|
||||
keyValue("source name", sourceName)};
|
||||
keyValue("source name", fileName)};
|
||||
|
||||
auto sourceId = readSourceNameId(sourceName);
|
||||
auto sourceId = readFileNameId(fileName);
|
||||
|
||||
if (!sourceId)
|
||||
sourceId = writeSourceNameId(sourceName);
|
||||
sourceId = writeFileNameId(fileName);
|
||||
|
||||
tracer.end(keyValue("source id", sourceId));
|
||||
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
SourceContextId SourcePathStorage::readSourceContextId(Utils::SmallStringView sourceContextPath)
|
||||
DirectoryPathId SourcePathStorage::readDirectoryPathId(Utils::SmallStringView directoryPath)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"read source context id",
|
||||
category(),
|
||||
keyValue("source context path", sourceContextPath)};
|
||||
keyValue("source context path", directoryPath)};
|
||||
|
||||
auto sourceContextId = s->selectSourceContextIdFromSourceContextsBySourceContextPathStatement
|
||||
.value<SourceContextId>(sourceContextPath);
|
||||
auto directoryPathId = s->selectDirectoryPathIdFromDirectoryPathsByDirectoryPathStatement
|
||||
.value<DirectoryPathId>(directoryPath);
|
||||
|
||||
tracer.end(keyValue("source context id", sourceContextId));
|
||||
tracer.end(keyValue("source context id", directoryPathId));
|
||||
|
||||
return sourceContextId;
|
||||
return directoryPathId;
|
||||
}
|
||||
|
||||
SourceContextId SourcePathStorage::writeSourceContextId(Utils::SmallStringView sourceContextPath)
|
||||
DirectoryPathId SourcePathStorage::writeDirectoryPathId(Utils::SmallStringView directoryPath)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"write source context id",
|
||||
category(),
|
||||
keyValue("source context path", sourceContextPath)};
|
||||
keyValue("source context path", directoryPath)};
|
||||
|
||||
s->insertIntoSourceContextsStatement.write(sourceContextPath);
|
||||
s->insertIntoDirectoryPathsStatement.write(directoryPath);
|
||||
|
||||
auto sourceContextId = SourceContextId::create(static_cast<int>(database.lastInsertedRowId()));
|
||||
auto directoryPathId = DirectoryPathId::create(static_cast<int>(database.lastInsertedRowId()));
|
||||
|
||||
tracer.end(keyValue("source context id", sourceContextId));
|
||||
tracer.end(keyValue("source context id", directoryPathId));
|
||||
|
||||
return sourceContextId;
|
||||
return directoryPathId;
|
||||
}
|
||||
|
||||
SourceNameId SourcePathStorage::writeSourceNameId(Utils::SmallStringView sourceName)
|
||||
FileNameId SourcePathStorage::writeFileNameId(Utils::SmallStringView fileName)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"write source id", category(), keyValue("source name", sourceName)};
|
||||
NanotraceHR::Tracer tracer{"write source id", category(), keyValue("source name", fileName)};
|
||||
|
||||
s->insertIntoSourcesStatement.write(sourceName);
|
||||
s->insertIntoSourcesStatement.write(fileName);
|
||||
|
||||
auto sourceNameId = SourceNameId::create(static_cast<int>(database.lastInsertedRowId()));
|
||||
auto fileNameId = FileNameId::create(static_cast<int>(database.lastInsertedRowId()));
|
||||
|
||||
tracer.end(keyValue("source name id", sourceNameId));
|
||||
tracer.end(keyValue("source name id", fileNameId));
|
||||
|
||||
return sourceNameId;
|
||||
return fileNameId;
|
||||
}
|
||||
|
||||
SourceNameId SourcePathStorage::readSourceNameId(Utils::SmallStringView sourceName)
|
||||
FileNameId SourcePathStorage::readFileNameId(Utils::SmallStringView fileName)
|
||||
{
|
||||
using NanotraceHR::keyValue;
|
||||
NanotraceHR::Tracer tracer{"read source id", category(), keyValue("source name", sourceName)};
|
||||
NanotraceHR::Tracer tracer{"read source id", category(), keyValue("source name", fileName)};
|
||||
|
||||
auto sourceNameId = s->selectSourceNameIdFromSourceNamesBySourceNameStatement.value<SourceNameId>(
|
||||
sourceName);
|
||||
auto fileNameId = s->selectFileNameIdFromFileNamesByFileNameStatement.value<FileNameId>(
|
||||
fileName);
|
||||
|
||||
tracer.end(keyValue("source id", sourceNameId));
|
||||
tracer.end(keyValue("source id", fileNameId));
|
||||
|
||||
return sourceNameId;
|
||||
return fileNameId;
|
||||
}
|
||||
|
||||
void SourcePathStorage::resetForTestsOnly()
|
||||
|
@@ -21,34 +21,34 @@ public:
|
||||
SourcePathStorage(Database &database, bool isInitialized);
|
||||
~SourcePathStorage();
|
||||
|
||||
SourceContextId fetchSourceContextIdUnguarded(Utils::SmallStringView sourceContextPath);
|
||||
DirectoryPathId fetchDirectoryPathIdUnguarded(Utils::SmallStringView directoryPath);
|
||||
|
||||
SourceContextId fetchSourceContextId(Utils::SmallStringView sourceContextPath);
|
||||
DirectoryPathId fetchDirectoryPathId(Utils::SmallStringView directoryPath);
|
||||
|
||||
Utils::PathString fetchSourceContextPath(SourceContextId sourceContextId) const;
|
||||
Utils::PathString fetchDirectoryPath(DirectoryPathId directoryPathId) const;
|
||||
|
||||
Cache::SourceContexts fetchAllSourceContexts() const;
|
||||
Cache::DirectoryPaths fetchAllDirectoryPaths() const;
|
||||
|
||||
SourceNameId fetchSourceNameId(Utils::SmallStringView sourceName);
|
||||
FileNameId fetchFileNameId(Utils::SmallStringView fileName);
|
||||
|
||||
Utils::SmallString fetchSourceName(SourceNameId sourceId) const;
|
||||
Utils::SmallString fetchFileName(FileNameId sourceId) const;
|
||||
|
||||
void clearSources();
|
||||
|
||||
Cache::SourceNames fetchAllSourceNames() const;
|
||||
Cache::FileNames fetchAllFileNames() const;
|
||||
|
||||
SourceNameId fetchSourceNameIdUnguarded(Utils::SmallStringView sourceName);
|
||||
FileNameId fetchFileNameIdUnguarded(Utils::SmallStringView fileName);
|
||||
|
||||
void resetForTestsOnly();
|
||||
|
||||
private:
|
||||
SourceContextId readSourceContextId(Utils::SmallStringView sourceContextPath);
|
||||
DirectoryPathId readDirectoryPathId(Utils::SmallStringView directoryPath);
|
||||
|
||||
SourceContextId writeSourceContextId(Utils::SmallStringView sourceContextPath);
|
||||
DirectoryPathId writeDirectoryPathId(Utils::SmallStringView directoryPath);
|
||||
|
||||
SourceNameId writeSourceNameId(Utils::SmallStringView sourceName);
|
||||
FileNameId writeFileNameId(Utils::SmallStringView fileName);
|
||||
|
||||
SourceNameId readSourceNameId(Utils::SmallStringView sourceName);
|
||||
FileNameId readFileNameId(Utils::SmallStringView fileName);
|
||||
|
||||
class Initializer;
|
||||
|
||||
|
@@ -214,10 +214,10 @@ public:
|
||||
, qmlDocumentParser{storage, pathCache}
|
||||
, pathWatcher{pathCache, fileStatusCache, &updater}
|
||||
, projectPartId{ProjectPartId::create(
|
||||
pathCache.sourceContextId(Utils::PathString{project->projectDirectory().path()})
|
||||
pathCache.directoryPathId(Utils::PathString{project->projectDirectory().path()})
|
||||
.internalId())}
|
||||
, qtPartId{ProjectPartId::create(
|
||||
pathCache.sourceContextId(Utils::PathString{qmlPath(project)}).internalId())}
|
||||
pathCache.directoryPathId(Utils::PathString{qmlPath(project)}).internalId())}
|
||||
, updater{fileSystem,
|
||||
storage,
|
||||
fileStatusCache,
|
||||
|
@@ -78,7 +78,7 @@ MATCHER_P3(IsItemLibraryProperty,
|
||||
|
||||
template<typename IconPathMatcher, typename TypeTraitsMatcher, typename HintsJsonMatcher, typename ItemLibraryJsonMatcher>
|
||||
auto IsTypeAnnotation(QmlDesigner::SourceId sourceId,
|
||||
QmlDesigner::SourceContextId directoryId,
|
||||
QmlDesigner::DirectoryPathId directoryId,
|
||||
Utils::SmallStringView typeName,
|
||||
QmlDesigner::ModuleId moduleId,
|
||||
IconPathMatcher iconPath,
|
||||
|
@@ -207,9 +207,9 @@ public:
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SmallSourceIds<4>,
|
||||
typeAnnotationSourceIds,
|
||||
(QmlDesigner::SourceContextId directoryId),
|
||||
(QmlDesigner::DirectoryPathId directoryId),
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SmallSourceContextIds<64>,
|
||||
MOCK_METHOD(QmlDesigner::SmallDirectoryPathIds<64>,
|
||||
typeAnnotationDirectoryIds,
|
||||
(),
|
||||
(const, override));
|
||||
@@ -315,18 +315,18 @@ public:
|
||||
|
||||
MOCK_METHOD(QmlDesigner::Storage::Synchronization::DirectoryInfos,
|
||||
fetchDirectoryInfos,
|
||||
(QmlDesigner::SourceContextId directoryId),
|
||||
(QmlDesigner::DirectoryPathId directoryId),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(QmlDesigner::Storage::Synchronization::DirectoryInfos,
|
||||
fetchDirectoryInfos,
|
||||
(QmlDesigner::SourceContextId directoryId,
|
||||
(QmlDesigner::DirectoryPathId directoryId,
|
||||
QmlDesigner::Storage::Synchronization::FileType),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(QmlDesigner::SmallSourceContextIds<32>,
|
||||
MOCK_METHOD(QmlDesigner::SmallDirectoryPathIds<32>,
|
||||
fetchSubdirectoryIds,
|
||||
(QmlDesigner::SourceContextId directoryId),
|
||||
(QmlDesigner::DirectoryPathId directoryId),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(std::optional<QmlDesigner::Storage::Synchronization::DirectoryInfo>,
|
||||
@@ -334,25 +334,25 @@ public:
|
||||
(QmlDesigner::SourceId sourceId),
|
||||
(const, override));
|
||||
|
||||
MOCK_METHOD(QmlDesigner::SourceContextId,
|
||||
fetchSourceContextId,
|
||||
(::Utils::SmallStringView SourceContextPath),
|
||||
MOCK_METHOD(QmlDesigner::DirectoryPathId,
|
||||
fetchDirectoryPathId,
|
||||
(::Utils::SmallStringView DirectoryPath),
|
||||
());
|
||||
MOCK_METHOD(QmlDesigner::SourceNameId, fetchSourceNameId, (::Utils::SmallStringView sourceName), ());
|
||||
MOCK_METHOD(QmlDesigner::SourceContextId,
|
||||
fetchSourceContextIdUnguarded,
|
||||
(::Utils::SmallStringView sourceContextPath),
|
||||
MOCK_METHOD(QmlDesigner::FileNameId, fetchFileNameId, (::Utils::SmallStringView fileName), ());
|
||||
MOCK_METHOD(QmlDesigner::DirectoryPathId,
|
||||
fetchDirectoryPathIdUnguarded,
|
||||
(::Utils::SmallStringView directoryPath),
|
||||
());
|
||||
MOCK_METHOD(QmlDesigner::SourceNameId,
|
||||
fetchSourceNameIdUnguarded,
|
||||
(::Utils::SmallStringView sourceName),
|
||||
MOCK_METHOD(QmlDesigner::FileNameId,
|
||||
fetchFileNameIdUnguarded,
|
||||
(::Utils::SmallStringView fileName),
|
||||
());
|
||||
MOCK_METHOD(::Utils::PathString,
|
||||
fetchSourceContextPath,
|
||||
(QmlDesigner::SourceContextId sourceContextId));
|
||||
MOCK_METHOD(Utils::SmallString, fetchSourceName, (QmlDesigner::SourceNameId sourceId));
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::SourceContext>, fetchAllSourceContexts, (), ());
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::SourceName>, fetchAllSourceNames, (), ());
|
||||
fetchDirectoryPath,
|
||||
(QmlDesigner::DirectoryPathId directoryPathId));
|
||||
MOCK_METHOD(Utils::SmallString, fetchFileName, (QmlDesigner::FileNameId sourceId));
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::DirectoryPath>, fetchAllDirectoryPaths, (), ());
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::FileName>, fetchAllFileNames, (), ());
|
||||
|
||||
MOCK_METHOD(QmlDesigner::SourceId,
|
||||
propertyEditorPathId,
|
||||
|
@@ -14,7 +14,7 @@ public:
|
||||
MOCK_METHOD(void,
|
||||
updateContextIdPaths,
|
||||
(const std::vector<QmlDesigner::IdPaths> &idPaths,
|
||||
const QmlDesigner::SourceContextIds &sourceContextIds),
|
||||
const QmlDesigner::DirectoryPathIds &directoryPathIds),
|
||||
(override));
|
||||
MOCK_METHOD(void, removeIds, (const QmlDesigner::ProjectPartIds &ids), (override));
|
||||
MOCK_METHOD(void,
|
||||
|
@@ -14,6 +14,6 @@ public:
|
||||
|
||||
MOCK_METHOD(void,
|
||||
checkForChangeInDirectory,
|
||||
(QmlDesigner::SourceContextIds sourceContextIds),
|
||||
(QmlDesigner::DirectoryPathIds directoryPathIds),
|
||||
(override));
|
||||
};
|
||||
|
@@ -22,27 +22,27 @@ public:
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SourceId,
|
||||
sourceId,
|
||||
(QmlDesigner::SourceContextId sourceContextId, Utils::SmallStringView sourceName),
|
||||
(QmlDesigner::DirectoryPathId directoryPathId, Utils::SmallStringView fileName),
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SourceNameId,
|
||||
sourceNameId,
|
||||
(Utils::SmallStringView sourceName),
|
||||
MOCK_METHOD(QmlDesigner::FileNameId,
|
||||
fileNameId,
|
||||
(Utils::SmallStringView fileName),
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SourcePath,
|
||||
sourcePath,
|
||||
(QmlDesigner::SourceId sourceId),
|
||||
(const, override));
|
||||
MOCK_METHOD(QmlDesigner::SourceContextId,
|
||||
sourceContextId,
|
||||
MOCK_METHOD(QmlDesigner::DirectoryPathId,
|
||||
directoryPathId,
|
||||
(Utils::SmallStringView directoryPath),
|
||||
(const, override));
|
||||
MOCK_METHOD(Utils::PathString,
|
||||
sourceContextPath,
|
||||
(QmlDesigner::SourceContextId directoryPathId),
|
||||
directoryPath,
|
||||
(QmlDesigner::DirectoryPathId directoryPathId),
|
||||
(const, override));
|
||||
MOCK_METHOD(Utils::SmallString,
|
||||
sourceName,
|
||||
(QmlDesigner::SourceNameId sourceName),
|
||||
fileName,
|
||||
(QmlDesigner::FileNameId fileName),
|
||||
(const, override));
|
||||
MOCK_METHOD(void, populateIfEmpty, (), (override));
|
||||
};
|
||||
|
@@ -64,21 +64,21 @@ public:
|
||||
(long long, Utils::SmallStringView),
|
||||
());
|
||||
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::SourceContext>,
|
||||
valuesReturnCacheSourceContexts,
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::DirectoryPath>,
|
||||
valuesReturnCacheDirectoryPaths,
|
||||
(std::size_t),
|
||||
());
|
||||
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::SourceName>,
|
||||
valuesReturnCacheSourceNames,
|
||||
MOCK_METHOD(std::vector<QmlDesigner::Cache::FileName>,
|
||||
valuesReturnCacheFileNames,
|
||||
(std::size_t),
|
||||
());
|
||||
|
||||
MOCK_METHOD(Sqlite::TimeStamp, valueWithTransactionReturnsTimeStamp, (Utils::SmallStringView), ());
|
||||
MOCK_METHOD(int, valueWithTransactionReturnsInt, (Utils::SmallStringView), ());
|
||||
|
||||
MOCK_METHOD(QmlDesigner::SourceContextId, valueReturnsSourceContextId, (Utils::SmallStringView), ());
|
||||
MOCK_METHOD(QmlDesigner::SourceContextId, valueWithTransactionReturnsSourceContextId, (int), ());
|
||||
MOCK_METHOD(QmlDesigner::DirectoryPathId, valueReturnsDirectoryPathId, (Utils::SmallStringView), ());
|
||||
MOCK_METHOD(QmlDesigner::DirectoryPathId, valueWithTransactionReturnsDirectoryPathId, (int), ());
|
||||
|
||||
MOCK_METHOD(QmlDesigner::SourceId, valueReturnsSourceId, (int, Utils::SmallStringView), ());
|
||||
|
||||
@@ -161,8 +161,8 @@ public:
|
||||
else if constexpr (std::is_same_v<ResultType,
|
||||
std::tuple<QmlDesigner::PropertyDeclarationId, QmlDesigner::TypeId>>)
|
||||
return valueReturnsPropertyDeclaration(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::SourceContextId>)
|
||||
return valueReturnsSourceContextId(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::DirectoryPathId>)
|
||||
return valueReturnsDirectoryPathId(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::SourceId>)
|
||||
return valueReturnsSourceId(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Storage::Synchronization::Type>)
|
||||
@@ -181,8 +181,8 @@ public:
|
||||
else if constexpr (std::is_same_v<ResultType,
|
||||
std::tuple<QmlDesigner::PropertyDeclarationId, QmlDesigner::TypeId>>)
|
||||
return valueReturnsPropertyDeclaration(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::SourceContextId>)
|
||||
return valueWithTransactionReturnsSourceContextId(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::DirectoryPathId>)
|
||||
return valueWithTransactionReturnsDirectoryPathId(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, Sqlite::TimeStamp>)
|
||||
return valueWithTransactionReturnsTimeStamp(queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, int>)
|
||||
@@ -207,10 +207,10 @@ public:
|
||||
return valuesReturnStringVector(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, long long>)
|
||||
return valuesReturnRowIds(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Cache::SourceContext>)
|
||||
return valuesReturnCacheSourceContexts(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Cache::SourceName>)
|
||||
return valuesReturnCacheSourceNames(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Cache::DirectoryPath>)
|
||||
return valuesReturnCacheDirectoryPaths(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Cache::FileName>)
|
||||
return valuesReturnCacheFileNames(reserveSize);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Storage::Synchronization::Type>)
|
||||
return valuesReturnsStorageTypes(reserveSize, queryValues...);
|
||||
else if constexpr (std::is_same_v<ResultType, QmlDesigner::Storage::Synchronization::ExportedType>)
|
||||
|
@@ -489,7 +489,7 @@ std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths)
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry)
|
||||
{
|
||||
return out << "(" << entry.sourceId << ", " << entry.sourceContextId << ", " << entry.id << ", "
|
||||
return out << "(" << entry.sourceId << ", " << entry.directoryPathId << ", " << entry.id << ", "
|
||||
<< entry.lastModified << ")";
|
||||
}
|
||||
|
||||
@@ -600,9 +600,9 @@ std::ostream &operator<<(std::ostream &out, AuxiliaryDataType type)
|
||||
|
||||
namespace Cache {
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext)
|
||||
std::ostream &operator<<(std::ostream &out, const DirectoryPath &directoryPath)
|
||||
{
|
||||
return out << "(" << sourceContext.id << ", " << sourceContext.value << ")";
|
||||
return out << "(" << directoryPath.id << ", " << directoryPath.value << ")";
|
||||
}
|
||||
} // namespace Cache
|
||||
|
||||
|
@@ -164,9 +164,9 @@ std::ostream &operator<<(std::ostream &out, const BasicAuxiliaryDataKey<Utils::S
|
||||
std::ostream &operator<<(std::ostream &out, AuxiliaryDataType type);
|
||||
|
||||
namespace Cache {
|
||||
class SourceContext;
|
||||
class DirectoryPath;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const SourceContext &sourceContext);
|
||||
std::ostream &operator<<(std::ostream &out, const DirectoryPath &directoryPath);
|
||||
} // namespace Cache
|
||||
|
||||
namespace ImageCache {
|
||||
@@ -175,8 +175,8 @@ class FontCollectorSizeAuxiliaryData;
|
||||
class FontCollectorSizesAuxiliaryData;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const LibraryIconAuxiliaryData &date);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizeAuxiliaryData &sourceContext);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizesAuxiliaryData &sourceContext);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizeAuxiliaryData &directoryPath);
|
||||
std::ostream &operator<<(std::ostream &out, const FontCollectorSizesAuxiliaryData &directoryPath);
|
||||
} // namespace ImageCache
|
||||
|
||||
namespace Storage {
|
||||
|
@@ -12,8 +12,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::SourceContextIds;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::DirectoryPathIds;
|
||||
|
||||
class DirectoryPathCompressor : public testing::Test
|
||||
{
|
||||
@@ -21,61 +21,61 @@ protected:
|
||||
void SetUp() { compressor.setCallback(mockCompressorCallback.AsStdFunction()); }
|
||||
|
||||
protected:
|
||||
NiceMock<MockFunction<void(const SourceContextIds &sourceContextIds)>> mockCompressorCallback;
|
||||
NiceMock<MockFunction<void(const DirectoryPathIds &directoryPathIds)>> mockCompressorCallback;
|
||||
QmlDesigner::DirectoryPathCompressor<NiceMock<MockTimer>> compressor;
|
||||
NiceMock<MockTimer> &mockTimer = compressor.timer();
|
||||
SourceContextId sourceContextId1{SourceContextId::create(1)};
|
||||
SourceContextId sourceContextId2{SourceContextId::create(2)};
|
||||
DirectoryPathId directoryPathId1{DirectoryPathId::create(1)};
|
||||
DirectoryPathId directoryPathId2{DirectoryPathId::create(2)};
|
||||
};
|
||||
|
||||
TEST_F(DirectoryPathCompressor, add_file_path)
|
||||
{
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
|
||||
ASSERT_THAT(compressor.sourceContextIds(), ElementsAre(sourceContextId1));
|
||||
ASSERT_THAT(compressor.directoryPathIds(), ElementsAre(directoryPathId1));
|
||||
}
|
||||
|
||||
TEST_F(DirectoryPathCompressor, clear__after_calling_callback)
|
||||
{
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
|
||||
compressor.timer().emitTimoutIfStarted();
|
||||
|
||||
ASSERT_THAT(compressor.sourceContextIds(), IsEmpty());
|
||||
ASSERT_THAT(compressor.directoryPathIds(), IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(DirectoryPathCompressor, dont_clear_for_thrown_exception)
|
||||
{
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.setCallback([](const SourceContextIds &) { throw std::exception{}; });
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
compressor.setCallback([](const DirectoryPathIds &) { throw std::exception{}; });
|
||||
|
||||
compressor.timer().emitTimoutIfStarted();
|
||||
|
||||
ASSERT_THAT(compressor.sourceContextIds(), ElementsAre(sourceContextId1));
|
||||
ASSERT_THAT(compressor.directoryPathIds(), ElementsAre(directoryPathId1));
|
||||
}
|
||||
|
||||
TEST_F(DirectoryPathCompressor, call_restart_timer_after_adding_path)
|
||||
{
|
||||
EXPECT_CALL(mockTimer, start(20));
|
||||
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
}
|
||||
|
||||
TEST_F(DirectoryPathCompressor, call_time_out_after_adding_path)
|
||||
{
|
||||
EXPECT_CALL(mockCompressorCallback, Call(ElementsAre(sourceContextId1, sourceContextId2)));
|
||||
EXPECT_CALL(mockCompressorCallback, Call(ElementsAre(directoryPathId1, directoryPathId2)));
|
||||
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addSourceContextId(sourceContextId2);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
compressor.addDirectoryPathId(directoryPathId2);
|
||||
}
|
||||
|
||||
TEST_F(DirectoryPathCompressor, remove_duplicates)
|
||||
{
|
||||
EXPECT_CALL(mockCompressorCallback, Call(ElementsAre(sourceContextId1, sourceContextId2)));
|
||||
EXPECT_CALL(mockCompressorCallback, Call(ElementsAre(directoryPathId1, directoryPathId2)));
|
||||
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addSourceContextId(sourceContextId2);
|
||||
compressor.addSourceContextId(sourceContextId1);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
compressor.addDirectoryPathId(directoryPathId2);
|
||||
compressor.addDirectoryPathId(directoryPathId1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -24,11 +24,11 @@ using QmlDesigner::FileStatuses;
|
||||
using QmlDesigner::FlagIs;
|
||||
using QmlDesigner::ModuleId;
|
||||
using QmlDesigner::PropertyDeclarationId;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::SourceContextIds;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::DirectoryPathIds;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::SourceIds;
|
||||
using QmlDesigner::SourceNameId;
|
||||
using QmlDesigner::FileNameId;
|
||||
using QmlDesigner::Storage::ModuleKind;
|
||||
using QmlDesigner::Storage::Synchronization::SynchronizationPackage;
|
||||
using QmlDesigner::Storage::Synchronization::TypeAnnotations;
|
||||
@@ -1070,16 +1070,16 @@ protected:
|
||||
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
|
||||
"QtObject",
|
||||
sourceId1,
|
||||
sourceContextIdPath6);
|
||||
directoryPathIdPath6);
|
||||
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
|
||||
"Item",
|
||||
sourceId2,
|
||||
sourceContextIdPath6);
|
||||
directoryPathIdPath6);
|
||||
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
|
||||
"Item3D",
|
||||
sourceId3,
|
||||
sourceContextIdPath6);
|
||||
package.updatedPropertyEditorQmlPathDirectoryIds.emplace_back(sourceContextIdPath6);
|
||||
directoryPathIdPath6);
|
||||
package.updatedPropertyEditorQmlPathDirectoryIds.emplace_back(directoryPathIdPath6);
|
||||
|
||||
return package;
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ protected:
|
||||
traits.visibleInLibrary = FlagIs::True;
|
||||
|
||||
annotations.emplace_back(sourceId4,
|
||||
sourceContextIdPath6,
|
||||
directoryPathIdPath6,
|
||||
"Object",
|
||||
qmlModuleId,
|
||||
"/path/to/icon.png",
|
||||
@@ -1115,7 +1115,7 @@ protected:
|
||||
"properties":[["color", "color", "#blue"]]}])xy");
|
||||
|
||||
annotations.emplace_back(sourceId5,
|
||||
sourceContextIdPath6,
|
||||
directoryPathIdPath6,
|
||||
"Item",
|
||||
qtQuickModuleId,
|
||||
"/path/to/quick.png",
|
||||
@@ -1140,7 +1140,7 @@ protected:
|
||||
traits.visibleInLibrary = FlagIs::True;
|
||||
|
||||
annotations.emplace_back(sourceId5,
|
||||
sourceContextIdPath1,
|
||||
directoryPathIdPath1,
|
||||
"Item",
|
||||
qtQuickModuleId,
|
||||
"/path/to/quick.png",
|
||||
@@ -1253,13 +1253,13 @@ protected:
|
||||
SourceId sourceId5{sourcePathCache.sourceId(path5)};
|
||||
SourceId sourceId6{sourcePathCache.sourceId(path6)};
|
||||
SourceId sourceIdPath1{sourcePathCache.sourceId(pathPath1)};
|
||||
SourceContextId sourceContextIdPath1{sourceIdPath1.contextId()};
|
||||
DirectoryPathId directoryPathIdPath1{sourceIdPath1.contextId()};
|
||||
SourceId sourceIdPath6{sourcePathCache.sourceId(pathPath6)};
|
||||
SourceContextId sourceContextIdPath6{sourceIdPath6.contextId()};
|
||||
DirectoryPathId directoryPathIdPath6{sourceIdPath6.contextId()};
|
||||
SourceId qmlProjectSourceId{sourcePathCache.sourceId("/path1/qmldir")};
|
||||
SourceContextId qmlProjectSourceContextId = qmlProjectSourceId.contextId();
|
||||
DirectoryPathId qmlProjectDirectoryPathId = qmlProjectSourceId.contextId();
|
||||
SourceId qtQuickProjectSourceId{sourcePathCache.sourceId("/path2/qmldir")};
|
||||
SourceContextId qtQuickProjectSourceContextId = qtQuickProjectSourceId.contextId();
|
||||
DirectoryPathId qtQuickProjectDirectoryPathId = qtQuickProjectSourceId.contextId();
|
||||
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
|
||||
ModuleId qmlNativeModuleId{storage.moduleId("Qml", ModuleKind::CppLibrary)};
|
||||
ModuleId qtQuickModuleId{storage.moduleId("QtQuick", ModuleKind::QmlLibrary)};
|
||||
@@ -5829,261 +5829,261 @@ TEST_F(ProjectStorage, populate_module_cache)
|
||||
|
||||
TEST_F(ProjectStorage, add_directory_infoes)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1, directoryInfo2, directoryInfo3));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, remove_directory_info)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, update_directory_info_file_type)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1, directoryInfo2b}});
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1, directoryInfo2b}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1, directoryInfo2b, directoryInfo3));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, update_directory_info_module_id)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1, directoryInfo2b}});
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1, directoryInfo2b}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1, directoryInfo2b, directoryInfo3));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, throw_for_invalid_source_id_in_directory_info)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
SourceId{},
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
|
||||
ASSERT_THROW(storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}}),
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1}}),
|
||||
QmlDesigner::DirectoryInfoHasInvalidSourceId);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, insert_directory_info_with_invalid_module_id)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, update_directory_info_with_invalid_module_id)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1}});
|
||||
directoryInfo1.moduleId = ModuleId{};
|
||||
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
|
||||
storage.synchronize(SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1}});
|
||||
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
|
||||
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId}),
|
||||
UnorderedElementsAre(directoryInfo1));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, throw_for_updating_with_invalid_project_source_context_id_in_directory_info)
|
||||
TEST_F(ProjectStorage, throw_for_updating_with_invalid_project_directory_path_id_in_directory_info)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{
|
||||
SourceContextId{}, sourceId1, qmlModuleId, Storage::Synchronization::FileType::QmlDocument};
|
||||
DirectoryPathId{}, sourceId1, qmlModuleId, Storage::Synchronization::FileType::QmlDocument};
|
||||
|
||||
ASSERT_THROW(storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}}),
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId}, {directoryInfo1}}),
|
||||
QmlDesigner::DirectoryInfoHasInvalidProjectSourceId);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_ids)
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_directory_path_ids)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
auto directoryInfos = storage.fetchDirectoryInfos(
|
||||
{qmlProjectSourceContextId, qtQuickProjectSourceContextId});
|
||||
{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId});
|
||||
|
||||
ASSERT_THAT(directoryInfos, UnorderedElementsAre(directoryInfo1, directoryInfo2, directoryInfo3));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_id)
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_directory_path_id)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceContextId);
|
||||
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectDirectoryPathId);
|
||||
|
||||
ASSERT_THAT(directoryInfo, UnorderedElementsAre(directoryInfo1, directoryInfo2));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_id_and_file_type)
|
||||
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_directory_path_id_and_file_type)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::Directory};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectDirectoryPathId,
|
||||
sourceId4,
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::Directory};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3, directoryInfo4}});
|
||||
|
||||
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceContextId,
|
||||
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectDirectoryPathId,
|
||||
Storage::Synchronization::FileType::Directory);
|
||||
|
||||
ASSERT_THAT(directoryInfo, UnorderedElementsAre(directoryInfo2, directoryInfo4));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, fetch_subdirectory_source_context_ids)
|
||||
TEST_F(ProjectStorage, fetch_subdirectory_directory_path_ids)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
auto directory1Id = SourceId::create(SourceNameId{}, sourceId2.contextId());
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
auto directory1Id = SourceId::create(FileNameId{}, sourceId2.contextId());
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
directory1Id,
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::Directory};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
auto directory2Id = SourceId::create(SourceNameId{}, sourceId4.contextId());
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectSourceContextId,
|
||||
auto directory2Id = SourceId::create(FileNameId{}, sourceId4.contextId());
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectDirectoryPathId,
|
||||
directory2Id,
|
||||
ModuleId{},
|
||||
Storage::Synchronization::FileType::Directory};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3, directoryInfo4}});
|
||||
|
||||
auto directoryInfo = storage.fetchSubdirectoryIds(qmlProjectSourceContextId);
|
||||
auto directoryInfo = storage.fetchSubdirectoryIds(qmlProjectDirectoryPathId);
|
||||
|
||||
ASSERT_THAT(directoryInfo,
|
||||
UnorderedElementsAre(directory1Id.contextId(), directory2Id.contextId()));
|
||||
@@ -6091,20 +6091,20 @@ TEST_F(ProjectStorage, fetch_subdirectory_source_context_ids)
|
||||
|
||||
TEST_F(ProjectStorage, fetch_directory_info_by_source_id)
|
||||
{
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectDirectoryPathId,
|
||||
sourceId1,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectDirectoryPathId,
|
||||
sourceId2,
|
||||
qmlModuleId,
|
||||
Storage::Synchronization::FileType::QmlDocument};
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
|
||||
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectDirectoryPathId,
|
||||
sourceId3,
|
||||
qtQuickModuleId,
|
||||
Storage::Synchronization::FileType::QmlTypes};
|
||||
storage.synchronize(
|
||||
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
|
||||
SynchronizationPackage{{qmlProjectDirectoryPathId, qtQuickProjectDirectoryPathId},
|
||||
{directoryInfo1, directoryInfo2, directoryInfo3}});
|
||||
|
||||
auto directoryInfo = storage.fetchDirectoryInfo(sourceId2);
|
||||
@@ -8295,7 +8295,7 @@ TEST_F(ProjectStorage, synchronize_property_editor_adds_path)
|
||||
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
|
||||
"Item3D",
|
||||
sourceId3,
|
||||
sourceContextIdPath6);
|
||||
directoryPathIdPath6);
|
||||
|
||||
storage.synchronize(package);
|
||||
|
||||
@@ -8310,7 +8310,7 @@ TEST_F(ProjectStorage, synchronize_property_editor_with_non_existing_type_name)
|
||||
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
|
||||
"Item4D",
|
||||
sourceId4,
|
||||
sourceContextIdPath6);
|
||||
directoryPathIdPath6);
|
||||
|
||||
storage.synchronize(package);
|
||||
|
||||
@@ -8675,7 +8675,7 @@ TEST_F(ProjectStorage, synchronize_type_annotation_directory_source_id)
|
||||
|
||||
storage.synchronize(package);
|
||||
|
||||
ASSERT_THAT(storage.typeAnnotationSourceIds(sourceContextIdPath6),
|
||||
ASSERT_THAT(storage.typeAnnotationSourceIds(directoryPathIdPath6),
|
||||
UnorderedElementsAre(sourceId4, sourceId5));
|
||||
}
|
||||
|
||||
@@ -8687,7 +8687,7 @@ TEST_F(ProjectStorage, get_type_annotation_source_ids)
|
||||
package.typeAnnotations);
|
||||
storage.synchronize(package);
|
||||
|
||||
auto sourceIds = storage.typeAnnotationSourceIds(sourceContextIdPath6);
|
||||
auto sourceIds = storage.typeAnnotationSourceIds(directoryPathIdPath6);
|
||||
|
||||
ASSERT_THAT(sourceIds, UnorderedElementsAre(sourceId4, sourceId5));
|
||||
}
|
||||
@@ -8702,7 +8702,7 @@ TEST_F(ProjectStorage, get_type_annotation_directory_source_ids)
|
||||
|
||||
auto sourceIds = storage.typeAnnotationDirectoryIds();
|
||||
|
||||
ASSERT_THAT(sourceIds, ElementsAre(sourceContextIdPath1, sourceContextIdPath6));
|
||||
ASSERT_THAT(sourceIds, ElementsAre(directoryPathIdPath1, directoryPathIdPath6));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, get_all_item_library_entries)
|
||||
|
@@ -27,8 +27,8 @@ using QmlDesigner::ProjectChunkId;
|
||||
using QmlDesigner::ProjectChunkIds;
|
||||
using QmlDesigner::ProjectPartId;
|
||||
using QmlDesigner::ProjectPartIds;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::SourceContextIds;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::DirectoryPathIds;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::SourceIds;
|
||||
using QmlDesigner::SourcePath;
|
||||
@@ -62,11 +62,11 @@ protected:
|
||||
return FileStatus{sourceId, 1, 1};
|
||||
});
|
||||
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(sourceContextPath)))
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(directoryPath)))
|
||||
.WillByDefault(Return(SourceIds{sourceIds[0], sourceIds[1]}));
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(sourceContextPath2)))
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(directoryPath2)))
|
||||
.WillByDefault(Return(SourceIds{sourceIds[2], sourceIds[3]}));
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(sourceContextPath3)))
|
||||
ON_CALL(mockFileSystem, directoryEntries(Eq(directoryPath3)))
|
||||
.WillByDefault(Return(SourceIds{sourceIds[4]}));
|
||||
}
|
||||
|
||||
@@ -98,40 +98,40 @@ protected:
|
||||
SourcePathView path5{"/path3/path"};
|
||||
QString path1QString = QString(path1.toStringView());
|
||||
QString path2QString = QString(path2.toStringView());
|
||||
QString sourceContextPath = "/path";
|
||||
QString sourceContextPath2 = "/path2";
|
||||
QString sourceContextPath3 = "/path3";
|
||||
Utils::PathString sourceContextPathString = sourceContextPath;
|
||||
Utils::PathString sourceContextPathString2 = sourceContextPath2;
|
||||
QString directoryPath = "/path";
|
||||
QString directoryPath2 = "/path2";
|
||||
QString directoryPath3 = "/path3";
|
||||
Utils::PathString directoryPathString = directoryPath;
|
||||
Utils::PathString directoryPathString2 = directoryPath2;
|
||||
SourceIds sourceIds = {pathCache.sourceId(path1),
|
||||
pathCache.sourceId(path2),
|
||||
pathCache.sourceId(path3),
|
||||
pathCache.sourceId(path4),
|
||||
pathCache.sourceId(path5)};
|
||||
SourceContextIds sourceContextIds = {sourceIds[0].contextId(),
|
||||
DirectoryPathIds directoryPathIds = {sourceIds[0].contextId(),
|
||||
sourceIds[2].contextId(),
|
||||
sourceIds[4].contextId()};
|
||||
ProjectChunkIds ids{projectChunkId1, projectChunkId2, projectChunkId3};
|
||||
WatcherEntry watcherEntry1{projectChunkId1, sourceContextIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry2{projectChunkId2, sourceContextIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry3{projectChunkId1, sourceContextIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry4{projectChunkId2, sourceContextIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry5{projectChunkId3, sourceContextIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry6{projectChunkId1, sourceContextIds[1], sourceIds[2]};
|
||||
WatcherEntry watcherEntry7{projectChunkId2, sourceContextIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry8{projectChunkId3, sourceContextIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry9{projectChunkId4, sourceContextIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry10{projectChunkId4, sourceContextIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry11{projectChunkId4, sourceContextIds[1], sourceIds[2]};
|
||||
WatcherEntry watcherEntry12{projectChunkId4, sourceContextIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry13{projectChunkId4, sourceContextIds[2], sourceIds[4]};
|
||||
WatcherEntry watcherEntry1{projectChunkId1, directoryPathIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry2{projectChunkId2, directoryPathIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry3{projectChunkId1, directoryPathIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry4{projectChunkId2, directoryPathIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry5{projectChunkId3, directoryPathIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry6{projectChunkId1, directoryPathIds[1], sourceIds[2]};
|
||||
WatcherEntry watcherEntry7{projectChunkId2, directoryPathIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry8{projectChunkId3, directoryPathIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry9{projectChunkId4, directoryPathIds[0], sourceIds[0]};
|
||||
WatcherEntry watcherEntry10{projectChunkId4, directoryPathIds[0], sourceIds[1]};
|
||||
WatcherEntry watcherEntry11{projectChunkId4, directoryPathIds[1], sourceIds[2]};
|
||||
WatcherEntry watcherEntry12{projectChunkId4, directoryPathIds[1], sourceIds[3]};
|
||||
WatcherEntry watcherEntry13{projectChunkId4, directoryPathIds[2], sourceIds[4]};
|
||||
};
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, add_id_paths)
|
||||
{
|
||||
EXPECT_CALL(mockQFileSytemWatcher,
|
||||
addPaths(
|
||||
UnorderedElementsAre(QString(sourceContextPath), QString(sourceContextPath2))));
|
||||
UnorderedElementsAre(QString(directoryPath), QString(directoryPath2))));
|
||||
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1], sourceIds[2]}},
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}}});
|
||||
@@ -142,7 +142,7 @@ TEST_F(ProjectStoragePathWatcher, update_id_paths_calls_add_path_in_file_watcher
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1]}},
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1]}}});
|
||||
|
||||
EXPECT_CALL(mockQFileSytemWatcher, addPaths(UnorderedElementsAre(QString(sourceContextPath2))));
|
||||
EXPECT_CALL(mockQFileSytemWatcher, addPaths(UnorderedElementsAre(QString(directoryPath2))));
|
||||
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1], sourceIds[2]}},
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}}});
|
||||
@@ -153,7 +153,7 @@ TEST_F(ProjectStoragePathWatcher, update_id_paths_and_remove_unused_paths_calls_
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1], sourceIds[2]}},
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}}});
|
||||
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(UnorderedElementsAre(QString(sourceContextPath2))));
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(UnorderedElementsAre(QString(directoryPath2))));
|
||||
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1]}},
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1]}}});
|
||||
@@ -226,7 +226,7 @@ TEST_F(ProjectStoragePathWatcher, add_empty_entries)
|
||||
TEST_F(ProjectStoragePathWatcher, add_entries_with_same_id_and_different_paths)
|
||||
{
|
||||
EXPECT_CALL(mockQFileSytemWatcher,
|
||||
addPaths(ElementsAre(sourceContextPath, sourceContextPath2, sourceContextPath3)));
|
||||
addPaths(ElementsAre(directoryPath, directoryPath2, directoryPath3)));
|
||||
|
||||
watcher.updateIdPaths(
|
||||
{{projectChunkId1, {sourceIds[0], sourceIds[1], sourceIds[2], sourceIds[4]}}});
|
||||
@@ -234,7 +234,7 @@ TEST_F(ProjectStoragePathWatcher, add_entries_with_same_id_and_different_paths)
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, add_entries_with_different_id_and_same_paths)
|
||||
{
|
||||
EXPECT_CALL(mockQFileSytemWatcher, addPaths(ElementsAre(sourceContextPath)));
|
||||
EXPECT_CALL(mockQFileSytemWatcher, addPaths(ElementsAre(directoryPath)));
|
||||
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1]}}});
|
||||
}
|
||||
@@ -294,7 +294,7 @@ TEST_F(ProjectStoragePathWatcher, remove_path_for_one_id)
|
||||
watcher.updateIdPaths({{projectChunkId1, {sourceIds[0], sourceIds[1]}},
|
||||
{projectChunkId3, {sourceIds[0], sourceIds[1], sourceIds[3]}}});
|
||||
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(ElementsAre(sourceContextPath2)));
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(ElementsAre(directoryPath2)));
|
||||
|
||||
watcher.removeIds({projectChunkId3.id});
|
||||
}
|
||||
@@ -316,7 +316,7 @@ TEST_F(ProjectStoragePathWatcher, remove_all_paths_for_three_id)
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}}});
|
||||
|
||||
EXPECT_CALL(mockQFileSytemWatcher,
|
||||
removePaths(ElementsAre(sourceContextPath, sourceContextPath2)));
|
||||
removePaths(ElementsAre(directoryPath, directoryPath2)));
|
||||
|
||||
watcher.removeIds({projectChunkId1.id, projectChunkId2.id, projectChunkId3.id});
|
||||
}
|
||||
@@ -327,7 +327,7 @@ TEST_F(ProjectStoragePathWatcher, remove_one_path_for_two_id)
|
||||
{projectChunkId2, {sourceIds[0], sourceIds[1]}},
|
||||
{projectChunkId3, {sourceIds[3]}}});
|
||||
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(ElementsAre(sourceContextPath)));
|
||||
EXPECT_CALL(mockQFileSytemWatcher, removePaths(ElementsAre(directoryPath)));
|
||||
|
||||
watcher.removeIds({projectChunkId1.id, projectChunkId2.id});
|
||||
}
|
||||
@@ -374,8 +374,8 @@ TEST_F(ProjectStoragePathWatcher, two_notify_file_changes)
|
||||
ElementsAre(IdPaths{projectChunkId1, {sourceIds[0], sourceIds[1]}},
|
||||
IdPaths{projectChunkId2, {sourceIds[0], sourceIds[1], sourceIds[3]}})));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath2);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath2);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_modified_time_changes)
|
||||
@@ -389,7 +389,7 @@ TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_modified_time_chang
|
||||
|
||||
EXPECT_CALL(notifier, pathsChanged(ElementsAre(sourceIds[0])));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_size_get_bigger)
|
||||
@@ -403,7 +403,7 @@ TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_size_get_bigger)
|
||||
|
||||
EXPECT_CALL(notifier, pathsChanged(ElementsAre(sourceIds[0])));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_size_get_smaller)
|
||||
@@ -417,7 +417,7 @@ TEST_F(ProjectStoragePathWatcher, notify_for_path_changes_if_size_get_smaller)
|
||||
|
||||
EXPECT_CALL(notifier, pathsChanged(ElementsAre(sourceIds[0])));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, no_notify_for_unwatched_path_changes)
|
||||
@@ -426,7 +426,7 @@ TEST_F(ProjectStoragePathWatcher, no_notify_for_unwatched_path_changes)
|
||||
|
||||
EXPECT_CALL(notifier, pathsChanged(IsEmpty()));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, no_duplicate_path_changes)
|
||||
@@ -438,8 +438,8 @@ TEST_F(ProjectStoragePathWatcher, no_duplicate_path_changes)
|
||||
|
||||
EXPECT_CALL(notifier, pathsChanged(ElementsAre(sourceIds[0])));
|
||||
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(sourceContextPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
mockQFileSytemWatcher.directoryChanged(directoryPath);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStoragePathWatcher, trigger_manual_two_notify_file_changes)
|
||||
@@ -493,7 +493,7 @@ TEST_F(ProjectStoragePathWatcher, update_context_id_paths_adds_entry_in_new_dire
|
||||
{projectChunkId4, {sourceIds[0], sourceIds[1], sourceIds[2], sourceIds[3]}},
|
||||
});
|
||||
|
||||
watcher.updateContextIdPaths({{projectChunkId4, {sourceIds[4]}}}, {sourceContextIds[2]});
|
||||
watcher.updateContextIdPaths({{projectChunkId4, {sourceIds[4]}}}, {directoryPathIds[2]});
|
||||
|
||||
ASSERT_THAT(watcher.watchedEntries(),
|
||||
UnorderedElementsAre(watcherEntry1,
|
||||
@@ -515,7 +515,7 @@ TEST_F(ProjectStoragePathWatcher, update_context_id_paths_adds_entry_to_director
|
||||
|
||||
watcher.updateContextIdPaths({{projectChunkId4,
|
||||
{sourceIds[0], sourceIds[1], sourceIds[2], sourceIds[3]}}},
|
||||
{sourceContextIds[1]});
|
||||
{directoryPathIds[1]});
|
||||
|
||||
ASSERT_THAT(watcher.watchedEntries(),
|
||||
UnorderedElementsAre(watcherEntry1,
|
||||
@@ -534,7 +534,7 @@ TEST_F(ProjectStoragePathWatcher, update_context_id_paths_removes_entry)
|
||||
{projectChunkId4, {sourceIds[0], sourceIds[1], sourceIds[2], sourceIds[3]}},
|
||||
});
|
||||
|
||||
watcher.updateContextIdPaths({{projectChunkId4, {sourceIds[3]}}}, {sourceContextIds[1]});
|
||||
watcher.updateContextIdPaths({{projectChunkId4, {sourceIds[3]}}}, {directoryPathIds[1]});
|
||||
|
||||
ASSERT_THAT(watcher.watchedEntries(),
|
||||
UnorderedElementsAre(watcherEntry1,
|
||||
|
@@ -62,12 +62,12 @@ using namespace Qt::StringLiterals;
|
||||
|
||||
namespace Storage = QmlDesigner::Storage;
|
||||
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::FileNameId;
|
||||
using QmlDesigner::FileStatus;
|
||||
using QmlDesigner::ModuleId;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::SourceNameId;
|
||||
using QmlDesigner::IdPaths;
|
||||
using QmlDesigner::ModuleId;
|
||||
using QmlDesigner::SourceId;
|
||||
using Storage::Import;
|
||||
using Storage::IsInsideProject;
|
||||
using Storage::ModuleKind;
|
||||
@@ -178,11 +178,11 @@ MATCHER(PackageIsEmpty, std::string(negation ? "isn't empty" : "is empty"))
|
||||
&& package.typeAnnotations.empty() && package.updatedTypeAnnotationSourceIds.empty();
|
||||
}
|
||||
|
||||
template<typename ModuleIdMatcher, typename TypeNameMatcher, typename SourceIdMatcher, typename SourceContextIdMatcher>
|
||||
template<typename ModuleIdMatcher, typename TypeNameMatcher, typename SourceIdMatcher, typename DirectoryPathIdMatcher>
|
||||
auto IsPropertyEditorQmlPath(const ModuleIdMatcher &moduleIdMatcher,
|
||||
const TypeNameMatcher &typeNameMatcher,
|
||||
const SourceIdMatcher &pathIdMatcher,
|
||||
const SourceContextIdMatcher &directoryIdMatcher)
|
||||
const DirectoryPathIdMatcher &directoryIdMatcher)
|
||||
{
|
||||
return AllOf(
|
||||
Field("PropertyEditorQmlPath::moduleId", &PropertyEditorQmlPath::moduleId, moduleIdMatcher),
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
setFileNames(directoryPath, qmlFileNames, {"*.qml"});
|
||||
}
|
||||
|
||||
void setDirectoryInfos(SourceContextId directorySourceId, const DirectoryInfos &directoryInfos)
|
||||
void setDirectoryInfos(DirectoryPathId directorySourceId, const DirectoryInfos &directoryInfos)
|
||||
{
|
||||
ON_CALL(projectStorageMock, fetchDirectoryInfos(Eq(directorySourceId)))
|
||||
.WillByDefault(Return(directoryInfos));
|
||||
@@ -340,8 +340,8 @@ public:
|
||||
ON_CALL(fileSystemMock, subdirectories(Eq(directoryPath))).WillByDefault(Return(subdirectoryPaths));
|
||||
}
|
||||
|
||||
void setStorageSubdirectories(SourceContextId directoryId,
|
||||
const QmlDesigner::SmallSourceContextIds<32> &subdirectoryIds)
|
||||
void setStorageSubdirectories(DirectoryPathId directoryId,
|
||||
const QmlDesigner::SmallDirectoryPathIds<32> &subdirectoryIds)
|
||||
{
|
||||
ON_CALL(projectStorageMock, fetchSubdirectoryIds(Eq(directoryId)))
|
||||
.WillByDefault(Return(subdirectoryIds));
|
||||
@@ -354,8 +354,8 @@ public:
|
||||
|
||||
SourceId createDirectorySourceId(Utils::SmallStringView path) const
|
||||
{
|
||||
auto directoryId = sourcePathCache.sourceContextId(path);
|
||||
return SourceId::create(SourceNameId{}, directoryId);
|
||||
auto directoryId = sourcePathCache.directoryPathId(path);
|
||||
return SourceId::create(FileNameId{}, directoryId);
|
||||
}
|
||||
|
||||
SourceId createDirectorySourceIdFromQString(const QString &path) const
|
||||
@@ -470,22 +470,21 @@ protected:
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
|
||||
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/path/example2.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
|
||||
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
|
||||
SourceId annotationDirectorySourceId = createDirectorySourceId("/path/designer");
|
||||
SourceId qmlDocumentSourceId1 = sourcePathCache.sourceId("/path/First.qml");
|
||||
SourceId qmlDocumentSourceId2 = sourcePathCache.sourceId("/path/First2.qml");
|
||||
SourceId qmlDocumentSourceId3 = sourcePathCache.sourceId("/path/Second.qml");
|
||||
const QString itemLibraryPath = QDir::cleanPath(
|
||||
UNITTEST_DIR "/../../../../share/qtcreator/qmldesigner/itemLibrary/");
|
||||
SourceContextId itemLibraryPathSourceContextId = sourcePathCache.sourceContextId(
|
||||
DirectoryPathId itemLibraryPathDirectoryPathId = sourcePathCache.directoryPathId(
|
||||
Utils::PathString{itemLibraryPath});
|
||||
SourceId itemLibraryPathSourceId = SourceId::create(SourceNameId{},
|
||||
itemLibraryPathSourceContextId);
|
||||
SourceId itemLibraryPathSourceId = SourceId::create(FileNameId{}, itemLibraryPathDirectoryPathId);
|
||||
const QString qmlImportsPath = QDir::cleanPath(UNITTEST_DIR "/projectstorage/data/qml");
|
||||
SourceContextId qmlImportsPathSourceContextId = sourcePathCache.sourceContextId(
|
||||
DirectoryPathId qmlImportsPathDirectoryPathId = sourcePathCache.directoryPathId(
|
||||
Utils::PathString{itemLibraryPath});
|
||||
SourceId qmlImportsPathSourceId = SourceId::create(SourceNameId{}, qmlImportsPathSourceContextId);
|
||||
SourceId qmlImportsPathSourceId = SourceId::create(FileNameId{}, qmlImportsPathDirectoryPathId);
|
||||
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
|
||||
ModuleId qmlCppNativeModuleId{storage.moduleId("Qml", ModuleKind::CppLibrary)};
|
||||
ModuleId exampleModuleId{storage.moduleId("Example", ModuleKind::QmlLibrary)};
|
||||
@@ -537,12 +536,12 @@ protected:
|
||||
QmlDesigner::SourceType::Qml};
|
||||
QmlDesigner::ProjectChunkId otherQmltypesProjectChunkId{otherProjectPartId,
|
||||
QmlDesigner::SourceType::QmlTypes};
|
||||
SourceContextId path1SourceContextId = sourcePathCache.sourceContextId("/path/one");
|
||||
SourceId path1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, path1SourceContextId);
|
||||
SourceContextId path2SourceContextId = sourcePathCache.sourceContextId("/path/two");
|
||||
SourceId path2SourceId = SourceId::create(QmlDesigner::SourceNameId{}, path2SourceContextId);
|
||||
SourceContextId path3SourceContextId = sourcePathCache.sourceContextId("/path/three");
|
||||
SourceId path3SourceId = SourceId::create(QmlDesigner::SourceNameId{}, path3SourceContextId);
|
||||
DirectoryPathId path1DirectoryPathId = sourcePathCache.directoryPathId("/path/one");
|
||||
SourceId path1SourceId = SourceId::create(QmlDesigner::FileNameId{}, path1DirectoryPathId);
|
||||
DirectoryPathId path2DirectoryPathId = sourcePathCache.directoryPathId("/path/two");
|
||||
SourceId path2SourceId = SourceId::create(QmlDesigner::FileNameId{}, path2DirectoryPathId);
|
||||
DirectoryPathId path3DirectoryPathId = sourcePathCache.directoryPathId("/path/three");
|
||||
SourceId path3SourceId = SourceId::create(QmlDesigner::FileNameId{}, path3DirectoryPathId);
|
||||
SourceId qmldir1SourceId = sourcePathCache.sourceId("/path/one/qmldir");
|
||||
SourceId qmldir2SourceId = sourcePathCache.sourceId("/path/two/qmldir");
|
||||
SourceId qmldir3SourceId = sourcePathCache.sourceId("/path/three/qmldir");
|
||||
@@ -609,8 +608,8 @@ public:
|
||||
QStringList directories = {"/path"};
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
|
||||
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
|
||||
};
|
||||
|
||||
TEST_F(ProjectStorageUpdater_get_content_for_qml_types, added_qml_types_file_provides_content)
|
||||
@@ -670,8 +669,8 @@ public:
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/root/path/example.qmltypes");
|
||||
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/root/path/example2.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/root/path/qmldir");
|
||||
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
|
||||
};
|
||||
|
||||
TEST_F(ProjectStorageUpdater_parse_qml_types, add_directory)
|
||||
@@ -783,8 +782,8 @@ public:
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/root/path/example.qmltypes");
|
||||
SourceId qmltypes2PathSourceId = sourcePathCache.sourceId("/root/path/example2.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/root/path/qmldir");
|
||||
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
|
||||
SourceId annotationDirectoryId = createDirectorySourceId("/root/path/designer");
|
||||
SourceId rootQmlDirPathSourceId = sourcePathCache.sourceId("/root/qmldir");
|
||||
SourceId rootDirectoryPathSourceId = createDirectorySourceId("/root");
|
||||
@@ -878,13 +877,13 @@ public:
|
||||
|
||||
public:
|
||||
SourceId rootDirectoryPathSourceId = createDirectorySourceId("/root");
|
||||
SourceContextId rootDirectoryPathId = rootDirectoryPathSourceId.contextId();
|
||||
DirectoryPathId rootDirectoryPathId = rootDirectoryPathSourceId.contextId();
|
||||
SourceId path1SourceId = createDirectorySourceId("/root/one");
|
||||
SourceContextId path1SourceContextId = path1SourceId.contextId();
|
||||
DirectoryPathId path1DirectoryPathId = path1SourceId.contextId();
|
||||
SourceId path2SourceId = createDirectorySourceId("/root/two");
|
||||
SourceContextId path2SourceContextId = path2SourceId.contextId();
|
||||
DirectoryPathId path2DirectoryPathId = path2SourceId.contextId();
|
||||
SourceId path3SourceId = createDirectorySourceId("/root/one/three");
|
||||
SourceContextId path3SourceContextId = path3SourceId.contextId();
|
||||
DirectoryPathId path3DirectoryPathId = path3SourceId.contextId();
|
||||
};
|
||||
|
||||
TEST_F(ProjectStorageUpdater_synchronize_subdirectories, added_qt_subdircectories)
|
||||
@@ -899,13 +898,13 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, added_qt_subdircectorie
|
||||
UnorderedElementsAre(
|
||||
IsDirectoryInfo(rootDirectoryPathId, path1SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(rootDirectoryPathId, path2SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(path1SourceContextId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
IsDirectoryInfo(path1DirectoryPathId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.qtDirectories = {"/root"}});
|
||||
}
|
||||
@@ -922,13 +921,13 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, changed_qt_subdircector
|
||||
UnorderedElementsAre(
|
||||
IsDirectoryInfo(rootDirectoryPathId, path1SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(rootDirectoryPathId, path2SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(path1SourceContextId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
IsDirectoryInfo(path1DirectoryPathId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.qtDirectories = {"/root"}});
|
||||
}
|
||||
@@ -945,13 +944,13 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, added_project_subdircec
|
||||
UnorderedElementsAre(
|
||||
IsDirectoryInfo(rootDirectoryPathId, path1SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(rootDirectoryPathId, path2SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(path1SourceContextId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
IsDirectoryInfo(path1DirectoryPathId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/root"});
|
||||
}
|
||||
@@ -968,13 +967,13 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, changed_project_subdirc
|
||||
UnorderedElementsAre(
|
||||
IsDirectoryInfo(rootDirectoryPathId, path1SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(rootDirectoryPathId, path2SourceId, ModuleId{}, FileType::Directory),
|
||||
IsDirectoryInfo(path1SourceContextId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
IsDirectoryInfo(path1DirectoryPathId, path3SourceId, ModuleId{}, FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/root"});
|
||||
}
|
||||
@@ -987,15 +986,15 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, qt_subdirectories_if_ro
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(AllOf(Field("SynchronizationPackage::directoryInfos",
|
||||
&SynchronizationPackage::directoryInfos,
|
||||
UnorderedElementsAre(IsDirectoryInfo(path1SourceContextId,
|
||||
UnorderedElementsAre(IsDirectoryInfo(path1DirectoryPathId,
|
||||
path3SourceId,
|
||||
ModuleId{},
|
||||
FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
UnorderedElementsAre(path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.qtDirectories = {"/root"}});
|
||||
}
|
||||
@@ -1008,15 +1007,15 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, project_subdirectories_
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
synchronize(AllOf(Field("SynchronizationPackage::directoryInfos",
|
||||
&SynchronizationPackage::directoryInfos,
|
||||
UnorderedElementsAre(IsDirectoryInfo(path1SourceContextId,
|
||||
UnorderedElementsAre(IsDirectoryInfo(path1DirectoryPathId,
|
||||
path3SourceId,
|
||||
ModuleId{},
|
||||
FileType::Directory))),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path1SourceContextId,
|
||||
path2SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
UnorderedElementsAre(path1DirectoryPathId,
|
||||
path2DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/root"});
|
||||
}
|
||||
@@ -1026,8 +1025,8 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, for_deleted_qt_subdirec
|
||||
setFilesChanged({rootDirectoryPathSourceId});
|
||||
setFilesRemoved({path1SourceId, path3SourceId});
|
||||
setFilesUnchanged({path2SourceId});
|
||||
setStorageSubdirectories(rootDirectoryPathId, {path1SourceContextId, path2SourceContextId});
|
||||
setStorageSubdirectories(path1SourceContextId, {path3SourceContextId});
|
||||
setStorageSubdirectories(rootDirectoryPathId, {path1DirectoryPathId, path2DirectoryPathId});
|
||||
setStorageSubdirectories(path1DirectoryPathId, {path3DirectoryPathId});
|
||||
setFileSystemSubdirectories(u"/root", {"/root/two"});
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
@@ -1040,8 +1039,8 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, for_deleted_qt_subdirec
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.qtDirectories = {"/root"}});
|
||||
}
|
||||
@@ -1051,8 +1050,8 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, for_deleted_project_sub
|
||||
setFilesChanged({rootDirectoryPathSourceId});
|
||||
setFilesRemoved({path1SourceId, path3SourceId});
|
||||
setFilesUnchanged({path2SourceId});
|
||||
setStorageSubdirectories(rootDirectoryPathId, {path1SourceContextId, path2SourceContextId});
|
||||
setStorageSubdirectories(path1SourceContextId, {path3SourceContextId});
|
||||
setStorageSubdirectories(rootDirectoryPathId, {path1DirectoryPathId, path2DirectoryPathId});
|
||||
setStorageSubdirectories(path1DirectoryPathId, {path3DirectoryPathId});
|
||||
setFileSystemSubdirectories(u"/root", {"/root/two"});
|
||||
|
||||
EXPECT_CALL(projectStorageMock,
|
||||
@@ -1065,8 +1064,8 @@ TEST_F(ProjectStorageUpdater_synchronize_subdirectories, for_deleted_project_sub
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(rootDirectoryPathId,
|
||||
path1SourceContextId,
|
||||
path3SourceContextId)))));
|
||||
path1DirectoryPathId,
|
||||
path3DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = {"/root"}});
|
||||
}
|
||||
@@ -1093,8 +1092,8 @@ public:
|
||||
public:
|
||||
SourceId qmltypesPathSourceId = sourcePathCache.sourceId("/path/example.qmltypes");
|
||||
SourceId qmlDirPathSourceId = sourcePathCache.sourceId("/path/qmldir");
|
||||
SourceContextId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryPathId);
|
||||
DirectoryPathId directoryPathId = qmlDirPathSourceId.contextId();
|
||||
SourceId directoryPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryPathId);
|
||||
SourceId annotationDirectorySourceId = createDirectorySourceId("/path/designer");
|
||||
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
|
||||
ModuleId exampleModuleId{storage.moduleId("Example", ModuleKind::QmlLibrary)};
|
||||
@@ -2744,11 +2743,11 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qml_files_changed)
|
||||
{
|
||||
setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId});
|
||||
setFilesChanged({firstSourceId, secondSourceId, thirdSourceId});
|
||||
setDirectoryInfos(path1SourceContextId,
|
||||
{{path1SourceContextId, firstSourceId, exampleModuleId, FileType::QmlDocument},
|
||||
{path1SourceContextId, secondSourceId, exampleModuleId, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path2SourceContextId,
|
||||
{{path2SourceContextId, thirdSourceId, ModuleId{}, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path1DirectoryPathId,
|
||||
{{path1DirectoryPathId, firstSourceId, exampleModuleId, FileType::QmlDocument},
|
||||
{path1DirectoryPathId, secondSourceId, exampleModuleId, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path2DirectoryPathId,
|
||||
{{path2DirectoryPathId, thirdSourceId, ModuleId{}, FileType::QmlDocument}});
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateIdPaths(Contains(IdPaths{qtPartId,
|
||||
@@ -2767,11 +2766,11 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qml_files_and_directories_dont
|
||||
firstSourceId,
|
||||
secondSourceId,
|
||||
thirdSourceId});
|
||||
setDirectoryInfos(path1SourceContextId,
|
||||
{{path1SourceContextId, firstSourceId, exampleModuleId, FileType::QmlDocument},
|
||||
{path1SourceContextId, secondSourceId, exampleModuleId, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path2SourceContextId,
|
||||
{{path2SourceContextId, thirdSourceId, ModuleId{}, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path1DirectoryPathId,
|
||||
{{path1DirectoryPathId, firstSourceId, exampleModuleId, FileType::QmlDocument},
|
||||
{path1DirectoryPathId, secondSourceId, exampleModuleId, FileType::QmlDocument}});
|
||||
setDirectoryInfos(path2DirectoryPathId,
|
||||
{{path2DirectoryPathId, thirdSourceId, ModuleId{}, FileType::QmlDocument}});
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateIdPaths(Contains(IdPaths{qtPartId,
|
||||
@@ -2822,10 +2821,10 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_only_qmltypes_files_changed)
|
||||
{
|
||||
setFilesUnchanged({qmldir1SourceId, qmldir2SourceId, path1SourceId, path2SourceId});
|
||||
setFilesChanged({qmltypes1SourceId, qmltypes2SourceId});
|
||||
setDirectoryInfos(path1SourceContextId,
|
||||
{{path1SourceContextId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path2SourceContextId,
|
||||
{{path2SourceContextId, qmltypes2SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path1DirectoryPathId,
|
||||
{{path1DirectoryPathId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path2DirectoryPathId,
|
||||
{{path2DirectoryPathId, qmltypes2SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateIdPaths(Contains(IdPaths{qtPartId,
|
||||
@@ -2843,10 +2842,10 @@ TEST_F(ProjectStorageUpdater, update_path_watcher_qmltypes_files_and_directories
|
||||
path2SourceId,
|
||||
qmltypes1SourceId,
|
||||
qmltypes2SourceId});
|
||||
setDirectoryInfos(path1SourceContextId,
|
||||
{{path1SourceContextId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path2SourceContextId,
|
||||
{{path2SourceContextId, qmltypes2SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path1DirectoryPathId,
|
||||
{{path1DirectoryPathId, qmltypes1SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
setDirectoryInfos(path2DirectoryPathId,
|
||||
{{path2DirectoryPathId, qmltypes2SourceId, exampleModuleId, FileType::QmlTypes}});
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateIdPaths(Contains(IdPaths{qtPartId,
|
||||
@@ -3244,8 +3243,8 @@ TEST_F(ProjectStorageUpdater, watcher_updates_subdirectories)
|
||||
FirstType 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
setContent(u"/path/qmldir", qmldir);
|
||||
SourceContextId rootPathId = sourcePathCache.sourceContextId("/root");
|
||||
SourceId rootPathSourceId = SourceId::create(QmlDesigner::SourceNameId{}, rootPathId);
|
||||
DirectoryPathId rootPathId = sourcePathCache.directoryPathId("/root");
|
||||
SourceId rootPathSourceId = SourceId::create(QmlDesigner::FileNameId{}, rootPathId);
|
||||
SourceId rootQmldirPathSourceId = sourcePathCache.sourceId("/root/qmldir");
|
||||
setFilesChanged({directoryPathSourceId, rootPathSourceId});
|
||||
setFilesUnchanged({qmlDirPathSourceId, rootQmldirPathSourceId});
|
||||
@@ -3357,7 +3356,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_directory_change
|
||||
setContent(u"/path/qmldir", qmldir);
|
||||
setFilesChanged({directoryPathSourceId});
|
||||
setFilesUnchanged({qmlDirPathSourceId});
|
||||
auto directorySourceContextId = directoryPathSourceId.contextId();
|
||||
auto directoryDirectoryPathId = directoryPathSourceId.contextId();
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateContextIdPaths(
|
||||
@@ -3367,7 +3366,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_directory_change
|
||||
IdPaths{qtPartId,
|
||||
QmlDesigner::SourceType::Qml,
|
||||
{qmlDocumentSourceId1, qmlDocumentSourceId2, qmlDocumentSourceId3}}),
|
||||
UnorderedElementsAre(directorySourceContextId)));
|
||||
UnorderedElementsAre(directoryDirectoryPathId)));
|
||||
|
||||
updater.pathsWithIdsChanged({{directoryProjectChunkId, {directoryPathSourceId}}});
|
||||
}
|
||||
@@ -3472,7 +3471,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_qmldir_changes)
|
||||
FirstType 2.2 First2.qml
|
||||
SecondType 2.2 Second.qml)"};
|
||||
setContent(u"/path/qmldir", qmldir);
|
||||
auto directorySourceContextId = qmlDirPathSourceId.contextId();
|
||||
auto directoryDirectoryPathId = qmlDirPathSourceId.contextId();
|
||||
|
||||
EXPECT_CALL(patchWatcherMock,
|
||||
updateContextIdPaths(
|
||||
@@ -3482,7 +3481,7 @@ TEST_F(ProjectStorageUpdater, watcher_watches_directories_after_qmldir_changes)
|
||||
IdPaths{qtPartId,
|
||||
QmlDesigner::SourceType::Qml,
|
||||
{qmlDocumentSourceId1, qmlDocumentSourceId2, qmlDocumentSourceId3}}),
|
||||
UnorderedElementsAre(directorySourceContextId)));
|
||||
UnorderedElementsAre(directoryDirectoryPathId)));
|
||||
|
||||
updater.pathsWithIdsChanged({{qmldirProjectChunkId, {qmlDirPathSourceId}}});
|
||||
}
|
||||
@@ -4793,9 +4792,9 @@ TEST_F(ProjectStorageUpdater, update_property_editor_panes)
|
||||
});
|
||||
auto sourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML/QtObjectPane.qml"});
|
||||
auto directoryId = sourcePathCache.sourceContextId(
|
||||
auto directoryId = sourcePathCache.directoryPathId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QML"});
|
||||
auto directorySourceId = SourceId::create(QmlDesigner::SourceNameId{}, directoryId);
|
||||
auto directorySourceId = SourceId::create(QmlDesigner::FileNameId{}, directoryId);
|
||||
setFilesChanged({directorySourceId});
|
||||
auto qmlModuleId = storage.moduleId("QML", ModuleKind::QmlLibrary);
|
||||
|
||||
@@ -4828,15 +4827,14 @@ TEST_F(ProjectStorageUpdater, update_property_editor_specifics)
|
||||
});
|
||||
auto textSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/TextSpecifics.qml"});
|
||||
auto qtQuickDirectoryId = sourcePathCache.sourceContextId(
|
||||
auto qtQuickDirectoryId = sourcePathCache.directoryPathId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick"});
|
||||
auto qtQuickDirectorySourceId = SourceId::create(QmlDesigner::SourceNameId{}, qtQuickDirectoryId);
|
||||
auto qtQuickDirectorySourceId = SourceId::create(QmlDesigner::FileNameId{}, qtQuickDirectoryId);
|
||||
auto buttonSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls/ButtonSpecifics.qml"});
|
||||
auto controlsDirectoryId = sourcePathCache.sourceContextId(
|
||||
auto controlsDirectoryId = sourcePathCache.directoryPathId(
|
||||
QmlDesigner::SourcePath{propertyEditorQmlPath + "/QtQuick/Controls"});
|
||||
auto controlsDirectorySourceId = SourceId::create(QmlDesigner::SourceNameId{},
|
||||
controlsDirectoryId);
|
||||
auto controlsDirectorySourceId = SourceId::create(QmlDesigner::FileNameId{}, controlsDirectoryId);
|
||||
setFilesChanged({qtQuickDirectorySourceId, controlsDirectorySourceId});
|
||||
auto qtQuickModuleId = storage.moduleId("QtQuick", ModuleKind::QmlLibrary);
|
||||
auto controlsModuleId = storage.moduleId("QtQuick.Controls", ModuleKind::QmlLibrary);
|
||||
@@ -4888,7 +4886,7 @@ TEST_F(ProjectStorageUpdater, update_type_annotations)
|
||||
synchronize(AllOf(Field("SynchronizationPackage::typeAnnotations",
|
||||
&SynchronizationPackage::typeAnnotations,
|
||||
IsSupersetOf({IsTypeAnnotation(qtQuickSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Item",
|
||||
qtQuickModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -4896,7 +4894,7 @@ TEST_F(ProjectStorageUpdater, update_type_annotations)
|
||||
_,
|
||||
_),
|
||||
IsTypeAnnotation(qtQuickControlSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Button",
|
||||
qtQuickControlsModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -4927,7 +4925,7 @@ TEST_F(ProjectStorageUpdater, update_added_type_annotation)
|
||||
synchronize(AllOf(Field("SynchronizationPackage::typeAnnotations",
|
||||
&SynchronizationPackage::typeAnnotations,
|
||||
IsSupersetOf({IsTypeAnnotation(qtQuickSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Item",
|
||||
qtQuickModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -4935,7 +4933,7 @@ TEST_F(ProjectStorageUpdater, update_added_type_annotation)
|
||||
_,
|
||||
_),
|
||||
IsTypeAnnotation(qtQuickControlSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Button",
|
||||
qtQuickControlsModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -4966,7 +4964,7 @@ TEST_F(ProjectStorageUpdater, update_changed_type_annotation)
|
||||
synchronize(AllOf(Field("SynchronizationPackage::typeAnnotations",
|
||||
&SynchronizationPackage::typeAnnotations,
|
||||
IsSupersetOf({IsTypeAnnotation(qtQuickSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Item",
|
||||
qtQuickModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -4974,7 +4972,7 @@ TEST_F(ProjectStorageUpdater, update_changed_type_annotation)
|
||||
_,
|
||||
_),
|
||||
IsTypeAnnotation(qtQuickControlSourceId,
|
||||
itemLibraryPathSourceContextId,
|
||||
itemLibraryPathDirectoryPathId,
|
||||
"Button",
|
||||
qtQuickControlsModuleId,
|
||||
StartsWith(itemLibraryPath),
|
||||
@@ -5020,8 +5018,8 @@ TEST_F(ProjectStorageUpdater, update_type_annotations_removed_meta_info_file)
|
||||
auto qtQuickControlSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{itemLibraryPath + "/qtquickcontrols2.metainfo"});
|
||||
ON_CALL(projectStorageMock, typeAnnotationDirectoryIds())
|
||||
.WillByDefault(Return(QmlDesigner::SmallSourceContextIds<64>{itemLibraryPathSourceContextId}));
|
||||
ON_CALL(projectStorageMock, typeAnnotationSourceIds(itemLibraryPathSourceContextId))
|
||||
.WillByDefault(Return(QmlDesigner::SmallDirectoryPathIds<64>{itemLibraryPathDirectoryPathId}));
|
||||
ON_CALL(projectStorageMock, typeAnnotationSourceIds(itemLibraryPathDirectoryPathId))
|
||||
.WillByDefault(Return(QmlDesigner::SmallSourceIds<4>{qtQuickSourceId, qtQuickControlSourceId}));
|
||||
setFilesChanged({itemLibraryPathSourceId});
|
||||
setFilesRemoved({qtQuickSourceId});
|
||||
@@ -5052,10 +5050,10 @@ TEST_F(ProjectStorageUpdater, update_type_annotations_removed_directory)
|
||||
auto qtQuickControlSourceId = sourcePathCache.sourceId(
|
||||
QmlDesigner::SourcePath{itemLibraryPath + "/qtquickcontrols2.metainfo"});
|
||||
ON_CALL(projectStorageMock, typeAnnotationDirectoryIds())
|
||||
.WillByDefault(Return(QmlDesigner::SmallSourceContextIds<64>{
|
||||
itemLibraryPathSourceContextId,
|
||||
.WillByDefault(Return(QmlDesigner::SmallDirectoryPathIds<64>{
|
||||
itemLibraryPathDirectoryPathId,
|
||||
}));
|
||||
ON_CALL(projectStorageMock, typeAnnotationSourceIds(itemLibraryPathSourceContextId))
|
||||
ON_CALL(projectStorageMock, typeAnnotationSourceIds(itemLibraryPathDirectoryPathId))
|
||||
.WillByDefault(Return(QmlDesigner::SmallSourceIds<4>{qtQuickSourceId, qtQuickControlSourceId}));
|
||||
setFilesRemoved({itemLibraryPathSourceId, qtQuickSourceId, qtQuickControlSourceId});
|
||||
|
||||
@@ -5073,8 +5071,8 @@ TEST_F(ProjectStorageUpdater, update_type_annotations_removed_directory)
|
||||
TEST_F(ProjectStorageUpdater, synchronize_added_property_editor_qml_paths_directory)
|
||||
{
|
||||
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesUnchanged({path1SourceId});
|
||||
setFilesAdded({designer1SourceId});
|
||||
|
||||
@@ -5099,7 +5097,7 @@ TEST_F(ProjectStorageUpdater, synchronize_added_property_editor_qml_paths_direct
|
||||
IsEmpty()),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path1SourceContextId)))));
|
||||
UnorderedElementsAre(path1DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/path/one"});
|
||||
}
|
||||
@@ -5107,8 +5105,8 @@ TEST_F(ProjectStorageUpdater, synchronize_added_property_editor_qml_paths_direct
|
||||
TEST_F(ProjectStorageUpdater, synchronize_changed_property_editor_qml_paths_directory)
|
||||
{
|
||||
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesUnchanged({path1SourceId});
|
||||
setFilesChanged({designer1SourceId});
|
||||
|
||||
@@ -5133,7 +5131,7 @@ TEST_F(ProjectStorageUpdater, synchronize_changed_property_editor_qml_paths_dire
|
||||
IsEmpty()),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path1SourceContextId)))));
|
||||
UnorderedElementsAre(path1DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/path/one"});
|
||||
}
|
||||
@@ -5141,8 +5139,8 @@ TEST_F(ProjectStorageUpdater, synchronize_changed_property_editor_qml_paths_dire
|
||||
TEST_F(ProjectStorageUpdater, dont_synchronize_empty_property_editor_qml_paths_directory)
|
||||
{
|
||||
setFileSystemSubdirectories(u"/path/two", {});
|
||||
SourceContextId designer2DirectoryId = sourcePathCache.sourceContextId("/path/two/designer");
|
||||
SourceId designer2SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer2DirectoryId);
|
||||
DirectoryPathId designer2DirectoryId = sourcePathCache.directoryPathId("/path/two/designer");
|
||||
SourceId designer2SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer2DirectoryId);
|
||||
setFilesChanged({path2SourceId});
|
||||
setFilesNotExists({designer2SourceId});
|
||||
|
||||
@@ -5166,15 +5164,15 @@ TEST_F(ProjectStorageUpdater, dont_synchronize_empty_property_editor_qml_paths_d
|
||||
IsEmpty()),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path2SourceContextId)))));
|
||||
UnorderedElementsAre(path2DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/path/two"});
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorageUpdater, remove_property_editor_qml_paths_if_designer_directory_is_removed)
|
||||
{
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesUnchanged({path1SourceId, qmldir1SourceId});
|
||||
setFilesRemoved({designer1SourceId});
|
||||
|
||||
@@ -5197,7 +5195,7 @@ TEST_F(ProjectStorageUpdater, remove_property_editor_qml_paths_if_designer_direc
|
||||
IsEmpty()),
|
||||
Field("SynchronizationPackage::updatedDirectoryInfoDirectoryIds",
|
||||
&SynchronizationPackage::updatedDirectoryInfoDirectoryIds,
|
||||
UnorderedElementsAre(path1SourceContextId)))));
|
||||
UnorderedElementsAre(path1DirectoryPathId)))));
|
||||
|
||||
updater.update({.projectDirectory = "/path/one"});
|
||||
}
|
||||
@@ -5208,14 +5206,14 @@ TEST_F(ProjectStorageUpdater,
|
||||
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
|
||||
QString qmldir{R"(module Bar)"};
|
||||
setContent(u"/path/one/qmldir", qmldir);
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId propertyEditorSpecificSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/FooSpecifics.qml");
|
||||
SourceId propertyEditorSpecificDynamicSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/HuoSpecificsDynamic.qml");
|
||||
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/CaoPane.qml");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesChanged({designer1SourceId});
|
||||
setFilesUnchanged({path1SourceId, qmldir1SourceId});
|
||||
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);
|
||||
@@ -5252,14 +5250,14 @@ TEST_F(ProjectStorageUpdater,
|
||||
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
|
||||
QString qmldir{R"(module Bar)"};
|
||||
setContent(u"/path/one/qmldir", qmldir);
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId propertyEditorSpecificSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/FooSpecifics.qml");
|
||||
SourceId propertyEditorSpecificDynamicSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/HuoSpecificsDynamic.qml");
|
||||
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/CaoPane.qml");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesChanged({path1SourceId});
|
||||
setFilesUnchanged({qmldir1SourceId, designer1SourceId});
|
||||
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);
|
||||
@@ -5295,14 +5293,14 @@ TEST_F(ProjectStorageUpdater, synchronize_property_editor_qml_paths_directory_if
|
||||
setFileSystemSubdirectories(u"/path/one", {"/path/one/designer"});
|
||||
QString qmldir{R"(module Bar)"};
|
||||
setContent(u"/path/one/qmldir", qmldir);
|
||||
SourceContextId designer1DirectoryId = sourcePathCache.sourceContextId("/path/one/designer");
|
||||
DirectoryPathId designer1DirectoryId = sourcePathCache.directoryPathId("/path/one/designer");
|
||||
SourceId propertyEditorSpecificSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/FooSpecifics.qml");
|
||||
SourceId propertyEditorSpecificDynamicSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/HuoSpecificsDynamic.qml");
|
||||
SourceId propertyEditorPaneSourceId = sourcePathCache.sourceId(
|
||||
"/path/one/designer/CaoPane.qml");
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::SourceNameId{}, designer1DirectoryId);
|
||||
SourceId designer1SourceId = SourceId::create(QmlDesigner::FileNameId{}, designer1DirectoryId);
|
||||
setFilesChanged({qmldir1SourceId});
|
||||
setFilesUnchanged({path1SourceId, designer1SourceId});
|
||||
auto barModuleId = storage.moduleId("Bar", ModuleKind::QmlLibrary);
|
||||
|
@@ -18,7 +18,7 @@ namespace {
|
||||
namespace Storage = QmlDesigner::Storage;
|
||||
namespace Synchronization = Storage::Synchronization;
|
||||
using QmlDesigner::ModuleId;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::Storage::ModuleKind;
|
||||
using Storage::TypeTraits;
|
||||
@@ -158,8 +158,8 @@ protected:
|
||||
QmlDesigner::QmlDocumentParser parser{storage, sourcePathCache};
|
||||
Storage::Imports imports;
|
||||
SourceId qmlFileSourceId{sourcePathCache.sourceId("/path/to/qmlfile.qml")};
|
||||
SourceContextId qmlFileSourceContextId{qmlFileSourceId.contextId()};
|
||||
Utils::PathString directoryPath{sourcePathCache.sourceContextPath(qmlFileSourceContextId)};
|
||||
DirectoryPathId qmlFileDirectoryPathId{qmlFileSourceId.contextId()};
|
||||
Utils::PathString directoryPath{sourcePathCache.directoryPath(qmlFileDirectoryPathId)};
|
||||
ModuleId directoryModuleId{storage.moduleId(directoryPath, ModuleKind::PathLibrary)};
|
||||
};
|
||||
|
||||
|
@@ -17,7 +17,7 @@ namespace {
|
||||
namespace Storage = QmlDesigner::Storage;
|
||||
namespace Synchronization = QmlDesigner::Storage::Synchronization;
|
||||
using QmlDesigner::ModuleId;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::Storage::ModuleKind;
|
||||
|
||||
@@ -200,7 +200,7 @@ protected:
|
||||
qmltypesFileSourceId,
|
||||
qtQmlNativeModuleId,
|
||||
Synchronization::FileType::QmlTypes};
|
||||
SourceContextId qmltypesFileSourceContextId{qmltypesFileSourceId.contextId()};
|
||||
DirectoryPathId qmltypesFileDirectoryPathId{qmltypesFileSourceId.contextId()};
|
||||
};
|
||||
|
||||
TEST_F(QmlTypesParser, imports)
|
||||
|
@@ -53,7 +53,7 @@ protected:
|
||||
QmlDesigner::ProjectStorage &storage = staticData->storage;
|
||||
QmlDesigner::Storage::TypeAnnotationReader reader{storage};
|
||||
QmlDesigner::SourceId sourceId = QmlDesigner::SourceId::create(33);
|
||||
QmlDesigner::SourceContextId directoryId = QmlDesigner::SourceContextId::create(77);
|
||||
QmlDesigner::DirectoryPathId directoryId = QmlDesigner::DirectoryPathId::create(77);
|
||||
QmlDesigner::Storage::TypeTraits traits;
|
||||
};
|
||||
|
||||
|
@@ -10,13 +10,13 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::SourceIds;
|
||||
using QmlDesigner::SourceNameId;
|
||||
using QmlDesigner::FileNameId;
|
||||
using Cache = QmlDesigner::SourcePathCache<NiceMock<ProjectStorageMock>>;
|
||||
using NFP = QmlDesigner::SourcePath;
|
||||
using QmlDesigner::Cache::SourceName;
|
||||
using QmlDesigner::Cache::FileName;
|
||||
using QmlDesigner::SourcePathView;
|
||||
using QmlDesigner::SourcePathViews;
|
||||
|
||||
@@ -25,48 +25,48 @@ class SourcePathCache : public testing::Test
|
||||
protected:
|
||||
SourcePathCache()
|
||||
{
|
||||
ON_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).WillByDefault(Return(sourceContextId5));
|
||||
ON_CALL(storageMock, fetchSourceContextId(Eq("/path2/to"))).WillByDefault(Return(sourceContextId6));
|
||||
ON_CALL(storageMock, fetchSourceNameId(Eq("file.cpp"))).WillByDefault(Return(sourceNameId42));
|
||||
ON_CALL(storageMock, fetchSourceNameId(Eq("file2.cpp"))).WillByDefault(Return(sourceNameId63));
|
||||
ON_CALL(storageMock, fetchSourceContextPath(sourceContextId5))
|
||||
ON_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to"))).WillByDefault(Return(directoryPathId5));
|
||||
ON_CALL(storageMock, fetchDirectoryPathId(Eq("/path2/to"))).WillByDefault(Return(directoryPathId6));
|
||||
ON_CALL(storageMock, fetchFileNameId(Eq("file.cpp"))).WillByDefault(Return(fileNameId42));
|
||||
ON_CALL(storageMock, fetchFileNameId(Eq("file2.cpp"))).WillByDefault(Return(fileNameId63));
|
||||
ON_CALL(storageMock, fetchDirectoryPath(directoryPathId5))
|
||||
.WillByDefault(Return(Utils::PathString("/path/to")));
|
||||
ON_CALL(storageMock, fetchSourceName(sourceNameId42)).WillByDefault(Return("file.cpp"));
|
||||
ON_CALL(storageMockFilled, fetchAllSourceNames())
|
||||
.WillByDefault(Return(std::vector<QmlDesigner::Cache::SourceName>(
|
||||
{{"file.cpp", sourceNameId42}, {"file2.cpp", sourceNameId63}})));
|
||||
ON_CALL(storageMockFilled, fetchAllSourceContexts())
|
||||
.WillByDefault(Return(std::vector<QmlDesigner::Cache::SourceContext>(
|
||||
{{"/path2/to", sourceContextId6}, {"/path/to", sourceContextId5}})));
|
||||
ON_CALL(storageMockFilled, fetchSourceContextId(Eq("/path/to")))
|
||||
.WillByDefault(Return(sourceContextId5));
|
||||
ON_CALL(storageMockFilled, fetchSourceNameId(Eq("file.cpp"))).WillByDefault(Return(sourceNameId42));
|
||||
ON_CALL(storageMock, fetchFileName(fileNameId42)).WillByDefault(Return("file.cpp"));
|
||||
ON_CALL(storageMockFilled, fetchAllFileNames())
|
||||
.WillByDefault(Return(std::vector<QmlDesigner::Cache::FileName>(
|
||||
{{"file.cpp", fileNameId42}, {"file2.cpp", fileNameId63}})));
|
||||
ON_CALL(storageMockFilled, fetchAllDirectoryPaths())
|
||||
.WillByDefault(Return(std::vector<QmlDesigner::Cache::DirectoryPath>(
|
||||
{{"/path2/to", directoryPathId6}, {"/path/to", directoryPathId5}})));
|
||||
ON_CALL(storageMockFilled, fetchDirectoryPathId(Eq("/path/to")))
|
||||
.WillByDefault(Return(directoryPathId5));
|
||||
ON_CALL(storageMockFilled, fetchFileNameId(Eq("file.cpp"))).WillByDefault(Return(fileNameId42));
|
||||
}
|
||||
|
||||
protected:
|
||||
SourceNameId sourceNameId42 = SourceNameId::create(42);
|
||||
SourceNameId sourceNameId63 = SourceNameId::create(63);
|
||||
SourceContextId sourceContextId5 = SourceContextId::create(5);
|
||||
SourceContextId sourceContextId6 = SourceContextId::create(6);
|
||||
SourceId sourceId542 = SourceId::create(sourceNameId42, sourceContextId5);
|
||||
SourceId sourceId563 = SourceId::create(sourceNameId63, sourceContextId5);
|
||||
SourceId sourceId642 = SourceId::create(sourceNameId42, sourceContextId6);
|
||||
FileNameId fileNameId42 = FileNameId::create(42);
|
||||
FileNameId fileNameId63 = FileNameId::create(63);
|
||||
DirectoryPathId directoryPathId5 = DirectoryPathId::create(5);
|
||||
DirectoryPathId directoryPathId6 = DirectoryPathId::create(6);
|
||||
SourceId sourceId542 = SourceId::create(fileNameId42, directoryPathId5);
|
||||
SourceId sourceId563 = SourceId::create(fileNameId63, directoryPathId5);
|
||||
SourceId sourceId642 = SourceId::create(fileNameId42, directoryPathId6);
|
||||
NiceMock<ProjectStorageMock> storageMock;
|
||||
Cache cache{storageMock};
|
||||
NiceMock<ProjectStorageMock> storageMockFilled;
|
||||
Cache cacheNotFilled{storageMockFilled};
|
||||
};
|
||||
|
||||
TEST_F(SourcePathCache, source_id_with_out_any_entry_call_source_context_id)
|
||||
TEST_F(SourcePathCache, source_id_with_out_any_entry_call_directory_path_id)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to")));
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to")));
|
||||
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_id_with_out_any_entry_calls)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp")));
|
||||
EXPECT_CALL(storageMock, fetchFileNameId(Eq("file.cpp")));
|
||||
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
@@ -78,11 +78,11 @@ TEST_F(SourcePathCache, source_id_of_source_id_with_out_any_entry)
|
||||
ASSERT_THAT(sourceId, sourceId542);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_id_with_source_context_id_and_source_name)
|
||||
TEST_F(SourcePathCache, source_id_with_directory_path_id_and_file_name)
|
||||
{
|
||||
auto sourceContextId = cache.sourceContextId("/path/to"_sv);
|
||||
auto directoryPathId = cache.directoryPathId("/path/to"_sv);
|
||||
|
||||
auto sourceId = cache.sourceId(sourceContextId, "file.cpp"_sv);
|
||||
auto sourceId = cache.sourceId(directoryPathId, "file.cpp"_sv);
|
||||
|
||||
ASSERT_THAT(sourceId, sourceId542);
|
||||
}
|
||||
@@ -91,18 +91,19 @@ TEST_F(SourcePathCache, if_entry_exists_dont_call_in_strorage)
|
||||
{
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchFileNameId(Eq("file.cpp"))).Times(0);
|
||||
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, if_directory_entry_exists_dont_call_fetch_source_context_id_but_still_call_fetch_source_id)
|
||||
TEST_F(SourcePathCache,
|
||||
if_directory_entry_exists_dont_call_fetch_directory_path_id_but_still_call_fetch_source_id)
|
||||
{
|
||||
cache.sourceId(SourcePathView("/path/to/file2.cpp"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp")));
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchFileNameId(Eq("file.cpp")));
|
||||
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
}
|
||||
@@ -116,7 +117,7 @@ TEST_F(SourcePathCache, get_source_id_with_cached_value)
|
||||
ASSERT_THAT(sourceId, sourceId542);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_source_id_with_source_context_id_cached)
|
||||
TEST_F(SourcePathCache, get_source_id_with_directory_path_id_cached)
|
||||
{
|
||||
cache.sourceId(SourcePathView("/path/to/file.cpp"));
|
||||
|
||||
@@ -166,135 +167,135 @@ TEST_F(SourcePathCache, duplicate_file_paths_are_equal)
|
||||
ASSERT_THAT(sourcePath2Id, Eq(sourcePath1Id));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_calls_fetch_source_context_id)
|
||||
TEST_F(SourcePathCache, directory_path_id_calls_fetch_directory_path_id)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to")));
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to")));
|
||||
|
||||
cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, second_source_context_id_calls_not_fetch_source_context_id)
|
||||
TEST_F(SourcePathCache, second_directory_path_id_calls_not_fetch_directory_path_id)
|
||||
{
|
||||
cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to"))).Times(0);
|
||||
|
||||
cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_with_trailing_slash)
|
||||
TEST_F(SourcePathCache, directory_path_id_with_trailing_slash)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceContextId(Eq("/path/to")));
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPathId(Eq("/path/to")));
|
||||
|
||||
cache.sourceContextId(Utils::SmallString("/path/to/"));
|
||||
cache.directoryPathId(Utils::SmallString("/path/to/"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id)
|
||||
TEST_F(SourcePathCache, directory_path_id)
|
||||
{
|
||||
auto id = cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
auto id = cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
ASSERT_THAT(id, Eq(sourceContextId5));
|
||||
ASSERT_THAT(id, Eq(directoryPathId5));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_is_already_in_cache)
|
||||
TEST_F(SourcePathCache, directory_path_id_is_already_in_cache)
|
||||
{
|
||||
auto firstId = cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
auto firstId = cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
auto secondId = cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
auto secondId = cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
ASSERT_THAT(secondId, firstId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_is_already_in_cache_with_trailing_slash)
|
||||
TEST_F(SourcePathCache, directory_path_id_is_already_in_cache_with_trailing_slash)
|
||||
{
|
||||
auto firstId = cache.sourceContextId(Utils::SmallString("/path/to/"));
|
||||
auto firstId = cache.directoryPathId(Utils::SmallString("/path/to/"));
|
||||
|
||||
auto secondId = cache.sourceContextId(Utils::SmallString("/path/to/"));
|
||||
auto secondId = cache.directoryPathId(Utils::SmallString("/path/to/"));
|
||||
|
||||
ASSERT_THAT(secondId, firstId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_is_already_in_cache_with_and_without_trailing_slash)
|
||||
TEST_F(SourcePathCache, directory_path_id_is_already_in_cache_with_and_without_trailing_slash)
|
||||
{
|
||||
auto firstId = cache.sourceContextId(Utils::SmallString("/path/to/"));
|
||||
auto firstId = cache.directoryPathId(Utils::SmallString("/path/to/"));
|
||||
|
||||
auto secondId = cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
auto secondId = cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
ASSERT_THAT(secondId, firstId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_context_id_is_already_in_cache_without_and_with_trailing_slash)
|
||||
TEST_F(SourcePathCache, directory_path_id_is_already_in_cache_without_and_with_trailing_slash)
|
||||
{
|
||||
auto firstId = cache.sourceContextId(Utils::SmallString("/path/to"));
|
||||
auto firstId = cache.directoryPathId(Utils::SmallString("/path/to"));
|
||||
|
||||
auto secondId = cache.sourceContextId(Utils::SmallString("/path/to/"));
|
||||
auto secondId = cache.directoryPathId(Utils::SmallString("/path/to/"));
|
||||
|
||||
ASSERT_THAT(secondId, firstId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, throw_for_getting_a_directory_path_with_an_invalid_id)
|
||||
{
|
||||
SourceContextId sourceContextId;
|
||||
DirectoryPathId directoryPathId;
|
||||
|
||||
ASSERT_THROW(cache.sourceContextPath(sourceContextId),
|
||||
QmlDesigner::NoSourceContextPathForInvalidSourceContextId);
|
||||
ASSERT_THROW(cache.directoryPath(directoryPathId),
|
||||
QmlDesigner::NoDirectoryPathForInvalidDirectoryPathId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_a_directory_path)
|
||||
{
|
||||
SourceContextId sourceContextId{sourceContextId5};
|
||||
DirectoryPathId directoryPathId{directoryPathId5};
|
||||
|
||||
auto sourceContextPath = cache.sourceContextPath(sourceContextId);
|
||||
auto directoryPath = cache.directoryPath(directoryPathId);
|
||||
|
||||
ASSERT_THAT(sourceContextPath, Eq(Utils::SmallStringView{"/path/to"}));
|
||||
ASSERT_THAT(directoryPath, Eq(Utils::SmallStringView{"/path/to"}));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_a_directory_path_with_cached_source_context_id)
|
||||
TEST_F(SourcePathCache, get_a_directory_path_with_cached_directory_path_id)
|
||||
{
|
||||
SourceContextId sourceContextId{sourceContextId5};
|
||||
cache.sourceContextPath(sourceContextId);
|
||||
DirectoryPathId directoryPathId{directoryPathId5};
|
||||
cache.directoryPath(directoryPathId);
|
||||
|
||||
auto sourceContextPath = cache.sourceContextPath(sourceContextId);
|
||||
auto directoryPath = cache.directoryPath(directoryPathId);
|
||||
|
||||
ASSERT_THAT(sourceContextPath, Eq(Utils::SmallStringView{"/path/to"}));
|
||||
ASSERT_THAT(directoryPath, Eq(Utils::SmallStringView{"/path/to"}));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, directory_path_calls_fetch_directory_path)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceContextPath(Eq(sourceContextId5)));
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPath(Eq(directoryPathId5)));
|
||||
|
||||
cache.sourceContextPath(sourceContextId5);
|
||||
cache.directoryPath(directoryPathId5);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, second_directory_path_calls_not_fetch_directory_path)
|
||||
{
|
||||
cache.sourceContextPath(sourceContextId5);
|
||||
cache.directoryPath(directoryPathId5);
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceContextPath(_)).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchDirectoryPath(_)).Times(0);
|
||||
|
||||
cache.sourceContextPath(sourceContextId5);
|
||||
cache.directoryPath(directoryPathId5);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, fetch_source_context_from_source_id)
|
||||
TEST_F(SourcePathCache, fetch_directory_path_from_source_id)
|
||||
{
|
||||
auto sourceContextId = sourceId542.contextId();
|
||||
auto directoryPathId = sourceId542.contextId();
|
||||
|
||||
ASSERT_THAT(sourceContextId, Eq(sourceContextId5));
|
||||
ASSERT_THAT(directoryPathId, Eq(directoryPathId5));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, fetch_source_context_id_after_fetching_file_path_by_source_id)
|
||||
TEST_F(SourcePathCache, fetch_directory_path_id_after_fetching_file_path_by_source_id)
|
||||
{
|
||||
cache.sourcePath(sourceId542);
|
||||
|
||||
auto sourceContextId = sourceId542.contextId();
|
||||
auto directoryPathId = sourceId542.contextId();
|
||||
|
||||
ASSERT_THAT(sourceContextId, Eq(sourceContextId5));
|
||||
ASSERT_THAT(directoryPathId, Eq(directoryPathId5));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, fetch_all_source_contexts_and_sources_at_creation)
|
||||
TEST_F(SourcePathCache, fetch_all_directory_paths_and_sources_at_creation)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchAllSourceContexts());
|
||||
EXPECT_CALL(storageMock, fetchAllSourceNames());
|
||||
EXPECT_CALL(storageMock, fetchAllDirectoryPaths());
|
||||
EXPECT_CALL(storageMock, fetchAllFileNames());
|
||||
|
||||
Cache cache{storageMock};
|
||||
}
|
||||
@@ -308,20 +309,20 @@ TEST_F(SourcePathCache, get_file_id_in_filled_cache)
|
||||
ASSERT_THAT(id, Eq(sourceId642));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_source_context_id_in_filled_cache)
|
||||
TEST_F(SourcePathCache, get_directory_path_id_in_filled_cache)
|
||||
{
|
||||
Cache cacheFilled{storageMockFilled};
|
||||
|
||||
auto id = sourceId542.contextId();
|
||||
|
||||
ASSERT_THAT(id, Eq(sourceContextId5));
|
||||
ASSERT_THAT(id, Eq(directoryPathId5));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_directory_path_in_filled_cache)
|
||||
{
|
||||
Cache cacheFilled{storageMockFilled};
|
||||
|
||||
auto path = cacheFilled.sourceContextPath(sourceContextId5);
|
||||
auto path = cacheFilled.directoryPath(directoryPathId5);
|
||||
|
||||
ASSERT_THAT(path, Eq("/path/to"));
|
||||
}
|
||||
@@ -348,8 +349,8 @@ TEST_F(SourcePathCache, dont_populate_if_not_empty)
|
||||
{
|
||||
cacheNotFilled.sourceId("/path/to/file.cpp");
|
||||
|
||||
EXPECT_CALL(storageMockFilled, fetchAllSourceContexts()).Times(0);
|
||||
EXPECT_CALL(storageMockFilled, fetchAllSourceNames()).Times(0);
|
||||
EXPECT_CALL(storageMockFilled, fetchAllDirectoryPaths()).Times(0);
|
||||
EXPECT_CALL(storageMockFilled, fetchAllFileNames()).Times(0);
|
||||
|
||||
cacheNotFilled.populateIfEmpty();
|
||||
}
|
||||
@@ -358,7 +359,7 @@ TEST_F(SourcePathCache, get_directory_path_after_populate_if_empty)
|
||||
{
|
||||
cacheNotFilled.populateIfEmpty();
|
||||
|
||||
auto path = cacheNotFilled.sourceContextPath(sourceContextId5);
|
||||
auto path = cacheNotFilled.directoryPath(directoryPathId5);
|
||||
|
||||
ASSERT_THAT(path, Eq("/path/to"));
|
||||
}
|
||||
@@ -372,78 +373,78 @@ TEST_F(SourcePathCache, get_file_path_after_populate_if_empty)
|
||||
ASSERT_THAT(path, Eq("/path/to/file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_name_id_calls_fetch_source_name_id)
|
||||
TEST_F(SourcePathCache, file_name_id_calls_fetch_file_name_id)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp")));
|
||||
EXPECT_CALL(storageMock, fetchFileNameId(Eq("file.cpp")));
|
||||
|
||||
cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, second_source_name_id_calls_not_fetch_source_name_id)
|
||||
TEST_F(SourcePathCache, second_file_name_id_calls_not_fetch_file_name_id)
|
||||
{
|
||||
cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceNameId(Eq("file.cpp"))).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchFileNameId(Eq("file.cpp"))).Times(0);
|
||||
|
||||
cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_name_id)
|
||||
TEST_F(SourcePathCache, file_name_id)
|
||||
{
|
||||
auto id = cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
auto id = cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
|
||||
ASSERT_THAT(id, Eq(sourceNameId42));
|
||||
ASSERT_THAT(id, Eq(fileNameId42));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_name_id_is_already_in_cache)
|
||||
TEST_F(SourcePathCache, file_name_id_is_already_in_cache)
|
||||
{
|
||||
auto firstId = cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
auto firstId = cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
|
||||
auto secondId = cache.sourceNameId(Utils::SmallString("file.cpp"));
|
||||
auto secondId = cache.fileNameId(Utils::SmallString("file.cpp"));
|
||||
|
||||
ASSERT_THAT(secondId, firstId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, throw_for_getting_source_name_with_an_invalid_id)
|
||||
TEST_F(SourcePathCache, throw_for_getting_file_name_with_an_invalid_id)
|
||||
{
|
||||
SourceNameId sourceNameId;
|
||||
FileNameId fileNameId;
|
||||
|
||||
ASSERT_THROW(cache.sourceName(sourceNameId), QmlDesigner::NoSourceNameForInvalidSourceNameId);
|
||||
ASSERT_THROW(cache.fileName(fileNameId), QmlDesigner::NoFileNameForInvalidFileNameId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_a_source_name)
|
||||
TEST_F(SourcePathCache, get_a_file_name)
|
||||
{
|
||||
SourceNameId sourceNameId{sourceNameId42};
|
||||
FileNameId fileNameId{fileNameId42};
|
||||
|
||||
auto sourceName = cache.sourceName(sourceNameId);
|
||||
auto fileName = cache.fileName(fileNameId);
|
||||
|
||||
ASSERT_THAT(sourceName, Eq(Utils::SmallStringView{"file.cpp"}));
|
||||
ASSERT_THAT(fileName, Eq(Utils::SmallStringView{"file.cpp"}));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, get_a_source_name_with_cached_source_name_id)
|
||||
TEST_F(SourcePathCache, get_a_file_name_with_cached_file_name_id)
|
||||
{
|
||||
SourceNameId sourceNameId{sourceNameId42};
|
||||
cache.sourceName(sourceNameId);
|
||||
FileNameId fileNameId{fileNameId42};
|
||||
cache.fileName(fileNameId);
|
||||
|
||||
auto sourceName = cache.sourceName(sourceNameId);
|
||||
auto fileName = cache.fileName(fileNameId);
|
||||
|
||||
ASSERT_THAT(sourceName, Eq(Utils::SmallStringView{"file.cpp"}));
|
||||
ASSERT_THAT(fileName, Eq(Utils::SmallStringView{"file.cpp"}));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, source_name_calls_fetch_source_name)
|
||||
TEST_F(SourcePathCache, file_name_calls_fetch_file_name)
|
||||
{
|
||||
EXPECT_CALL(storageMock, fetchSourceName(Eq(sourceNameId42)));
|
||||
EXPECT_CALL(storageMock, fetchFileName(Eq(fileNameId42)));
|
||||
|
||||
cache.sourceName(sourceNameId42);
|
||||
cache.fileName(fileNameId42);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathCache, second_source_name_calls_not_fetch_source_name)
|
||||
TEST_F(SourcePathCache, second_file_name_calls_not_fetch_file_name)
|
||||
{
|
||||
cache.sourceName(sourceNameId42);
|
||||
cache.fileName(fileNameId42);
|
||||
|
||||
EXPECT_CALL(storageMock, fetchSourceName(_)).Times(0);
|
||||
EXPECT_CALL(storageMock, fetchFileName(_)).Times(0);
|
||||
|
||||
cache.sourceName(sourceNameId42);
|
||||
cache.fileName(fileNameId42);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -7,21 +7,21 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using QmlDesigner::Cache::SourceContext;
|
||||
using QmlDesigner::Cache::SourceName;
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::Cache::DirectoryPath;
|
||||
using QmlDesigner::Cache::FileName;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::SourceId;
|
||||
using QmlDesigner::SourceIds;
|
||||
using QmlDesigner::SourceNameId;
|
||||
using QmlDesigner::FileNameId;
|
||||
|
||||
MATCHER_P2(IsSourceContext,
|
||||
MATCHER_P2(IsDirectoryPath,
|
||||
id,
|
||||
value,
|
||||
std::string(negation ? "isn't " : "is ") + PrintToString(SourceContext{value, id}))
|
||||
std::string(negation ? "isn't " : "is ") + PrintToString(DirectoryPath{value, id}))
|
||||
{
|
||||
const SourceContext &sourceContext = arg;
|
||||
const DirectoryPath &directoryPath = arg;
|
||||
|
||||
return sourceContext.id == id && sourceContext.value == value;
|
||||
return directoryPath.id == id && directoryPath.value == value;
|
||||
}
|
||||
|
||||
class SourcePathStorage : public testing::Test
|
||||
@@ -43,14 +43,14 @@ protected:
|
||||
|
||||
void addSomeDummyData()
|
||||
{
|
||||
storage.fetchSourceContextId("/path/dummy");
|
||||
storage.fetchSourceContextId("/path/dummy2");
|
||||
storage.fetchSourceContextId("/path/");
|
||||
storage.fetchDirectoryPathId("/path/dummy");
|
||||
storage.fetchDirectoryPathId("/path/dummy2");
|
||||
storage.fetchDirectoryPathId("/path/");
|
||||
|
||||
storage.fetchSourceNameId("foo");
|
||||
storage.fetchSourceNameId("dummy");
|
||||
storage.fetchSourceNameId("bar");
|
||||
storage.fetchSourceNameId("bar");
|
||||
storage.fetchFileNameId("foo");
|
||||
storage.fetchFileNameId("dummy");
|
||||
storage.fetchFileNameId("bar");
|
||||
storage.fetchFileNameId("bar");
|
||||
}
|
||||
|
||||
template<typename Range>
|
||||
@@ -67,112 +67,112 @@ protected:
|
||||
Sqlite::Database &database = staticData->database;
|
||||
};
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_context_id_returns_always_the_same_id_for_the_same_path)
|
||||
TEST_F(SourcePathStorage, fetch_directory_path_id_returns_always_the_same_id_for_the_same_path)
|
||||
|
||||
{
|
||||
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
||||
auto directoryPathId = storage.fetchDirectoryPathId("/path/to");
|
||||
|
||||
auto newSourceContextId = storage.fetchSourceContextId("/path/to");
|
||||
auto newDirectoryPathId = storage.fetchDirectoryPathId("/path/to");
|
||||
|
||||
ASSERT_THAT(newSourceContextId, Eq(sourceContextId));
|
||||
ASSERT_THAT(newDirectoryPathId, Eq(directoryPathId));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_context_id_returns_not_the_same_id_for_different_path)
|
||||
TEST_F(SourcePathStorage, fetch_directory_path_id_returns_not_the_same_id_for_different_path)
|
||||
{
|
||||
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
||||
auto directoryPathId = storage.fetchDirectoryPathId("/path/to");
|
||||
|
||||
auto newSourceContextId = storage.fetchSourceContextId("/path/to2");
|
||||
auto newDirectoryPathId = storage.fetchDirectoryPathId("/path/to2");
|
||||
|
||||
ASSERT_THAT(newSourceContextId, Ne(sourceContextId));
|
||||
ASSERT_THAT(newDirectoryPathId, Ne(directoryPathId));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_context_path)
|
||||
TEST_F(SourcePathStorage, fetch_directory_path_path)
|
||||
{
|
||||
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
||||
auto directoryPathId = storage.fetchDirectoryPathId("/path/to");
|
||||
|
||||
auto path = storage.fetchSourceContextPath(sourceContextId);
|
||||
auto path = storage.fetchDirectoryPath(directoryPathId);
|
||||
|
||||
ASSERT_THAT(path, Eq("/path/to"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_unknown_source_context_path_throws)
|
||||
TEST_F(SourcePathStorage, fetch_unknown_directory_path_path_throws)
|
||||
{
|
||||
ASSERT_THROW(storage.fetchSourceContextPath(SourceContextId::create(323)),
|
||||
QmlDesigner::SourceContextIdDoesNotExists);
|
||||
ASSERT_THROW(storage.fetchDirectoryPath(DirectoryPathId::create(323)),
|
||||
QmlDesigner::DirectoryPathIdDoesNotExists);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_all_source_contexts_are_empty_if_no_source_contexts_exists)
|
||||
TEST_F(SourcePathStorage, fetch_all_directory_paths_are_empty_if_no_directory_paths_exists)
|
||||
{
|
||||
storage.clearSources();
|
||||
|
||||
auto sourceContexts = storage.fetchAllSourceContexts();
|
||||
auto directoryPaths = storage.fetchAllDirectoryPaths();
|
||||
|
||||
ASSERT_THAT(toValues(sourceContexts), IsEmpty());
|
||||
ASSERT_THAT(toValues(directoryPaths), IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_all_source_contexts)
|
||||
TEST_F(SourcePathStorage, fetch_all_directory_paths)
|
||||
{
|
||||
storage.clearSources();
|
||||
auto sourceContextId = storage.fetchSourceContextId("/path/to");
|
||||
auto sourceContextId2 = storage.fetchSourceContextId("/path/to2");
|
||||
auto directoryPathId = storage.fetchDirectoryPathId("/path/to");
|
||||
auto directoryPathId2 = storage.fetchDirectoryPathId("/path/to2");
|
||||
|
||||
auto sourceContexts = storage.fetchAllSourceContexts();
|
||||
auto directoryPaths = storage.fetchAllDirectoryPaths();
|
||||
|
||||
ASSERT_THAT(toValues(sourceContexts),
|
||||
UnorderedElementsAre(IsSourceContext(sourceContextId, "/path/to"),
|
||||
IsSourceContext(sourceContextId2, "/path/to2")));
|
||||
ASSERT_THAT(toValues(directoryPaths),
|
||||
UnorderedElementsAre(IsDirectoryPath(directoryPathId, "/path/to"),
|
||||
IsDirectoryPath(directoryPathId2, "/path/to2")));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_id_first_time)
|
||||
{
|
||||
addSomeDummyData();
|
||||
|
||||
auto sourceNameId = storage.fetchSourceNameId("foo");
|
||||
auto fileNameId = storage.fetchFileNameId("foo");
|
||||
|
||||
ASSERT_TRUE(sourceNameId.isValid());
|
||||
ASSERT_TRUE(fileNameId.isValid());
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_existing_source_id)
|
||||
{
|
||||
addSomeDummyData();
|
||||
auto createdSourceNameId = storage.fetchSourceNameId("foo");
|
||||
auto createdFileNameId = storage.fetchFileNameId("foo");
|
||||
|
||||
auto sourceNameId = storage.fetchSourceNameId("foo");
|
||||
auto fileNameId = storage.fetchFileNameId("foo");
|
||||
|
||||
ASSERT_THAT(sourceNameId, createdSourceNameId);
|
||||
ASSERT_THAT(fileNameId, createdFileNameId);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_id_with_different_name_are_not_equal)
|
||||
{
|
||||
addSomeDummyData();
|
||||
auto sourceNameId2 = storage.fetchSourceNameId("foo");
|
||||
auto fileNameId2 = storage.fetchFileNameId("foo");
|
||||
|
||||
auto sourceNameId = storage.fetchSourceNameId("foo2");
|
||||
auto fileNameId = storage.fetchFileNameId("foo2");
|
||||
|
||||
ASSERT_THAT(sourceNameId, Ne(sourceNameId2));
|
||||
ASSERT_THAT(fileNameId, Ne(fileNameId2));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_name_and_source_context_id_for_non_existing_source_id)
|
||||
TEST_F(SourcePathStorage, fetch_file_name_and_directory_path_id_for_non_existing_source_id)
|
||||
{
|
||||
ASSERT_THROW(storage.fetchSourceName(SourceNameId::create(212)),
|
||||
QmlDesigner::SourceNameIdDoesNotExists);
|
||||
ASSERT_THROW(storage.fetchFileName(FileNameId::create(212)),
|
||||
QmlDesigner::FileNameIdDoesNotExists);
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_source_name_for_non_existing_entry)
|
||||
TEST_F(SourcePathStorage, fetch_file_name_for_non_existing_entry)
|
||||
{
|
||||
addSomeDummyData();
|
||||
auto sourceNameId = storage.fetchSourceNameId("foo");
|
||||
auto fileNameId = storage.fetchFileNameId("foo");
|
||||
|
||||
auto sourceName = storage.fetchSourceName(sourceNameId);
|
||||
auto fileName = storage.fetchFileName(fileNameId);
|
||||
|
||||
ASSERT_THAT(sourceName, Eq("foo"));
|
||||
ASSERT_THAT(fileName, Eq("foo"));
|
||||
}
|
||||
|
||||
TEST_F(SourcePathStorage, fetch_all_sources)
|
||||
{
|
||||
storage.clearSources();
|
||||
|
||||
auto sources = storage.fetchAllSourceNames();
|
||||
auto sources = storage.fetchAllFileNames();
|
||||
|
||||
ASSERT_THAT(toValues(sources), IsEmpty());
|
||||
}
|
||||
@@ -182,7 +182,7 @@ TEST_F(SourcePathStorage, fetch_source_id_unguarded_first_time)
|
||||
addSomeDummyData();
|
||||
std::lock_guard lock{database};
|
||||
|
||||
auto sourceId = storage.fetchSourceNameIdUnguarded("foo");
|
||||
auto sourceId = storage.fetchFileNameIdUnguarded("foo");
|
||||
|
||||
ASSERT_TRUE(sourceId.isValid());
|
||||
}
|
||||
@@ -191,9 +191,9 @@ TEST_F(SourcePathStorage, fetch_existing_source_id_unguarded)
|
||||
{
|
||||
addSomeDummyData();
|
||||
std::lock_guard lock{database};
|
||||
auto createdSourceId = storage.fetchSourceNameIdUnguarded("foo");
|
||||
auto createdSourceId = storage.fetchFileNameIdUnguarded("foo");
|
||||
|
||||
auto sourceId = storage.fetchSourceNameIdUnguarded("foo");
|
||||
auto sourceId = storage.fetchFileNameIdUnguarded("foo");
|
||||
|
||||
ASSERT_THAT(sourceId, createdSourceId);
|
||||
}
|
||||
@@ -202,9 +202,9 @@ TEST_F(SourcePathStorage, fetch_source_id_unguarded_with_different_name_are_not_
|
||||
{
|
||||
addSomeDummyData();
|
||||
std::lock_guard lock{database};
|
||||
auto sourceId2 = storage.fetchSourceNameIdUnguarded("foo");
|
||||
auto sourceId2 = storage.fetchFileNameIdUnguarded("foo");
|
||||
|
||||
auto sourceId = storage.fetchSourceNameIdUnguarded("foo2");
|
||||
auto sourceId = storage.fetchFileNameIdUnguarded("foo2");
|
||||
|
||||
ASSERT_THAT(sourceId, Ne(sourceId2));
|
||||
}
|
||||
|
@@ -14,18 +14,18 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using QmlDesigner::SourceContextId;
|
||||
using QmlDesigner::DirectoryPathId;
|
||||
using QmlDesigner::StorageCacheException;
|
||||
using Utils::compare;
|
||||
|
||||
class StorageAdapter
|
||||
{
|
||||
public:
|
||||
auto fetchId(Utils::SmallStringView view) const { return storage.fetchSourceContextId(view); }
|
||||
auto fetchId(Utils::SmallStringView view) const { return storage.fetchDirectoryPathId(view); }
|
||||
|
||||
auto fetchValue(SourceContextId id) const { return storage.fetchSourceContextPath(id); }
|
||||
auto fetchValue(DirectoryPathId id) const { return storage.fetchDirectoryPath(id); }
|
||||
|
||||
auto fetchAll() const { return storage.fetchAllSourceContexts(); }
|
||||
auto fetchAll() const { return storage.fetchAllDirectoryPaths(); }
|
||||
|
||||
ProjectStorageMock &storage;
|
||||
};
|
||||
@@ -40,19 +40,19 @@ struct Less
|
||||
|
||||
using CacheWithMockLocking = QmlDesigner::StorageCache<Utils::PathString,
|
||||
Utils::SmallStringView,
|
||||
SourceContextId,
|
||||
DirectoryPathId,
|
||||
StorageAdapter,
|
||||
NiceMock<MockMutex>,
|
||||
Less,
|
||||
QmlDesigner::Cache::SourceContext>;
|
||||
QmlDesigner::Cache::DirectoryPath>;
|
||||
|
||||
using CacheWithoutLocking = QmlDesigner::StorageCache<Utils::PathString,
|
||||
Utils::SmallStringView,
|
||||
SourceContextId,
|
||||
DirectoryPathId,
|
||||
StorageAdapter,
|
||||
NiceMock<MockMutexNonLocking>,
|
||||
Less,
|
||||
QmlDesigner::Cache::SourceContext>;
|
||||
QmlDesigner::Cache::DirectoryPath>;
|
||||
|
||||
template<typename Cache>
|
||||
class StorageCache : public testing::Test
|
||||
@@ -67,17 +67,17 @@ protected:
|
||||
return std::lexicographical_compare(f.rbegin(), f.rend(), l.rbegin(), l.rend());
|
||||
});
|
||||
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq("foo"))).WillByDefault(Return(id42));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq("bar"))).WillByDefault(Return(id43));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq("poo"))).WillByDefault(Return(id44));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq("taa"))).WillByDefault(Return(id45));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextPath(this->id41))
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo"))).WillByDefault(Return(id42));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq("bar"))).WillByDefault(Return(id43));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq("poo"))).WillByDefault(Return(id44));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq("taa"))).WillByDefault(Return(id45));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPath(this->id41))
|
||||
.WillByDefault(Return(Utils::PathString("bar")));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq(filePath1))).WillByDefault(Return(id1));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq(filePath2))).WillByDefault(Return(id2));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq(filePath3))).WillByDefault(Return(id3));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq(filePath4))).WillByDefault(Return(id4));
|
||||
ON_CALL(this->mockStorage, fetchSourceContextId(Eq(filePath5))).WillByDefault(Return(id5));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq(filePath1))).WillByDefault(Return(id1));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq(filePath2))).WillByDefault(Return(id2));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq(filePath3))).WillByDefault(Return(id3));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq(filePath4))).WillByDefault(Return(id4));
|
||||
ON_CALL(this->mockStorage, fetchDirectoryPathId(Eq(filePath5))).WillByDefault(Return(id5));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -92,16 +92,16 @@ protected:
|
||||
Utils::PathString filePath5{"/file/pathFife"};
|
||||
Utils::PathStringVector filePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
||||
Utils::PathStringVector reverseFilePaths{filePath1, filePath2, filePath3, filePath4, filePath5};
|
||||
SourceContextId id1{SourceContextId::create(1)};
|
||||
SourceContextId id2{SourceContextId::create(2)};
|
||||
SourceContextId id3{SourceContextId::create(3)};
|
||||
SourceContextId id4{SourceContextId::create(4)};
|
||||
SourceContextId id5{SourceContextId::create(5)};
|
||||
SourceContextId id41{SourceContextId::create(41)};
|
||||
SourceContextId id42{SourceContextId::create(42)};
|
||||
SourceContextId id43{SourceContextId::create(43)};
|
||||
SourceContextId id44{SourceContextId::create(44)};
|
||||
SourceContextId id45{SourceContextId::create(45)};
|
||||
DirectoryPathId id1{DirectoryPathId::create(1)};
|
||||
DirectoryPathId id2{DirectoryPathId::create(2)};
|
||||
DirectoryPathId id3{DirectoryPathId::create(3)};
|
||||
DirectoryPathId id4{DirectoryPathId::create(4)};
|
||||
DirectoryPathId id5{DirectoryPathId::create(5)};
|
||||
DirectoryPathId id41{DirectoryPathId::create(41)};
|
||||
DirectoryPathId id42{DirectoryPathId::create(42)};
|
||||
DirectoryPathId id43{DirectoryPathId::create(43)};
|
||||
DirectoryPathId id44{DirectoryPathId::create(44)};
|
||||
DirectoryPathId id45{DirectoryPathId::create(45)};
|
||||
};
|
||||
|
||||
using CacheTypes = ::testing::Types<CacheWithMockLocking, CacheWithoutLocking>;
|
||||
@@ -220,8 +220,8 @@ TYPED_TEST(StorageCache, is_not_empty_after_populate_with_some_entries)
|
||||
typename TypeParam::CacheEntries entries{{this->filePath1, this->id1},
|
||||
{this->filePath2, this->id4},
|
||||
{this->filePath3, this->id3},
|
||||
{this->filePath4, SourceContextId::create(5)}};
|
||||
ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries));
|
||||
{this->filePath4, DirectoryPathId::create(5)}};
|
||||
ON_CALL(this->mockStorage, fetchAllDirectoryPaths()).WillByDefault(Return(entries));
|
||||
|
||||
this->cache.uncheckedPopulate();
|
||||
|
||||
@@ -232,12 +232,12 @@ TYPED_TEST(StorageCache, get_entry_after_populate_with_some_entries)
|
||||
{
|
||||
typename TypeParam::CacheEntries entries{{this->filePath1, this->id1},
|
||||
{this->filePath2, this->id2},
|
||||
{this->filePath3, SourceContextId::create(7)},
|
||||
{this->filePath3, DirectoryPathId::create(7)},
|
||||
{this->filePath4, this->id4}};
|
||||
ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries));
|
||||
ON_CALL(this->mockStorage, fetchAllDirectoryPaths()).WillByDefault(Return(entries));
|
||||
this->cache.uncheckedPopulate();
|
||||
|
||||
auto value = this->cache.value(SourceContextId::create(7));
|
||||
auto value = this->cache.value(DirectoryPathId::create(7));
|
||||
|
||||
ASSERT_THAT(value, this->filePath3);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ TYPED_TEST(StorageCache, entries_have_unique_ids)
|
||||
{this->filePath2, this->id2},
|
||||
{this->filePath3, this->id3},
|
||||
{this->filePath4, this->id3}};
|
||||
ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries));
|
||||
ON_CALL(this->mockStorage, fetchAllDirectoryPaths()).WillByDefault(Return(entries));
|
||||
|
||||
ASSERT_THROW(this->cache.populate(), StorageCacheException);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ TYPED_TEST(StorageCache, multiple_entries)
|
||||
{this->filePath1, this->id2},
|
||||
{this->filePath3, this->id3},
|
||||
{this->filePath4, this->id4}};
|
||||
ON_CALL(this->mockStorage, fetchAllSourceContexts()).WillByDefault(Return(entries));
|
||||
ON_CALL(this->mockStorage, fetchAllDirectoryPaths()).WillByDefault(Return(entries));
|
||||
|
||||
ASSERT_THROW(this->cache.populate(), StorageCacheException);
|
||||
}
|
||||
@@ -283,7 +283,7 @@ TYPED_TEST(StorageCache, id_with_storage_function_is_read_and_write_locked_for_u
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock());
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockMutex, unlock());
|
||||
|
||||
this->cache.id("foo");
|
||||
@@ -297,7 +297,7 @@ TYPED_TEST(StorageCache, id_with_storage_function_is_read_locked_for_known_entry
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock()).Times(0);
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo"))).Times(0);
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo"))).Times(0);
|
||||
EXPECT_CALL(this->mockMutex, unlock()).Times(0);
|
||||
|
||||
this->cache.id("foo");
|
||||
@@ -358,7 +358,7 @@ TYPED_TEST(StorageCache, value_with_storage_function_is_read_and_write_locked_fo
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock());
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextPath(Eq(this->id41)));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPath(Eq(this->id41)));
|
||||
EXPECT_CALL(this->mockMutex, unlock());
|
||||
|
||||
this->cache.value(this->id41);
|
||||
@@ -372,7 +372,7 @@ TYPED_TEST(StorageCache, value_with_storage_function_is_read_locked_for_known_id
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock()).Times(0);
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextPath(Eq(this->id41))).Times(0);
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPath(Eq(this->id41))).Times(0);
|
||||
EXPECT_CALL(this->mockMutex, unlock()).Times(0);
|
||||
|
||||
this->cache.value(this->id41);
|
||||
@@ -380,7 +380,7 @@ TYPED_TEST(StorageCache, value_with_storage_function_is_read_locked_for_known_id
|
||||
|
||||
TYPED_TEST(StorageCache, id_with_storage_function_which_has_no_entry_is_calling_storage_function)
|
||||
{
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo")));
|
||||
|
||||
this->cache.id("foo");
|
||||
}
|
||||
@@ -389,7 +389,7 @@ TYPED_TEST(StorageCache, id_with_storage_function_which_has_entry_is_not_calling
|
||||
{
|
||||
this->cache.id("foo");
|
||||
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo"))).Times(0);
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo"))).Times(0);
|
||||
|
||||
this->cache.id("foo");
|
||||
}
|
||||
@@ -419,24 +419,24 @@ TYPED_TEST(StorageCache, get_entry_by_index_after_inserting_by_custom_index)
|
||||
ASSERT_THAT(value, Eq("foo"));
|
||||
}
|
||||
|
||||
TYPED_TEST(StorageCache, call_fetch_source_context_path_for_lower_index)
|
||||
TYPED_TEST(StorageCache, call_fetch_directory_path_path_for_lower_index)
|
||||
{
|
||||
auto index = this->cache.id("foo");
|
||||
SourceContextId lowerIndex{SourceContextId::create(index.internalId() - 1)};
|
||||
DirectoryPathId lowerIndex{DirectoryPathId::create(index.internalId() - 1)};
|
||||
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextPath(Eq(lowerIndex)));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPath(Eq(lowerIndex)));
|
||||
|
||||
this->cache.value(lowerIndex);
|
||||
}
|
||||
|
||||
TYPED_TEST(StorageCache, call_fetch_source_context_path_for_unknown_index)
|
||||
TYPED_TEST(StorageCache, call_fetch_directory_path_path_for_unknown_index)
|
||||
{
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextPath(Eq(this->id1)));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPath(Eq(this->id1)));
|
||||
|
||||
this->cache.value(this->id1);
|
||||
}
|
||||
|
||||
TYPED_TEST(StorageCache, fetch_source_context_path_for_unknown_index)
|
||||
TYPED_TEST(StorageCache, fetch_directory_path_path_for_unknown_index)
|
||||
{
|
||||
auto value = this->cache.value(this->id41);
|
||||
|
||||
@@ -445,9 +445,9 @@ TYPED_TEST(StorageCache, fetch_source_context_path_for_unknown_index)
|
||||
|
||||
TYPED_TEST(StorageCache, add_calls)
|
||||
{
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("bar")));
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("poo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("bar")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("poo")));
|
||||
|
||||
this->cache.add({"foo", "bar", "poo"});
|
||||
}
|
||||
@@ -456,8 +456,8 @@ TYPED_TEST(StorageCache, add_calls_only_for_new_values)
|
||||
{
|
||||
this->cache.add({"foo", "poo"});
|
||||
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("taa")));
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("bar")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("taa")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("bar")));
|
||||
|
||||
this->cache.add({"foo", "bar", "poo", "taa"});
|
||||
}
|
||||
@@ -504,12 +504,12 @@ TYPED_TEST(StorageCache, fetch_ids_from_storage_calls)
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock());
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("foo")));
|
||||
EXPECT_CALL(this->mockMutex, unlock());
|
||||
EXPECT_CALL(this->mockMutex, lock_shared());
|
||||
EXPECT_CALL(this->mockMutex, unlock_shared());
|
||||
EXPECT_CALL(this->mockMutex, lock());
|
||||
EXPECT_CALL(this->mockStorage, fetchSourceContextId(Eq("bar")));
|
||||
EXPECT_CALL(this->mockStorage, fetchDirectoryPathId(Eq("bar")));
|
||||
EXPECT_CALL(this->mockMutex, unlock());
|
||||
|
||||
this->cache.ids({"foo", "bar"});
|
||||
|
Reference in New Issue
Block a user