forked from qt-creator/qt-creator
CppTools: Hide "QPrivateSignal" on signal completion (Qt5)
See also http://woboq.com/blog/how-qt-signals-slots-work-part2-qt5.html Task-number: QTCREATORBUG-8540 Change-Id: Iccad837d7a0da982e7d7a1eda95ff1828cf1dce6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
@@ -2463,3 +2463,36 @@ void CppToolsPlugin::test_completion_recursive_using_typedef_declarations()
|
|||||||
|
|
||||||
QCOMPARE(completions.size(), 0);
|
QCOMPARE(completions.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppToolsPlugin::test_completion_signals_hide_QPrivateSignal()
|
||||||
|
{
|
||||||
|
const QByteArray source =
|
||||||
|
"#define SIGNAL(a) #a\n"
|
||||||
|
"#define SLOT(a) #a\n"
|
||||||
|
"#define signals public\n"
|
||||||
|
"#define Q_OBJECT struct QPrivateSignal {};\n"
|
||||||
|
"\n"
|
||||||
|
"class QObject\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" void connect(QObject *, char *, QObject *, char *);\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"class Timer : public QObject\n"
|
||||||
|
"{\n"
|
||||||
|
" Q_OBJECT\n"
|
||||||
|
"signals:\n"
|
||||||
|
" void timeout(QPrivateSignal);\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"void client()\n"
|
||||||
|
"{\n"
|
||||||
|
" Timer *timer = new Timer;\n"
|
||||||
|
" connect(timer, SIGNAL(@\n"
|
||||||
|
"}\n";
|
||||||
|
CompletionTestCase test(source);
|
||||||
|
|
||||||
|
const QStringList completions = test.getCompletions();
|
||||||
|
QCOMPARE(completions.size(), 1);
|
||||||
|
QVERIFY(completions.contains(QLatin1String("timeout()")));
|
||||||
|
}
|
||||||
|
|||||||
@@ -602,6 +602,24 @@ Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isQPrivateSignal(const Symbol *symbol)
|
||||||
|
{
|
||||||
|
if (!symbol)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
static Identifier qPrivateSignalIdentifier("QPrivateSignal", 14);
|
||||||
|
|
||||||
|
if (FullySpecifiedType type = symbol->type()) {
|
||||||
|
if (NamedType *namedType = type->asNamedType()) {
|
||||||
|
if (const Name *name = namedType->name()) {
|
||||||
|
if (name->isEqualTo(&qPrivateSignalIdentifier))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // Anonymous
|
} // Anonymous
|
||||||
|
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
@@ -1620,6 +1638,8 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
|
|||||||
signature += QLatin1Char('(');
|
signature += QLatin1Char('(');
|
||||||
for (unsigned i = 0; i < count; ++i) {
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
Symbol *arg = fun->argumentAt(i);
|
Symbol *arg = fun->argumentAt(i);
|
||||||
|
if (isQPrivateSignal(arg))
|
||||||
|
continue;
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
signature += QLatin1Char(',');
|
signature += QLatin1Char(',');
|
||||||
signature += o.prettyType(arg->type());
|
signature += o.prettyType(arg->type());
|
||||||
|
|||||||
@@ -148,6 +148,8 @@ private slots:
|
|||||||
void test_completion_recursive_using_declarations2();
|
void test_completion_recursive_using_declarations2();
|
||||||
void test_completion_recursive_using_typedef_declarations();
|
void test_completion_recursive_using_typedef_declarations();
|
||||||
|
|
||||||
|
void test_completion_signals_hide_QPrivateSignal();
|
||||||
|
|
||||||
void test_format_pointerdeclaration_in_simpledeclarations();
|
void test_format_pointerdeclaration_in_simpledeclarations();
|
||||||
void test_format_pointerdeclaration_in_simpledeclarations_data();
|
void test_format_pointerdeclaration_in_simpledeclarations_data();
|
||||||
void test_format_pointerdeclaration_in_controlflowstatements();
|
void test_format_pointerdeclaration_in_controlflowstatements();
|
||||||
|
|||||||
Reference in New Issue
Block a user