summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
authorPrzemyslaw Gorszkowski <pgorszkowski@gmail.com>2012-11-21 09:56:31 +0100
committerEike Ziller <eike.ziller@digia.com>2012-11-22 16:39:15 +0100
commit56966f3712b9ec2d790b7185d230d3193f261a62 (patch)
tree20f0e624a739c8927c689a9155e52438c61713c6 /src/plugins/cpptools
parentadc8dc7bfb2ed8bc1d28cbbcb5e0a67f18fc6f2b (diff)
downloadqt-creator-56966f3712b9ec2d790b7185d230d3193f261a62.tar.gz
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: Erik Verbruggen <erik.verbruggen@digia.com> Conflicts: src/plugins/cpptools/cppcompletion_test.cpp Change-Id: I9f665276926f2e440ad0c92e94dd1aeee89005b3 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp39
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.h1
2 files changed, 40 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index f36ac54a6c..8dce2e5db1 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -370,6 +370,45 @@ void CppToolsPlugin::test_completion_template_5()
QVERIFY(completions.contains("b"));
}
+void CppToolsPlugin::test_completion_template_6()
+{
+ TestData data;
+ data.srcText = "\n"
+ "class Item\n"
+ "{\n"
+ " int i;\n"
+ "};\n"
+ "\n"
+ "template <typename T>\n"
+ "class Container\n"
+ "{\n"
+ " T get();\n"
+ "};\n"
+ "\n"
+ "template <typename T> class Container;\n"
+ "\n"
+ "class ItemContainer: public Container<Item>\n"
+ "{};\n"
+ "ItemContainer container;\n"
+ "@\n"
+ ;
+
+ setup(&data);
+
+ Utils::ChangeSet change;
+ QString txt = QLatin1String("container.get().");
+ 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("Item"));
+ QVERIFY(completions.contains("i"));
+}
+
void CppToolsPlugin::test_completion()
{
QFETCH(QByteArray, code);
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h
index 4bfafddb31..597a6ab27c 100644
--- a/src/plugins/cpptools/cpptoolsplugin.h
+++ b/src/plugins/cpptools/cpptoolsplugin.h
@@ -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();