From 2b0e643e3da74af206a1826ae1a52075ac3efdc0 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gorszkowski Date: Sat, 16 Feb 2013 13:28:34 +0100 Subject: C++: fixed resolving complex typedef Unit test describe this complex typedef. Another step to bring code completion for stl containers. Change-Id: I27985c4ea7c26c723d7a88ce42c5ecf164b6c903 Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cppcompletion_test.cpp | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 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 19267fa6e8..fb61faec0d 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -1570,3 +1570,46 @@ void CppToolsPlugin::test_completion_typedef_is_inside_function_before_declarati QVERIFY(completions.contains(QLatin1String("Foo"))); QVERIFY(completions.contains(QLatin1String("bar"))); } + +void CppToolsPlugin::test_completion_resolve_complex_typedef_with_template() +{ + TestData data; + data.srcText = "\n" + "template \n" + "struct Template2\n" + "{\n" + " typedef typename T::template Template1::TT TemplateTypedef;\n" + " TemplateTypedef templateTypedef;\n" + "};\n" + "struct Foo\n" + "{\n" + " int bar;\n" + " template \n" + " struct Template1\n" + " {\n" + " typedef T TT;\n" + " };\n" + "};\n" + "void fun()\n" + "{\n" + " Template2 template2;\n" + " @\n" + " // padding so we get the scope right\n" + "}\n" + ; + setup(&data); + + Utils::ChangeSet change; + QString txt = QLatin1String("template2.templateTypedef."); + change.insert(data.pos, txt); + QTextCursor cursor(data.doc); + change.apply(&cursor); + data.pos += txt.length(); + + QStringList completions = getCompletions(data); + + QCOMPARE(completions.size(), 3); + QVERIFY(completions.contains(QLatin1String("Foo"))); + QVERIFY(completions.contains(QLatin1String("bar"))); + QVERIFY(completions.contains(QLatin1String("Template1"))); +} -- cgit v1.2.1