Bug 80671

Summary: code completion not working in try/catch code blocks
Product: [Applications] kdevelop Reporter: Hendrik Kueck <TNHCWXSTKSJX>
Component: Code completionAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 3.0.3   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Hendrik Kueck 2004-04-30 05:36:30 UTC
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.
   }
}
Comment 1 Hendrik Kueck 2004-04-30 05:41:49 UTC
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. 
Comment 2 Hendrik Kueck 2004-07-21 22:25:31 UTC
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. 
Comment 3 Hendrik Kueck 2004-08-22 23:29:26 UTC
still present in 3.1
Comment 4 Adam Treat 2005-03-11 19:04:35 UTC
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 );