Skip to content
Snippets Groups Projects
Commit 9539a8dc authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

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

parent 0714893c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment