Commit 8b339f92 authored by Christian Kamm's avatar Christian Kamm
Browse files

JS checks: Check code block script bindings for common errors.

Reviewed-by: Erik Verbruggen
parent 23d77528
......@@ -191,14 +191,8 @@ class FunctionBodyCheck : protected Visitor
public:
QList<DiagnosticMessage> operator()(FunctionExpression *function, Check::Options options)
{
clear();
_options = options;
_messages.clear();
_declaredFunctions.clear();
_declaredVariables.clear();
_possiblyUndeclaredUses.clear();
_seenNonDeclarationStatement = false;
_formalParameterNames.clear();
for (FormalParameterList *plist = function->formals; plist; plist = plist->next) {
if (plist->name)
_formalParameterNames += plist->name->asString();
......@@ -208,7 +202,25 @@ public:
return _messages;
}
QList<DiagnosticMessage> operator()(StatementList *statements, Check::Options options)
{
clear();
_options = options;
Node::accept(statements, this);
return _messages;
}
protected:
void clear()
{
_messages.clear();
_declaredFunctions.clear();
_declaredVariables.clear();
_possiblyUndeclaredUses.clear();
_seenNonDeclarationStatement = false;
_formalParameterNames.clear();
}
void postVisit(Node *ast)
{
if (!_seenNonDeclarationStatement && ast->statementCast()
......@@ -470,6 +482,11 @@ bool Check::visit(UiScriptBinding *ast)
}
if (Block *block = cast<Block *>(ast->statement)) {
FunctionBodyCheck bodyCheck;
_messages.append(bodyCheck(block->statements, _options));
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment