Version: 3.0.3 (using KDE KDE 3.2.0KDE 1.2) Installed from: RedHat RPMsRedHat RPMs class A { ... }; int main() { A a1; a1.<code completion> works. try { aInst.<code completion> fails. } catch( exception e ) { aInst.<code completion> fails. } }
Aargh. Was not done editing. Stupid tab key behaviour. Anyway: ignore the first post. And again: class A { ... }; int main() { A a1; a1.<code completion> works. try { A a2; a1.<code completion> works. a2.<code completion> fails. } catch( exception e ) { A a3; a1.<code completion> works. a3.<code completion> fails. } } I only noticed this in the try and catch code blocks. Code completion works fine in for(...) { } code blocks for example.
Just wanted to report that this bug is still present in the latest release (3.0.91) and also rather annoying. At least if you are like me and use exceptions and code completion a lot.
still present in 3.1
CVS commit by treat: * Add support for completion in try/catch blocks BUGS:80671 M +37 -0 cppcodecompletion.cpp 1.164 M +3 -0 cppcodecompletion.h 1.56 --- kdevelop/languages/cpp/cppcodecompletion.cpp #1.163:1.164 @@ -1480,4 +1480,7 @@ void CppCodeCompletion::computeContext( computeContext( ctx, static_cast<SwitchStatementAST*>( stmt ), line, col ); break; + case NodeType_TryBlockStatement: + computeContext( ctx, static_cast<TryBlockStatementAST*>( stmt ), line, col ); + break; case NodeType_DeclarationStatement: computeContext( ctx, static_cast<DeclarationStatementAST*>( stmt ), line, col ); @@ -1554,4 +1557,38 @@ void CppCodeCompletion::computeContext( } +void CppCodeCompletion::computeContext( SimpleContext*& ctx, TryBlockStatementAST* ast, int line, int col ) +{ + if ( !inContextScope( ast, line, col ) ) + return; + + computeContext( ctx, ast->statement(), line, col ); + computeContext( ctx, ast->catchStatementList(), line, col ); +} + +void CppCodeCompletion::computeContext( SimpleContext*& ctx, CatchStatementListAST* ast, int line, int col ) +{ + if ( !inContextScope( ast, line, col, false, true ) ) + return; + + QPtrList<CatchStatementAST> l( ast->statementList() ); + QPtrListIterator<CatchStatementAST> it( l ); + while ( it.current() ) + { + CatchStatementAST * stmt = it.current(); + ++it; + + computeContext( ctx, stmt, line, col ); + } +} + +void CppCodeCompletion::computeContext( SimpleContext*& ctx, CatchStatementAST* ast, int line, int col ) +{ + if ( !inContextScope( ast, line, col ) ) + return; + + computeContext( ctx, ast->condition(), line, col ); + computeContext( ctx, ast->statement(), line, col ); +} + void CppCodeCompletion::computeContext( SimpleContext*& ctx, DeclarationStatementAST* ast, int line, int col ) { --- kdevelop/languages/cpp/cppcodecompletion.h #1.55:1.56 @@ -129,4 +129,7 @@ private: void computeContext( SimpleContext*& ctx, WhileStatementAST* ast, int line, int col ); void computeContext( SimpleContext*& ctx, SwitchStatementAST* ast, int line, int col ); + void computeContext( SimpleContext*& ctx, TryBlockStatementAST* ast, int line, int col ); + void computeContext( SimpleContext*& ctx, CatchStatementListAST* ast, int line, int col ); + void computeContext( SimpleContext*& ctx, CatchStatementAST* ast, int line, int col ); void computeContext( SimpleContext*& ctx, DeclarationStatementAST* ast, int line, int col ); void computeContext( SimpleContext*& ctx, ConditionAST* ast, int line, int col );