forked from qt-creator/qt-creator
QmlDesigner: Use import in exported types
We can remove the version from exported types because the are implicit by the import. Task-number: QDS-4458 Change-Id: I4a259dff5e59537b72a57d7df95256a38d036e7b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -117,11 +117,27 @@ public:
|
|||||||
.template valueWithTransaction<PropertyDeclarationId>(&typeId, name);
|
.template valueWithTransaction<PropertyDeclarationId>(&typeId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeId fetchTypeIdByQualifiedNameAndVersion(Utils::SmallStringView name,
|
TypeId fetchTypeIdByExportedName(Utils::SmallStringView name) const
|
||||||
Storage::Version version = Storage::Version{})
|
|
||||||
{
|
{
|
||||||
return selectTypeIdByQualifiedNameStatement.template valueWithTransaction<TypeId>(
|
return selectTypeIdByExportedNameStatement.template valueWithTransaction<TypeId>(name);
|
||||||
name, version.major.version, version.minor.version);
|
}
|
||||||
|
|
||||||
|
TypeId fetchTypeIdByImportIdsAndExportedName(const ImportIds &importsIds,
|
||||||
|
Utils::SmallStringView name) const
|
||||||
|
{
|
||||||
|
std::vector<ImportId::DatabaseType> ids;
|
||||||
|
ids.resize(importsIds.size());
|
||||||
|
|
||||||
|
std::memcpy(ids.data(), importsIds.data(), ids.size() * sizeof(ImportId::DatabaseType));
|
||||||
|
|
||||||
|
return selectTypeIdByImportIdsAndExportedNameStatement
|
||||||
|
.template valueWithTransaction<TypeId>(Utils::span{ids}, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeId fetchTypeIdByName(ImportId importId, Utils::SmallStringView name)
|
||||||
|
{
|
||||||
|
return selectTypeIdByImportIdAndNameStatement.template valueWithTransaction<TypeId>(&importId,
|
||||||
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::Type fetchTypeByTypeId(TypeId typeId)
|
Storage::Type fetchTypeByTypeId(TypeId typeId)
|
||||||
@@ -443,12 +459,9 @@ private:
|
|||||||
selectTypeIdsForImportIdStatement.readCallback(callback, &importId);
|
selectTypeIdsForImportIdStatement.readCallback(callback, &importId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upsertExportedType(Utils::SmallStringView qualifiedName, Storage::Version version, TypeId typeId)
|
void upsertExportedType(ImportId importId, Utils::SmallStringView name, TypeId typeId)
|
||||||
{
|
{
|
||||||
upsertExportedTypesStatement.write(qualifiedName,
|
upsertExportedTypesStatement.write(&importId, name, &typeId);
|
||||||
version.major.version,
|
|
||||||
version.minor.version,
|
|
||||||
&typeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizePropertyDeclarations(TypeId typeId,
|
void synchronizePropertyDeclarations(TypeId typeId,
|
||||||
@@ -469,7 +482,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto insert = [&](const Storage::PropertyDeclaration &value) {
|
auto insert = [&](const Storage::PropertyDeclaration &value) {
|
||||||
auto propertyTypeId = fetchTypeIdByName(value.typeName);
|
auto propertyTypeId = fetchTypeIdByNameUngarded(value.typeName);
|
||||||
|
|
||||||
insertPropertyDeclarationStatement.write(&typeId,
|
insertPropertyDeclarationStatement.write(&typeId,
|
||||||
value.name,
|
value.name,
|
||||||
@@ -479,7 +492,7 @@ private:
|
|||||||
|
|
||||||
auto update = [&](const Storage::PropertyDeclarationView &view,
|
auto update = [&](const Storage::PropertyDeclarationView &view,
|
||||||
const Storage::PropertyDeclaration &value) {
|
const Storage::PropertyDeclaration &value) {
|
||||||
auto propertyTypeId = fetchTypeIdByName(value.typeName);
|
auto propertyTypeId = fetchTypeIdByNameUngarded(value.typeName);
|
||||||
|
|
||||||
if (view.traits == value.traits && propertyTypeId == view.typeId)
|
if (view.traits == value.traits && propertyTypeId == view.typeId)
|
||||||
return;
|
return;
|
||||||
@@ -680,12 +693,12 @@ private:
|
|||||||
{
|
{
|
||||||
auto typeId = type.typeId;
|
auto typeId = type.typeId;
|
||||||
|
|
||||||
auto prototypeId = fetchTypeIdByName(type.prototype);
|
auto prototypeId = fetchTypeIdByNameUngarded(type.prototype);
|
||||||
|
|
||||||
updatePrototypeStatement.write(&typeId, &prototypeId);
|
updatePrototypeStatement.write(&typeId, &prototypeId);
|
||||||
|
|
||||||
for (const auto &exportedType : type.exportedTypes)
|
for (const auto &exportedType : type.exportedTypes)
|
||||||
upsertExportedType(exportedType.qualifiedTypeName, exportedType.version, typeId);
|
upsertExportedType(type.importId, exportedType.qualifiedTypeName, typeId);
|
||||||
|
|
||||||
synchronizePropertyDeclarations(typeId, type.propertyDeclarations);
|
synchronizePropertyDeclarations(typeId, type.propertyDeclarations);
|
||||||
synchronizeFunctionDeclarations(typeId, type.functionDeclarations);
|
synchronizeFunctionDeclarations(typeId, type.functionDeclarations);
|
||||||
@@ -693,7 +706,7 @@ private:
|
|||||||
synchronizeEnumerationDeclarations(typeId, type.enumerationDeclarations);
|
synchronizeEnumerationDeclarations(typeId, type.enumerationDeclarations);
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeId fetchTypeIdByName(Utils::SmallStringView name)
|
TypeId fetchTypeIdByNameUngarded(Utils::SmallStringView name)
|
||||||
{
|
{
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
return TypeId{};
|
return TypeId{};
|
||||||
@@ -901,12 +914,11 @@ private:
|
|||||||
table.setUseIfNotExists(true);
|
table.setUseIfNotExists(true);
|
||||||
table.setUseWithoutRowId(true);
|
table.setUseWithoutRowId(true);
|
||||||
table.setName("exportedTypes");
|
table.setName("exportedTypes");
|
||||||
auto &qualifiedNameColumn = table.addColumn("qualifiedName");
|
auto &importIdColumn = table.addColumn("importId");
|
||||||
|
auto &nameColumn = table.addColumn("name");
|
||||||
table.addColumn("typeId");
|
table.addColumn("typeId");
|
||||||
auto &majorVersionColumn = table.addColumn("majorVersion");
|
|
||||||
auto &minorVersionColumn = table.addColumn("minorVersion");
|
|
||||||
|
|
||||||
table.addPrimaryKeyContraint({qualifiedNameColumn, majorVersionColumn, minorVersionColumn});
|
table.addPrimaryKeyContraint({importIdColumn, nameColumn});
|
||||||
|
|
||||||
table.initialize(database);
|
table.initialize(database);
|
||||||
}
|
}
|
||||||
@@ -1002,10 +1014,8 @@ public:
|
|||||||
database};
|
database};
|
||||||
WriteStatement updatePrototypeStatement{
|
WriteStatement updatePrototypeStatement{
|
||||||
"UPDATE types SET prototypeId=nullif(?2, -1) WHERE typeId=?1", database};
|
"UPDATE types SET prototypeId=nullif(?2, -1) WHERE typeId=?1", database};
|
||||||
mutable ReadStatement<1> selectTypeIdByQualifiedNameStatement{
|
mutable ReadStatement<1> selectTypeIdByExportedNameStatement{
|
||||||
"SELECT typeId FROM exportedTypes WHERE qualifiedName=?1 AND majorVersion=?2 AND "
|
"SELECT typeId FROM exportedTypes WHERE name=?1", database};
|
||||||
"minorVersion<=?3 ORDER BY minorVersion DESC LIMIT 1",
|
|
||||||
database};
|
|
||||||
mutable ReadStatement<1> selectPrototypeIdStatement{
|
mutable ReadStatement<1> selectPrototypeIdStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" typeSelection(typeId) AS ("
|
" typeSelection(typeId) AS ("
|
||||||
@@ -1029,12 +1039,9 @@ public:
|
|||||||
"SELECT propertyDeclarationId FROM propertyDeclarations JOIN typeSelection USING(typeId) "
|
"SELECT propertyDeclarationId FROM propertyDeclarations JOIN typeSelection USING(typeId) "
|
||||||
" WHERE name=?2 LIMIT 1",
|
" WHERE name=?2 LIMIT 1",
|
||||||
database};
|
database};
|
||||||
WriteStatement upsertExportedTypesStatement{
|
WriteStatement upsertExportedTypesStatement{"INSERT INTO exportedTypes(importId, name, typeId) "
|
||||||
"INSERT INTO exportedTypes(qualifiedName, majorVersion, minorVersion, typeId) VALUES(?1, "
|
"VALUES(?1, ?2, ?3) ON CONFLICT DO NOTHING",
|
||||||
"?2, ?3, ?4) ON CONFLICT DO NOTHING",
|
database};
|
||||||
database};
|
|
||||||
mutable ReadStatement<1> selectAccessSemanticsStatement{
|
|
||||||
"SELECT typeId FROM exportedTypes WHERE qualifiedName=?", database};
|
|
||||||
mutable ReadStatement<1> selectPrototypeIdsStatement{
|
mutable ReadStatement<1> selectPrototypeIdsStatement{
|
||||||
"WITH RECURSIVE "
|
"WITH RECURSIVE "
|
||||||
" typeSelection(typeId) AS ("
|
" typeSelection(typeId) AS ("
|
||||||
@@ -1067,9 +1074,8 @@ public:
|
|||||||
"SELECT importId, name, (SELECT name FROM types WHERE typeId=outerTypes.prototypeId), "
|
"SELECT importId, name, (SELECT name FROM types WHERE typeId=outerTypes.prototypeId), "
|
||||||
"accessSemantics, ifnull(sourceId, -1) FROM types AS outerTypes WHERE typeId=?",
|
"accessSemantics, ifnull(sourceId, -1) FROM types AS outerTypes WHERE typeId=?",
|
||||||
database};
|
database};
|
||||||
mutable ReadStatement<3> selectExportedTypesByTypeIdStatement{
|
mutable ReadStatement<1> selectExportedTypesByTypeIdStatement{
|
||||||
"SELECT qualifiedName, majorVersion, minorVersion FROM exportedTypes WHERE typeId=?",
|
"SELECT name FROM exportedTypes WHERE typeId=?", database};
|
||||||
database};
|
|
||||||
mutable ReadStatement<6> selectTypesStatement{
|
mutable ReadStatement<6> selectTypesStatement{
|
||||||
"SELECT importId, name, typeId, (SELECT name FROM types WHERE "
|
"SELECT importId, name, typeId, (SELECT name FROM types WHERE "
|
||||||
"typeId=outerTypes.prototypeId), accessSemantics, ifnull(sourceId, -1) FROM types AS "
|
"typeId=outerTypes.prototypeId), accessSemantics, ifnull(sourceId, -1) FROM types AS "
|
||||||
@@ -1195,6 +1201,10 @@ public:
|
|||||||
database};
|
database};
|
||||||
mutable ReadStatement<1> selectTypeIdsForImportIdStatement{
|
mutable ReadStatement<1> selectTypeIdsForImportIdStatement{
|
||||||
"SELECT typeId FROM types WHERE importId=?", database};
|
"SELECT typeId FROM types WHERE importId=?", database};
|
||||||
|
mutable ReadStatement<1> selectTypeIdByImportIdAndNameStatement{
|
||||||
|
"SELECT typeId FROM types WHERE importId=?1 and name=?2", database};
|
||||||
|
mutable ReadStatement<1> selectTypeIdByImportIdsAndExportedNameStatement{
|
||||||
|
"SELECT typeId FROM exportedTypes WHERE importId IN carray(?1) AND name=?2", database};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -105,19 +105,12 @@ class ExportedType
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ExportedType() = default;
|
explicit ExportedType() = default;
|
||||||
explicit ExportedType(Utils::SmallStringView qualifiedTypeName, Version version = Version{})
|
explicit ExportedType(Utils::SmallStringView qualifiedTypeName)
|
||||||
: qualifiedTypeName{qualifiedTypeName}
|
: qualifiedTypeName{qualifiedTypeName}
|
||||||
, version{version}
|
|
||||||
{}
|
|
||||||
|
|
||||||
explicit ExportedType(Utils::SmallStringView qualifiedTypeName, int majorVersion, int minorVersion)
|
|
||||||
: qualifiedTypeName{qualifiedTypeName}
|
|
||||||
, version{majorVersion, minorVersion}
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Utils::SmallString qualifiedTypeName;
|
Utils::SmallString qualifiedTypeName;
|
||||||
Version version;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using ExportedTypes = std::vector<ExportedType>;
|
using ExportedTypes = std::vector<ExportedType>;
|
||||||
|
@@ -1661,7 +1661,7 @@ std::ostream &operator<<(std::ostream &out, Version version)
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType)
|
std::ostream &operator<<(std::ostream &out, const ExportedType &exportedType)
|
||||||
{
|
{
|
||||||
return out << "(\"" << exportedType.qualifiedTypeName << "\", " << exportedType.version << ")";
|
return out << "(\"" << exportedType.qualifiedTypeName << "\")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const Type &type)
|
std::ostream &operator<<(std::ostream &out, const Type &type)
|
||||||
|
@@ -98,15 +98,14 @@ MATCHER_P4(IsStorageTypeWithInvalidSourceId,
|
|||||||
&& type.accessSemantics == accessSemantics && !type.sourceId.isValid();
|
&& type.accessSemantics == accessSemantics && !type.sourceId.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
MATCHER_P2(IsExportedType,
|
MATCHER_P(IsExportedType,
|
||||||
qualifiedTypeName,
|
qualifiedTypeName,
|
||||||
version,
|
std::string(negation ? "isn't " : "is ")
|
||||||
std::string(negation ? "isn't " : "is ")
|
+ PrintToString(Storage::ExportedType{qualifiedTypeName}))
|
||||||
+ PrintToString(Storage::ExportedType{qualifiedTypeName, version}))
|
|
||||||
{
|
{
|
||||||
const Storage::ExportedType &type = arg;
|
const Storage::ExportedType &type = arg;
|
||||||
|
|
||||||
return type.qualifiedTypeName == qualifiedTypeName && type.version == version;
|
return type.qualifiedTypeName == qualifiedTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
MATCHER_P3(IsPropertyDeclaration,
|
MATCHER_P3(IsPropertyDeclaration,
|
||||||
@@ -193,7 +192,7 @@ protected:
|
|||||||
NiceMock<SqliteDatabaseMock> databaseMock;
|
NiceMock<SqliteDatabaseMock> databaseMock;
|
||||||
ProjectStorageMock storage{databaseMock, true};
|
ProjectStorageMock storage{databaseMock, true};
|
||||||
ReadWriteStatement<1> &upsertTypeStatement = storage.upsertTypeStatement;
|
ReadWriteStatement<1> &upsertTypeStatement = storage.upsertTypeStatement;
|
||||||
ReadStatement<1> &selectTypeIdByQualifiedNameStatement = storage.selectTypeIdByQualifiedNameStatement;
|
ReadStatement<1> &selectTypeIdByExportedNameStatement = storage.selectTypeIdByExportedNameStatement;
|
||||||
ReadWriteStatement<1> &upsertPropertyDeclarationStatement = storage.upsertPropertyDeclarationStatement;
|
ReadWriteStatement<1> &upsertPropertyDeclarationStatement = storage.upsertPropertyDeclarationStatement;
|
||||||
ReadStatement<1> &selectPropertyDeclarationByTypeIdAndNameStatement = storage.selectPropertyDeclarationByTypeIdAndNameStatement;
|
ReadStatement<1> &selectPropertyDeclarationByTypeIdAndNameStatement = storage.selectPropertyDeclarationByTypeIdAndNameStatement;
|
||||||
WriteStatement &upsertExportedTypesStatement = storage.upsertExportedTypesStatement;
|
WriteStatement &upsertExportedTypesStatement = storage.upsertExportedTypesStatement;
|
||||||
@@ -212,7 +211,7 @@ protected:
|
|||||||
ReadStatement<1> &selectSourceContextIdFromSourcesBySourceIdStatement = storage.selectSourceContextIdFromSourcesBySourceIdStatement;
|
ReadStatement<1> &selectSourceContextIdFromSourcesBySourceIdStatement = storage.selectSourceContextIdFromSourcesBySourceIdStatement;
|
||||||
ReadStatement<1> &selectTypeIdByNameStatement = storage.selectTypeIdByNameStatement;
|
ReadStatement<1> &selectTypeIdByNameStatement = storage.selectTypeIdByNameStatement;
|
||||||
ReadStatement<5> &selectTypeByTypeIdStatement = storage.selectTypeByTypeIdStatement;
|
ReadStatement<5> &selectTypeByTypeIdStatement = storage.selectTypeByTypeIdStatement;
|
||||||
ReadStatement<3> &selectExportedTypesByTypeIdStatement = storage.selectExportedTypesByTypeIdStatement;
|
ReadStatement<1> &selectExportedTypesByTypeIdStatement = storage.selectExportedTypesByTypeIdStatement;
|
||||||
ReadStatement<6> &selectTypesStatement = storage.selectTypesStatement;
|
ReadStatement<6> &selectTypesStatement = storage.selectTypesStatement;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -477,8 +476,7 @@ protected:
|
|||||||
"QObject",
|
"QObject",
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
sourceId1,
|
sourceId1,
|
||||||
{Storage::ExportedType{"Item", Storage::Version{5, 15}},
|
{Storage::ExportedType{"Item"}},
|
||||||
Storage::ExportedType{"Item", Storage::Version{5, 1}}},
|
|
||||||
{Storage::PropertyDeclaration{"data", "QObject", Storage::DeclarationTraits::IsList},
|
{Storage::PropertyDeclaration{"data", "QObject", Storage::DeclarationTraits::IsList},
|
||||||
Storage::PropertyDeclaration{"children",
|
Storage::PropertyDeclaration{"children",
|
||||||
"QQuickItem",
|
"QQuickItem",
|
||||||
@@ -508,8 +506,7 @@ protected:
|
|||||||
{},
|
{},
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
sourceId2,
|
sourceId2,
|
||||||
{Storage::ExportedType{"Object", Storage::Version{5, 14}},
|
{Storage::ExportedType{"Object"}, Storage::ExportedType{"Obj"}}}};
|
||||||
Storage::ExportedType{"Object", Storage::Version{5, 1}}}}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto createImports()
|
auto createImports()
|
||||||
@@ -773,12 +770,9 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypes)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesReverseOrder)
|
TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesReverseOrder)
|
||||||
@@ -793,12 +787,9 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesAddsNewTypesReverseOrder)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypeAccessSemantics)
|
TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypeAccessSemantics)
|
||||||
@@ -815,12 +806,9 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypeAccessSemantics)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Value, sourceId2),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Value, sourceId2),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Value, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Value, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesSources)
|
TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesSources)
|
||||||
@@ -837,38 +825,9 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesSources)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId4),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId4),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId3),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId3),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesOverwritesTypes)
|
|
||||||
{
|
|
||||||
Storage::Types types{createTypes()};
|
|
||||||
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
|
||||||
types[0].exportedTypes.push_back(Storage::ExportedType{"Item", Storage::Version{5, 19}});
|
|
||||||
types[0].exportedTypes.push_back(Storage::ExportedType{"Item", Storage::Version{6, 1}});
|
|
||||||
types[1].exportedTypes.push_back(Storage::ExportedType{"Object", Storage::Version{6, 1}});
|
|
||||||
|
|
||||||
storage.synchronizeTypes(types, {sourceId3, sourceId4});
|
|
||||||
|
|
||||||
ASSERT_THAT(
|
|
||||||
storage.fetchTypes(),
|
|
||||||
UnorderedElementsAre(
|
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
|
||||||
Field(&Storage::Type::exportedTypes,
|
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Object", Storage::Version{5, 14}),
|
|
||||||
IsExportedType("Object", Storage::Version{6, 1})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
|
||||||
Field(&Storage::Type::exportedTypes,
|
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 19}),
|
|
||||||
IsExportedType("Item", Storage::Version{6, 1}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain)
|
TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain)
|
||||||
@@ -881,7 +840,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain)
|
|||||||
"QObject",
|
"QObject",
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
sourceId1,
|
sourceId1,
|
||||||
{Storage::ExportedType{"Object", Storage::Version{5, 15}}}});
|
{Storage::ExportedType{"Object"}}});
|
||||||
|
|
||||||
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
@@ -890,15 +849,11 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesInsertTypeIntoPrototypeChain)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickObject", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickObject", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Object")))),
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 15})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QQuickObject", TypeAccessSemantics::Reference, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QQuickObject", TypeAccessSemantics::Reference, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, SynchronizeTypesDontThrowsForMissingPrototype)
|
TEST_F(ProjectStorageSlowTest, SynchronizeTypesDontThrowsForMissingPrototype)
|
||||||
@@ -909,7 +864,7 @@ TEST_F(ProjectStorageSlowTest, SynchronizeTypesDontThrowsForMissingPrototype)
|
|||||||
"QObject",
|
"QObject",
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
sourceId1,
|
sourceId1,
|
||||||
{Storage::ExportedType{"Item", Storage::Version{5, 15}}}}};
|
{Storage::ExportedType{"Item"}}}};
|
||||||
|
|
||||||
ASSERT_NO_THROW(storage.synchronizeTypes(types, {sourceId1}));
|
ASSERT_NO_THROW(storage.synchronizeTypes(types, {sourceId1}));
|
||||||
}
|
}
|
||||||
@@ -921,7 +876,7 @@ TEST_F(ProjectStorageSlowTest, TypeWithInvalidSourceIdThrows)
|
|||||||
"",
|
"",
|
||||||
TypeAccessSemantics::Reference,
|
TypeAccessSemantics::Reference,
|
||||||
SourceId{},
|
SourceId{},
|
||||||
{Storage::ExportedType{"Item", Storage::Version{5, 15}}}}};
|
{Storage::ExportedType{"Item"}}}};
|
||||||
|
|
||||||
ASSERT_THROW(storage.synchronizeTypes(types, {}), QmlDesigner::TypeHasInvalidSourceId);
|
ASSERT_THROW(storage.synchronizeTypes(types, {}), QmlDesigner::TypeHasInvalidSourceId);
|
||||||
}
|
}
|
||||||
@@ -934,13 +889,11 @@ TEST_F(ProjectStorageSlowTest, DeleteTypeIfSourceIdIsSynchronized)
|
|||||||
|
|
||||||
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
ASSERT_THAT(
|
ASSERT_THAT(storage.fetchTypes(),
|
||||||
storage.fetchTypes(),
|
UnorderedElementsAre(AllOf(
|
||||||
UnorderedElementsAre(
|
IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
Field(&Storage::Type::exportedTypes,
|
||||||
Field(&Storage::Type::exportedTypes,
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Object", Storage::Version{5, 14}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, DontDeleteTypeIfSourceIdIsNotSynchronized)
|
TEST_F(ProjectStorageSlowTest, DontDeleteTypeIfSourceIdIsNotSynchronized)
|
||||||
@@ -956,12 +909,9 @@ TEST_F(ProjectStorageSlowTest, DontDeleteTypeIfSourceIdIsNotSynchronized)
|
|||||||
UnorderedElementsAre(
|
UnorderedElementsAre(
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj")))),
|
||||||
IsExportedType("Object", Storage::Version{5, 14})))),
|
|
||||||
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
AllOf(IsStorageType(importId2, "QQuickItem", "QObject", TypeAccessSemantics::Reference, sourceId1),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes, UnorderedElementsAre(IsExportedType("Item"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Item", Storage::Version{5, 1}),
|
|
||||||
IsExportedType("Item", Storage::Version{5, 15}))))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ProjectStorageSlowTest, BreakingPrototypeChainByDeletingBaseComponentThrows)
|
TEST_F(ProjectStorageSlowTest, BreakingPrototypeChainByDeletingBaseComponentThrows)
|
||||||
@@ -1973,13 +1923,71 @@ TEST_F(ProjectStorageSlowTest, RemovingImportRemovesDependentTypesToo)
|
|||||||
imports.pop_back();
|
imports.pop_back();
|
||||||
storage.synchronizeImports(imports);
|
storage.synchronizeImports(imports);
|
||||||
|
|
||||||
ASSERT_THAT(
|
ASSERT_THAT(storage.fetchTypes(),
|
||||||
storage.fetchTypes(),
|
UnorderedElementsAre(AllOf(
|
||||||
UnorderedElementsAre(
|
IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
||||||
AllOf(IsStorageType(importId1, "QObject", "", TypeAccessSemantics::Reference, sourceId2),
|
Field(&Storage::Type::exportedTypes,
|
||||||
Field(&Storage::Type::exportedTypes,
|
UnorderedElementsAre(IsExportedType("Object"), IsExportedType("Obj"))))));
|
||||||
UnorderedElementsAre(IsExportedType("Object", Storage::Version{5, 1}),
|
}
|
||||||
IsExportedType("Object", Storage::Version{5, 14}))))));
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchTypeIdByImportIdAndName)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByName(importId1, "QObject");
|
||||||
|
|
||||||
|
ASSERT_THAT(storage.fetchTypeIdByExportedName("Object"), Eq(typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchTypeIdByExportedName)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByExportedName("Object");
|
||||||
|
|
||||||
|
ASSERT_THAT(storage.fetchTypeIdByName(importId1, "QObject"), Eq(typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchTypeIdByImporIdsAndExportedName)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByImportIdsAndExportedName({importId1, importId2}, "Object");
|
||||||
|
|
||||||
|
ASSERT_THAT(storage.fetchTypeIdByName(importId1, "QObject"), Eq(typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreEmpty)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByImportIdsAndExportedName({}, "Object");
|
||||||
|
|
||||||
|
ASSERT_FALSE(typeId.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfImportIdsAreInvalid)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByImportIdsAndExportedName({ImportId{}}, "Object");
|
||||||
|
|
||||||
|
ASSERT_FALSE(typeId.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ProjectStorageSlowTest, FetchInvalidTypeIdByImporIdsAndExportedNameIfNotInImport)
|
||||||
|
{
|
||||||
|
Storage::Types types{createTypes()};
|
||||||
|
storage.synchronizeTypes(types, {sourceId1, sourceId2});
|
||||||
|
|
||||||
|
auto typeId = storage.fetchTypeIdByImportIdsAndExportedName({importId2, importId3}, "Object");
|
||||||
|
|
||||||
|
ASSERT_FALSE(typeId.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user