[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/languages/cpp
From: David Nolden <david.nolden.kde () art-master ! de>
Date: 2009-04-04 23:51:17
Message-ID: 1238889077.549947.25288.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 949338 by zwabel:
- Fix signal/slot completion when "SIGNAL(" or "SLOT(" is already typed
- Add a test for signal/slot completion
M +4 -4 codecompletion/context.cpp
M +24 -0 tests/test_cppcodecompletion.cpp
M +1 -0 tests/test_cppcodecompletion.h
--- trunk/KDE/kdevelop/languages/cpp/codecompletion/context.cpp #949337:949338
@@ -364,7 +364,7 @@
}
}
}
-
+
///Handle recursive contexts(Example: "ret = function1(param1, function2(" )
if( expressionPrefix.endsWith( '<' ) || expressionPrefix.endsWith('(') || \
expressionPrefix.endsWith(',') || expressionPrefix.endsWith(':') ) {
log( QString("Recursive function-call: Searching parent-context in \
\"%1\"").arg(expressionPrefix) ); @@ -388,10 +388,10 @@
if(!m_duContext)
return;
- if(parentContext()->functionName() == "SIGNAL" || \
parentContext()->functionName() == "SLOT") {
- if(parentContext()->functionName() == "SIGNAL")
+ if(parentContext()->m_expression == "SIGNAL" || parentContext()->m_expression == \
"SLOT") { + if(parentContext()->m_expression == "SIGNAL")
m_onlyShowSignals = true;
- if(parentContext()->functionName() == "SLOT") {
+ if(parentContext()->m_expression == "SLOT") {
m_onlyShowSlots = true;
}
--- trunk/KDE/kdevelop/languages/cpp/tests/test_cppcodecompletion.cpp #949337:949338
@@ -159,9 +159,33 @@
QVERIFY(tester.completionContext->parentContext()->parentContext()->isConstructorInitialization());
}
}
+}
+void TestCppCodeCompletion::testSignalSlotCompletion() {
+ addInclude("QObject.h", "class QObject { void connect(QObject* from, const char* \
signal, QObject* to, const char* slot); void connect(QObject* from, const char* \
signal, const char* slot); };"); +
+ QByteArray test("#include \"QObject.h\"\n class TE; class A : public QObject { \
public slots: void slot1(); void slot2(TE*); signals: void signal1(TE*, char);void \
signal2(); public: void test() { } };"); +
+ TopDUContext* context = parse( test, DumpAll );
+ DUChainWriteLocker lock(DUChain::lock());
+ QCOMPARE(context->childContexts().count(), 1);
+ QCOMPARE(context->childContexts()[0]->childContexts().count(), 6);
+ CompletionItemTester(context->childContexts()[0]->childContexts()[5], "connect( \
this, "); + QCOMPARE(CompletionItemTester(context->childContexts()[0]->childContexts()[5], \
"connect( this, ").names.toSet(), (QStringList() << "connect" << "signal1" << \
"signal2").toSet()); + \
QCOMPARE(CompletionItemTester(context->childContexts()[0]->childContexts()[5], \
"connect( this, SIGNAL(").names.toSet(), (QStringList() << "connect" << "signal1" << \
"signal2").toSet()); + kDebug() << "ITEMS:" << \
CompletionItemTester(context->childContexts()[0]->childContexts()[5], "connect( this, \
SIGNAL(signal2()), this, SLOT(").names; + \
QCOMPARE(CompletionItemTester(context->childContexts()[0]->childContexts()[5], \
"connect( this, SIGNAL(signal2()), this, ").names.toSet(), (QStringList() << \
"connect" << "signal1" << "signal2" << "slot1" << "slot2" << "Connect to A::signal2 \
()").toSet()); + QCOMPARE(CompletionItemTester(context->childContexts()[0]->childContexts()[5], \
"connect( this, SIGNAL(signal2()), this, SIGNAL(").names.toSet(), (QStringList() << \
"connect" << "signal1" << "signal2" << "Connect to A::signal2 ()").toSet()); + \
QCOMPARE(CompletionItemTester(context->childContexts()[0]->childContexts()[5], \
"connect( this, SIGNAL(signal2()), this, SLOT(").names.toSet(), (QStringList() << \
"connect" << "slot1" << "slot2" << "Connect to A::signal2 ()" << "signal2").toSet()); \
+ + QVERIFY(((QStringList() << "connect" << "signal1" << "signal2" << "slot1" << \
"slot2" << "Connect to A::signal2 ()").toSet() - \
CompletionItemTester(context->childContexts()[0]->childContexts()[5], "connect( this, \
SIGNAL(signal2()), ").names.toSet()).isEmpty()); + QVERIFY(((QStringList() << \
"connect" << "signal1" << "signal2" << "Connect to A::signal2 ()").toSet() - \
CompletionItemTester(context->childContexts()[0]->childContexts()[5], "connect( this, \
SIGNAL(signal2()), SIGNAL(").names.toSet()).isEmpty()); + QVERIFY(((QStringList() \
<< "connect" << "slot1" << "slot2" << "Connect to A::signal2 ()").toSet() - \
CompletionItemTester(context->childContexts()[0]->childContexts()[5], "connect( this, \
SIGNAL(signal2()), SLOT(").names.toSet()).isEmpty()); +
+ release(context);
}
+
void TestCppCodeCompletion::testAssistant() {
{
QByteArray test = "int n; class C { C() : member(n) {} }; }";
--- trunk/KDE/kdevelop/languages/cpp/tests/test_cppcodecompletion.h #949337:949338
@@ -100,6 +100,7 @@
void testCompletionInExternalClassDefinition();
void testCompletionBehindTypedeffedConstructor();
void testSubClassVisibility();
+ void testSignalSlotCompletion();
public:
enum DumpArea {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic