diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2016-10-26 14:15:02 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2016-10-26 16:08:29 +0000 |
commit | 99aaf86a33ce08536b1a0f34940687c589026b6f (patch) | |
tree | 30df733deebde80db97a7505b101cf6061b57e90 /src/libs | |
parent | de6021c71a7f6067581fe9b0b71d81b6f5d0c07f (diff) | |
download | qt-creator-99aaf86a33ce08536b1a0f34940687c589026b6f.tar.gz |
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>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/qmljs/qmljscheck.cpp | 43 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsstaticanalysismessage.cpp | 2 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsstaticanalysismessage.h | 1 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 9610a95f72..c9c136d178 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -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; diff --git a/src/libs/qmljs/qmljsstaticanalysismessage.cpp b/src/libs/qmljs/qmljsstaticanalysismessage.cpp index fe5213b6bc..157537be1a 100644 --- a/src/libs/qmljs/qmljsstaticanalysismessage.cpp +++ b/src/libs/qmljs/qmljsstaticanalysismessage.cpp @@ -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, diff --git a/src/libs/qmljs/qmljsstaticanalysismessage.h b/src/libs/qmljs/qmljsstaticanalysismessage.h index ced78ee686..4d07614c8d 100644 --- a/src/libs/qmljs/qmljsstaticanalysismessage.h +++ b/src/libs/qmljs/qmljsstaticanalysismessage.h @@ -97,6 +97,7 @@ enum Type WarnUndefinedValueForVisualDesigner = 206, WarnStatesOnlyInRootItemForVisualDesigner = 207, ErrUnsupportedRootTypeInVisualDesigner = 208, + ErrInvalidIdeInVisualDesigner = 209, ErrUnsupportedRootTypeInQmlUi = 220, ErrUnsupportedTypeInQmlUi = 221, ErrFunctionsNotSupportedInQmlUi = 222, |