Changed error to warning when using a string literal for an ID.

This commit is contained in:
Erik Verbruggen
2010-03-04 16:40:47 +01:00
parent 0714893c8f
commit 9539a8dcb0

View File

@@ -255,13 +255,18 @@ bool Check::visit(UiScriptBinding *ast)
return false;
}
IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression);
if (! idExp) {
QString id;
if (IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression)) {
id = idExp->name->asString();
} else if (StringLiteral *strExp = cast<StringLiteral *>(expStmt->expression)) {
id = strExp->value->asString();
warning(loc, QCoreApplication::translate("QmlJS::Check", "using string literals for ids is discouraged"));
} else {
error(loc, QCoreApplication::translate("QmlJS::Check", "expected id"));
return false;
}
if (! idExp->name->asString()[0].isLower()) {
if (id.isEmpty() || ! id[0].isLower()) {
error(loc, QCoreApplication::translate("QmlJS::Check", "ids must be lower case"));
return false;
}