QmlDesigner: Extract default property in qmltypes parser

Change-Id: I0cc9ac71ba764db252e302d11d1cd3e4aff834f5
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2024-04-03 12:48:37 +02:00
parent afd1b3b6e9
commit 665d043e72
3 changed files with 17 additions and 2 deletions

View File

@@ -2092,7 +2092,7 @@ const Storage::Info::Type &NodeMetaInfo::typeData() const
PropertyDeclarationId NodeMetaInfo::defaultPropertyDeclarationId() const
{
if (!m_defaultPropertyId)
m_defaultPropertyId = m_projectStorage->defaultPropertyDeclarationId(m_typeId);
m_defaultPropertyId.emplace(m_projectStorage->defaultPropertyDeclarationId(m_typeId));
return *m_defaultPropertyId;
}

View File

@@ -458,7 +458,9 @@ void addType(Storage::Synchronization::Types &types,
createProperties(component.ownProperties(), enumerationTypes, componentNameWithoutNamespace),
std::move(functionsDeclarations),
std::move(signalDeclarations),
createEnumeration(enumerations));
createEnumeration(enumerations),
Storage::Synchronization::ChangeLevel::Full,
Utils::SmallString{component.ownDefaultPropertyName()});
tracer.end(keyValue("type", type));
}

View File

@@ -838,4 +838,17 @@ TEST_F(QmlTypesParser, uses_no_custom_parser)
ASSERT_THAT(types, ElementsAre(IsTypeTrait(UsesCustomParser(false))));
}
TEST_F(QmlTypesParser, default_property)
{
QString source{R"(import QtQuick.tooling 1.2
Module{
Component { name: "QObject"
defaultProperty: "children" }})"};
parser.parse(source, imports, types, projectData);
ASSERT_THAT(types,
ElementsAre(Field(&Synchronization::Type::defaultPropertyName, Eq("children"))));
}
} // namespace