QmlDesigner: Remove '.' workaround in project storage

The '.' file paths were always a workaround. Since some time the context
id is now
part of the source id. So a source ids can be generated from source
context id
without a file name.

Task-number: QDS-14672
Change-Id: Ia278b9d06030ca8ea6e150d0c7ffd762979d5d62
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-02-04 23:37:18 +01:00
parent 9f232746a5
commit 50b2ff3c50
16 changed files with 1016 additions and 1057 deletions

View File

@@ -50,7 +50,9 @@ long long FileSystem::lastModified(SourceId sourceId) const
FileStatus FileSystem::fileStatus(SourceId sourceId) const
{
QFileInfo fileInfo(QString(m_sourcePathCache.sourcePath(sourceId)));
auto path = sourceId.mainId() ? m_sourcePathCache.sourcePath(sourceId)
: m_sourcePathCache.sourceContextPath(sourceId.contextId());
QFileInfo fileInfo(QString{path});
fileInfo.refresh();

View File

@@ -649,31 +649,31 @@ struct ProjectStorage::Statements
"DELETE FROM exportedTypeNames WHERE exportedTypeNameId=?", database};
Sqlite::WriteStatement<2> updateExportedTypeNameTypeIdStatement{
"UPDATE exportedTypeNames SET typeId=?2 WHERE exportedTypeNameId=?1", database};
mutable Sqlite::ReadStatement<4, 1> selectDirectoryInfosForSourceIdsStatement{
"SELECT directorySourceId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directorySourceId IN carray(?1) ORDER BY directorySourceId, sourceId",
mutable Sqlite::ReadStatement<4, 1> selectDirectoryInfosForDirectoryIdsStatement{
"SELECT directoryId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directoryId IN carray(?1) ORDER BY directoryId, sourceId",
database};
Sqlite::WriteStatement<4> insertDirectoryInfoStatement{
"INSERT INTO directoryInfos(directorySourceId, sourceId, "
"INSERT INTO directoryInfos(directoryId, sourceId, "
"moduleId, fileType) VALUES(?1, ?2, ?3, ?4)",
database};
Sqlite::WriteStatement<2> deleteDirectoryInfoStatement{
"DELETE FROM directoryInfos WHERE directorySourceId=?1 AND sourceId=?2", database};
"DELETE FROM directoryInfos WHERE directoryId=?1 AND sourceId=?2", database};
Sqlite::WriteStatement<4> updateDirectoryInfoStatement{
"UPDATE directoryInfos SET moduleId=?3, fileType=?4 WHERE directorySourceId=?1 AND sourceId=?2",
"UPDATE directoryInfos SET moduleId=?3, fileType=?4 WHERE directoryId=?1 AND sourceId=?2",
database};
mutable Sqlite::ReadStatement<4, 1> selectDirectoryInfosForSourceIdStatement{
"SELECT directorySourceId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directorySourceId=?1",
mutable Sqlite::ReadStatement<4, 1> selectDirectoryInfosForDirectoryIdStatement{
"SELECT directoryId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directoryId=?1",
database};
mutable Sqlite::ReadStatement<4, 2> selectDirectoryInfosForSourceIdAndFileTypeStatement{
"SELECT directorySourceId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directorySourceId=?1 AND fileType=?2",
mutable Sqlite::ReadStatement<4, 2> selectDirectoryInfosForDiectoryIdAndFileTypeStatement{
"SELECT directoryId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"directoryId=?1 AND fileType=?2",
database};
mutable Sqlite::ReadStatement<1, 2> selectDirectoryInfosSourceIdsForSourceIdAndFileTypeStatement{
"SELECT sourceId FROM directoryInfos WHERE directorySourceId=?1 AND fileType=?2", database};
mutable Sqlite::ReadStatement<1, 2> selectDirectoryInfosSourceIdsForDirectoryIdAndFileTypeStatement{
"SELECT sourceId FROM directoryInfos WHERE directoryId=?1 AND fileType=?2", database};
mutable Sqlite::ReadStatement<4, 1> selectDirectoryInfoForSourceIdStatement{
"SELECT directorySourceId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"SELECT directoryId, sourceId, moduleId, fileType FROM directoryInfos WHERE "
"sourceId=?1 LIMIT 1",
database};
mutable Sqlite::ReadStatement<1, 1> selectTypeIdsForSourceIdsStatement{
@@ -817,7 +817,7 @@ struct ProjectStorage::Statements
database};
Sqlite::WriteStatement<7> insertTypeAnnotationStatement{
"INSERT INTO "
" typeAnnotations(typeId, sourceId, directorySourceId, typeName, iconPath, itemLibrary, "
" typeAnnotations(typeId, sourceId, directoryId, typeName, iconPath, itemLibrary, "
" hints) "
"VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7)",
database};
@@ -836,9 +836,9 @@ struct ProjectStorage::Statements
"WHERE typeId=?1 AND hints IS NOT NULL",
database};
mutable Sqlite::ReadStatement<1, 1> selectTypeAnnotationSourceIdsStatement{
"SELECT sourceId FROM typeAnnotations WHERE directorySourceId=?1 ORDER BY sourceId", database};
mutable Sqlite::ReadStatement<1, 0> selectTypeAnnotationDirectorySourceIdsStatement{
"SELECT DISTINCT directorySourceId FROM typeAnnotations ORDER BY directorySourceId", database};
"SELECT sourceId FROM typeAnnotations WHERE directoryId=?1 ORDER BY sourceId", database};
mutable Sqlite::ReadStatement<1, 0> selectTypeAnnotationDirectoryIdsStatement{
"SELECT DISTINCT directoryId FROM typeAnnotations ORDER BY directoryId", database};
mutable Sqlite::ReadStatement<10> selectItemLibraryEntriesStatement{
"SELECT typeId, typeName, i.value->>'$.name', i.value->>'$.iconPath', "
" i.value->>'$.category', i.value->>'$.import', i.value->>'$.toolTip', "
@@ -1222,15 +1222,14 @@ public:
table.setUseIfNotExists(true);
table.setUseWithoutRowId(true);
table.setName("directoryInfos");
auto &directorySourceIdColumn = table.addColumn("directorySourceId",
Sqlite::StrictColumnType::Integer);
auto &directoryIdColumn = table.addColumn("directoryId", Sqlite::StrictColumnType::Integer);
auto &sourceIdColumn = table.addColumn("sourceId", Sqlite::StrictColumnType::Integer);
table.addColumn("moduleId", Sqlite::StrictColumnType::Integer);
auto &fileTypeColumn = table.addColumn("fileType", Sqlite::StrictColumnType::Integer);
table.addPrimaryKeyContraint({directorySourceIdColumn, sourceIdColumn});
table.addPrimaryKeyContraint({directoryIdColumn, sourceIdColumn});
table.addUniqueIndex({sourceIdColumn});
table.addIndex({directorySourceIdColumn, fileTypeColumn});
table.addIndex({directoryIdColumn, fileTypeColumn});
table.initialize(database);
}
@@ -1260,15 +1259,14 @@ public:
Sqlite::StrictColumnType::Integer,
{Sqlite::PrimaryKey{}});
auto &sourceIdColumn = table.addColumn("sourceId", Sqlite::StrictColumnType::Integer);
auto &directorySourceIdColumn = table.addColumn("directorySourceId",
Sqlite::StrictColumnType::Integer);
auto &directoryIdColumn = table.addColumn("directoryId", Sqlite::StrictColumnType::Integer);
table.addColumn("typeName", Sqlite::StrictColumnType::Text);
table.addColumn("iconPath", Sqlite::StrictColumnType::Text);
table.addColumn("itemLibrary", Sqlite::StrictColumnType::Text);
table.addColumn("hints", Sqlite::StrictColumnType::Text);
table.addUniqueIndex({sourceIdColumn, typeIdColumn});
table.addIndex({directorySourceIdColumn});
table.addIndex({directoryIdColumn});
table.initialize(database);
}
@@ -1337,7 +1335,7 @@ void ProjectStorage::synchronize(Storage::Synchronization::SynchronizationPackag
package.updatedSourceIds);
synchronizeTypeAnnotations(package.typeAnnotations, package.updatedTypeAnnotationSourceIds);
synchronizePropertyEditorQmlPaths(package.propertyEditorQmlPaths,
package.updatedPropertyEditorQmlPathSourceIds);
package.updatedPropertyEditorQmlPathSourceContextIds);
deleteNotUpdatedTypes(updatedTypeIds,
package.updatedSourceIds,
@@ -1358,7 +1356,7 @@ void ProjectStorage::synchronize(Storage::Synchronization::SynchronizationPackag
linkAliases(aliasPropertyDeclarationsToLink, RaiseError::Yes);
synchronizeDirectoryInfos(package.directoryInfos, package.updatedDirectoryInfoSourceIds);
synchronizeDirectoryInfos(package.directoryInfos, package.updatedDirectoryInfoDirectoryIds);
commonTypeCache_.resetTypeIds();
});
@@ -1748,7 +1746,7 @@ Storage::Info::TypeHints ProjectStorage::typeHints(TypeId typeId) const
return typeHints;
}
SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(SourceId directoryId) const
SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(SourceContextId directoryId) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"get type annotaion source ids",
@@ -1763,13 +1761,13 @@ SmallSourceIds<4> ProjectStorage::typeAnnotationSourceIds(SourceId directoryId)
return sourceIds;
}
SmallSourceIds<64> ProjectStorage::typeAnnotationDirectorySourceIds() const
SmallSourceContextIds<64> ProjectStorage::typeAnnotationDirectoryIds() const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"get type annotaion source ids", projectStorageCategory()};
auto sourceIds = s->selectTypeAnnotationDirectorySourceIdsStatement
.valuesWithTransaction<SmallSourceIds<64>>();
auto sourceIds = s->selectTypeAnnotationDirectoryIdsStatement
.valuesWithTransaction<SmallSourceContextIds<64>>();
tracer.end(keyValue("source ids", sourceIds));
@@ -2198,16 +2196,16 @@ std::optional<Storage::Synchronization::DirectoryInfo> ProjectStorage::fetchDire
return directoryInfo;
}
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(SourceId directorySourceId) const
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(SourceContextId directoryId) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"fetch directory infos by source id",
NanotraceHR::Tracer tracer{"fetch directory infos by directory id",
projectStorageCategory(),
keyValue("source id", directorySourceId)};
keyValue("directory id", directoryId)};
auto directoryInfos = s->selectDirectoryInfosForSourceIdStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 1024>(
directorySourceId);
auto directoryInfos = s->selectDirectoryInfosForDirectoryIdStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 1024>(
directoryId);
tracer.end(keyValue("directory infos", directoryInfos));
@@ -2215,17 +2213,17 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(Sou
}
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
SourceId directorySourceId, Storage::Synchronization::FileType fileType) const
SourceContextId directoryId, Storage::Synchronization::FileType fileType) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"fetch directory infos by source id and file type",
projectStorageCategory(),
keyValue("source id", directorySourceId),
keyValue("directory id", directoryId),
keyValue("file type", fileType)};
auto directoryInfos = s->selectDirectoryInfosForSourceIdAndFileTypeStatement
auto directoryInfos = s->selectDirectoryInfosForDiectoryIdAndFileTypeStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 16>(
directorySourceId, fileType);
directoryId, fileType);
tracer.end(keyValue("directory infos", directoryInfos));
@@ -2233,36 +2231,40 @@ Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
}
Storage::Synchronization::DirectoryInfos ProjectStorage::fetchDirectoryInfos(
const SourceIds &directorySourceIds) const
const SourceContextIds &directoryIds) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"fetch directory infos by source ids",
projectStorageCategory(),
keyValue("source ids", directorySourceIds)};
keyValue("directory ids", directoryIds)};
auto directoryInfos = s->selectDirectoryInfosForSourceIdsStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 64>(
toIntegers(directorySourceIds));
auto directoryInfos = s->selectDirectoryInfosForDirectoryIdsStatement
.valuesWithTransaction<Storage::Synchronization::DirectoryInfo, 64>(
toIntegers(directoryIds));
tracer.end(keyValue("directory infos", directoryInfos));
return directoryInfos;
}
SmallSourceIds<32> ProjectStorage::fetchSubdirectorySourceIds(SourceId directorySourceId) const
SmallSourceContextIds<32> ProjectStorage::fetchSubdirectoryIds(SourceContextId directoryId) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"fetch subdirectory source ids",
projectStorageCategory(),
keyValue("source id", directorySourceId)};
keyValue("directory id", directoryId)};
auto sourceIds = s->selectDirectoryInfosSourceIdsForSourceIdAndFileTypeStatement
.valuesWithTransaction<SmallSourceIds<32>>(
directorySourceId, Storage::Synchronization::FileType::Directory);
auto sourceIds = s->selectDirectoryInfosSourceIdsForDirectoryIdAndFileTypeStatement
.rangeWithTransaction<SourceId>(directoryId,
Storage::Synchronization::FileType::Directory);
tracer.end(keyValue("source ids", sourceIds));
SmallSourceContextIds<32> directoryIds;
for (SourceId sourceId : sourceIds)
directoryIds.push_back(sourceId.contextId());
return sourceIds;
tracer.end(keyValue("directory ids", directoryIds));
return directoryIds;
}
void ProjectStorage::setPropertyEditorPathId(TypeId typeId, SourceId pathId)
@@ -2447,7 +2449,7 @@ void ProjectStorage::synchronizeTypeAnnotations(Storage::Synchronization::TypeAn
s->insertTypeAnnotationStatement.write(annotation.typeId,
annotation.sourceId,
annotation.directorySourceId,
annotation.directoryId,
annotation.typeName,
annotation.iconPath,
createEmptyAsNull(annotation.itemLibraryJson),
@@ -2571,22 +2573,23 @@ void ProjectStorage::synchronizeTypes(Storage::Synchronization::Types &types,
}
void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::DirectoryInfos &directoryInfos,
const SourceIds &updatedDirectoryInfoSourceIds)
const SourceContextIds &updatedDirectoryInfoDirectoryIds)
{
NanotraceHR::Tracer tracer{"synchronize directory infos", projectStorageCategory()};
auto compareKey = [](auto &&first, auto &&second) {
return std::tie(first.directorySourceId, first.sourceId)
<=> std::tie(second.directorySourceId, second.sourceId);
return std::tie(first.directoryId, first.sourceId)
<=> std::tie(second.directoryId, second.sourceId);
};
std::ranges::sort(directoryInfos, [&](auto &&first, auto &&second) {
return std::tie(first.directorySourceId, first.sourceId)
< std::tie(second.directorySourceId, second.sourceId);
return std::tie(first.directoryId, first.sourceId)
< std::tie(second.directoryId, second.sourceId);
});
auto range = s->selectDirectoryInfosForSourceIdsStatement.range<Storage::Synchronization::DirectoryInfo>(
toIntegers(updatedDirectoryInfoSourceIds));
auto range = s->selectDirectoryInfosForDirectoryIdsStatement
.range<Storage::Synchronization::DirectoryInfo>(
toIntegers(updatedDirectoryInfoDirectoryIds));
auto insert = [&](const Storage::Synchronization::DirectoryInfo &directoryInfo) {
using NanotraceHR::keyValue;
@@ -2594,15 +2597,15 @@ void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::Directo
projectStorageCategory(),
keyValue("directory info", directoryInfo)};
if (!directoryInfo.directorySourceId)
if (!directoryInfo.directoryId)
throw DirectoryInfoHasInvalidProjectSourceId{};
if (!directoryInfo.sourceId)
throw DirectoryInfoHasInvalidSourceId{};
s->insertDirectoryInfoStatement.write(directoryInfo.directorySourceId,
directoryInfo.sourceId,
directoryInfo.moduleId,
directoryInfo.fileType);
s->insertDirectoryInfoStatement.write(directoryInfo.directoryId,
directoryInfo.sourceId,
directoryInfo.moduleId,
directoryInfo.fileType);
};
auto update = [&](const Storage::Synchronization::DirectoryInfo &directoryInfoFromDatabase,
@@ -2616,10 +2619,10 @@ void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::Directo
keyValue("directory info from database",
directoryInfoFromDatabase)};
s->updateDirectoryInfoStatement.write(directoryInfo.directorySourceId,
directoryInfo.sourceId,
directoryInfo.moduleId,
directoryInfo.fileType);
s->updateDirectoryInfoStatement.write(directoryInfo.directoryId,
directoryInfo.sourceId,
directoryInfo.moduleId,
directoryInfo.fileType);
return Sqlite::UpdateChange::Update;
}
@@ -2632,7 +2635,7 @@ void ProjectStorage::synchronizeDirectoryInfos(Storage::Synchronization::Directo
projectStorageCategory(),
keyValue("directory info", directoryInfo)};
s->deleteDirectoryInfoStatement.write(directoryInfo.directorySourceId, directoryInfo.sourceId);
s->deleteDirectoryInfoStatement.write(directoryInfo.directoryId, directoryInfo.sourceId);
};
Sqlite::insertUpdateDelete(range, directoryInfos, compareKey, insert, update, remove);
@@ -4003,14 +4006,15 @@ void ProjectStorage::addTypeIdToPropertyEditorQmlPaths(
path.typeId = fetchTypeIdByModuleIdAndExportedName(path.moduleId, path.typeName);
}
void ProjectStorage::synchronizePropertyEditorPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds)
void ProjectStorage::synchronizePropertyEditorPaths(
Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceContextIds updatedPropertyEditorQmlPathsSourceContextIds)
{
using Storage::Synchronization::PropertyEditorQmlPath;
std::ranges::sort(paths, std::ranges::less{}, &PropertyEditorQmlPath::typeId);
auto range = s->selectPropertyEditorPathsForForSourceIdsStatement.range<PropertyEditorQmlPathView>(
toIntegers(updatedPropertyEditorQmlPathsSourceIds));
toIntegers(updatedPropertyEditorQmlPathsSourceContextIds));
auto compareKey = [](const PropertyEditorQmlPathView &view, const PropertyEditorQmlPath &value) {
return view.typeId <=> value.typeId;
@@ -4057,7 +4061,7 @@ void ProjectStorage::synchronizePropertyEditorPaths(Storage::Synchronization::Pr
void ProjectStorage::synchronizePropertyEditorQmlPaths(
Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds)
SourceContextIds updatedPropertyEditorQmlPathsSourceIds)
{
NanotraceHR::Tracer tracer{"synchronize property editor qml paths", projectStorageCategory()};

View File

@@ -105,9 +105,9 @@ public:
Storage::Info::TypeHints typeHints(TypeId typeId) const override;
SmallSourceIds<4> typeAnnotationSourceIds(SourceId directoryId) const override;
SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const override;
SmallSourceIds<64> typeAnnotationDirectorySourceIds() const override;
SmallSourceContextIds<64> typeAnnotationDirectoryIds() const override;
Storage::Info::ItemLibraryEntries itemLibraryEntries(TypeId typeId) const override;
@@ -222,11 +222,11 @@ public:
std::optional<Storage::Synchronization::DirectoryInfo> fetchDirectoryInfo(SourceId sourceId) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceId directorySourceId) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
SourceId directorySourceId, Storage::Synchronization::FileType fileType) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const SourceIds &directorySourceIds) const;
SmallSourceIds<32> fetchSubdirectorySourceIds(SourceId directorySourceId) const override;
SourceContextId directoryId, Storage::Synchronization::FileType fileType) const override;
Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(const SourceContextIds &directoryIds) const;
SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const override;
void setPropertyEditorPathId(TypeId typeId, SourceId pathId);
@@ -568,7 +568,7 @@ private:
const SourceIds &updatedSourceIds);
void synchronizeDirectoryInfos(Storage::Synchronization::DirectoryInfos &directoryInfos,
const SourceIds &updatedDirectoryInfoSourceIds);
const SourceContextIds &updatedDirectoryInfoDirectoryIds);
void synchronizeFileStatuses(FileStatuses &fileStatuses, const SourceIds &updatedSourceIds);
@@ -781,7 +781,7 @@ private:
class PropertyEditorQmlPathView
{
public:
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, SourceId directoryId)
PropertyEditorQmlPathView(TypeId typeId, SourceId pathId, SourceContextId directoryId)
: typeId{typeId}
, pathId{pathId}
, directoryId{directoryId}
@@ -803,14 +803,14 @@ private:
public:
TypeId typeId;
SourceId pathId;
SourceId directoryId;
SourceContextId directoryId;
};
void synchronizePropertyEditorPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds);
SourceContextIds updatedPropertyEditorQmlPathsSourceContextIds);
void synchronizePropertyEditorQmlPaths(Storage::Synchronization::PropertyEditorQmlPaths &paths,
SourceIds updatedPropertyEditorQmlPathsSourceIds);
SourceContextIds updatedPropertyEditorQmlPathsSourceIds);
void synchronizeFunctionDeclarations(
TypeId typeId, Storage::Synchronization::FunctionDeclarations &functionsDeclarations);

