forked from qt-creator/qt-creator
C++: fix instantiation of template special. with pointer argument
Fixed code completion for instantiation of template specialization
with argument as pointer, e.g.:
template <typename T>
struct Template
{ T variable; };
template <typename T>
struct Template<T *>
{ T *pointer; };
Template<int*> templ;
templ.pointer;
Change-Id: I7c79fe0cd7119b1208f064aece0cafdf50e1a012
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
195d39242d
commit
ea32191542
@@ -1613,3 +1613,36 @@ void CppToolsPlugin::test_completion_resolve_complex_typedef_with_template()
|
||||
QVERIFY(completions.contains(QLatin1String("bar")));
|
||||
QVERIFY(completions.contains(QLatin1String("Template1")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_template_specialization_with_pointer()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"template <typename T>\n"
|
||||
"struct Template\n"
|
||||
"{\n"
|
||||
" T variable;\n"
|
||||
"};\n"
|
||||
"template <typename T>\n"
|
||||
"struct Template<T *>\n"
|
||||
"{\n"
|
||||
" T *pointer;\n"
|
||||
"};\n"
|
||||
"Template<int*> templ;\n"
|
||||
"@\n"
|
||||
;
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("templ.");
|
||||
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("Template")));
|
||||
QVERIFY(completions.contains(QLatin1String("pointer")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user