Skip to content
Snippets Groups Projects
Commit ca350468 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS checks: Improve warning about accidental empty blocks.

Change-Id: I2bddd65aef9092bf87f5a441e065ebca0e772174
Reviewed-on: http://codereview.qt-project.org/4331


Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent 5b8d7b46
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
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