forked from qt-creator/qt-creator
C++: fix typedefed struct
Fixed: * replacing dot with arrow * code completion Task-number: QTCREATORBUG-7373 Change-Id: I6bd3781e91876567ce6f0d4160373438c756c417 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
783ec18424
commit
a439d12b48
@@ -1473,7 +1473,61 @@ void CppToolsPlugin::test_completion_member_access_operator_1()
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_typedef_of_type_and_replace_access_operator()
|
||||
void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_type_no_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_and_decl_of_pointer_no_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(), 0);
|
||||
QVERIFY(! replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
@@ -1501,7 +1555,7 @@ void CppToolsPlugin::test_completion_typedef_of_type_and_replace_access_operator
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_typedef_of_pointer_of_type_and_replace_access_operator()
|
||||
void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
@@ -1529,6 +1583,116 @@ void CppToolsPlugin::test_completion_typedef_of_pointer_of_type_and_replace_acce
|
||||
QVERIFY(replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"typedef struct S SType;\n"
|
||||
"struct S { int m; };\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_predecl_typedef_of_type_and_decl_type_no_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"typedef struct S SType;\n"
|
||||
"struct S { int m; };\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_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"typedef struct S *SType;\n"
|
||||
"struct S { int m; };\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(), 0);
|
||||
QVERIFY(! replaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText = "\n"
|
||||
"typedef struct S *SType;\n"
|
||||
"struct S { int m; };\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()
|
||||
{
|
||||
TestData data;
|
||||
|
||||
@@ -113,8 +113,17 @@ private slots:
|
||||
void test_completion_instantiate_template_with_default_argument_type();
|
||||
void test_completion_instantiate_template_with_default_argument_type_as_template();
|
||||
void test_completion_member_access_operator_1();
|
||||
void test_completion_typedef_of_type_and_replace_access_operator();
|
||||
void test_completion_typedef_of_pointer_of_type_and_replace_access_operator();
|
||||
|
||||
void test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator();
|
||||
void test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
|
||||
void test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator();
|
||||
void test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator();
|
||||
|
||||
void test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator();
|
||||
void test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator();
|
||||
void test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
|
||||
void test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator();
|
||||
|
||||
void test_completion_typedef_of_pointer();
|
||||
void test_completion_typedef_of_pointer_inside_function();
|
||||
void test_completion_typedef_is_inside_function_before_declaration_block();
|
||||
|
||||
Reference in New Issue
Block a user