Add support for new javascript methods to QML/JS outline

Extened AST visitor for outline, declaration and locator to include
Javascript methods, prototype functions with formal parameters for
better readability.

Change-Id: Ifbb2b157699c929412196f356b0c28ae0564f866
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
This commit is contained in:
Vlad Seryakov
2014-12-14 21:13:35 -05:00
committed by Orgad Shaneh
parent 4320aeea18
commit af56457ab6
4 changed files with 143 additions and 2 deletions

View File

@@ -327,6 +327,34 @@ protected:
return false;
}
bool visit(AST::BinaryExpression *ast)
{
AST::FieldMemberExpression *field = AST::cast<AST::FieldMemberExpression *>(ast->left);
AST::FunctionExpression *funcExpr = AST::cast<AST::FunctionExpression *>(ast->right);
if (field && funcExpr && funcExpr->body && (ast->op == QSOperator::Assign)) {
Declaration decl;
init(&decl, ast);
decl.text.fill(QLatin1Char(' '), _depth);
decl.text += field->name;
decl.text += QLatin1Char('(');
for (FormalParameterList *it = funcExpr->formals; it; it = it->next) {
if (!it->name.isEmpty())
decl.text += it->name;
if (it->next)
decl.text += QLatin1String(", ");
}
decl.text += QLatin1Char(')');
_declarations.append(decl);
}
return true;
}
};
class CreateRanges: protected AST::Visitor
@@ -373,6 +401,16 @@ protected:
return true;
}
bool visit(AST::BinaryExpression *ast)
{
auto field = AST::cast<AST::FieldMemberExpression *>(ast->left);
auto funcExpr = AST::cast<AST::FunctionExpression *>(ast->right);
if (field && funcExpr && funcExpr->body && (ast->op == QSOperator::Assign))
_ranges.append(createRange(ast, ast->firstSourceLocation(), ast->lastSourceLocation()));
return true;
}
virtual bool visit(AST::UiScriptBinding *ast)
{
if (AST::Block *block = AST::cast<AST::Block *>(ast->statement))