forked from qt-creator/qt-creator
QmlDesigner: Remove project type traits
Project type traits are increasing the code complexity in the updater by quite lot. The discover can be done in an other way too. Change-Id: Ied9b7df445e854c76243ece6666690ea10b8d33d Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -75,8 +75,6 @@ public:
|
|||||||
|
|
||||||
MetaInfoType type() const;
|
MetaInfoType type() const;
|
||||||
bool isFileComponent() const;
|
bool isFileComponent() const;
|
||||||
bool isProjectComponent() const;
|
|
||||||
bool isInProjectModule() const;
|
|
||||||
FlagIs canBeContainer() const;
|
FlagIs canBeContainer() const;
|
||||||
FlagIs forceClip() const;
|
FlagIs forceClip() const;
|
||||||
FlagIs doesLayoutChildren() const;
|
FlagIs doesLayoutChildren() const;
|
||||||
|
@@ -1538,44 +1538,6 @@ bool NodeMetaInfo::isFileComponent() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeMetaInfo::isProjectComponent() const
|
|
||||||
{
|
|
||||||
if constexpr (useProjectStorage()) {
|
|
||||||
if (!isValid())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
using NanotraceHR::keyValue;
|
|
||||||
NanotraceHR::Tracer tracer{"is project component"_t, category(), keyValue("type id", m_typeId)};
|
|
||||||
|
|
||||||
auto isProjectComponent = typeData().traits.isProjectComponent;
|
|
||||||
|
|
||||||
tracer.end(keyValue("is project component", isProjectComponent));
|
|
||||||
|
|
||||||
return isProjectComponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NodeMetaInfo::isInProjectModule() const
|
|
||||||
{
|
|
||||||
if constexpr (useProjectStorage()) {
|
|
||||||
if (!isValid())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
using NanotraceHR::keyValue;
|
|
||||||
NanotraceHR::Tracer tracer{"is project module"_t, category(), keyValue("type id", m_typeId)};
|
|
||||||
|
|
||||||
auto isInProjectModule = typeData().traits.isInProjectModule;
|
|
||||||
|
|
||||||
tracer.end(keyValue("is project module", isInProjectModule));
|
|
||||||
|
|
||||||
return isInProjectModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
FlagIs NodeMetaInfo::canBeContainer() const
|
FlagIs NodeMetaInfo::canBeContainer() const
|
||||||
{
|
{
|
||||||
if constexpr (useProjectStorage()) {
|
if constexpr (useProjectStorage()) {
|
||||||
|
@@ -131,8 +131,6 @@ struct TypeTraits
|
|||||||
: kind{TypeTraitsKind::None}
|
: kind{TypeTraitsKind::None}
|
||||||
, isEnum{false}
|
, isEnum{false}
|
||||||
, isFileComponent{false}
|
, isFileComponent{false}
|
||||||
, isProjectComponent{false}
|
|
||||||
, isInProjectModule{false}
|
|
||||||
, usesCustomParser{false}
|
, usesCustomParser{false}
|
||||||
, dummy{0U}
|
, dummy{0U}
|
||||||
, canBeContainer{FlagIs::False}
|
, canBeContainer{FlagIs::False}
|
||||||
@@ -181,8 +179,6 @@ struct TypeTraits
|
|||||||
keyValue("kind", typeTraits.kind),
|
keyValue("kind", typeTraits.kind),
|
||||||
keyValue("is enum", typeTraits.isEnum),
|
keyValue("is enum", typeTraits.isEnum),
|
||||||
keyValue("is file component", typeTraits.isFileComponent),
|
keyValue("is file component", typeTraits.isFileComponent),
|
||||||
keyValue("is project component", typeTraits.isProjectComponent),
|
|
||||||
keyValue("is in project module", typeTraits.isInProjectModule),
|
|
||||||
keyValue("uses custom parser", typeTraits.usesCustomParser),
|
keyValue("uses custom parser", typeTraits.usesCustomParser),
|
||||||
keyValue("can be container", typeTraits.canBeContainer),
|
keyValue("can be container", typeTraits.canBeContainer),
|
||||||
keyValue("force clip", typeTraits.forceClip),
|
keyValue("force clip", typeTraits.forceClip),
|
||||||
@@ -207,10 +203,8 @@ struct TypeTraits
|
|||||||
TypeTraitsKind kind : 4;
|
TypeTraitsKind kind : 4;
|
||||||
unsigned int isEnum : 1;
|
unsigned int isEnum : 1;
|
||||||
unsigned int isFileComponent : 1;
|
unsigned int isFileComponent : 1;
|
||||||
unsigned int isProjectComponent : 1;
|
|
||||||
unsigned int isInProjectModule : 1;
|
|
||||||
unsigned int usesCustomParser : 1;
|
unsigned int usesCustomParser : 1;
|
||||||
unsigned int dummy : 23;
|
unsigned int dummy : 25;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
@@ -614,12 +614,6 @@ std::ostream &operator<<(std::ostream &out, TypeTraits traits)
|
|||||||
if (traits.isFileComponent)
|
if (traits.isFileComponent)
|
||||||
out << " | isFileComponent";
|
out << " | isFileComponent";
|
||||||
|
|
||||||
if (traits.isProjectComponent)
|
|
||||||
out << " | isProjectComponent";
|
|
||||||
|
|
||||||
if (traits.isInProjectModule)
|
|
||||||
out << " | isInProjectModule";
|
|
||||||
|
|
||||||
if (traits.usesCustomParser)
|
if (traits.usesCustomParser)
|
||||||
out << " | usesCustomParser";
|
out << " | usesCustomParser";
|
||||||
|
|
||||||
|
@@ -230,74 +230,6 @@ TEST_F(NodeMetaInfo, component_is_file_component)
|
|||||||
ASSERT_TRUE(isFileComponent);
|
ASSERT_TRUE(isFileComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, is_project_component)
|
|
||||||
{
|
|
||||||
auto moduleId = projectStorageMock.createModule("/path/to/project", ModuleKind::PathLibrary);
|
|
||||||
TypeTraits traits{TypeTraitsKind::Reference};
|
|
||||||
traits.isProjectComponent = true;
|
|
||||||
auto typeId = projectStorageMock.createType(moduleId, "Foo", traits);
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
|
|
||||||
|
|
||||||
bool isProjectComponent = metaInfo.isProjectComponent();
|
|
||||||
|
|
||||||
ASSERT_TRUE(isProjectComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, is_not_project_component)
|
|
||||||
{
|
|
||||||
using QmlDesigner::Storage::TypeTraits;
|
|
||||||
auto moduleId = projectStorageMock.createModule("/path/to/project", ModuleKind::PathLibrary);
|
|
||||||
auto typeId = projectStorageMock.createType(moduleId, "Foo", {});
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
|
|
||||||
|
|
||||||
bool isProjectComponent = metaInfo.isProjectComponent();
|
|
||||||
|
|
||||||
ASSERT_FALSE(isProjectComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, invalid_is_not_project_component)
|
|
||||||
{
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo;
|
|
||||||
|
|
||||||
bool isProjectComponent = metaInfo.isProjectComponent();
|
|
||||||
|
|
||||||
ASSERT_FALSE(isProjectComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, is_in_project_module)
|
|
||||||
{
|
|
||||||
auto moduleId = projectStorageMock.createModule("/path/to/project", ModuleKind::PathLibrary);
|
|
||||||
TypeTraits traits{TypeTraitsKind::Reference};
|
|
||||||
traits.isInProjectModule = true;
|
|
||||||
auto typeId = projectStorageMock.createType(moduleId, "Foo", traits);
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
|
|
||||||
|
|
||||||
bool isInProjectModule = metaInfo.isInProjectModule();
|
|
||||||
|
|
||||||
ASSERT_TRUE(isInProjectModule);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, is_not_in_project_module)
|
|
||||||
{
|
|
||||||
using QmlDesigner::Storage::TypeTraits;
|
|
||||||
auto moduleId = projectStorageMock.createModule("/path/to/project", ModuleKind::PathLibrary);
|
|
||||||
auto typeId = projectStorageMock.createType(moduleId, "Foo", {});
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo{typeId, &projectStorageMock};
|
|
||||||
|
|
||||||
bool isInProjectModule = metaInfo.isInProjectModule();
|
|
||||||
|
|
||||||
ASSERT_FALSE(isInProjectModule);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, invalid_is_not_in_project_module)
|
|
||||||
{
|
|
||||||
QmlDesigner::NodeMetaInfo metaInfo;
|
|
||||||
|
|
||||||
bool isInProjectModule = metaInfo.isInProjectModule();
|
|
||||||
|
|
||||||
ASSERT_FALSE(isInProjectModule);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NodeMetaInfo, has_property)
|
TEST_F(NodeMetaInfo, has_property)
|
||||||
{
|
{
|
||||||
auto metaInfo = model.qtQuickItemMetaInfo();
|
auto metaInfo = model.qtQuickItemMetaInfo();
|
||||||
|
Reference in New Issue
Block a user