aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2024-03-27 17:07:10 +0100
committerMarco Bubke <marco.bubke@qt.io>2024-04-09 13:41:14 +0000
commit4e5a0cd02b83f0ea2c7b6066ecb3465488b923de (patch)
tree08ff44951648347ed2d76d66c64f4c1a4b33aa17
parent91f3c4c5e0484a779d86859abf956e99c8efffc0 (diff)
QmlDesigner: Improve performance of prototype walk
The optimizer took quite often the slow join first. So now we have one method to walk the prototype chain and then use the type ids in simpler statements to get the end result. Task-number: QTCREATORBUG-30599 Change-Id: I3e9d4ec85ba75801769eb8760fda6e0400300899 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
-rw-r--r--src/plugins/qmldesigner/designercore/include/projectstorageids.h4
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h230
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h6
-rw-r--r--tests/unit/tests/mocks/projectstoragemock.cpp22
-rw-r--r--tests/unit/tests/mocks/projectstoragemock.h37
-rw-r--r--tests/unit/tests/unittests/componentcore/propertyeditorcomponentgenerator-test.cpp2
-rw-r--r--tests/unit/tests/unittests/model/model-test.cpp16
7 files changed, 138 insertions, 179 deletions
diff --git a/src/plugins/qmldesigner/designercore/include/projectstorageids.h b/src/plugins/qmldesigner/designercore/include/projectstorageids.h
index bc66e0d2b20..90c174e04e0 100644
--- a/src/plugins/qmldesigner/designercore/include/projectstorageids.h
+++ b/src/plugins/qmldesigner/designercore/include/projectstorageids.h
@@ -7,6 +7,8 @@
#include <utils/span.h>
+#include <QVarLengthArray>
+
namespace QmlDesigner {
enum class BasicIdType {
@@ -29,6 +31,8 @@ enum class BasicIdType {
using TypeId = Sqlite::BasicId<BasicIdType::Type>;
using TypeIds = std::vector<TypeId>;
+template<std::size_t size>
+using SmallTypeIds = QVarLengthArray<TypeId, size>;
using PropertyDeclarationId = Sqlite::BasicId<BasicIdType::PropertyDeclaration>;
using PropertyDeclarationIds = std::vector<PropertyDeclarationId>;
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
index aa7b511115b..7188d0e814e 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
+++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
@@ -345,9 +345,11 @@ public:
projectStorageCategory(),
keyValue("type id", typeId)};
- auto propertyDeclarationIds = selectPropertyDeclarationIdsForTypeStatement
- .template valuesWithTransaction<
- QVarLengthArray<PropertyDeclarationId, 128>>(typeId);
+ auto propertyDeclarationIds = Sqlite::withDeferredTransaction(database, [&] {
+ return fetchPropertyDeclarationIds(typeId);
+ });
+
+ std::sort(propertyDeclarationIds.begin(), propertyDeclarationIds.end());
tracer.end(keyValue("property declaration ids", propertyDeclarationIds));
@@ -379,9 +381,9 @@ public:
keyValue("type id", typeId),
keyValue("property name", propertyName)};
- auto propertyDeclarationId = selectPropertyDeclarationIdForTypeAndPropertyNameStatement
- .template valueWithTransaction<PropertyDeclarationId>(
- typeId, propertyName);
+ auto propertyDeclarationId = Sqlite::withDeferredTransaction(database, [&] {
+ return fetchPropertyDeclarationId(typeId, propertyName);
+ });
tracer.end(keyValue("property declaration id", propertyDeclarationId));
@@ -663,40 +665,43 @@ public:
return typeId;
}
- TypeIds prototypeIds(TypeId type) const override
+ SmallTypeIds<16> prototypeIds(TypeId type) const override
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"get prototypes"_t,
projectStorageCategory(),
keyValue("type id", type)};
- auto prototypeIds = selectPrototypeIdsForTypeIdInOrderStatement
- .template valuesWithTransaction<TypeId, 16>(type);
+ auto prototypeIds = selectPrototypeAndExtensionIdsStatement
+ .template valuesWithTransaction<SmallTypeIds<16>>(type);
tracer.end(keyValue("type ids", prototypeIds));
return prototypeIds;
}
- TypeIds prototypeAndSelfIds(TypeId type) const override
+ SmallTypeIds<16> prototypeAndSelfIds(TypeId typeId) const override
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"get prototypes and self"_t, projectStorageCategory()};
- TypeIds prototypeAndSelfIds = selectPrototypeAndSelfIdsForTypeIdInOrderStatement
- .template valuesWithTransaction<TypeId, 16>(type);
+ SmallTypeIds<16> prototypeAndSelfIds;
+ prototypeAndSelfIds.push_back(typeId);
+
+ selectPrototypeAndExtensionIdsStatement.readToWithTransaction(prototypeAndSelfIds, typeId);
tracer.end(keyValue("type ids", prototypeAndSelfIds));
return prototypeAndSelfIds;
}
- TypeIds heirIds(TypeId typeId) const override
+ SmallTypeIds<64> heirIds(TypeId typeId) const override
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"get heirs"_t, projectStorageCategory()};
- auto heirIds = selectHeirTypeIdsStatement.template valuesWithTransaction<TypeId, 64>(typeId);
+ auto heirIds = selectHeirTypeIdsStatement.template valuesWithTransaction<SmallTypeIds<64>>(
+ typeId);
tracer.end(keyValue("type ids", heirIds));
@@ -719,7 +724,8 @@ public:
return true;
}
- auto range = selectPrototypeIdsStatement.template rangeWithTransaction<TypeId>(typeId);
+ auto range = selectPrototypeAndExtensionIdsStatement.template rangeWithTransaction<TypeId>(
+ typeId);
auto isBasedOn = std::any_of(range.begin(), range.end(), [&](TypeId currentTypeId) {
return ((currentTypeId == baseTypeIds) || ...);
@@ -2340,6 +2346,52 @@ private:
insertAliasPropertyDeclarationStatement.readCallback(callback, typeId, value.name);
}
+ auto fetchPropertyDeclarationIds(TypeId baseTypeId) const
+ {
+ QVarLengthArray<PropertyDeclarationId, 128> propertyDeclarationIds;
+
+ selectLocalPropertyDeclarationIdsForTypeStatement.readTo(propertyDeclarationIds, baseTypeId);
+
+ auto range = selectPrototypeAndExtensionIdsStatement.template range<TypeId>(baseTypeId);
+
+ for (TypeId prototype : range) {
+ selectLocalPropertyDeclarationIdsForTypeStatement.readTo(propertyDeclarationIds,
+ prototype);
+ }
+
+ return propertyDeclarationIds;
+ }
+
+ PropertyDeclarationId fetchNextPropertyDeclarationId(TypeId baseTypeId,
+ Utils::SmallStringView propertyName) const
+ {
+ auto range = selectPrototypeAndExtensionIdsStatement.template range<TypeId>(baseTypeId);
+
+ for (TypeId prototype : range) {
+ auto propertyDeclarationId = selectPropertyDeclarationIdByTypeIdAndNameStatement
+ .template value<PropertyDeclarationId>(prototype,
+ propertyName);
+
+ if (propertyDeclarationId)
+ return propertyDeclarationId;
+ }
+
+ return PropertyDeclarationId{};
+ }
+
+ PropertyDeclarationId fetchPropertyDeclarationId(TypeId baseTypeId,
+ Utils::SmallStringView propertyName) const
+ {
+ auto propertyDeclarationId = selectPropertyDeclarationIdByTypeIdAndNameStatement
+ .template value<PropertyDeclarationId>(baseTypeId,
+ propertyName);
+
+ if (propertyDeclarationId)
+ return propertyDeclarationId;
+
+ return fetchNextPropertyDeclarationId(baseTypeId, propertyName);
+ }
+
void synchronizePropertyDeclarationsInsertProperty(
const Storage::Synchronization::PropertyDeclaration &value, SourceId sourceId, TypeId typeId)
{
@@ -2357,9 +2409,7 @@ private:
auto propertyDeclarationId = insertPropertyDeclarationStatement.template value<PropertyDeclarationId>(
typeId, value.name, propertyTypeId, value.traits, propertyImportedTypeNameId);
- auto nextPropertyDeclarationId = selectPropertyDeclarationIdPrototypeChainDownStatement
- .template value<PropertyDeclarationId>(typeId,
- value.name);
+ auto nextPropertyDeclarationId = fetchNextPropertyDeclarationId(typeId, value.name);
if (nextPropertyDeclarationId) {
updateAliasIdPropertyDeclarationStatement.write(nextPropertyDeclarationId,
propertyDeclarationId);
@@ -2484,9 +2534,8 @@ private:
projectStorageCategory(),
keyValue("property declaratio viewn", view)};
- auto nextPropertyDeclarationId = selectPropertyDeclarationIdPrototypeChainDownStatement
- .template value<PropertyDeclarationId>(typeId,
- view.name);
+ auto nextPropertyDeclarationId = fetchNextPropertyDeclarationId(typeId, view.name);
+
if (nextPropertyDeclarationId) {
updateAliasPropertyDeclarationByAliasPropertyDeclarationIdStatement
.write(nextPropertyDeclarationId, view.id);
@@ -3313,7 +3362,7 @@ private:
throw PrototypeChainCycle{};
};
- selectTypeIdsForPrototypeChainIdStatement.readCallback(callback, typeId);
+ selectPrototypeAndExtensionIdsStatement.readCallback(callback, typeId);
}
void checkForAliasChainCycle(PropertyDeclarationId propertyDeclarationId) const
@@ -3586,9 +3635,10 @@ private:
keyValue("type id", typeId),
keyValue("property name", name)};
- auto propertyDeclaration = selectPropertyDeclarationByTypeIdAndNameStatement
- .template optionalValue<FetchPropertyDeclarationResult>(typeId,
- name);
+ auto propertyDeclarationId = fetchPropertyDeclarationId(typeId, name);
+ auto propertyDeclaration = selectPropertyDeclarationResultByPropertyDeclarationIdStatement
+ .template optionalValue<FetchPropertyDeclarationResult>(
+ propertyDeclarationId);
tracer.end(keyValue("property declaration", propertyDeclaration));
@@ -3623,8 +3673,7 @@ private:
keyValue("type id", typeId),
keyValue("property name", name)};
- auto propertyDeclarationId = selectPropertyDeclarationIdByTypeIdAndNameStatement
- .template value<PropertyDeclarationId>(typeId, name);
+ auto propertyDeclarationId = fetchPropertyDeclarationId(typeId, name);
tracer.end(keyValue("property declaration id", propertyDeclarationId));
@@ -4236,57 +4285,11 @@ public:
"ORDER BY minorVersion DESC "
"LIMIT 1",
database};
- mutable ReadStatement<1, 2> selectPrototypeIdStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeSelection(typeId) AS ("
- " VALUES(?1) "
- " UNION ALL "
- " SELECT prototypeId FROM all_prototype_and_extension JOIN typeSelection "
- " USING(typeId))"
- "SELECT typeId FROM typeSelection WHERE typeId=?2 LIMIT 1",
- database};
- mutable ReadStatement<1, 2> selectPropertyDeclarationIdByTypeIdAndNameStatement{
- "WITH RECURSIVE "
- " typeSelection(typeId, level) AS ("
- " VALUES(?1, 0) "
- " UNION ALL "
- " SELECT prototypeId, ts.level+1 FROM types JOIN typeSelection AS ts USING(typeId) "
- " UNION ALL "
- " SELECT extensionId, ts.level+1 FROM types JOIN typeSelection AS ts USING(typeId)) "
- "SELECT propertyDeclarationId FROM propertyDeclarations JOIN typeSelection USING(typeId) "
- " WHERE name=?2 ORDER BY level LIMIT 1",
- database};
- mutable ReadStatement<3, 2> selectPropertyDeclarationByTypeIdAndNameStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeSelection(typeId) AS ("
- " VALUES(?1) "
- " UNION ALL "
- " SELECT prototypeId FROM all_prototype_and_extension JOIN "
- " typeSelection USING(typeId))"
+ mutable ReadStatement<3, 1> selectPropertyDeclarationResultByPropertyDeclarationIdStatement{
"SELECT propertyTypeId, propertyDeclarationId, propertyTraits "
- " FROM propertyDeclarations JOIN typeSelection USING(typeId) "
- " WHERE name=?2 LIMIT 1",
- database};
- mutable ReadStatement<1, 1> selectPrototypeIdsInOrderStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeSelection(typeId, level) AS ("
- " VALUES(?1, 0) "
- " UNION ALL "
- " SELECT prototypeId, typeSelection.level+1 FROM all_prototype_and_extension JOIN "
- " typeSelection USING(typeId) WHERE prototypeId IS NOT NULL) "
- "SELECT typeId FROM typeSelection ORDER BY level DESC",
+ "FROM propertyDeclarations "
+ "WHERE propertyDeclarationId=?1 "
+ "LIMIT 1",
database};
mutable ReadStatement<1, 1> selectSourceContextIdFromSourceContextsBySourceContextPathStatement{
"SELECT sourceContextId FROM sourceContexts WHERE sourceContextPath = ?", database};
@@ -4514,18 +4517,11 @@ public:
"DELETE FROM documentImports WHERE sourceId=?1 AND parentImportId=?2", database};
WriteStatement<1> deleteDocumentImportsWithSourceIdsStatement{
"DELETE FROM documentImports WHERE sourceId IN carray(?1)", database};
- ReadStatement<1, 2> selectPropertyDeclarationIdPrototypeChainDownStatement{
- "WITH RECURSIVE "
- " typeSelection(typeId, level) AS ("
- " SELECT prototypeId, 0 FROM types WHERE typeId=?1"
- " UNION ALL"
- " SELECT extensionId, 0 FROM types WHERE typeId=?1"
- " UNION ALL "
- " SELECT prototypeId, ts.level+1 FROM types JOIN typeSelection AS ts USING(typeId) "
- " UNION ALL "
- " SELECT extensionId, ts.level+1 FROM types JOIN typeSelection AS ts USING(typeId)) "
- "SELECT propertyDeclarationId FROM propertyDeclarations JOIN typeSelection USING(typeId) "
- " WHERE name=?2 ORDER BY level LIMIT 1",
+ mutable ReadStatement<1, 2> selectPropertyDeclarationIdByTypeIdAndNameStatement{
+ "SELECT propertyDeclarationId "
+ "FROM propertyDeclarations "
+ "WHERE typeId=?1 AND name=?2 "
+ "LIMIT 1",
database};
WriteStatement<2> updateAliasIdPropertyDeclarationStatement{
"UPDATE propertyDeclarations SET aliasPropertyDeclarationId=?2 WHERE "
@@ -4601,7 +4597,7 @@ public:
"UPDATE types SET prototypeId=?2 WHERE typeId=?1", database};
WriteStatement<2> updateTypeExtensionStatement{
"UPDATE types SET extensionId=?2 WHERE typeId=?1", database};
- mutable ReadStatement<1, 1> selectTypeIdsForPrototypeChainIdStatement{
+ mutable ReadStatement<1, 1> selectPrototypeAndExtensionIdsStatement{
"WITH RECURSIVE "
" prototypes(typeId) AS ( "
" SELECT prototypeId FROM types WHERE typeId=?1 "
@@ -4793,40 +4789,12 @@ public:
"SELECT DISTINCT moduleId, ifnull(majorVersion, -1), ifnull(minorVersion, -1) "
"FROM imports",
database};
- mutable ReadStatement<1, 1> selectPropertyDeclarationIdsForTypeStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeChain(typeId) AS ("
- " VALUES(?1)"
- " UNION ALL "
- " SELECT prototypeId FROM all_prototype_and_extension JOIN typeChain "
- " USING(typeId))"
- "SELECT propertyDeclarationId FROM typeChain JOIN propertyDeclarations "
- " USING(typeId) ORDER BY propertyDeclarationId",
- database};
mutable ReadStatement<1, 1> selectLocalPropertyDeclarationIdsForTypeStatement{
"SELECT propertyDeclarationId "
"FROM propertyDeclarations "
"WHERE typeId=? "
"ORDER BY propertyDeclarationId",
database};
- mutable ReadStatement<1, 2> selectPropertyDeclarationIdForTypeAndPropertyNameStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeChain(typeId, level) AS ("
- " VALUES(?1, 0)"
- " UNION ALL "
- " SELECT prototypeId, typeChain.level + 1 FROM all_prototype_and_extension JOIN "
- " typeChain USING(typeId))"
- "SELECT propertyDeclarationId FROM typeChain JOIN propertyDeclarations "
- " USING(typeId) WHERE name=?2 ORDER BY level LIMIT 1",
- database};
mutable ReadStatement<1, 2> selectLocalPropertyDeclarationIdForTypeAndPropertyNameStatement{
"SELECT propertyDeclarationId "
"FROM propertyDeclarations "
@@ -4887,32 +4855,6 @@ public:
" prototypes AS p USING(typeId)) "
"SELECT typeId FROM prototypes ORDER BY level",
database};
- mutable ReadStatement<1, 1> selectPrototypeAndSelfIdsForTypeIdInOrderStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeChain(typeId, level) AS ("
- " VALUES(?1, 0)"
- " UNION ALL "
- " SELECT prototypeId, tc.level+1 FROM all_prototype_and_extension JOIN "
- " typeChain AS tc USING(typeId)) "
- "SELECT typeId FROM typeChain ORDER BY level",
- database};
- mutable ReadStatement<1, 1> selectPrototypeIdsStatement{
- "WITH RECURSIVE "
- " all_prototype_and_extension(typeId, prototypeId) AS ("
- " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
- " UNION ALL "
- " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
- " typeSelection(typeId) AS ("
- " SELECT prototypeId FROM all_prototype_and_extension WHERE typeId=?1 "
- " UNION ALL "
- " SELECT prototypeId FROM all_prototype_and_extension JOIN typeSelection "
- " USING(typeId))"
- "SELECT typeId FROM typeSelection",
- database};
WriteStatement<2> upsertPropertyEditorPathIdStatement{
"INSERT INTO propertyEditorPaths(typeId, pathSourceId) VALUES(?1, ?2) ON CONFLICT DO "
"UPDATE SET pathSourceId=excluded.pathSourceId WHERE pathSourceId IS NOT "
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h
index 266c6ee7caa..edf35f745cb 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h
+++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorageinterface.h
@@ -64,9 +64,9 @@ public:
virtual std::vector<::Utils::SmallString> functionDeclarationNames(TypeId typeId) const = 0;
virtual std::optional<::Utils::SmallString>
propertyName(PropertyDeclarationId propertyDeclarationId) const = 0;
- virtual TypeIds prototypeAndSelfIds(TypeId type) const = 0;
- virtual TypeIds prototypeIds(TypeId type) const = 0;
- virtual TypeIds heirIds(TypeId typeId) const = 0;
+ virtual SmallTypeIds<16> prototypeAndSelfIds(TypeId type) const = 0;
+ virtual SmallTypeIds<16> prototypeIds(TypeId type) const = 0;
+ virtual SmallTypeIds<64> heirIds(TypeId typeId) const = 0;
virtual bool isBasedOn(TypeId, TypeId) const = 0;
virtual bool isBasedOn(TypeId, TypeId, TypeId) const = 0;
virtual bool isBasedOn(TypeId, TypeId, TypeId, TypeId) const = 0;
diff --git a/tests/unit/tests/mocks/projectstoragemock.cpp b/tests/unit/tests/mocks/projectstoragemock.cpp
index 83ff85fe9a3..27e5c152d21 100644
--- a/tests/unit/tests/mocks/projectstoragemock.cpp
+++ b/tests/unit/tests/mocks/projectstoragemock.cpp
@@ -227,7 +227,9 @@ void ProjectStorageMock::setItemLibraryEntries(
}
namespace {
-void addBaseProperties(TypeId typeId, TypeIds baseTypeIds, ProjectStorageMock &storage)
+void addBaseProperties(TypeId typeId,
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds,
+ ProjectStorageMock &storage)
{
for (TypeId baseTypeId : baseTypeIds) {
for (const auto &propertyId : storage.localPropertyDeclarationIds(baseTypeId)) {
@@ -254,7 +256,7 @@ TypeId ProjectStorageMock::createType(ModuleId moduleId,
PropertyDeclarationTraits defaultPropertyTraits,
TypeId defaultPropertyTypeId,
Storage::TypeTraits typeTraits,
- TypeIds baseTypeIds,
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds,
SourceId sourceId)
{
if (auto id = typeId(moduleId, typeName)) {
@@ -290,10 +292,9 @@ TypeId ProjectStorageMock::createType(ModuleId moduleId,
for (TypeId baseTypeId : baseTypeIds)
ON_CALL(*this, isBasedOn(Eq(typeId), Eq(baseTypeId))).WillByDefault(Return(true));
- TypeIds selfAndPrototypes;
- selfAndPrototypes.reserve(baseTypeIds.size() + 1);
+ QmlDesigner::SmallTypeIds<16> selfAndPrototypes;
selfAndPrototypes.push_back(typeId);
- selfAndPrototypes.insert(selfAndPrototypes.end(), baseTypeIds.begin(), baseTypeIds.end());
+ std::copy(baseTypeIds.begin(), baseTypeIds.end(), std::back_inserter(selfAndPrototypes));
ON_CALL(*this, prototypeAndSelfIds(Eq(typeId))).WillByDefault(Return(selfAndPrototypes));
ON_CALL(*this, prototypeIds(Eq(typeId))).WillByDefault(Return(baseTypeIds));
@@ -314,7 +315,7 @@ void ProjectStorageMock::removeType(QmlDesigner::ModuleId moduleId, Utils::Small
QmlDesigner::TypeId ProjectStorageMock::createType(QmlDesigner::ModuleId moduleId,
Utils::SmallStringView typeName,
QmlDesigner::Storage::TypeTraits typeTraits,
- QmlDesigner::TypeIds baseTypeIds,
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds,
SourceId sourceId)
{
return createType(moduleId, typeName, {}, {}, TypeId{}, typeTraits, baseTypeIds, sourceId);
@@ -325,7 +326,7 @@ TypeId ProjectStorageMock::createObject(ModuleId moduleId,
Utils::SmallStringView defaultPropertyName,
PropertyDeclarationTraits defaultPropertyTraits,
QmlDesigner::TypeId defaultPropertyTypeId,
- TypeIds baseTypeIds,
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds,
QmlDesigner::SourceId sourceId)
{
return createType(moduleId,
@@ -340,19 +341,20 @@ TypeId ProjectStorageMock::createObject(ModuleId moduleId,
TypeId ProjectStorageMock::createObject(ModuleId moduleId,
Utils::SmallStringView typeName,
- TypeIds baseTypeIds)
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds)
{
return createType(moduleId, typeName, Storage::TypeTraitsKind::Reference, baseTypeIds);
}
QmlDesigner::TypeId ProjectStorageMock::createValue(QmlDesigner::ModuleId moduleId,
Utils::SmallStringView typeName,
- QmlDesigner::TypeIds baseTypeIds)
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds)
{
return createType(moduleId, typeName, Storage::TypeTraitsKind::Value, baseTypeIds);
}
-void ProjectStorageMock::setHeirs(QmlDesigner::TypeId typeId, QmlDesigner::TypeIds heirIds)
+void ProjectStorageMock::setHeirs(QmlDesigner::TypeId typeId,
+ const QmlDesigner::SmallTypeIds<64> &heirIds)
{
ON_CALL(*this, heirIds(typeId)).WillByDefault(Return(heirIds));
}
diff --git a/tests/unit/tests/mocks/projectstoragemock.h b/tests/unit/tests/mocks/projectstoragemock.h
index 198e54b370b..ed370bde96f 100644
--- a/tests/unit/tests/mocks/projectstoragemock.h
+++ b/tests/unit/tests/mocks/projectstoragemock.h
@@ -56,7 +56,7 @@ public:
QmlDesigner::Storage::PropertyDeclarationTraits defaultPropertyTraits,
QmlDesigner::TypeId defaultPropertyTypeId,
QmlDesigner::Storage::TypeTraits typeTraits,
- QmlDesigner::TypeIds baseTypeIds = {},
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {},
QmlDesigner::SourceId sourceId = QmlDesigner::SourceId{});
void removeType(QmlDesigner::ModuleId moduleId, Utils::SmallStringView typeName);
@@ -64,27 +64,26 @@ public:
QmlDesigner::TypeId createType(QmlDesigner::ModuleId moduleId,
Utils::SmallStringView typeName,
QmlDesigner::Storage::TypeTraits typeTraits,
- QmlDesigner::TypeIds baseTypeIds = {},
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {},
QmlDesigner::SourceId sourceId = QmlDesigner::SourceId{});
- QmlDesigner::TypeId createObject(
- QmlDesigner::ModuleId moduleId,
- Utils::SmallStringView typeName,
- Utils::SmallStringView defaultPropertyName,
- QmlDesigner::Storage::PropertyDeclarationTraits defaultPropertyTraits,
- QmlDesigner::TypeId defaultPropertyTypeId,
- QmlDesigner::TypeIds baseTypeIds = {},
- QmlDesigner::SourceId sourceId = QmlDesigner::SourceId{});
+ QmlDesigner::TypeId createObject(QmlDesigner::ModuleId moduleId,
+ Utils::SmallStringView typeName,
+ Utils::SmallStringView defaultPropertyName,
+ QmlDesigner::Storage::PropertyDeclarationTraits defaultPropertyTraits,
+ QmlDesigner::TypeId defaultPropertyTypeId,
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {},
+ QmlDesigner::SourceId sourceId = QmlDesigner::SourceId{});
QmlDesigner::TypeId createObject(QmlDesigner::ModuleId moduleId,
Utils::SmallStringView typeName,
- QmlDesigner::TypeIds baseTypeIds = {});
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {});
QmlDesigner::TypeId createValue(QmlDesigner::ModuleId moduleId,
Utils::SmallStringView typeName,
- QmlDesigner::TypeIds baseTypeIds = {});
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {});
- void setHeirs(QmlDesigner::TypeId typeId, QmlDesigner::TypeIds heirIds);
+ void setHeirs(QmlDesigner::TypeId typeId, const QmlDesigner::SmallTypeIds<64> &heirIds);
QmlDesigner::PropertyDeclarationId createProperty(
QmlDesigner::TypeId typeId,
@@ -215,9 +214,15 @@ public:
propertyName,
(QmlDesigner::PropertyDeclarationId propertyDeclarationId),
(const, override));
- MOCK_METHOD(QmlDesigner::TypeIds, prototypeAndSelfIds, (QmlDesigner::TypeId type), (const, override));
- MOCK_METHOD(QmlDesigner::TypeIds, prototypeIds, (QmlDesigner::TypeId type), (const, override));
- MOCK_METHOD(QmlDesigner::TypeIds, heirIds, (QmlDesigner::TypeId type), (const, override));
+ MOCK_METHOD(QmlDesigner::SmallTypeIds<16>,
+ prototypeAndSelfIds,
+ (QmlDesigner::TypeId type),
+ (const, override));
+ MOCK_METHOD(QmlDesigner::SmallTypeIds<16>,
+ prototypeIds,
+ (QmlDesigner::TypeId type),
+ (const, override));
+ MOCK_METHOD(QmlDesigner::SmallTypeIds<64>, heirIds, (QmlDesigner::TypeId type), (const, override));
MOCK_METHOD(bool, isBasedOn, (QmlDesigner::TypeId typeId, QmlDesigner::TypeId), (const, override));
MOCK_METHOD(bool,
isBasedOn,
diff --git a/tests/unit/tests/unittests/componentcore/propertyeditorcomponentgenerator-test.cpp b/tests/unit/tests/unittests/componentcore/propertyeditorcomponentgenerator-test.cpp
index 3b9a8bbfe25..d2f2143a737 100644
--- a/tests/unit/tests/unittests/componentcore/propertyeditorcomponentgenerator-test.cpp
+++ b/tests/unit/tests/unittests/componentcore/propertyeditorcomponentgenerator-test.cpp
@@ -18,7 +18,7 @@ class PropertyEditorComponentGenerator : public ::testing::Test
{
protected:
QmlDesigner::NodeMetaInfo createType(Utils::SmallStringView name,
- QmlDesigner::TypeIds baseTypeIds = {})
+ const QmlDesigner::SmallTypeIds<16> &baseTypeIds = {})
{
auto typeId = projectStorageMock.createValue(qtQuickModuleId, name, baseTypeIds);
diff --git a/tests/unit/tests/unittests/model/model-test.cpp b/tests/unit/tests/unittests/model/model-test.cpp
index bda942fec0b..bd34a3a6b12 100644
--- a/tests/unit/tests/unittests/model/model-test.cpp
+++ b/tests/unit/tests/unittests/model/model-test.cpp
@@ -116,11 +116,11 @@ protected:
NiceMock<SourcePathCacheMockWithPaths> pathCacheMock{"/path/foo.qml"};
NiceMock<ProjectStorageMockWithQtQtuick> projectStorageMock{pathCacheMock.sourceId};
NiceMock<ModelResourceManagementMock> resourceManagementMock;
+ QmlDesigner::Imports imports = {QmlDesigner::Import::createLibraryImport("QtQuick")};
QmlDesigner::Model model{{projectStorageMock, pathCacheMock},
"Item",
- -1,
- -1,
- nullptr,
+ imports,
+ pathCacheMock.path.toQString(),
std::make_unique<ModelResourceManagementMockWrapper>(
resourceManagementMock)};
NiceMock<AbstractViewMock> viewMock;
@@ -541,7 +541,10 @@ TEST_F(Model, by_default_remove_properties_removes_property)
TEST_F(Model, by_default_remove_model_node_in_factory_method_calls_removes_node)
{
model.detachView(&viewMock);
- auto newModel = QmlDesigner::Model::create({projectStorageMock, pathCacheMock}, "QtQuick.Item");
+ auto newModel = QmlDesigner::Model::create({projectStorageMock, pathCacheMock},
+ "Item",
+ imports,
+ pathCacheMock.path.toQString());
newModel->attachView(&viewMock);
auto node = createNodeWithParent(viewMock.rootModelNode());
@@ -553,7 +556,10 @@ TEST_F(Model, by_default_remove_model_node_in_factory_method_calls_removes_node)
TEST_F(Model, by_default_remove_properties_in_factory_method_calls_remove_property)
{
model.detachView(&viewMock);
- auto newModel = QmlDesigner::Model::create({projectStorageMock, pathCacheMock}, "QtQuick.Item");
+ auto newModel = QmlDesigner::Model::create({projectStorageMock, pathCacheMock},
+ "Item",
+ imports,
+ pathCacheMock.path.toQString());
newModel->attachView(&viewMock);
rootNode = viewMock.rootModelNode();
auto property = createProperty(rootNode, "yi");