forked from qt-creator/qt-creator
C++: Fix (Find)LocalSymbols for lambda parameters
Change-Id: I5cb69749b4f15e4f70dea410aa6f943c4189c502 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -175,6 +175,19 @@ protected:
|
||||
_scopeStack.removeLast();
|
||||
}
|
||||
|
||||
virtual bool visit(LambdaExpressionAST *ast)
|
||||
{
|
||||
if (ast->lambda_declarator && ast->lambda_declarator->symbol)
|
||||
enterScope(ast->lambda_declarator->symbol);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void endVisit(LambdaExpressionAST *ast)
|
||||
{
|
||||
if (ast->lambda_declarator && ast->lambda_declarator->symbol)
|
||||
_scopeStack.removeLast();
|
||||
}
|
||||
|
||||
virtual bool visit(CompoundStatementAST *ast)
|
||||
{
|
||||
if (ast->symbol)
|
||||
|
||||
@@ -157,6 +157,18 @@ void CppToolsPlugin::test_cpplocalsymbols_data()
|
||||
<< Result(_("local"), 3, 8, 5)
|
||||
<< Result(_("local"), 4, 12, 5)
|
||||
<< Result(_("arg"), 4, 20, 3));
|
||||
|
||||
QTest::newRow("lambda")
|
||||
<< _("void f()\n"
|
||||
"{\n"
|
||||
" auto func = [](int arg) { return arg; };\n"
|
||||
" func(1);\n"
|
||||
"}\n")
|
||||
<< (QList<Result>()
|
||||
<< Result(_("func"), 2, 10, 4)
|
||||
<< Result(_("arg"), 2, 24, 3)
|
||||
<< Result(_("arg"), 2, 38, 3)
|
||||
<< Result(_("func"), 3, 5, 4));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocalsymbols()
|
||||
|
||||
Reference in New Issue
Block a user