From eb30ab6604063550fea2d44a573299b95d459c3c Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Sun, 7 Apr 2013 17:48:16 +0200 Subject: C++: fixed code completion for namespace aliases Task-number: QTCREATORBUG-166 Change-Id: I7a19065a57bfb943e5fc4e2bd9bd81988c1175e3 Reviewed-by: Sergey Shambir Reviewed-by: Orgad Shaneh Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cppcompletion_test.cpp | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/plugins/cpptools/cppcompletion_test.cpp') diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 6e35e263da..67af9b9497 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -1751,3 +1751,50 @@ void CppToolsPlugin::test_completion_typedef_using_templates2() QVERIFY(completions.contains(QLatin1String("Foo"))); QVERIFY(completions.contains(QLatin1String("bar"))); } + +void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declarations() +{ + TestData data; + data.srcText = + "namespace NS1\n" + "{\n" + "namespace NS2\n" + "{\n" + "struct Foo1\n" + "{\n" + " int bar1;\n" + "};\n" + "}\n" + "}\n" + "namespace NS1\n" + "{\n" + "namespace NS2\n" + "{\n" + "struct Foo2\n" + "{\n" + " int bar2;\n" + "};\n" + "}\n" + "}\n" + "namespace NS = NS1::NS2;\n" + "int main()\n" + "{\n" + " @\n" + " // padding so we get the scope right\n" + "}\n" + ; + setup(&data); + + Utils::ChangeSet change; + QString txt = QLatin1String("NS::"); + change.insert(data.pos, txt); + QTextCursor cursor(data.doc); + change.apply(&cursor); + data.pos += txt.length(); + + QStringList completions = getCompletions(data); + + QCOMPARE(completions.size(), 2); + QVERIFY(completions.contains(QLatin1String("Foo1"))); + QVERIFY(completions.contains(QLatin1String("Foo2"))); +} -- cgit v1.2.1