forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user