aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs/qmljscheck.cpp
diff options
context:
space:
mode:
authorChristian Kamm <[email protected]>2010-02-23 14:55:38 +0100
committerChristian Kamm <[email protected]>2010-02-23 14:57:19 +0100
commitfeacbf8a2aba95c47790dc6f0133a8976ada9cc8 (patch)
tree9149304e88255b2557ca5a50cc7e006a82fea4c7 /src/libs/qmljs/qmljscheck.cpp
parent0e2685332c3ea3bea9d3290750e456695b8d3b8d (diff)
Check that the id property is a plain lowercase identifier.
Diffstat (limited to 'src/libs/qmljs/qmljscheck.cpp')
-rw-r--r--src/libs/qmljs/qmljscheck.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 7322d1f8f39..8269f92c893 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -144,6 +144,32 @@ void Check::errorOnWrongRhs(const SourceLocation &loc, const Value *lhsValue)
bool Check::visit(UiScriptBinding *ast)
{
+ // special case for id property
+ if (ast->qualifiedId->name->asString() == QLatin1String("id") && ! ast->qualifiedId->next) {
+ if (! ast->statement)
+ return false;
+
+ const SourceLocation loc = locationFromRange(ast->statement->firstSourceLocation(),
+ ast->statement->lastSourceLocation());
+
+ ExpressionStatement *expStmt = cast<ExpressionStatement *>(ast->statement);
+ if (!expStmt) {
+ error(loc, QCoreApplication::translate("QmlJS::Check", "expected id"));
+ return false;
+ }
+
+ IdentifierExpression *idExp = cast<IdentifierExpression *>(expStmt->expression);
+ if (! idExp) {
+ error(loc, QCoreApplication::translate("QmlJS::Check", "expected id"));
+ return false;
+ }
+
+ if (! idExp->name->asString()[0].isLower()) {
+ error(loc, QCoreApplication::translate("QmlJS::Check", "ids must be lower case"));
+ return false;
+ }
+ }
+
const Value *lhsValue = checkScopeObjectMember(ast->qualifiedId);
if (lhsValue) {
// ### Fix the evaluator to accept statements!