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 exports = exportScope.exports;
|
||||||
|
|
||||||
auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations);
|
auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations);
|
||||||
types.emplace_back(Utils::SmallStringView{typeName},
|
types.emplace_back(
|
||||||
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
|
Utils::SmallStringView{typeName},
|
||||||
Storage::Synchronization::ImportedType{},
|
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
|
||||||
createTypeTraits(component.accessSemantics()),
|
Storage::Synchronization::ImportedType{TypeNameString{component.extensionTypeName()}},
|
||||||
sourceId,
|
createTypeTraits(component.accessSemantics()),
|
||||||
createExports(exports, typeName, storage, cppModuleId),
|
sourceId,
|
||||||
createProperties(component.ownProperties(),
|
createExports(exports, typeName, storage, cppModuleId),
|
||||||
enumerationTypes,
|
createProperties(component.ownProperties(), enumerationTypes, componentNameWithoutNamespace),
|
||||||
componentNameWithoutNamespace),
|
std::move(functionsDeclarations),
|
||||||
std::move(functionsDeclarations),
|
std::move(signalDeclarations),
|
||||||
std::move(signalDeclarations),
|
createEnumeration(enumerations));
|
||||||
createEnumeration(enumerations));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTypes(Storage::Synchronization::Types &types,
|
void addTypes(Storage::Synchronization::Types &types,
|
||||||
|
@@ -39,16 +39,17 @@ MATCHER_P(HasPrototype, prototype, std::string(negation ? "isn't " : "is ") + Pr
|
|||||||
MATCHER_P5(IsType,
|
MATCHER_P5(IsType,
|
||||||
typeName,
|
typeName,
|
||||||
prototype,
|
prototype,
|
||||||
extensionType,
|
extension,
|
||||||
traits,
|
traits,
|
||||||
sourceId,
|
sourceId,
|
||||||
std::string(negation ? "isn't " : "is ")
|
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;
|
const Storage::Type &type = arg;
|
||||||
|
|
||||||
return type.typeName == typeName && type.prototype == Storage::ImportedTypeName{prototype}
|
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,
|
MATCHER_P3(IsPropertyDeclaration,
|
||||||
@@ -181,6 +182,28 @@ TEST_F(QmlTypesParser, Imports)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QmlTypesParser, Types)
|
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
|
QString source{R"(import QtQuick.tooling 1.2
|
||||||
Module{
|
Module{
|
||||||
@@ -203,6 +226,29 @@ TEST_F(QmlTypesParser, Types)
|
|||||||
qmltypesFileSourceId)));
|
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)
|
TEST_F(QmlTypesParser, ExportedTypes)
|
||||||
{
|
{
|
||||||
QString source{R"(import QtQuick.tooling 1.2
|
QString source{R"(import QtQuick.tooling 1.2
|
||||||
|
Reference in New Issue
Block a user