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); disableMessage(HintExtraParentheses);
if (isQtQuick2Ui()) { if (isQtQuick2Ui()) {
enableQmlDesignerChecks(); disableQmlDesignerChecks();
} else { } else {
disableQmlDesignerChecks(); disableQmlDesignerChecks();
disableQmlDesignerUiFileChecks(); disableQmlDesignerUiFileChecks();
@@ -633,12 +633,11 @@ void Check::disableMessage(Type type)
void Check::enableQmlDesignerChecks() void Check::enableQmlDesignerChecks()
{ {
enableMessage(StaticAnalysis::WarnImperativeCodeNotEditableInVisualDesigner); enableMessage(WarnImperativeCodeNotEditableInVisualDesigner);
enableMessage(StaticAnalysis::WarnUnsupportedTypeInVisualDesigner); enableMessage(WarnUnsupportedTypeInVisualDesigner);
enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner); enableMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner);
enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner); enableMessage(WarnAboutQtQuick1InsteadQtQuick2);
enableMessage(StaticAnalysis::WarnAboutQtQuick1InsteadQtQuick2); enableMessage(ErrUnsupportedRootTypeInVisualDesigner);
enableMessage(StaticAnalysis::ErrUnsupportedRootTypeInVisualDesigner);
//## triggers too often ## check.enableMessage(StaticAnalysis::WarnUndefinedValueForVisualDesigner); //## triggers too often ## check.enableMessage(StaticAnalysis::WarnUndefinedValueForVisualDesigner);
} }
@@ -659,6 +658,8 @@ void Check::enableQmlDesignerUiFileChecks()
enableMessage(ErrFunctionsNotSupportedInQmlUi); enableMessage(ErrFunctionsNotSupportedInQmlUi);
enableMessage(ErrBlocksNotSupportedInQmlUi); enableMessage(ErrBlocksNotSupportedInQmlUi);
enableMessage(ErrBehavioursNotSupportedInQmlUi); enableMessage(ErrBehavioursNotSupportedInQmlUi);
enableMessage(ErrStatesOnlyInRootItemInQmlUi);
enableMessage(ErrReferenceToParentItemNotSupportedInQmlUi);
} }
void Check::disableQmlDesignerUiFileChecks() void Check::disableQmlDesignerUiFileChecks()
@@ -668,6 +669,8 @@ void Check::disableQmlDesignerUiFileChecks()
disableMessage(ErrFunctionsNotSupportedInQmlUi); disableMessage(ErrFunctionsNotSupportedInQmlUi);
disableMessage(ErrBlocksNotSupportedInQmlUi); disableMessage(ErrBlocksNotSupportedInQmlUi);
disableMessage(ErrBehavioursNotSupportedInQmlUi); disableMessage(ErrBehavioursNotSupportedInQmlUi);
disableMessage(ErrStatesOnlyInRootItemInQmlUi);
disableMessage(ErrReferenceToParentItemNotSupportedInQmlUi);
} }
bool Check::preVisit(Node *ast) bool Check::preVisit(Node *ast)
@@ -823,8 +826,10 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
if (checkTypeForQmlUiSupport(typeId)) if (checkTypeForQmlUiSupport(typeId))
addMessage(ErrUnsupportedTypeInQmlUi, typeErrorLocation, typeName); 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(WarnStatesOnlyInRootItemForVisualDesigner, typeErrorLocation);
addMessage(ErrStatesOnlyInRootItemInQmlUi, typeErrorLocation);
}
if (m_typeStack.isEmpty() if (m_typeStack.isEmpty()
&& unsupportedRootObjectTypesByVisualDesigner()->contains(typeName)) && unsupportedRootObjectTypesByVisualDesigner()->contains(typeName))
@@ -929,6 +934,8 @@ bool Check::visit(UiScriptBinding *ast)
&& checkTopLevelBindingForParentReference(cast<ExpressionStatement *>(ast->statement), _doc->source())) { && checkTopLevelBindingForParentReference(cast<ExpressionStatement *>(ast->statement), _doc->source())) {
addMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner, addMessage(WarnReferenceToParentItemNotSupportedByVisualDesigner,
locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation())); locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()));
addMessage(ErrReferenceToParentItemNotSupportedInQmlUi,
locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()));
} }
checkProperty(ast->qualifiedId); checkProperty(ast->qualifiedId);

View File

@@ -234,6 +234,10 @@ StaticAnalysisMessages::StaticAnalysisMessages()
tr("Java Script blocks are not supported in a Qt Quick ui file.")); tr("Java Script blocks are not supported in a Qt Quick ui file."));
newMsg(ErrBehavioursNotSupportedInQmlUi, Error, newMsg(ErrBehavioursNotSupportedInQmlUi, Error,
tr("Behaviours are not supported in a Qt Quick ui file.")); 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 } // anonymous namespace

View File

@@ -104,6 +104,8 @@ enum Type
ErrFunctionsNotSupportedInQmlUi = 222, ErrFunctionsNotSupportedInQmlUi = 222,
ErrBlocksNotSupportedInQmlUi = 223, ErrBlocksNotSupportedInQmlUi = 223,
ErrBehavioursNotSupportedInQmlUi = 224, ErrBehavioursNotSupportedInQmlUi = 224,
ErrStatesOnlyInRootItemInQmlUi = 225,
ErrReferenceToParentItemNotSupportedInQmlUi = 226,
ErrUnknownComponent = 300, ErrUnknownComponent = 300,
ErrCouldNotResolvePrototypeOf = 301, ErrCouldNotResolvePrototypeOf = 301,
ErrCouldNotResolvePrototype = 302, ErrCouldNotResolvePrototype = 302,