forked from qt-creator/qt-creator
C++: fix replacing dot(.) with arrow(->)
Fix replacing operator dot(.) with operator arrow(->) for typedef pointer. Task-number: QTCREATORBUG-8488 Change-Id: Ic4462bc437a4aa37adfed4fa50b32d9bc20fe194 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -1354,3 +1354,59 @@ void CppToolsPlugin::test_completion_member_access_operator_1()
|
||||
QVERIFY(completions.contains(QLatin1String("t")));
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_typedef_of_type_and_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"struct S { int m; };\n"
|
||||
"typedef S SType;\n"
|
||||
"SType *p;\n"
|
||||
"@\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();
|
||||
|
||||
bool replaceAccessOperator = false;
|
||||
QStringList completions = getCompletions(data, &replaceAccessOperator);
|
||||
|
||||
QCOMPARE(completions.size(), 2);
|
||||
QVERIFY(completions.contains(QLatin1String("S")));
|
||||
QVERIFY(completions.contains(QLatin1String("m")));
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_typedef_of_pointer_of_type_and_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"struct S { int m; };\n"
|
||||
"typedef S* SPtr;\n"
|
||||
"SPtr p;\n"
|
||||
"@\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();
|
||||
|
||||
bool replaceAccessOperator = false;
|
||||
QStringList completions = getCompletions(data, &replaceAccessOperator);
|
||||
|
||||
QCOMPARE(completions.size(), 2);
|
||||
QVERIFY(completions.contains(QLatin1String("S")));
|
||||
QVERIFY(completions.contains(QLatin1String("m")));
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user