forked from qt-creator/qt-creator
CppEditor: Fix ConvertQt4Connect for different namespace
Change-Id: I152d7cda02bb034bf817eeeb4b467667e1188b2f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
7bb2d833f1
commit
e99aaf23b9
@@ -130,6 +130,7 @@ private slots:
|
|||||||
void test_quickfix_ConvertQt4Connect_connectOutOfClass();
|
void test_quickfix_ConvertQt4Connect_connectOutOfClass();
|
||||||
void test_quickfix_ConvertQt4Connect_connectWithinClass_data();
|
void test_quickfix_ConvertQt4Connect_connectWithinClass_data();
|
||||||
void test_quickfix_ConvertQt4Connect_connectWithinClass();
|
void test_quickfix_ConvertQt4Connect_connectWithinClass();
|
||||||
|
void test_quickfix_ConvertQt4Connect_differentNamespace();
|
||||||
|
|
||||||
void test_quickfix_InsertDefFromDecl_afterClass();
|
void test_quickfix_InsertDefFromDecl_afterClass();
|
||||||
void test_quickfix_InsertDefFromDecl_headerSource_basic1();
|
void test_quickfix_InsertDefFromDecl_headerSource_basic1();
|
||||||
|
|||||||
@@ -4796,5 +4796,38 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass()
|
|||||||
QuickFixOperationTest(testDocuments, &factory);
|
QuickFixOperationTest(testDocuments, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_differentNamespace()
|
||||||
|
{
|
||||||
|
const QByteArray prefix =
|
||||||
|
"namespace NsA {\n"
|
||||||
|
"class ClassA : public QObject\n"
|
||||||
|
"{\n"
|
||||||
|
" static ClassA *instance();\n"
|
||||||
|
"signals:\n"
|
||||||
|
" void sig();\n"
|
||||||
|
"};\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"namespace NsB {\n"
|
||||||
|
"class ClassB : public QObject\n"
|
||||||
|
"{\n"
|
||||||
|
" void slot();\n"
|
||||||
|
" void connector() {\n";
|
||||||
|
|
||||||
|
const QByteArray suffix = " }\n};\n}";
|
||||||
|
|
||||||
|
const QByteArray original = "co@nnect(NsA::ClassA::instance(), SIGNAL(sig()),\n"
|
||||||
|
" this, SLOT(slot()));\n";
|
||||||
|
const QByteArray expected = "connect(NsA::ClassA::instance(), &NsA::ClassA::sig,\n"
|
||||||
|
" this, &ClassB::slot);\n";
|
||||||
|
QList<QuickFixTestDocument::Ptr> testDocuments;
|
||||||
|
testDocuments << QuickFixTestDocument::create("file.cpp",
|
||||||
|
prefix + original + suffix,
|
||||||
|
prefix + expected + suffix);
|
||||||
|
|
||||||
|
ConvertQt4Connect factory;
|
||||||
|
QuickFixOperationTest(testDocuments, &factory);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
|
|||||||
@@ -5783,7 +5783,10 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
|
|||||||
QTC_ASSERT(objectType, return 0);
|
QTC_ASSERT(objectType, return 0);
|
||||||
|
|
||||||
ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
|
ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
|
||||||
QTC_ASSERT(objectClassCON, return 0);
|
if (!objectClassCON) {
|
||||||
|
objectClassCON = objectPointerExpressions.first().binding();
|
||||||
|
QTC_ASSERT(objectClassCON, return 0);
|
||||||
|
}
|
||||||
QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0);
|
QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0);
|
||||||
|
|
||||||
Symbol *objectClassSymbol = skipForwardDeclarations(objectClassCON->symbols());
|
Symbol *objectClassSymbol = skipForwardDeclarations(objectClassCON->symbols());
|
||||||
|
|||||||
Reference in New Issue
Block a user