Version: 3.0.0b2 (using KDE 3.1.3) Installed from: Mandrake Linux Cooker i586 - Cooker Compiler: gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk) OS: Linux (i686) release 2.4.22-10mdk I'm having trouble from time to time with kdevelop refusing to complete code. Just now I think I found one issue, I suspect there are others. It seems the completion parses comments, but only C++ style comments. If I add a . or a -> to the comment line then auto-completion won't work on the line below. oh, the completion is for code in the project, not from persistant class store, in case there is a difference.
Oh, forgot to mention, the . or -> has to be placed last on the line.
I've noticed the same thing in KDevelop-3.1.1: void addFoo(const QString &bar) { if(foo) { someList_.append( bar ); /* code completion works here */ // A comment with dot. /* doesn't work here!! */ } /* works here again */ } Really weird.
*** Bug 78255 has been marked as a duplicate of this bug. ***
CVS commit by treat: * C++ style comments present issues with finding the expr so I'm matching for them and replacing them with empty C style comments of the same length for purposes of finding the expr. BUGS:72692 CCBUGS:72692 M +1 -1 codeinformationrepository.cpp 1.35 M +30 -3 cppcodecompletion.cpp 1.155 --- kdevelop/languages/cpp/codeinformationrepository.cpp #1.34:1.35 @@ -152,5 +152,5 @@ QValueList<KTextEditor::CompletionEntry> QValueList<Tag> CodeInformationRepository::getBaseClassList( const QString& className ) { - kdDebug( 9007 ) << "CodeInformationRepository::getBaseClasseList()" << endl; + kdDebug( 9007 ) << "CodeInformationRepository::getBaseClassList()" << endl; if ( className.isEmpty() ) --- kdevelop/languages/cpp/cppcodecompletion.cpp #1.154:1.155 @@ -463,8 +463,35 @@ void CppCodeCompletion::slotTextChanged( enum { T_ACCESS, T_PAREN, T_BRACKET, T_IDE, T_UNKNOWN }; -int CppCodeCompletion::expressionAt( const QString& text, int index ) +int CppCodeCompletion::expressionAt( const QString& contents, int index ) { kdDebug( 9007 ) << k_funcinfo << endl; + /* C++ style comments present issues with finding the expr so I'm + matching for them and replacing them with empty C style comments + of the same length for purposes of finding the expr. */ + + QString text = contents; + QRegExp rx( "(//([^\n]*)(\n|$)|/\\*.*\\*/|\"([^\\\\]|\\\\.)*\")" ); + rx.setMinimal( TRUE ); + + int pos = 0; + while ( (pos = rx.search( text, pos )) != -1 ) + { + if ( rx.cap( 1 ).startsWith( "//" ) ) + { + QString before = rx.cap( 1 ); + QString after; + after.fill(' ', before.length() - 5 ); + after.prepend( "/*" ); + after.append( "*/" ); + text.replace( pos, before.length() - 1, after ); + pos += after.length(); + } + else + { + pos += rx.matchedLength(); + } + } + int last = T_UNKNOWN; int start = index; @@ -840,6 +867,6 @@ void CppCodeCompletion::completeText( ) QString textToReparse = getText( recoveryPoint->startLine, recoveryPoint->startColumn, line, showArguments ? column - 1 : column ); - //kdDebug(9007) << "-------------> please reparse only text" << endl << textToReparse << endl - // << "--------------------------------------------" << endl; +// kdDebug(9007) << "-------------> please reparse only text" << endl << textToReparse << endl +// << "--------------------------------------------" << endl; Driver d;