forked from qt-creator/qt-creator
QmlDesigner: Provide ProjectStorage::localPropertyDeclarationId
Even if there is a property with that name in the prototype chain an invalid id should be returned. Task-nubmer: QDS-7281 Change-Id: I08611390c8e9a75036ed5d5b54d2e5637adcfd84 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -169,6 +169,13 @@ public:
|
||||
.template valueWithTransaction<PropertyDeclarationId>(&typeId, propertyName);
|
||||
}
|
||||
|
||||
PropertyDeclarationId localPropertyDeclarationId(TypeId typeId,
|
||||
Utils::SmallStringView propertyName) const
|
||||
{
|
||||
return selectLocalPropertyDeclarationIdForTypeAndPropertyNameStatement
|
||||
.template valueWithTransaction<PropertyDeclarationId>(&typeId, propertyName);
|
||||
}
|
||||
|
||||
Utils::optional<Utils::SmallString> propertyName(PropertyDeclarationId propertyDeclarationId) const
|
||||
{
|
||||
return selectPropertyNameStatement.template optionalValueWithTransaction<Utils::SmallString>(
|
||||
@@ -2914,6 +2921,11 @@ public:
|
||||
"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 "
|
||||
"WHERE typeId=?1 AND name=?2 LIMIT 1",
|
||||
database};
|
||||
};
|
||||
extern template class ProjectStorage<Sqlite::Database>;
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -5685,4 +5685,48 @@ TEST_F(ProjectStorage, GetInvalidPropertyDeclarationIdForWrongPropertyName)
|
||||
ASSERT_FALSE(propertyId);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, GetLocalPropertyDeclarationId)
|
||||
{
|
||||
auto package{createPackageWithProperties()};
|
||||
storage.synchronize(package);
|
||||
auto typeId = fetchTypeId(sourceId1, "QObject");
|
||||
|
||||
auto propertyId = storage.localPropertyDeclarationId(typeId, "data");
|
||||
|
||||
ASSERT_THAT(propertyId, HasName("data"));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, GetInvalidLocalPropertyDeclarationIdForWrongType)
|
||||
{
|
||||
auto package{createPackageWithProperties()};
|
||||
storage.synchronize(package);
|
||||
auto typeId = fetchTypeId(sourceId1, "QObject2");
|
||||
|
||||
auto propertyId = storage.localPropertyDeclarationId(typeId, "data");
|
||||
|
||||
ASSERT_FALSE(propertyId);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, GetInvalidLocalPropertyDeclarationIdForInvalidTypeId)
|
||||
{
|
||||
auto package{createPackageWithProperties()};
|
||||
storage.synchronize(package);
|
||||
auto typeId = fetchTypeId(sourceId1, "WrongQObject");
|
||||
|
||||
auto propertyId = storage.localPropertyDeclarationId(typeId, "data");
|
||||
|
||||
ASSERT_FALSE(propertyId);
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, GetInvalidLocalPropertyDeclarationIdForWrongPropertyName)
|
||||
{
|
||||
auto package{createPackageWithProperties()};
|
||||
storage.synchronize(package);
|
||||
auto typeId = fetchTypeId(sourceId1, "QObject");
|
||||
|
||||
auto propertyId = storage.localPropertyDeclarationId(typeId, "wrongName");
|
||||
|
||||
ASSERT_FALSE(propertyId);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user