forked from qt-creator/qt-creator
C++: Fix code completion for operator ->
Fix code completion for operator '->' when returned value is a pointer of typedef(e.g.:std::auto_ptr). Included unit test. Task-number: QTCREATORBUG-629 Change-Id: I36b53a3f80b3c99d52791e18ad1244923c1373f6 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
0b3eb65fc9
commit
6b67f24865
@@ -409,6 +409,49 @@ void CppToolsPlugin::test_completion_template_6()
|
||||
QVERIFY(completions.contains(QLatin1String("i")));
|
||||
}
|
||||
|
||||
|
||||
void CppToolsPlugin::test_completion_template_7()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"struct Test\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<typename T>\n"
|
||||
"struct TemplateClass\n"
|
||||
"{\n"
|
||||
" T* ptr;\n"
|
||||
"\n"
|
||||
" typedef T element_type;\n"
|
||||
" TemplateClass(T* t) : ptr(t) {}\n"
|
||||
" element_type* operator->()\n"
|
||||
" {\n"
|
||||
" return ptr;\n"
|
||||
" }\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"TemplateClass<Test> p(new Test);\n"
|
||||
"@\n"
|
||||
;
|
||||
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("p->");
|
||||
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("Test")));
|
||||
QVERIFY(completions.contains(QLatin1String("i")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
|
||||
@@ -97,6 +97,7 @@ private slots:
|
||||
void test_completion_template_4();
|
||||
void test_completion_template_5();
|
||||
void test_completion_template_6();
|
||||
void test_completion_template_7();
|
||||
void test_completion_template_as_base();
|
||||
void test_completion_template_as_base_data();
|
||||
void test_completion_use_global_identifier_as_base_class();
|
||||
|
||||
Reference in New Issue
Block a user