forked from qt-creator/qt-creator
C++: Fix typedef resolving when templates are involved.
Task-number: QTCREATORBUG-7978 Change-Id: I27e6ebe56e410d509580a1e00f8986642cacc5ba Reviewed-by: David Schulz <david.schulz@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -296,6 +296,76 @@ void CppToolsPlugin::test_completion_template_3()
|
||||
QVERIFY(completions.contains("Tupple"));
|
||||
QVERIFY(completions.contains("a"));
|
||||
QVERIFY(completions.contains("b"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_template_4()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"template <class T>\n"
|
||||
"struct List\n"
|
||||
"{\n"
|
||||
" typedef T U;\n"
|
||||
" U u;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Tupple { int a; int b; };\n"
|
||||
"\n"
|
||||
"void func() {\n"
|
||||
" List<Tupple> l;\n"
|
||||
" @\n"
|
||||
" // padding so we get the scope right\n"
|
||||
"}";
|
||||
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("l.u.");
|
||||
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("Tupple"));
|
||||
QVERIFY(completions.contains("a"));
|
||||
QVERIFY(completions.contains("b"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_template_5()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"template <class T>\n"
|
||||
"struct List\n"
|
||||
"{\n"
|
||||
" T u;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Tupple { int a; int b; };\n"
|
||||
"\n"
|
||||
"void func() {\n"
|
||||
" typedef List<Tupple> LT;\n"
|
||||
" LT l;"
|
||||
" @\n"
|
||||
" // padding so we get the scope right\n"
|
||||
"}";
|
||||
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("l.u.");
|
||||
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("Tupple"));
|
||||
QVERIFY(completions.contains("a"));
|
||||
QVERIFY(completions.contains("b"));
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ public:
|
||||
|
||||
private slots:
|
||||
void switchHeaderSource();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
// codegen tests
|
||||
@@ -95,6 +94,8 @@ private slots:
|
||||
void test_completion_template_1();
|
||||
void test_completion_template_2();
|
||||
void test_completion_template_3();
|
||||
void test_completion_template_4();
|
||||
void test_completion_template_5();
|
||||
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