forked from qt-creator/qt-creator
JS checks: Allow blocks after for(var ...).
Also * check the condition of the 'for(var' statement for assignment * allow comma expressions in 'for(var' Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -587,6 +587,8 @@ bool Check::visit(Block *ast)
|
||||
&& !cast<Finally *>(p)
|
||||
&& !cast<ForStatement *>(p)
|
||||
&& !cast<ForEachStatement *>(p)
|
||||
&& !cast<LocalForStatement *>(p)
|
||||
&& !cast<LocalForEachStatement *>(p)
|
||||
&& !cast<DoWhileStatement *>(p)
|
||||
&& !cast<WhileStatement *>(p)
|
||||
&& !cast<IfStatement *>(p)
|
||||
@@ -615,8 +617,11 @@ bool Check::visit(VoidExpression *ast)
|
||||
bool Check::visit(Expression *ast)
|
||||
{
|
||||
if (_options & WarnCommaExpression && ast->left && ast->right) {
|
||||
if (!cast<ForStatement *>(parent()))
|
||||
Node *p = parent();
|
||||
if (!cast<ForStatement *>(p)
|
||||
&& !cast<LocalForStatement *>(p)) {
|
||||
warning(ast->commaToken, tr("avoid comma expressions"));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -681,6 +686,13 @@ bool Check::visit(ForStatement *ast)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Check::visit(LocalForStatement *ast)
|
||||
{
|
||||
if (ast->condition)
|
||||
checkAssignInCondition(ast->condition);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Check::visit(WhileStatement *ast)
|
||||
{
|
||||
if (ast->expression)
|
||||
|
Reference in New Issue
Block a user