From kdevelop-bugs Fri May 07 00:31:46 2010 From: Hamish Rodda Date: Fri, 07 May 2010 00:31:46 +0000 To: kdevelop-bugs Subject: [Bug 203950] Code completion should not show constructors and Message-Id: <20100507003146.B90EF3FB79 () immanuel ! kde ! org> X-MARC-Message: https://marc.info/?l=kdevelop-bugs&m=127319240214824 https://bugs.kde.org/show_bug.cgi?id=203950 Hamish Rodda changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED --- Comment #6 from Hamish Rodda 2010-05-07 02:31:18 --- commit b9b0cc9340f41f1bdcd748514e0855d330715b99 Author: Hamish Rodda 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 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(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().").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().").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; -- Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. _______________________________________________ KDevelop-bugs mailing list KDevelop-bugs@kdevelop.org https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-bugs