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: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
Thomas Hartmann
2014-10-15 12:32:26 +02:00
parent eacaf93a59
commit 7956107187
3 changed files with 21 additions and 8 deletions

View File

@@ -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);