C++: fix auto completion for member of classes accessed by using

Example:
namespace NS { struct S { int member; void fun(); }; }
using NS::S;
void S::fun()
{
mem// ctrl+space
}

Task-number: QTCREATORBUG-9037
Change-Id: I5a568be1b5c44deb02caa04996167a88a9c5d4d7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-09-03 22:51:53 +02:00
committed by Nikolai Kosjar
parent 4b4e5f6990
commit 4836fa0106
3 changed files with 49 additions and 0 deletions

View File

@@ -2821,3 +2821,46 @@ void CppToolsPlugin::test_completion_signals_hide_QPrivateSignal()
QCOMPARE(completions.size(), 1);
QVERIFY(completions.contains(QLatin1String("timeout()")));
}
void CppToolsPlugin::test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_1()
{
const QByteArray source =
"namespace NS { struct S { int member; void fun(); }; }\n"
"using NS::S;\n"
"void S::fun()\n"
"{\n"
" @\n"
" // padding so we get the scope right\n"
"}\n"
;
CompletionTestCase test(source, "mem");
QStringList completions = test.getCompletions();
QCOMPARE(completions.size(), 1);
QVERIFY(completions.contains(QLatin1String("member")));
}
void CppToolsPlugin::test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_2()
{
const QByteArray source =
"namespace NS \n"
"{\n"
" namespace Internal\n"
" {\n"
" struct S { int member; void fun(); };\n"
" }\n"
" using Internal::S;\n"
"}\n"
"using NS::S;\n"
"void S::fun()\n"
"{\n"
" @\n"
" // padding so we get the scope right\n"
"}\n"
;
CompletionTestCase test(source, "mem");
QStringList completions = test.getCompletions();
QCOMPARE(completions.size(), 1);
QVERIFY(completions.contains(QLatin1String("member")));
}