[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop-bugs
Subject:    [Bug 203950] Code completion should not show constructors and
From:       Hamish Rodda <rodda () kde ! org>
Date:       2010-05-07 0:31:46
Message-ID: 20100507003146.B90EF3FB79 () immanuel ! kde ! org
[Download RAW message or body]

https://bugs.kde.org/show_bug.cgi?id=203950


Hamish Rodda <rodda@kde.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #6 from Hamish Rodda <rodda kde org>  2010-05-07 02:31:18 ---
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;

-- 
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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic