Commit d4ce5109 authored by Nikolai Kosjar's avatar Nikolai Kosjar

C++: Fix completion for lambda parameters

Change-Id: I6db51aeba328dbb69ec59082a70be7bc2d95699b
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent f5cad52a
......@@ -1087,11 +1087,10 @@ bool Bind::visit(LambdaDeclaratorAST *ast)
return false;
}
void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
Function *Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
{
if (! ast)
return;
return 0;
Function *fun = control()->newFunction(0, 0);
fun->setStartOffset(tokenAt(ast->firstToken()).utf16charsBegin());
......@@ -1109,6 +1108,7 @@ void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
}
// unsigned mutable_token = ast->mutable_token;
_type = this->exceptionSpecification(ast->exception_specification, type);
return fun;
}
bool Bind::visit(TrailingReturnTypeAST *ast)
......@@ -1780,8 +1780,15 @@ bool Bind::visit(ObjCSelectorExpressionAST *ast)
bool Bind::visit(LambdaExpressionAST *ast)
{
this->lambdaIntroducer(ast->lambda_introducer);
this->lambdaDeclarator(ast->lambda_declarator);
if (Function *function = this->lambdaDeclarator(ast->lambda_declarator)) {
_scope->addMember(function);
Scope *previousScope = switchScope(function);
this->statement(ast->statement);
(void) switchScope(previousScope);
} else {
this->statement(ast->statement);
}
return false;
}
......
......@@ -103,7 +103,7 @@ protected:
void lambdaIntroducer(LambdaIntroducerAST *ast);
void lambdaCapture(LambdaCaptureAST *ast);
void capture(CaptureAST *ast);
void lambdaDeclarator(LambdaDeclaratorAST *ast);
Function *lambdaDeclarator(LambdaDeclaratorAST *ast);
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken);
......
......@@ -2263,6 +2263,11 @@ void CppToolsPlugin::test_completion_data()
) << _("n2.n1.t.") << (QStringList()
<< QLatin1String("foo")
<< QLatin1String("Foo"));
QTest::newRow("lambda_parameter") << _(
"auto func = [](int arg1) { return @; };\n"
) << _("ar") << (QStringList()
<< QLatin1String("arg1"));
}
void CppToolsPlugin::test_completion_member_access_operator()
......
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