Commit 56966f37 authored by Przemyslaw Gorszkowski's avatar Przemyslaw Gorszkowski Committed by Eike Ziller
Browse files

C++: Fix code completion for Qt containers

This change solves only problem with Qt containers.
stl containers need separate change.
Problem was with predeclaration of template class after
declaration of this template class.
(there is unit test added which shows the problem).

Task-number: QTCREATORBUG-8228 (cover only Qt containers)

Change-Id: If1f76c88c955b7b55347d302b353f5cd52b244a4
Reviewed-by: default avatarErik Verbruggen <>


Change-Id: I9f665276926f2e440ad0c92e94dd1aeee89005b3
Reviewed-by: default avatarEike Ziller <>
parent adc8dc7b
......@@ -730,7 +730,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
return reference;
const TemplateNameId *templId = name->asTemplateNameId();
if (_alreadyConsideredClasses.contains(referenceClass) ||
if ((! templId && _alreadyConsideredClasses.contains(referenceClass)) ||
(templId &&
_alreadyConsideredTemplates.contains(templId))) {
return reference;
......@@ -370,6 +370,45 @@ void CppToolsPlugin::test_completion_template_5()
void CppToolsPlugin::test_completion_template_6()
TestData data;
data.srcText = "\n"
"class Item\n"
" int i;\n"
"template <typename T>\n"
"class Container\n"
" T get();\n"
"template <typename T> class Container;\n"
"class ItemContainer: public Container<Item>\n"
"ItemContainer container;\n"
Utils::ChangeSet change;
QString txt = QLatin1String("container.get().");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
data.pos += txt.length();
QStringList completions = getCompletions(data);
QCOMPARE(completions.size(), 2);
void CppToolsPlugin::test_completion()
QFETCH(QByteArray, code);
......@@ -96,6 +96,7 @@ private slots:
void test_completion_template_3();
void test_completion_template_4();
void test_completion_template_5();
void test_completion_template_6();
void test_completion_template_as_base();
void test_completion_template_as_base_data();
void test_completion_use_global_identifier_as_base_class();
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