forked from qt-creator/qt-creator
QmlDesigner: Don't export enumerations as qml types
Qml types can be derived. So we have to use a different mechnanism because otherwise we have to export a enumeration type for every derived class too. Task-number: QDS-6182 Change-Id: Ib3ab3629328511e932f4d8cd360cbe3b01369d8f Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -99,28 +99,34 @@ Storage::Version createVersion(QTypeRevision qmlVersion)
|
|||||||
Storage::ExportedTypes createExports(const QList<QQmlJSScope::Export> &qmlExports,
|
Storage::ExportedTypes createExports(const QList<QQmlJSScope::Export> &qmlExports,
|
||||||
Utils::SmallStringView interanalName,
|
Utils::SmallStringView interanalName,
|
||||||
QmlTypesParser::ProjectStorage &storage,
|
QmlTypesParser::ProjectStorage &storage,
|
||||||
ModuleId cppModuleId,
|
ModuleId cppModuleId)
|
||||||
Utils::SmallStringView typeNameAppendix = {})
|
|
||||||
{
|
{
|
||||||
Storage::ExportedTypes exportedTypes;
|
Storage::ExportedTypes exportedTypes;
|
||||||
exportedTypes.reserve(Utils::usize(qmlExports));
|
exportedTypes.reserve(Utils::usize(qmlExports));
|
||||||
|
|
||||||
for (const QQmlJSScope::Export &qmlExport : qmlExports) {
|
for (const QQmlJSScope::Export &qmlExport : qmlExports) {
|
||||||
Utils::SmallString exportedTypeName{qmlExport.type()};
|
Utils::SmallString exportedTypeName{qmlExport.type()};
|
||||||
if (!typeNameAppendix.empty()) {
|
|
||||||
exportedTypeName += ".";
|
|
||||||
exportedTypeName += typeNameAppendix;
|
|
||||||
}
|
|
||||||
exportedTypes.emplace_back(storage.moduleId(Utils::SmallString{qmlExport.package()}),
|
exportedTypes.emplace_back(storage.moduleId(Utils::SmallString{qmlExport.package()}),
|
||||||
std::move(exportedTypeName),
|
std::move(exportedTypeName),
|
||||||
createVersion(qmlExport.version()));
|
createVersion(qmlExport.version()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::SmallString cppExportedTypeName{interanalName};
|
Utils::SmallString cppExportedTypeName{interanalName};
|
||||||
if (!typeNameAppendix.empty()) {
|
exportedTypes.emplace_back(cppModuleId, cppExportedTypeName);
|
||||||
cppExportedTypeName += "::";
|
|
||||||
cppExportedTypeName += typeNameAppendix;
|
return exportedTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Storage::ExportedTypes createCppEnumerationExports(Utils::SmallStringView interanalName,
|
||||||
|
ModuleId cppModuleId,
|
||||||
|
Utils::SmallStringView enumeration)
|
||||||
|
{
|
||||||
|
Storage::ExportedTypes exportedTypes;
|
||||||
|
exportedTypes.reserve(1);
|
||||||
|
|
||||||
|
Utils::SmallString cppExportedTypeName{interanalName};
|
||||||
|
cppExportedTypeName += "::";
|
||||||
|
cppExportedTypeName += enumeration;
|
||||||
|
|
||||||
exportedTypes.emplace_back(cppModuleId, cppExportedTypeName);
|
exportedTypes.emplace_back(cppModuleId, cppExportedTypeName);
|
||||||
|
|
||||||
@@ -283,12 +289,14 @@ EnumerationTypes addEnumerationTypes(Storage::Types &types,
|
|||||||
for (const QQmlJSMetaEnum &qmlEnumeration : qmlEnumerations) {
|
for (const QQmlJSMetaEnum &qmlEnumeration : qmlEnumerations) {
|
||||||
Utils::SmallString enumerationName{qmlEnumeration.name()};
|
Utils::SmallString enumerationName{qmlEnumeration.name()};
|
||||||
auto fullTypeName = Utils::SmallString::join({typeName, "::", enumerationName});
|
auto fullTypeName = Utils::SmallString::join({typeName, "::", enumerationName});
|
||||||
auto &type = types.emplace_back(
|
auto &type = types.emplace_back(fullTypeName,
|
||||||
fullTypeName,
|
Storage::ImportedType{Utils::SmallString{}},
|
||||||
Storage::ImportedType{Utils::SmallString{}},
|
Storage::TypeAccessSemantics::Value
|
||||||
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
|
| Storage::TypeAccessSemantics::IsEnum,
|
||||||
sourceId,
|
sourceId,
|
||||||
createExports(qmlExports, typeName, storage, cppModuleId, enumerationName));
|
createCppEnumerationExports(typeName,
|
||||||
|
cppModuleId,
|
||||||
|
enumerationName));
|
||||||
enumerationTypes.emplace_back(enumerationName, std::move(fullTypeName));
|
enumerationTypes.emplace_back(enumerationName, std::move(fullTypeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -428,13 +428,7 @@ TEST_F(QmlTypesParser, EnumerationIsExportedAsType)
|
|||||||
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
|
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
|
||||||
qmltypesFileSourceId),
|
qmltypesFileSourceId),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType(qmlModuleId,
|
UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId,
|
||||||
"QtObject.NamedColorSpace",
|
|
||||||
Storage::Version{1, 0}),
|
|
||||||
IsExportedType(qtQmlModuleId,
|
|
||||||
"QtObject.NamedColorSpace",
|
|
||||||
Storage::Version{2, 1}),
|
|
||||||
IsExportedType(qtQmlNativeModuleId,
|
|
||||||
"QObject::NamedColorSpace",
|
"QObject::NamedColorSpace",
|
||||||
Storage::Version{})))),
|
Storage::Version{})))),
|
||||||
AllOf(IsType("QObject::VerticalLayoutDirection",
|
AllOf(IsType("QObject::VerticalLayoutDirection",
|
||||||
@@ -442,13 +436,7 @@ TEST_F(QmlTypesParser, EnumerationIsExportedAsType)
|
|||||||
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
|
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
|
||||||
qmltypesFileSourceId),
|
qmltypesFileSourceId),
|
||||||
Field(&Storage::Type::exportedTypes,
|
Field(&Storage::Type::exportedTypes,
|
||||||
UnorderedElementsAre(IsExportedType(qmlModuleId,
|
UnorderedElementsAre(IsExportedType(qtQmlNativeModuleId,
|
||||||
"QtObject.VerticalLayoutDirection",
|
|
||||||
Storage::Version{1, 0}),
|
|
||||||
IsExportedType(qtQmlModuleId,
|
|
||||||
"QtObject.VerticalLayoutDirection",
|
|
||||||
Storage::Version{2, 1}),
|
|
||||||
IsExportedType(qtQmlNativeModuleId,
|
|
||||||
"QObject::VerticalLayoutDirection",
|
"QObject::VerticalLayoutDirection",
|
||||||
Storage::Version{})))),
|
Storage::Version{})))),
|
||||||
_));
|
_));
|
||||||
|
Reference in New Issue
Block a user