View File

@@ -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(SourceId directoryId) const = 0;
virtual SmallSourceIds<64> typeAnnotationDirectorySourceIds() const = 0;
virtual SmallSourceIds<4> typeAnnotationSourceIds(SourceContextId directoryId) const = 0;
virtual SmallSourceContextIds<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;
@@ -81,12 +81,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(SourceId sourceId) const = 0;
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(SourceContextId directoryId) const = 0;
virtual Storage::Synchronization::DirectoryInfos fetchDirectoryInfos(
SourceId directorySourceId, Storage::Synchronization::FileType) const
SourceContextId directoryId, Storage::Synchronization::FileType) const
= 0;
virtual std::optional<Storage::Synchronization::DirectoryInfo> fetchDirectoryInfo(SourceId sourceId) const = 0;
virtual SmallSourceIds<32> fetchSubdirectorySourceIds(SourceId directorySourceId) const = 0;
virtual std::optional<Storage::Synchronization::DirectoryInfo>
fetchDirectoryInfo(SourceId sourceId) const = 0;
virtual SmallSourceContextIds<32> fetchSubdirectoryIds(SourceContextId directoryId) const = 0;
virtual SourceId propertyEditorPathId(TypeId typeId) const = 0;
virtual const Storage::Info::CommonTypeCache<ProjectStorageType> &commonTypeCache() const = 0;

