Commit 79561071 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlJS: Distinguish between erros for ui.qml files and designer warnings

We properly distinguish between warnings in the Qt Quick Designer and
error in a .ui.qml file.

The warnings are a subset of the errors anyway.

Change-Id: Ib3b21a845436381df10863b464c975b0b39fc063
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent eacaf93a
......@@ -599,7 +599,7 @@ Check::Check(Document::Ptr doc, const ContextPtr &context)
disableMessage(HintExtraParentheses);
if (isQtQuick2Ui()) {
enableQmlDesignerChecks();
disableQmlDesignerChecks();
} else {
disableQmlDesignerChecks();
disableQmlDesignerUiFileChecks();
......@@ -633,12 +633,11 @@ void Check::disableMessage(Type type)
void Check::enableQmlDesignerChecks()
{
enableMessage(StaticAnalysis::WarnImperativeCodeNotEditableInVisualDesigner);
enableMessage(StaticAnalysis::WarnUnsupportedTypeInVisualDesigner);
enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner);
enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner);
enableMessage(StaticAnalysis::WarnAboutQtQuick1InsteadQtQuick2);
enableMessage(StaticAnalysis::ErrUnsupportedRootTypeInVisualDesigner);
enableMessage(WarnImperativeCodeNotEditableInVisualDesigner);
enableMessage(WarnUnsupportedTypeInVisualDesigner);
enableMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner);
enableMessage(WarnAboutQtQuick1InsteadQtQuick2);
enableMessage(ErrUnsupportedRootTypeInVisualDesigner);
//## triggers too often ## check.enableMessage(StaticAnalysis::WarnUndefinedValueForVisualDesigner);
}
......@@ -659,6 +658,8 @@ void Check::enableQmlDesignerUiFileChecks()
enableMessage(ErrFunctionsNotSupportedInQmlUi);
enableMessage(ErrBlocksNotSupportedInQmlUi);
enableMessage(ErrBehavioursNotSupportedInQmlUi);
enableMessage(ErrStatesOnlyInRootItemInQmlUi);
enableMessage(ErrReferenceToParentItemNotSupportedInQmlUi);
}
void Check::disableQmlDesignerUiFileChecks()
......@@ -668,6 +669,8 @@ void Check::disableQmlDesignerUiFileChecks()
disableMessage(ErrFunctionsNotSupportedInQmlUi);
disableMessage(ErrBlocksNotSupportedInQmlUi);
disableMessage(ErrBehavioursNotSupportedInQmlUi);
disableMessage(ErrStatesOnlyInRootItemInQmlUi);
disableMessage(ErrReferenceToParentItemNotSupportedInQmlUi);
}
bool Check::preVisit(Node *ast)
......@@ -823,8 +826,10 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
if (checkTypeForQmlUiSupport(typeId))
addMessage(ErrUnsupportedTypeInQmlUi, typeErrorLocation, typeName);
if (m_typeStack.count() > 1 && getRightMostIdentifier(typeId)->name.toString() == QLatin1String("State"))
if (m_typeStack.count() > 1 && getRightMostIdentifier(typeId)->name.toString() == QLatin1String("State")) {
addMessage(WarnStatesOnlyInRootItemForVisualDesigner, typeErrorLocation);
addMessage(ErrStatesOnlyInRootItemInQmlUi, typeErrorLocation);
}
if (m_typeStack.isEmpty()
&& unsupportedRootObjectTypesByVisualDesigner()->contains(typeName))
......@@ -929,6 +934,8 @@ bool Check::visit(UiScriptBinding *ast)
&& checkTopLevelBindingForParentReference(cast<ExpressionStatement *>(ast->statement), _doc->source())) {
addMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner,
locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()));
addMessage(ErrReferenceToParentItemNotSupportedInQmlUi,
locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()));
}
checkProperty(ast->qualifiedId);
......
......@@ -234,6 +234,10 @@ StaticAnalysisMessages::StaticAnalysisMessages()
tr("Java Script blocks are not supported in a Qt Quick ui file."));
newMsg(ErrBehavioursNotSupportedInQmlUi, Error,
tr("Behaviours are not supported in a Qt Quick ui file."));
newMsg(ErrStatesOnlyInRootItemInQmlUi, Error,
tr("States are only supported in the root item in a Qt Quick ui file."));
newMsg(ErrReferenceToParentItemNotSupportedInQmlUi, Error,
tr("Referencing the parent of the root item is not supported in a Qt Quick ui file."));
}
} // anonymous namespace
......
......@@ -104,6 +104,8 @@ enum Type
ErrFunctionsNotSupportedInQmlUi = 222,
ErrBlocksNotSupportedInQmlUi = 223,
ErrBehavioursNotSupportedInQmlUi = 224,
ErrStatesOnlyInRootItemInQmlUi = 225,
ErrReferenceToParentItemNotSupportedInQmlUi = 226,
ErrUnknownComponent = 300,
ErrCouldNotResolvePrototypeOf = 301,
ErrCouldNotResolvePrototype = 302,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment