forked from qt-creator/qt-creator
QmlDesigner: Add extension support in qmltypesparser
Task-number: QDS-7384 Change-Id: I3f84f361360bd085d0ee78f32d808151e32a2436 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -410,18 +410,17 @@ void addType(Storage::Synchronization::Types &types,
|
||||
auto exports = exportScope.exports;
|
||||
|
||||
auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations);
|
||||
types.emplace_back(Utils::SmallStringView{typeName},
|
||||
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
|
||||
Storage::Synchronization::ImportedType{},
|
||||
createTypeTraits(component.accessSemantics()),
|
||||
sourceId,
|
||||
createExports(exports, typeName, storage, cppModuleId),
|
||||
createProperties(component.ownProperties(),
|
||||
enumerationTypes,
|
||||
componentNameWithoutNamespace),
|
||||
std::move(functionsDeclarations),
|
||||
std::move(signalDeclarations),
|
||||
createEnumeration(enumerations));
|
||||
types.emplace_back(
|
||||
Utils::SmallStringView{typeName},
|
||||
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
|
||||
Storage::Synchronization::ImportedType{TypeNameString{component.extensionTypeName()}},
|
||||
createTypeTraits(component.accessSemantics()),
|
||||
sourceId,
|
||||
createExports(exports, typeName, storage, cppModuleId),
|
||||
createProperties(component.ownProperties(), enumerationTypes, componentNameWithoutNamespace),
|
||||
std::move(functionsDeclarations),
|
||||
std::move(signalDeclarations),
|
||||
createEnumeration(enumerations));
|
||||
}
|
||||
|
||||
void addTypes(Storage::Synchronization::Types &types,
|
||||
|
@@ -39,16 +39,17 @@ MATCHER_P(HasPrototype, prototype, std::string(negation ? "isn't " : "is ") + Pr
|
||||
MATCHER_P5(IsType,
|
||||
typeName,
|
||||
prototype,
|
||||
extensionType,
|
||||
extension,
|
||||
traits,
|
||||
sourceId,
|
||||
std::string(negation ? "isn't " : "is ")
|
||||
+ PrintToString(Storage::Type{typeName, prototype, extensionType, traits, sourceId}))
|
||||
+ PrintToString(Storage::Type{typeName, prototype, extension, traits, sourceId}))
|
||||
{
|
||||
const Storage::Type &type = arg;
|
||||
|
||||
return type.typeName == typeName && type.prototype == Storage::ImportedTypeName{prototype}
|
||||
&& type.traits == traits && type.sourceId == sourceId;
|
||||
&& type.extension == Storage::ImportedTypeName{extension} && type.traits == traits
|
||||
&& type.sourceId == sourceId;
|
||||
}
|
||||
|
||||
MATCHER_P3(IsPropertyDeclaration,
|
||||
@@ -181,6 +182,28 @@ TEST_F(QmlTypesParser, Imports)
|
||||
}
|
||||
|
||||
TEST_F(QmlTypesParser, Types)
|
||||
{
|
||||
QString source{R"(import QtQuick.tooling 1.2
|
||||
Module{
|
||||
Component { name: "QObject"}
|
||||
Component { name: "QQmlComponent"}})"};
|
||||
|
||||
parser.parse(source, imports, types, projectData);
|
||||
|
||||
ASSERT_THAT(types,
|
||||
UnorderedElementsAre(IsType("QObject",
|
||||
Storage::ImportedType{},
|
||||
Storage::ImportedType{},
|
||||
QmlDesigner::Storage::TypeTraits::Reference,
|
||||
qmltypesFileSourceId),
|
||||
IsType("QQmlComponent",
|
||||
Storage::ImportedType{},
|
||||
Storage::ImportedType{},
|
||||
QmlDesigner::Storage::TypeTraits::Reference,
|
||||
qmltypesFileSourceId)));
|
||||
}
|
||||
|
||||
TEST_F(QmlTypesParser, Prototype)
|
||||
{
|
||||
QString source{R"(import QtQuick.tooling 1.2
|
||||
Module{
|
||||
@@ -203,6 +226,29 @@ TEST_F(QmlTypesParser, Types)
|
||||
qmltypesFileSourceId)));
|
||||
}
|
||||
|
||||
TEST_F(QmlTypesParser, Extension)
|
||||
{
|
||||
QString source{R"(import QtQuick.tooling 1.2
|
||||
Module{
|
||||
Component { name: "QObject"}
|
||||
Component { name: "QQmlComponent"
|
||||
extension: "QObject"}})"};
|
||||
|
||||
parser.parse(source, imports, types, projectData);
|
||||
|
||||
ASSERT_THAT(types,
|
||||
UnorderedElementsAre(IsType("QObject",
|
||||
Storage::ImportedType{},
|
||||
Storage::ImportedType{},
|
||||
QmlDesigner::Storage::TypeTraits::Reference,
|
||||
qmltypesFileSourceId),
|
||||
IsType("QQmlComponent",
|
||||
Storage::ImportedType{},
|
||||
Storage::ImportedType{"QObject"},
|
||||
QmlDesigner::Storage::TypeTraits::Reference,
|
||||
qmltypesFileSourceId)));
|
||||
}
|
||||
|
||||
TEST_F(QmlTypesParser, ExportedTypes)
|
||||
{
|
||||
QString source{R"(import QtQuick.tooling 1.2
|
||||
|
Reference in New Issue
Block a user