[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [KDevelop] b9b0cc9: Remove constructors from the completion list when
From: Hamish Rodda <rodda () kde ! org>
Date: 2010-05-07 0:30:04
Message-ID: 201005070030.o470U4wV024812 () kore ! kollide ! net
[Download RAW message or body]
commit b9b0cc9340f41f1bdcd748514e0855d330715b99
Author: Hamish Rodda <rodda@kde.org>
Date: Thu May 6 09:18:08 2010 +1000
Remove constructors from the completion list when a variable is accessed with the \
"." and "->" member access operators. It is not valid c++ to call/reference a \
constructor in this way. Adjust test to check for this.
BUG:203950
diff --git a/languages/cpp/codecompletion/context.cpp \
b/languages/cpp/codecompletion/context.cpp index 5000e65..79ed5f0 100644
--- a/languages/cpp/codecompletion/context.cpp
+++ b/languages/cpp/codecompletion/context.cpp
@@ -1197,6 +1197,13 @@ QList<CompletionTreeItemPointer> \
CodeCompletionContext::completionItems(bool& sh continue;
else if(!filterDeclaration(decl.first, ctx))
continue;
+
+ if (memberAccessOperation() == MemberAccess || \
memberAccessOperation() == ArrowMemberAccess) { + // Don't allow \
constructors to be accessed with . or -> + if \
(ClassFunctionDeclaration* classFun = \
dynamic_cast<ClassFunctionDeclaration*>(classMember)) + if \
(classFun->isConstructor()) + continue;
+ }
if(decl.first->kind() == Declaration::Namespace) {
QualifiedIdentifier id = decl.first->qualifiedIdentifier();
diff --git a/languages/cpp/tests/test_cppcodecompletion.cpp \
b/languages/cpp/tests/test_cppcodecompletion.cpp index c846c6c..1b040c4 100644
--- a/languages/cpp/tests/test_cppcodecompletion.cpp
+++ b/languages/cpp/tests/test_cppcodecompletion.cpp
@@ -755,8 +755,9 @@ void \
TestCppCodeCompletion::testCompletionBehindTypedeffedConstructor() { \
QCOMPARE(top->childContexts()[1]->localDeclarations().size(), 2);
//Member completion
- QCOMPARE(CompletionItemTester(top->childContexts()[3], \
"A<int>().").names.toSet(), (QStringList() << QString("m") << \
QString("A")).toSet());
- QCOMPARE(CompletionItemTester(top->childContexts()[3], "TInt().").names.toSet(), \
(QStringList() << QString("m") << QString("A")).toSet()); + // NOTE: constructor A \
is not listed, as you can't call the constructor in this way + \
QCOMPARE(CompletionItemTester(top->childContexts()[3], "A<int>().").names.toSet(), \
(QStringList() << QString("m")).toSet()); + \
QCOMPARE(CompletionItemTester(top->childContexts()[3], "TInt().").names.toSet(), \
(QStringList() << QString("m")).toSet());
//Argument-hints
kDebug() << CompletionItemTester(top->childContexts()[3], \
"TInt(").parent().names;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic