forked from qt-creator/qt-creator
QmlJSCheck: Add error for ambiguous ids
Certain ids can be ambiguous and have name clashes with properties. Those ids are not supported in the designer. Change-Id: Ida293d24611c467df6ef813a541e8abfc06b51cb Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
de6021c71a
commit
99aaf86a33
@@ -489,6 +489,42 @@ private:
|
||||
bool _seenNonDeclarationStatement;
|
||||
};
|
||||
|
||||
class IdsThatShouldNotBeUsedInDesigner : public QStringList
|
||||
{
|
||||
public:
|
||||
IdsThatShouldNotBeUsedInDesigner() : QStringList({ "top",
|
||||
"bottom",
|
||||
"left",
|
||||
"right",
|
||||
"width",
|
||||
"height",
|
||||
"x",
|
||||
"y",
|
||||
"opacity",
|
||||
"parent",
|
||||
"item",
|
||||
"flow",
|
||||
"color",
|
||||
"margin",
|
||||
"padding",
|
||||
"border",
|
||||
"font",
|
||||
"text",
|
||||
"source",
|
||||
"state",
|
||||
"visible",
|
||||
"focus",
|
||||
"data",
|
||||
"clip",
|
||||
"layer",
|
||||
"scale",
|
||||
"enabled",
|
||||
"anchors"})
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class VisualAspectsPropertyBlackList : public QStringList
|
||||
{
|
||||
public:
|
||||
@@ -563,6 +599,7 @@ public:
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
Q_GLOBAL_STATIC(IdsThatShouldNotBeUsedInDesigner, idsThatShouldNotBeUsedInDesigner)
|
||||
Q_GLOBAL_STATIC(VisualAspectsPropertyBlackList, visualAspectsPropertyBlackList)
|
||||
Q_GLOBAL_STATIC(UnsupportedTypesByVisualDesigner, unsupportedTypesByVisualDesigner)
|
||||
Q_GLOBAL_STATIC(UnsupportedRootObjectTypesByVisualDesigner, unsupportedRootObjectTypesByVisualDesigner)
|
||||
@@ -634,6 +671,7 @@ void Check::enableQmlDesignerChecks()
|
||||
enableMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner);
|
||||
enableMessage(WarnAboutQtQuick1InsteadQtQuick2);
|
||||
enableMessage(ErrUnsupportedRootTypeInVisualDesigner);
|
||||
enableMessage(ErrInvalidIdeInVisualDesigner);
|
||||
//## triggers too often ## check.enableMessage(StaticAnalysis::WarnUndefinedValueForVisualDesigner);
|
||||
}
|
||||
|
||||
@@ -645,6 +683,7 @@ void Check::disableQmlDesignerChecks()
|
||||
disableMessage(WarnUndefinedValueForVisualDesigner);
|
||||
disableMessage(WarnStatesOnlyInRootItemForVisualDesigner);
|
||||
disableMessage(ErrUnsupportedRootTypeInVisualDesigner);
|
||||
disableMessage(ErrInvalidIdeInVisualDesigner);
|
||||
}
|
||||
|
||||
void Check::enableQmlDesignerUiFileChecks()
|
||||
@@ -927,6 +966,10 @@ bool Check::visit(UiScriptBinding *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idsThatShouldNotBeUsedInDesigner->contains(id)) {
|
||||
addMessage(ErrInvalidIdeInVisualDesigner, loc);
|
||||
}
|
||||
|
||||
if (m_idStack.top().contains(id)) {
|
||||
addMessage(ErrDuplicateId, loc);
|
||||
return false;
|
||||
|
@@ -220,6 +220,8 @@ StaticAnalysisMessages::StaticAnalysisMessages()
|
||||
"and might not show up in Qt Quick Designer as expected."));
|
||||
newMsg(WarnStatesOnlyInRootItemForVisualDesigner, Warning,
|
||||
tr("Qt Quick Designer only supports states in the root item."));
|
||||
newMsg(ErrInvalidIdeInVisualDesigner, Error,
|
||||
tr("This id might be ambiguous and is not supported in the Qt Quick Designer"));
|
||||
newMsg(WarnAboutQtQuick1InsteadQtQuick2, Warning,
|
||||
tr("Using Qt Quick 1 code model instead of Qt Quick 2."));
|
||||
newMsg(ErrUnsupportedRootTypeInVisualDesigner, Error,
|
||||
|
@@ -97,6 +97,7 @@ enum Type
|
||||
WarnUndefinedValueForVisualDesigner = 206,
|
||||
WarnStatesOnlyInRootItemForVisualDesigner = 207,
|
||||
ErrUnsupportedRootTypeInVisualDesigner = 208,
|
||||
ErrInvalidIdeInVisualDesigner = 209,
|
||||
ErrUnsupportedRootTypeInQmlUi = 220,
|
||||
ErrUnsupportedTypeInQmlUi = 221,
|
||||
ErrFunctionsNotSupportedInQmlUi = 222,
|
||||
|
Reference in New Issue
Block a user