View File

@@ -1149,7 +1149,10 @@ using Types = std::vector<Type>;
class PropertyEditorQmlPath
{
public:
PropertyEditorQmlPath(ModuleId moduleId, TypeNameString typeName, SourceId pathId, SourceId directoryId)
PropertyEditorQmlPath(ModuleId moduleId,
TypeNameString typeName,
SourceId pathId,
SourceContextId directoryId)
: typeName{typeName}
, pathId{pathId}
, directoryId{directoryId}
@@ -1174,7 +1177,7 @@ public:
TypeNameString typeName;
TypeId typeId;
SourceId pathId;
SourceId directoryId;
SourceContextId directoryId;
ModuleId moduleId;
};
@@ -1183,8 +1186,8 @@ using PropertyEditorQmlPaths = std::vector<class PropertyEditorQmlPath>;
class DirectoryInfo
{
public:
DirectoryInfo(SourceId directorySourceId, SourceId sourceId, ModuleId moduleId, FileType fileType)
: directorySourceId{directorySourceId}
DirectoryInfo(SourceContextId directoryId, SourceId sourceId, ModuleId moduleId, FileType fileType)
: directoryId{directoryId}
, sourceId{sourceId}
, moduleId{moduleId}
, fileType{fileType}
@@ -1192,7 +1195,7 @@ public:
friend bool operator==(const DirectoryInfo &first, const DirectoryInfo &second)
{
return first.directorySourceId == second.directorySourceId && first.sourceId == second.sourceId
return first.directoryId == second.directoryId && first.sourceId == second.sourceId
&& first.moduleId.internalId() == second.moduleId.internalId()
&& first.fileType == second.fileType;
}
@@ -1202,7 +1205,7 @@ public:
{
using NanotraceHR::dictonary;
using NanotraceHR::keyValue;
auto dict = dictonary(keyValue("project source id", directoryInfo.directorySourceId),
auto dict = dictonary(keyValue("directory id", directoryInfo.directoryId),
keyValue("source id", directoryInfo.sourceId),
keyValue("module id", directoryInfo.moduleId),
keyValue("file type", directoryInfo.fileType));
@@ -1211,7 +1214,7 @@ public:
}
public:
SourceId directorySourceId;
SourceContextId directoryId;
SourceId sourceId;
ModuleId moduleId;
FileType fileType;
@@ -1222,13 +1225,13 @@ using DirectoryInfos = std::vector<DirectoryInfo>;
class TypeAnnotation
{
public:
TypeAnnotation(SourceId sourceId, SourceId directorySourceId)
TypeAnnotation(SourceId sourceId, SourceContextId directoryId)
: sourceId{sourceId}
, directorySourceId{directorySourceId}
, directoryId{directoryId}
{}
TypeAnnotation(SourceId sourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Utils::SmallStringView typeName,
ModuleId moduleId,
Utils::SmallStringView iconPath,
@@ -1242,7 +1245,7 @@ public:
, sourceId{sourceId}
, moduleId{moduleId}
, traits{traits}
, directorySourceId{directorySourceId}
, directoryId{directoryId}
{}
template<typename String>
@@ -1271,7 +1274,7 @@ public:
SourceId sourceId;
ModuleId moduleId;
TypeTraits traits;
SourceId directorySourceId;
SourceContextId directoryId;
};
using TypeAnnotations = std::vector<TypeAnnotation>;
@@ -1311,9 +1314,10 @@ public:
, fileStatuses(std::move(fileStatuses))
{}
SynchronizationPackage(SourceIds updatedDirectoryInfoSourceIds, DirectoryInfos directoryInfos)
SynchronizationPackage(SourceContextIds updatedDirectoryInfoDirectoryIds,
DirectoryInfos directoryInfos)
: directoryInfos(std::move(directoryInfos))
, updatedDirectoryInfoSourceIds(std::move(updatedDirectoryInfoSourceIds))
, updatedDirectoryInfoDirectoryIds(std::move(updatedDirectoryInfoDirectoryIds))
{}
public:
@@ -1323,13 +1327,13 @@ public:
SourceIds updatedFileStatusSourceIds;
FileStatuses fileStatuses;
DirectoryInfos directoryInfos;
SourceIds updatedDirectoryInfoSourceIds;
SourceContextIds updatedDirectoryInfoDirectoryIds;
Imports moduleDependencies;
SourceIds updatedModuleDependencySourceIds;
ModuleExportedImports moduleExportedImports;
ModuleIds updatedModuleIds;
PropertyEditorQmlPaths propertyEditorQmlPaths;
SourceIds updatedPropertyEditorQmlPathSourceIds;
SourceContextIds updatedPropertyEditorQmlPathSourceContextIds;
TypeAnnotations typeAnnotations;
SourceIds updatedTypeAnnotationSourceIds;
};

View File

@@ -88,11 +88,11 @@ ProjectStorageUpdater::Components createComponents(
ModuleId moduleId,
ModuleId pathModuleId,
FileSystemInterface &fileSystem,
const Utils::PathString &directory)
const QString &directory)
{
ProjectStorageUpdater::Components components;
auto qmlFileNames = fileSystem.qmlFileNames(QString{directory});
auto qmlFileNames = fileSystem.qmlFileNames(directory);
components.reserve(static_cast<std::size_t>(qmlDirParserComponents.size() + qmlFileNames.size()));
@@ -250,8 +250,7 @@ std::vector<IdPaths> createIdPaths(ProjectStorageUpdater::WatchedSourceIdsIds wa
std::vector<IdPaths> idPaths;
idPaths.reserve(4);
idPaths.push_back(
{projectPartId, SourceType::Directory, std::move(watchedSourceIds.directorySourceIds)});
idPaths.push_back({projectPartId, SourceType::Directory, std::move(watchedSourceIds.directoryIds)});
idPaths.push_back({projectPartId, SourceType::QmlDir, std::move(watchedSourceIds.qmldirSourceIds)});
idPaths.push_back({projectPartId, SourceType::Qml, std::move(watchedSourceIds.qmlSourceIds)});
idPaths.push_back(
@@ -304,11 +303,10 @@ ProjectStorageUpdater::FileState combineState(FileStates... fileStates)
} // namespace
void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPath,
void ProjectStorageUpdater::updateDirectoryChanged(Utils::SmallStringView directoryPath,
FileState qmldirState,
SourcePath qmldirSourcePath,
SourceId qmldirSourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -341,7 +339,7 @@ void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPat
tracer.tick("append updated module id", keyValue("module id", moduleId));
package.updatedModuleIds.push_back(moduleId);
const auto qmlDirectoryInfos = m_projectStorage.fetchDirectoryInfos(directorySourceId);
const auto qmlDirectoryInfos = m_projectStorage.fetchDirectoryInfos(directoryId);
addSourceIds(package.updatedSourceIds, qmlDirectoryInfos, "append updated source id", tracer);
addSourceIds(package.updatedFileStatusSourceIds,
qmlDirectoryInfos,
@@ -350,28 +348,32 @@ void ProjectStorageUpdater::updateDirectoryChanged(std::string_view directoryPat
auto qmlTypes = filterMultipleEntries(parser.typeInfos());
QString directoryPathAsQString{directoryPath};
if (!qmlTypes.isEmpty()) {
parseTypeInfos(qmlTypes,
filterMultipleEntries(parser.dependencies()),
imports,
directorySourceId,
directoryPath,
directoryId,
directoryPathAsQString,
cppModuleId,
package,
notUpdatedSourceIds,
watchedSourceIdsIds);
}
parseQmlComponents(
createComponents(parser.components(), moduleId, pathModuleId, m_fileSystem, directoryPath),
directorySourceId,
directoryId,
package,
notUpdatedSourceIds,
watchedSourceIdsIds,
qmldirState,
qmldirSourceId);
parseQmlComponents(createComponents(parser.components(),
moduleId,
pathModuleId,
m_fileSystem,
directoryPathAsQString),
directoryId,
package,
notUpdatedSourceIds,
watchedSourceIdsIds,
qmldirState,
qmldirSourceId);
tracer.tick("append updated project source id", keyValue("module id", moduleId));
package.updatedDirectoryInfoSourceIds.push_back(directorySourceId);
package.updatedDirectoryInfoDirectoryIds.push_back(directoryId);
}
void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
@@ -386,7 +388,7 @@ void ProjectStorageUpdater::updateDirectories(const QStringList &directories,
}
void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &directoryPath,
SourceId directorySourceId,
SourceContextId directoryId,
FileState directoryState,
const SourceContextIds &subdirectoriesToIgnore,
Storage::Synchronization::SynchronizationPackage &package,
@@ -395,51 +397,22 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
{
struct Directory
{
Directory(Utils::SmallStringView path, SourceId sourceId)
Directory(Utils::SmallStringView path, SourceContextId sourceContextId)
: path{path}
, sourceId{sourceId}
, sourceContextId{sourceContextId}
{}
bool operator<(const Directory &other) const
{
return sourceId.contextId() < other.sourceId.contextId();
}
bool operator==(const Directory &other) const
{
return sourceId.contextId() == other.sourceId.contextId();
}
Utils::PathString path;
SourceId sourceId;
};
struct Compare
{
bool operator()(const Directory &first, const Directory &second) const
{
return first.sourceId.contextId() < second.sourceId.contextId();
}
bool operator()(const Directory &first, SourceContextId second) const
{
return first.sourceId.contextId() < second;
}
bool operator()(SourceContextId first, const Directory &second) const
{
return first < second.sourceId.contextId();
}
SourceContextId sourceContextId;
};
using Directories = QVarLengthArray<Directory, 32>;
auto subdirectorySourceIds = m_projectStorage.fetchSubdirectorySourceIds(directorySourceId);
auto subdirectoryIds = m_projectStorage.fetchSubdirectoryIds(directoryId);
auto subdirectories = Utils::transform<Directories>(
subdirectorySourceIds, [&](SourceId sourceId) -> Directory {
auto sourceContextId = sourceId.contextId();
subdirectoryIds, [&](SourceContextId sourceContextId) -> Directory {
auto subdirectoryPath = m_pathCache.sourceContextPath(sourceContextId);
return {subdirectoryPath, sourceId};
return {subdirectoryPath, sourceContextId};
});
auto exisitingSubdirectoryPaths = m_fileSystem.subdirectories(directoryPath.toQString());
@@ -449,32 +422,32 @@ void ProjectStorageUpdater::updateSubdirectories(const Utils::PathString &direct
|| subdirectory.endsWith("/QtQuick/Scene3D"))
continue;
Utils::PathString subdirectoryPath = subdirectory;
SourceId sourceId = m_pathCache.sourceId(SourcePath{subdirectoryPath + "/."});
subdirectories.emplace_back(subdirectoryPath, sourceId);
existingSubdirecories.emplace_back(subdirectoryPath, sourceId);
SourceContextId sourceContextId = m_pathCache.sourceContextId(subdirectoryPath);
subdirectories.emplace_back(subdirectoryPath, sourceContextId);
existingSubdirecories.emplace_back(subdirectoryPath, sourceContextId);
}
std::sort(subdirectories.begin(), subdirectories.end());
subdirectories.erase(std::unique(subdirectories.begin(), subdirectories.end()),
subdirectories.end());
std::ranges::sort(subdirectories, {}, &Directory::sourceContextId);
auto removed = std::ranges::unique(subdirectories, {}, &Directory::sourceContextId);
subdirectories.erase(removed.begin(), removed.end());
std::set_difference(subdirectories.begin(),
subdirectories.end(),
subdirectoriesToIgnore.begin(),
subdirectoriesToIgnore.end(),
Utils::make_iterator([&](const Directory &subdirectory) {
updateDirectory(subdirectory.path,
subdirectoriesToIgnore,
package,
notUpdatedSourceIds,
watchedSourceIdsIds);
}),
Compare{});
Utils::set_greedy_difference(
subdirectories,
subdirectoriesToIgnore,
[&](const Directory &subdirectory) {
updateDirectory(subdirectory.path,
subdirectoriesToIgnore,
package,
notUpdatedSourceIds,
watchedSourceIdsIds);
},
{},
&Directory::sourceContextId);
if (directoryState == FileState::Changed) {
for (const auto &[subdirectoryPath, subdirectorySourceId] : existingSubdirecories) {
package.directoryInfos.emplace_back(directorySourceId,
subdirectorySourceId,
for (const auto &[subdirectoryPath, subdirectoryId] : existingSubdirecories) {
package.directoryInfos.emplace_back(directoryId,
SourceId::create(SourceNameId{}, subdirectoryId),
ModuleId{},
Storage::Synchronization::FileType::Directory);
}
@@ -492,11 +465,9 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
SourcePath qmldirSourcePath{directoryPath + "/qmldir"};
auto [directoryId, qmldirSourceId] = m_pathCache.sourceContextAndSourceId(qmldirSourcePath);
SourcePath directorySourcePath{directoryPath + "/."};
auto directorySourceId = m_pathCache.sourceId(directorySourcePath);
auto directoryState = fileState(directorySourceId, package, notUpdatedSourceIds);
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
if (directoryState != FileState::NotExists)
watchedSourceIdsIds.directorySourceIds.push_back(directorySourceId);
watchedSourceIdsIds.directoryIds.push_back(SourceId::create(SourceNameId{}, directoryId));
auto qmldirState = fileState(qmldirSourceId, package, notUpdatedSourceIds);
if (qmldirState != FileState::NotExists)
@@ -509,7 +480,6 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
qmldirState,
qmldirSourcePath,
qmldirSourceId,
directorySourceId,
directoryId,
package,
notUpdatedSourceIds,
@@ -520,7 +490,7 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
case FileState::NotChanged: {
tracer.tick("update directory not changed");
parseDirectoryInfos(m_projectStorage.fetchDirectoryInfos(directorySourceId),
parseDirectoryInfos(m_projectStorage.fetchDirectoryInfos(directoryId),
package,
notUpdatedSourceIds,
watchedSourceIdsIds);
@@ -529,11 +499,12 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
case FileState::NotExists: {
tracer.tick("update directory don't exits");
auto directorySourceId = SourceId::create(SourceNameId{}, directoryId);
package.updatedFileStatusSourceIds.push_back(directorySourceId);
package.updatedFileStatusSourceIds.push_back(qmldirSourceId);
package.updatedDirectoryInfoSourceIds.push_back(directorySourceId);
package.updatedDirectoryInfoDirectoryIds.push_back(directoryId);
package.updatedSourceIds.push_back(qmldirSourceId);
auto qmlDirectoryInfos = m_projectStorage.fetchDirectoryInfos(directorySourceId);
auto qmlDirectoryInfos = m_projectStorage.fetchDirectoryInfos(directoryId);
for (const Storage::Synchronization::DirectoryInfo &directoryInfo : qmlDirectoryInfos) {
tracer.tick("append updated source id", keyValue("source id", directoryInfo.sourceId));
package.updatedSourceIds.push_back(directoryInfo.sourceId);
@@ -547,7 +518,7 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
}
updateSubdirectories(directoryPath,
directorySourceId,
directoryId,
directoryState,
subdirectoriesToIgnore,
package,
@@ -555,10 +526,8 @@ void ProjectStorageUpdater::updateDirectory(const Utils::PathString &directoryPa
watchedSourceIdsIds);
tracer.end(keyValue("qmldir source path", qmldirSourcePath),
keyValue("directory source path", directorySourcePath),
keyValue("directory id", directoryId),
keyValue("qmldir source id", qmldirSourceId),
keyValue("directory source source id", directorySourceId),
keyValue("qmldir state", qmldirState),
keyValue("directory state", directoryState));
}
@@ -582,14 +551,15 @@ void ProjectStorageUpdater::updatePropertyEditorPaths(
while (dirIterator.hasNext()) {
auto pathInfo = dirIterator.nextFileInfo();
SourceId directorySourceId = m_pathCache.sourceId(SourcePath{pathInfo.filePath() + "/."});
SourceContextId directoryId = m_pathCache.sourceContextId(
Utils::PathString{pathInfo.filePath()});
auto state = fileState(directorySourceId, package, notUpdatedSourceIds);
auto state = fileState(directoryId, package, notUpdatedSourceIds);
if (state == FileState::Changed) {
updatePropertyEditorPath(pathInfo.filePath(),
package,
directorySourceId,
directoryId,
propertyEditorResourcesPath.size() + 1);
}
}
@@ -618,9 +588,9 @@ void ProjectStorageUpdater::updateTypeAnnotations(const QStringList &directoryPa
{
NanotraceHR::Tracer tracer("update type annotations", category());
std::map<SourceId, SmallSourceIds<16>> updatedSourceIdsDictonary;
std::map<SourceContextId, SmallSourceIds<16>> updatedSourceIdsDictonary;
for (SourceId directoryId : m_projectStorage.typeAnnotationDirectorySourceIds())
for (SourceContextId directoryId : m_projectStorage.typeAnnotationDirectoryIds())
updatedSourceIdsDictonary[directoryId] = {};
for (const auto &directoryPath : directoryPaths)
@@ -633,7 +603,7 @@ void ProjectStorageUpdater::updateTypeAnnotations(
const QString &rootDirectoryPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
std::map<SourceId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
{
NanotraceHR::Tracer tracer("update type annotation directory",
category(),
@@ -654,28 +624,28 @@ void ProjectStorageUpdater::updateTypeAnnotations(
auto directoryPath = fileInfo.canonicalPath();
SourceId directorySourceId = m_pathCache.sourceId(SourcePath{directoryPath + "/."});
SourceContextId directoryId = m_pathCache.sourceContextId(Utils::PathString{directoryPath});
auto state = fileState(sourceId, package, notUpdatedSourceIds);
if (state == FileState::Changed)
updateTypeAnnotation(directoryPath, fileInfo.filePath(), sourceId, directorySourceId, package);
updateTypeAnnotation(directoryPath, fileInfo.filePath(), sourceId, directoryId, package);
if (state != FileState::NotChanged)
updatedSourceIdsDictonary[directorySourceId].push_back(sourceId);
updatedSourceIdsDictonary[directoryId].push_back(sourceId);
}
}
void ProjectStorageUpdater::updateTypeAnnotationDirectories(
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
std::map<SourceId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary)
{
for (auto &[directorySourceId, updatedSourceIds] : updatedSourceIdsDictonary) {
auto directoryState = fileState(directorySourceId, package, notUpdatedSourceIds);
for (auto &[directoryId, updatedSourceIds] : updatedSourceIdsDictonary) {
auto directoryState = fileState(directoryId, package, notUpdatedSourceIds);
if (directoryState != FileState::NotChanged) {
auto existingTypeAnnotationSourceIds = m_projectStorage.typeAnnotationSourceIds(
directorySourceId);
directoryId);
std::sort(updatedSourceIds.begin(), updatedSourceIds.end());
@@ -705,7 +675,7 @@ QString contentFromFile(const QString &path)
void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
const QString &filePath,
SourceId sourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package)
{
NanotraceHR::Tracer tracer{"update type annotation path",
@@ -718,7 +688,7 @@ void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
auto annotations = reader.parseTypeAnnotation(contentFromFile(filePath),
directoryPath,
sourceId,
directorySourceId);
directoryId);
auto &typeAnnotations = package.typeAnnotations;
package.typeAnnotations.insert(typeAnnotations.end(),
std::make_move_iterator(annotations.begin()),
@@ -728,33 +698,33 @@ void ProjectStorageUpdater::updateTypeAnnotation(const QString &directoryPath,
void ProjectStorageUpdater::updatePropertyEditorPath(
const QString &directoryPath,
Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId,
SourceContextId directoryId,
long long pathOffset)
{
NanotraceHR::Tracer tracer{"update property editor path",
category(),
keyValue("directory path", directoryPath),
keyValue("directory source id", directorySourceId)};
keyValue("directory id", directoryId)};
tracer.tick("append updated property editor qml path source id",
keyValue("source id", directorySourceId));
package.updatedPropertyEditorQmlPathSourceIds.push_back(directorySourceId);
keyValue("source id", directoryId));
package.updatedPropertyEditorQmlPathSourceContextIds.push_back(directoryId);
auto dir = QDir{directoryPath};
const auto fileInfos = dir.entryInfoList({"*Pane.qml", "*Specifics.qml"}, QDir::Files);
for (const auto &fileInfo : fileInfos)
updatePropertyEditorFilePath(fileInfo.filePath(), package, directorySourceId, pathOffset);
updatePropertyEditorFilePath(fileInfo.filePath(), package, directoryId, pathOffset);
}
void ProjectStorageUpdater::updatePropertyEditorFilePath(
const QString &path,
Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId,
SourceContextId directoryId,
long long pathOffset)
{
NanotraceHR::Tracer tracer{"update property editor file path",
category(),
keyValue("directory path", path),
keyValue("directory source id", directorySourceId)};
keyValue("directory id", directoryId)};
QRegularExpression regex{R"xo((.+)\/(\w+)(Specifics|Pane).qml)xo"};
auto match = regex.match(QStringView{path}.mid(pathOffset));
@@ -773,7 +743,7 @@ void ProjectStorageUpdater::updatePropertyEditorFilePath(
const auto &paths = package.propertyEditorQmlPaths.emplace_back(moduleId,
typeName,
pathId,
directorySourceId);
directoryId);
tracer.tick("append property editor qml paths",
keyValue("property editor qml paths", paths));
}
@@ -848,26 +818,22 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
}
}
auto directorySourceContextIds = filterUniqueSourceContextIds(directorySourceIds);
auto directoryIds = filterUniqueSourceContextIds(directorySourceIds);
for (auto sourceContextId : directorySourceContextIds) {
Utils::PathString directory = m_pathCache.sourceContextPath(sourceContextId);
updateDirectory(directory,
directorySourceContextIds,
package,
notUpdatedSourceIds,
watchedSourceIds);
for (auto directoryId : directoryIds) {
Utils::PathString directory = m_pathCache.sourceContextPath(directoryId);
updateDirectory(directory, directoryIds, package, notUpdatedSourceIds, watchedSourceIds);
}
for (SourceId sourceId : filterUniqueSourceIds(qmlDocumentSourceIds)) {
if (!contains(directorySourceContextIds, sourceId.contextId()))
if (!contains(directoryIds, sourceId.contextId()))
parseQmlComponent(sourceId, package, notUpdatedSourceIds);
}
try {
for (SourceId sourceId : filterUniqueSourceIds(std::move(qmltypesSourceIds))) {
if (!contains(directorySourceContextIds, sourceId.contextId())) {
auto qmltypesPath = m_pathCache.sourcePath(sourceId);
if (!contains(directoryIds, sourceId.contextId())) {
QString qmltypesPath{m_pathCache.sourcePath(sourceId)};
auto directoryInfo = m_projectStorage.fetchDirectoryInfo(sourceId);
if (directoryInfo)
parseTypeInfo(*directoryInfo, qmltypesPath, package, notUpdatedSourceIds);
@@ -889,9 +855,9 @@ void ProjectStorageUpdater::pathsWithIdsChanged(const std::vector<IdPaths> &chan
return;
}
if (directorySourceContextIds.size()) {
if (directoryIds.size()) {
m_pathWatcher.updateContextIdPaths(createIdPaths(watchedSourceIds, m_projectPartId),
directorySourceContextIds);
directoryIds);
}
m_changedIdPaths.clear();
@@ -902,8 +868,8 @@ void ProjectStorageUpdater::pathsChanged(const SourceIds &) {}
void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
const QList<QmlDirParser::Import> &qmldirDependencies,
const QList<QmlDirParser::Import> &qmldirImports,
SourceId directorySourceId,
Utils::SmallStringView directoryPath,
SourceContextId directoryId,
const QString &directoryPath,
ModuleId moduleId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -911,16 +877,15 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
{
NanotraceHR::Tracer tracer{"parse type infos",
category(),
keyValue("directory source id", directorySourceId),
keyValue("directory id", directoryId),
keyValue("directory path", directoryPath),
keyValue("module id", moduleId)};
for (const QString &typeInfo : typeInfos) {
NanotraceHR::Tracer tracer{"parse type info", category(), keyValue("type info", typeInfo)};
Utils::PathString qmltypesPath = Utils::PathString::join(
{directoryPath, "/", Utils::SmallString{typeInfo}});
SourceId sourceId = m_pathCache.sourceId(SourcePathView{qmltypesPath});
Utils::PathString qmltypesFileName = typeInfo;
SourceId sourceId = m_pathCache.sourceId(directoryId, qmltypesFileName);
tracer.tick("append qmltypes source id", keyValue("source id", sourceId));
watchedSourceIds.qmltypesSourceIds.push_back(sourceId);
@@ -936,9 +901,11 @@ void ProjectStorageUpdater::parseTypeInfos(const QStringList &typeInfos,
package.updatedModuleDependencySourceIds.push_back(sourceId);
const auto &directoryInfo = package.directoryInfos.emplace_back(
directorySourceId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
directoryId, sourceId, moduleId, Storage::Synchronization::FileType::QmlTypes);
tracer.tick("append project data", keyValue("source id", sourceId));
const QString qmltypesPath = directoryPath + "/" + typeInfo;
parseTypeInfo(directoryInfo, qmltypesPath, package, notUpdatedSourceIds);
}
}
@@ -956,7 +923,7 @@ void ProjectStorageUpdater::parseDirectoryInfos(
case Storage::Synchronization::FileType::QmlTypes: {
watchedSourceIds.qmltypesSourceIds.push_back(directoryInfo.sourceId);
auto qmltypesPath = m_pathCache.sourcePath(directoryInfo.sourceId);
QString qmltypesPath{m_pathCache.sourcePath(directoryInfo.sourceId)};
parseTypeInfo(directoryInfo, qmltypesPath, package, notUpdatedSourceIds);
break;
}
@@ -973,7 +940,7 @@ void ProjectStorageUpdater::parseDirectoryInfos(
}
auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::DirectoryInfo &directoryInfo,
Utils::SmallStringView qmltypesPath,
const QString &qmltypesPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) -> FileState
{
@@ -987,7 +954,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Direct
tracer.tick("append updated source ids", keyValue("source id", directoryInfo.sourceId));
package.updatedSourceIds.push_back(directoryInfo.sourceId);
const auto content = m_fileSystem.contentAsQString(QString{qmltypesPath});
const auto content = m_fileSystem.contentAsQString(qmltypesPath);
m_qmlTypesParser.parse(content, package.imports, package.types, directoryInfo);
break;
}
@@ -1008,7 +975,7 @@ auto ProjectStorageUpdater::parseTypeInfo(const Storage::Synchronization::Direct
void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFilePath,
Utils::SmallStringView directoryPath,
Storage::Synchronization::ExportedTypes exportedTypes,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIds,
@@ -1020,7 +987,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
keyValue("relative file path", relativeFilePath),
keyValue("directory path", directoryPath),
keyValue("exported types", exportedTypes),
keyValue("directory source id", directorySourceId),
keyValue("directory id", directoryId),
keyValue("qmldir state", qmldirState)};
if (std::find(relativeFilePath.begin(), relativeFilePath.end(), '+') != relativeFilePath.end())
@@ -1042,7 +1009,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
notUpdatedSourceIds.sourceIds.emplace_back(sourceId);
const auto &directoryInfo = package.directoryInfos.emplace_back(
directorySourceId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
directoryId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
tracer.tick("append project data", keyValue("project data", directoryInfo));
return;
@@ -1065,7 +1032,7 @@ void ProjectStorageUpdater::parseQmlComponent(Utils::SmallStringView relativeFil
}
const auto &directoryInfo = package.directoryInfos.emplace_back(
directorySourceId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
directoryId, sourceId, ModuleId{}, Storage::Synchronization::FileType::QmlDocument);
tracer.tick("append project data", keyValue("project data", directoryInfo));
tracer.tick("append updated source id", keyValue("source id", sourceId));
@@ -1111,6 +1078,15 @@ void ProjectStorageUpdater::parseQmlComponent(SourceId sourceId,
package.types.push_back(std::move(type));
}
ProjectStorageUpdater::FileState ProjectStorageUpdater::fileState(
SourceContextId sourceContextId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) const
{
auto sourceId = SourceId::create(SourceNameId{}, sourceContextId);
return fileState(sourceId, package, notUpdatedSourceIds);
}
namespace {
template<typename Callback>
@@ -1166,7 +1142,6 @@ Storage::Synchronization::ExportedTypes createExportedTypes(ProjectStorageUpdate
} // namespace
void ProjectStorageUpdater::parseQmlComponents(Components components,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -1176,7 +1151,6 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
{
NanotraceHR::Tracer tracer{"parse qml components",
category(),
keyValue("directory source id", directorySourceId),
keyValue("directory id", directoryId),
keyValue("qmldir state", qmldirState)};
@@ -1191,7 +1165,7 @@ void ProjectStorageUpdater::parseQmlComponents(Components components,
parseQmlComponent(fileName,
directoryPath,
createExportedTypes(componentsWithSameFileName),
directorySourceId,
directoryId,
package,
notUpdatedSourceIds,
watchedSourceIdsIds,

View File

@@ -114,13 +114,13 @@ public:
{
WatchedSourceIdsIds(std::size_t reserve)
{
directorySourceIds.reserve(reserve);
directoryIds.reserve(reserve);
qmldirSourceIds.reserve(reserve);
qmlSourceIds.reserve(reserve * 30);
qmltypesSourceIds.reserve(reserve * 30);
}
SourceIds directorySourceIds;
SourceIds directoryIds;
SourceIds qmldirSourceIds;
SourceIds qmlSourceIds;
SourceIds qmltypesSourceIds;
@@ -150,17 +150,16 @@ private:
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds);
void updateSubdirectories(const Utils::PathString &directory,
SourceId directorySourceId,
SourceContextId directoryId,
FileState directoryFileState,
const SourceContextIds &subdirecoriesToIgnore,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds);
void updateDirectoryChanged(std::string_view directoryPath,
void updateDirectoryChanged(Utils::SmallStringView directoryPath,
FileState qmldirState,
SourcePath qmldirSourcePath,
SourceId qmldirSourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -173,31 +172,32 @@ private:
void updateTypeAnnotations(const QString &directoryPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
std::map<SourceId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
void updateTypeAnnotationDirectories(Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
std::map<SourceId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
void updateTypeAnnotationDirectories(
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
std::map<SourceContextId, SmallSourceIds<16>> &updatedSourceIdsDictonary);
void updateTypeAnnotations(const QStringList &directoryPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds);
void updateTypeAnnotation(const QString &directoryPath,
const QString &filePath,
SourceId sourceId,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package);
void updatePropertyEditorPath(const QString &path,
Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId,
SourceContextId directoryId,
long long pathOffset);
void updatePropertyEditorFilePath(const QString &filePath,
Storage::Synchronization::SynchronizationPackage &package,
SourceId directorySourceId,
SourceContextId directoryId,
long long pathOffset);
void parseTypeInfos(const QStringList &typeInfos,
const QList<QmlDirParser::Import> &qmldirDependencies,
const QList<QmlDirParser::Import> &qmldirImports,
SourceId directorySourceId,
Utils::SmallStringView directoryPath,
SourceContextId directoryId,
const QString &directoryPath,
ModuleId moduleId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -207,11 +207,10 @@ private:
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds);
FileState parseTypeInfo(const Storage::Synchronization::DirectoryInfo &directoryInfo,
Utils::SmallStringView qmltypesPath,
const QString &qmltypesPath,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds);
void parseQmlComponents(Components components,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
@@ -221,7 +220,7 @@ private:
void parseQmlComponent(Utils::SmallStringView fileName,
Utils::SmallStringView directory,
Storage::Synchronization::ExportedTypes exportedTypes,
SourceId directorySourceId,
SourceContextId directoryId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds,
WatchedSourceIdsIds &watchedSourceIdsIds,
@@ -234,6 +233,9 @@ private:
FileState fileState(SourceId sourceId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) const;
FileState fileState(SourceContextId sourceContextId,
Storage::Synchronization::SynchronizationPackage &package,
NotUpdatedSourceIds &notUpdatedSourceIds) const;
private:
std::vector<IdPaths> m_changedIdPaths;

View File

@@ -28,10 +28,10 @@ constexpr auto extraFileElementName = "ExtraFile"_L1;
} // namespace
Synchronization::TypeAnnotations TypeAnnotationReader::parseTypeAnnotation(
const QString &content, const QString &directoryPath, SourceId sourceId, SourceId directorySourceId)
const QString &content, const QString &directoryPath, SourceId sourceId, SourceContextId directoryId)
{
m_sourceId = sourceId;
m_directorySourceId = directorySourceId;
m_directoryId = directoryId;
m_directoryPath = directoryPath;
m_parserState = ParsingDocument;
if (!SimpleAbstractStreamReader::readFromSource(content)) {
@@ -178,7 +178,7 @@ TypeAnnotationReader::ParserSate TypeAnnotationReader::readDocument(const QStrin
TypeAnnotationReader::ParserSate TypeAnnotationReader::readMetaInfoRootElement(const QString &name)
{
if (name == typeElementName) {
auto &annotation = m_typeAnnotations.emplace_back(m_sourceId, m_directorySourceId);
auto &annotation = m_typeAnnotations.emplace_back(m_sourceId, m_directoryId);
annotation.traits.canBeContainer = FlagIs::True;
annotation.traits.canBeDroppedInFormEditor = FlagIs::True;
annotation.traits.canBeDroppedInNavigator = FlagIs::True;

View File

@@ -50,7 +50,7 @@ public:
Synchronization::TypeAnnotations parseTypeAnnotation(const QString &content,
const QString &directoryPath,
SourceId sourceId,
SourceId directorySourceId);
SourceContextId directoryId);
QStringList errors();
@@ -125,7 +125,7 @@ private:
json m_itemLibraryEntries;
Property m_currentProperty;
SourceId m_sourceId;
SourceId m_directorySourceId;
SourceContextId m_directoryId;
};
} // namespace QmlDesigner::Storage

View File

@@ -78,7 +78,7 @@ MATCHER_P3(IsItemLibraryProperty,
template<typename IconPathMatcher, typename TypeTraitsMatcher, typename HintsJsonMatcher, typename ItemLibraryJsonMatcher>
auto IsTypeAnnotation(QmlDesigner::SourceId sourceId,
QmlDesigner::SourceId directorySourceId,
QmlDesigner::SourceContextId directoryId,
Utils::SmallStringView typeName,
QmlDesigner::ModuleId moduleId,
IconPathMatcher iconPath,
@@ -88,7 +88,7 @@ auto IsTypeAnnotation(QmlDesigner::SourceId sourceId,
{
using QmlDesigner::Storage::Synchronization::TypeAnnotation;
return AllOf(Field("sourceId", &TypeAnnotation::sourceId, sourceId),
Field("directory sourceId", &TypeAnnotation::directorySourceId, directorySourceId),
Field("directory sourceId", &TypeAnnotation::directoryId, directoryId),
Field("typeName", &TypeAnnotation::typeName, typeName),
Field("moduleId", &TypeAnnotation::moduleId, moduleId),
Field("iconPath", &TypeAnnotation::iconPath, iconPath),

View File

@@ -205,9 +205,12 @@ public:
(const, override));
MOCK_METHOD(QmlDesigner::SmallSourceIds<4>,
typeAnnotationSourceIds,
(QmlDesigner::SourceId directoryId),
(QmlDesigner::SourceContextId directoryId),
(const, override));
MOCK_METHOD(QmlDesigner::SmallSourceContextIds<64>,
typeAnnotationDirectoryIds,
(),
(const, override));
MOCK_METHOD(QmlDesigner::SmallSourceIds<64>, typeAnnotationDirectorySourceIds, (), (const, override));
MOCK_METHOD(Utils::PathString, typeIconPath, (QmlDesigner::TypeId typeId), (const, override));
MOCK_METHOD(QmlDesigner::Storage::Info::TypeHints,
typeHints,
@@ -306,17 +309,18 @@ public:
MOCK_METHOD(QmlDesigner::Storage::Synchronization::DirectoryInfos,
fetchDirectoryInfos,
(QmlDesigner::SourceId sourceId),
(QmlDesigner::SourceContextId directoryId),
(const, override));
MOCK_METHOD(QmlDesigner::Storage::Synchronization::DirectoryInfos,
fetchDirectoryInfos,
(QmlDesigner::SourceId sourceId, QmlDesigner::Storage::Synchronization::FileType),
(QmlDesigner::SourceContextId directoryId,
QmlDesigner::Storage::Synchronization::FileType),
(const, override));
MOCK_METHOD(QmlDesigner::SmallSourceIds<32>,
fetchSubdirectorySourceIds,
(QmlDesigner::SourceId sourceId),
MOCK_METHOD(QmlDesigner::SmallSourceContextIds<32>,
fetchSubdirectoryIds,
(QmlDesigner::SourceContextId directoryId),
(const, override));
MOCK_METHOD(std::optional<QmlDesigner::Storage::Synchronization::DirectoryInfo>,

View File

@@ -853,11 +853,11 @@ std::ostream &operator<<(std::ostream &out, const SynchronizationPackage &packag
<< ", updatedSourceIds: " << package.updatedSourceIds
<< ", fileStatuses: " << package.fileStatuses
<< ", updatedFileStatusSourceIds: " << package.updatedFileStatusSourceIds
<< ", updatedDirectoryInfoSourceIds: " << package.updatedDirectoryInfoSourceIds
<< ", updatedDirectoryInfoDirectoryIds: " << package.updatedDirectoryInfoDirectoryIds
<< ", directoryInfos: " << package.directoryInfos
<< ", propertyEditorQmlPaths: " << package.propertyEditorQmlPaths
<< ", updatedPropertyEditorQmlPathSourceIds: "
<< package.updatedPropertyEditorQmlPathSourceIds
<< package.updatedPropertyEditorQmlPathSourceContextIds
<< ", typeAnnotations: " << package.typeAnnotations
<< ", updatedTypeAnnotationSourceIds: " << package.updatedTypeAnnotationSourceIds
<< ")";
@@ -865,8 +865,8 @@ std::ostream &operator<<(std::ostream &out, const SynchronizationPackage &packag
std::ostream &operator<<(std::ostream &out, const DirectoryInfo &data)
{
return out << "(" << data.directorySourceId << ", " << data.sourceId << ", " << data.moduleId
<< ", " << data.fileType << ")";
return out << "(" << data.directoryId << ", " << data.sourceId << ", " << data.moduleId << ", "
<< data.fileType << ")";
}
std::ostream &operator<<(std::ostream &out, IsQualified isQualified)

View File

@@ -24,6 +24,8 @@ using QmlDesigner::FileStatuses;
using QmlDesigner::FlagIs;
using QmlDesigner::ModuleId;
using QmlDesigner::PropertyDeclarationId;
using QmlDesigner::SourceContextId;
using QmlDesigner::SourceContextIds;
using QmlDesigner::SourceId;
using QmlDesigner::SourceIds;
using QmlDesigner::SourceNameId;
@@ -1039,10 +1041,19 @@ protected:
package.updatedSourceIds = {sourceId1, sourceId2, sourceId3};
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId, "QtObject", sourceId1, sourceIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId, "Item", sourceId2, sourceIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId, "Item3D", sourceId3, sourceIdPath6);
package.updatedPropertyEditorQmlPathSourceIds.emplace_back(sourceIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
"QtObject",
sourceId1,
sourceContextIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
"Item",
sourceId2,
sourceContextIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
"Item3D",
sourceId3,
sourceContextIdPath6);
package.updatedPropertyEditorQmlPathSourceContextIds.emplace_back(sourceContextIdPath6);
return package;
}
@@ -1056,7 +1067,7 @@ protected:
traits.visibleInLibrary = FlagIs::True;
annotations.emplace_back(sourceId4,
sourceIdPath6,
sourceContextIdPath6,
"Object",
qmlModuleId,
"/path/to/icon.png",
@@ -1078,7 +1089,7 @@ protected:
"properties":[["color", "color", "#blue"]]}])xy");
annotations.emplace_back(sourceId5,
sourceIdPath6,
sourceContextIdPath6,
"Item",
qtQuickModuleId,
"/path/to/quick.png",
@@ -1103,7 +1114,7 @@ protected:
traits.visibleInLibrary = FlagIs::True;
annotations.emplace_back(sourceId5,
sourceIdPath1,
sourceContextIdPath1,
"Item",
qtQuickModuleId,
"/path/to/quick.png",
@@ -1216,9 +1227,13 @@ protected:
SourceId sourceId5{sourcePathCache.sourceId(path5)};
SourceId sourceId6{sourcePathCache.sourceId(path6)};
SourceId sourceIdPath1{sourcePathCache.sourceId(pathPath1)};
SourceContextId sourceContextIdPath1{sourceIdPath1.contextId()};
SourceId sourceIdPath6{sourcePathCache.sourceId(pathPath6)};
SourceContextId sourceContextIdPath6{sourceIdPath6.contextId()};
SourceId qmlProjectSourceId{sourcePathCache.sourceId("/path1/qmldir")};
SourceContextId qmlProjectSourceContextId = qmlProjectSourceId.contextId();
SourceId qtQuickProjectSourceId{sourcePathCache.sourceId("/path2/qmldir")};
SourceContextId qtQuickProjectSourceContextId = qtQuickProjectSourceId.contextId();
ModuleId qmlModuleId{storage.moduleId("Qml", ModuleKind::QmlLibrary)};
ModuleId qmlNativeModuleId{storage.moduleId("Qml", ModuleKind::CppLibrary)};
ModuleId qtQuickModuleId{storage.moduleId("QtQuick", ModuleKind::QmlLibrary)};
@@ -5669,259 +5684,285 @@ TEST_F(ProjectStorage, populate_module_cache)
TEST_F(ProjectStorage, add_directory_infoes)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1, directoryInfo2, directoryInfo3));
}
TEST_F(ProjectStorage, remove_directory_info)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId}, {directoryInfo1}});
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1));
}
TEST_F(ProjectStorage, update_directory_info_file_type)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlTypes};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlTypes};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1, directoryInfo2b}});
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1, directoryInfo2b}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1, directoryInfo2b, directoryInfo3));
}
TEST_F(ProjectStorage, update_directory_info_module_id)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId3,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId2,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId3,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2b{qmlProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId2,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1, directoryInfo2b}});
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1, directoryInfo2b}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1, directoryInfo2b, directoryInfo3));
}
TEST_F(ProjectStorage, throw_for_invalid_source_id_in_directory_info)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
SourceId{},
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
SourceId{},
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
ASSERT_THROW(storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1}}),
ASSERT_THROW(storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}}),
QmlDesigner::DirectoryInfoHasInvalidSourceId);
}
TEST_F(ProjectStorage, insert_directory_info_with_invalid_module_id)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
ModuleId{},
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
ModuleId{},
Storage::Synchronization::FileType::QmlDocument};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1}});
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1));
}
TEST_F(ProjectStorage, update_directory_info_with_invalid_module_id)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
directoryInfo1.moduleId = ModuleId{};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1}});
storage.synchronize(SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}});
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId}),
ASSERT_THAT(storage.fetchDirectoryInfos({qmlProjectSourceContextId, qtQuickProjectSourceContextId}),
UnorderedElementsAre(directoryInfo1));
}
TEST_F(ProjectStorage, throw_for_updating_with_invalid_project_source_id_in_directory_info)
TEST_F(ProjectStorage, throw_for_updating_with_invalid_project_source_context_id_in_directory_info)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{SourceId{},
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo1{
SourceContextId{}, sourceId1, qmlModuleId, Storage::Synchronization::FileType::QmlDocument};
ASSERT_THROW(storage.synchronize(SynchronizationPackage{{qmlProjectSourceId}, {directoryInfo1}}),
ASSERT_THROW(storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId}, {directoryInfo1}}),
QmlDesigner::DirectoryInfoHasInvalidProjectSourceId);
}
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_ids)
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_ids)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
auto directoryInfos = storage.fetchDirectoryInfos({qmlProjectSourceId, qtQuickProjectSourceId});
auto directoryInfos = storage.fetchDirectoryInfos(
{qmlProjectSourceContextId, qtQuickProjectSourceContextId});
ASSERT_THAT(directoryInfos, UnorderedElementsAre(directoryInfo1, directoryInfo2, directoryInfo3));
}
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_id)
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_id)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceId);
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceContextId);
ASSERT_THAT(directoryInfo, UnorderedElementsAre(directoryInfo1, directoryInfo2));
}
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_id_and_file_type)
TEST_F(ProjectStorage, fetch_directory_infos_by_directory_source_context_id_and_file_type)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{
qmlProjectSourceId, sourceId1, qmlModuleId, Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{
qmlProjectSourceId, sourceId2, ModuleId{}, Storage::Synchronization::FileType::Directory};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
ModuleId{},
Storage::Synchronization::FileType::Directory};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
Storage::Synchronization::DirectoryInfo directoryInfo4{
qmlProjectSourceId, sourceId4, ModuleId{}, Storage::Synchronization::FileType::Directory};
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectSourceContextId,
sourceId4,
ModuleId{},
Storage::Synchronization::FileType::Directory};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3, directoryInfo4}});
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceId,
auto directoryInfo = storage.fetchDirectoryInfos(qmlProjectSourceContextId,
Storage::Synchronization::FileType::Directory);
ASSERT_THAT(directoryInfo, UnorderedElementsAre(directoryInfo2, directoryInfo4));
}
TEST_F(ProjectStorage, fetch_subdirectory_source_ids)
TEST_F(ProjectStorage, fetch_subdirectory_source_context_ids)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{
qmlProjectSourceId, sourceId1, qmlModuleId, Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{
qmlProjectSourceId, sourceId2, ModuleId{}, Storage::Synchronization::FileType::Directory};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
auto directory1Id = SourceId::create(SourceNameId{}, sourceId2.contextId());
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
directory1Id,
ModuleId{},
Storage::Synchronization::FileType::Directory};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
Storage::Synchronization::DirectoryInfo directoryInfo4{
qmlProjectSourceId, sourceId4, ModuleId{}, Storage::Synchronization::FileType::Directory};
auto directory2Id = SourceId::create(SourceNameId{}, sourceId4.contextId());
Storage::Synchronization::DirectoryInfo directoryInfo4{qmlProjectSourceContextId,
directory2Id,
ModuleId{},
Storage::Synchronization::FileType::Directory};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3, directoryInfo4}});
auto directoryInfo = storage.fetchSubdirectorySourceIds(qmlProjectSourceId);
auto directoryInfo = storage.fetchSubdirectoryIds(qmlProjectSourceContextId);
ASSERT_THAT(directoryInfo, UnorderedElementsAre(sourceId2, sourceId4));
ASSERT_THAT(directoryInfo,
UnorderedElementsAre(directory1Id.contextId(), directory2Id.contextId()));
}
TEST_F(ProjectStorage, fetch_directory_info_by_source_ids)
TEST_F(ProjectStorage, fetch_directory_info_by_source_id)
{
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(SynchronizationPackage{{qmlProjectSourceId, qtQuickProjectSourceId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
Storage::Synchronization::DirectoryInfo directoryInfo1{qmlProjectSourceContextId,
sourceId1,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo2{qmlProjectSourceContextId,
sourceId2,
qmlModuleId,
Storage::Synchronization::FileType::QmlDocument};
Storage::Synchronization::DirectoryInfo directoryInfo3{qtQuickProjectSourceContextId,
sourceId3,
qtQuickModuleId,
Storage::Synchronization::FileType::QmlTypes};
storage.synchronize(
SynchronizationPackage{{qmlProjectSourceContextId, qtQuickProjectSourceContextId},
{directoryInfo1, directoryInfo2, directoryInfo3}});
auto directoryInfo = storage.fetchDirectoryInfo({sourceId2});
auto directoryInfo = storage.fetchDirectoryInfo(sourceId2);
ASSERT_THAT(directoryInfo, Eq(directoryInfo2));
}
@@ -8064,7 +8105,10 @@ TEST_F(ProjectStorage, synchronize_property_editor_adds_path)
auto package{createPropertyEditorPathsSynchronizationPackage()};
package.propertyEditorQmlPaths.pop_back();
storage.synchronize(package);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId, "Item3D", sourceId3, sourceIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
"Item3D",
sourceId3,
sourceContextIdPath6);
storage.synchronize(package);
@@ -8076,7 +8120,10 @@ TEST_F(ProjectStorage, synchronize_property_editor_adds_path)
TEST_F(ProjectStorage, synchronize_property_editor_with_non_existing_type_name)
{
auto package{createPropertyEditorPathsSynchronizationPackage()};
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId, "Item4D", sourceId4, sourceIdPath6);
package.propertyEditorQmlPaths.emplace_back(qtQuickModuleId,
"Item4D",
sourceId4,
sourceContextIdPath6);
storage.synchronize(package);
@@ -8441,7 +8488,7 @@ TEST_F(ProjectStorage, synchronize_type_annotation_directory_source_id)
storage.synchronize(package);
ASSERT_THAT(storage.typeAnnotationSourceIds(sourceIdPath6),
ASSERT_THAT(storage.typeAnnotationSourceIds(sourceContextIdPath6),
UnorderedElementsAre(sourceId4, sourceId5));
}
@@ -8453,7 +8500,7 @@ TEST_F(ProjectStorage, get_type_annotation_source_ids)
package.typeAnnotations);
storage.synchronize(package);
auto sourceIds = storage.typeAnnotationSourceIds(sourceIdPath6);
auto sourceIds = storage.typeAnnotationSourceIds(sourceContextIdPath6);
ASSERT_THAT(sourceIds, UnorderedElementsAre(sourceId4, sourceId5));
}
@@ -8466,9 +8513,9 @@ TEST_F(ProjectStorage, get_type_annotation_directory_source_ids)
package.typeAnnotations);
storage.synchronize(package);
auto sourceIds = storage.typeAnnotationDirectorySourceIds();
auto sourceIds = storage.typeAnnotationDirectoryIds();
ASSERT_THAT(sourceIds, ElementsAre(sourceIdPath1, sourceIdPath6));
ASSERT_THAT(sourceIds, ElementsAre(sourceContextIdPath1, sourceContextIdPath6));
}
TEST_F(ProjectStorage, get_all_item_library_entries)

