QmlJS checks: Improve warning about accidental empty blocks.

Change-Id: I2bddd65aef9092bf87f5a441e065ebca0e772174
Reviewed-on: http://codereview.qt-project.org/4331
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2011-09-07 11:01:13 +02:00
parent 5b8d7b465c
commit ca35046827

View File

@@ -737,6 +737,7 @@ bool Check::visit(Block *ast)
if (Node *p = parent()) {
if (_options & WarnBlocks
&& !cast<UiScriptBinding *>(p)
&& !cast<UiPublicMember *>(p)
&& !cast<TryStatement *>(p)
&& !cast<Catch *>(p)
&& !cast<Finally *>(p)
@@ -751,6 +752,12 @@ bool Check::visit(Block *ast)
&& !cast<WithStatement *>(p)) {
warning(ast->lbraceToken, tr("blocks do not introduce a new scope, avoid"));
}
if (!ast->statements
&& (cast<UiPublicMember *>(p)
|| cast<UiScriptBinding *>(p))) {
warning(locationFromRange(ast->firstSourceLocation(), ast->lastSourceLocation()),
tr("unintentional empty block, use ({}) for empty object literal"));
}
}
return true;
}