Commit 4836fa01 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Nikolai Kosjar

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: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 4b4e5f69
......@@ -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")));
}
......@@ -1380,6 +1380,9 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
}
for (; currentBinding; currentBinding = currentBinding->parent()) {
foreach (ClassOrNamespace* u, currentBinding->usings())
usingBindings.append(u);
const QList<Symbol *> symbols = currentBinding->symbols();
if (!symbols.isEmpty()) {
......
......@@ -179,6 +179,9 @@ private slots:
void test_completion_lambdaCalls_4();
void test_completion_lambdaCalls_5();
void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_1();
void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_2();
void test_completion_local_type_and_member_1();
void test_completion_local_type_and_member_2();
void test_completion_local_type_and_member_3();
......
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