View File

@@ -189,10 +189,10 @@ protected:
Synchronization::Types types;
SourceId qmltypesFileSourceId{sourcePathCache.sourceId("path/to/types.qmltypes")};
ModuleId qtQmlNativeModuleId = storage.moduleId("QtQml", ModuleKind::CppLibrary);
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId,
qmltypesFileSourceId,
qtQmlNativeModuleId,
Synchronization::FileType::QmlTypes};
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.contextId(),
qmltypesFileSourceId,
qtQmlNativeModuleId,
Synchronization::FileType::QmlTypes};
SourceContextId qmltypesFileSourceContextId{qmltypesFileSourceId.contextId()};
};
@@ -886,10 +886,10 @@ TEST_F(QmlTypesParser, default_property)
TEST_F(QmlTypesParser, skip_template_item)
{
ModuleId moduleId = storage.moduleId("QtQuick.Templates", ModuleKind::CppLibrary);
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId,
qmltypesFileSourceId,
moduleId,
Synchronization::FileType::QmlTypes};
Synchronization::DirectoryInfo directoryInfo{qmltypesFileSourceId.contextId(),
qmltypesFileSourceId,
moduleId,
Synchronization::FileType::QmlTypes};
QString source{R"(import QtQuick.tooling 1.2
Module{
Component { name: "QQuickItem"}

View File

@@ -53,7 +53,7 @@ protected:
QmlDesigner::ProjectStorage &storage = staticData->storage;
QmlDesigner::Storage::TypeAnnotationReader reader{storage};
QmlDesigner::SourceId sourceId = QmlDesigner::SourceId::create(33);
QmlDesigner::SourceId directorySourceId = QmlDesigner::SourceId::create(77);
QmlDesigner::SourceContextId directoryId = QmlDesigner::SourceContextId::create(77);
QmlDesigner::Storage::TypeTraits traits;
};
@@ -71,11 +71,11 @@ TEST_F(TypeAnnotationReader, parse_type)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
UnorderedElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -83,7 +83,7 @@ TEST_F(TypeAnnotationReader, parse_type)
IsEmpty(),
IsEmpty()),
IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Item",
moduleId("QtQuick"),
"/path/images/item-icon16.png",
@@ -108,11 +108,11 @@ TEST_F(TypeAnnotationReader, parse_true_canBeContainer)
})xy"};
traits.canBeContainer = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -137,11 +137,11 @@ TEST_F(TypeAnnotationReader, parse_true_forceClip)
})xy"};
traits.forceClip = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -166,11 +166,11 @@ TEST_F(TypeAnnotationReader, parse_true_doesLayoutChildren)
})xy"};
traits.doesLayoutChildren = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -195,11 +195,11 @@ TEST_F(TypeAnnotationReader, parse_false_canBeDroppedInFormEditor)
})xy"};
traits.canBeDroppedInFormEditor = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -224,11 +224,11 @@ TEST_F(TypeAnnotationReader, parse_false_canBeDroppedInNavigator)
})xy"};
traits.canBeDroppedInNavigator = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -253,11 +253,11 @@ TEST_F(TypeAnnotationReader, parse_true_hideInNavigator)
})xy"};
traits.hideInNavigator = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -282,11 +282,11 @@ TEST_F(TypeAnnotationReader, parse_true_canBeDroppedInView3D)
})xy"};
traits.canBeDroppedInView3D = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -311,11 +311,11 @@ TEST_F(TypeAnnotationReader, parse_false_isMovable)
})xy"};
traits.isMovable = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -340,11 +340,11 @@ TEST_F(TypeAnnotationReader, parse_false_isResizable)
})xy"};
traits.isResizable = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -369,11 +369,11 @@ TEST_F(TypeAnnotationReader, parse_false_hasFormEditorItem)
})xy"};
traits.hasFormEditorItem = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -398,11 +398,11 @@ TEST_F(TypeAnnotationReader, parse_true_isStackedContainer)
})xy"};
traits.isStackedContainer = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -427,11 +427,11 @@ TEST_F(TypeAnnotationReader, parse_true_takesOverRenderingOfChildren)
})xy"};
traits.takesOverRenderingOfChildren = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -456,11 +456,11 @@ TEST_F(TypeAnnotationReader, parse_true_visibleInNavigator)
})xy"};
traits.visibleInNavigator = FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -485,11 +485,11 @@ TEST_F(TypeAnnotationReader, parse_false_visibleInLibrary)
})xy"};
traits.visibleInLibrary = FlagIs::False;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -513,11 +513,11 @@ TEST_F(TypeAnnotationReader, parse_false)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -555,11 +555,11 @@ TEST_F(TypeAnnotationReader, parse_complex_expression)
QmlDesigner::Storage::TypeTraits itemTraits = traits;
itemTraits.canBeContainer = QmlDesigner::FlagIs::True;
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
UnorderedElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -568,7 +568,7 @@ TEST_F(TypeAnnotationReader, parse_complex_expression)
"visibleNonDefaultProperties":"layer.effect"})xy"),
IsEmpty()),
IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Item",
moduleId("QtQuick"),
"/path/images/item-icon16.png",
@@ -603,11 +603,11 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -659,11 +659,11 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry_with_properties)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
"/path/images/frame-icon16.png",
@@ -709,11 +709,11 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry_template_path)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
Utils::SmallStringView{},
@@ -724,7 +724,7 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry_template_path)
"templatePath":"/path/templates/frame.qml"}]
)xy")),
IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Item",
moduleId("QtQuick"),
Utils::SmallStringView{},
@@ -761,11 +761,11 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry_extra_file_paths)
}
})xy"};
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directorySourceId);
auto annotations = reader.parseTypeAnnotation(content, "/path", sourceId, directoryId);
ASSERT_THAT(annotations,
ElementsAre(IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Frame",
moduleId("QtQuick.Controls"),
Utils::SmallStringView{},
@@ -776,7 +776,7 @@ TEST_F(TypeAnnotationReader, parse_item_library_entry_extra_file_paths)
"name":"Frame"}]
)xy")),
IsTypeAnnotation(sourceId,
directorySourceId,
directoryId,
"Item",
moduleId("QtQuick"),
Utils::SmallStringView{},