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

List:       kde-commits
Subject:    kdevelop/languages/cpp
From:       Adam Treat <manyoso () yahoo ! com>
Date:       2005-03-11 20:42:26
Message-ID: 20050311204226.86828EED3 () office ! kde ! org
[Download RAW message or body]

CVS commit by treat: 

* Change so that member access operator checking doesn't get in the way of
more complex expression such as foo.method()->anotherMethod. etc, etc  We 
still don't check the operator for the access operators on a method call, but
I'm working on it.


  M +22 -34    cppcodecompletion.cpp   1.166
  M +0 -1      cppcodecompletion.h   1.57


--- kdevelop/languages/cpp/cppcodecompletion.cpp  #1.165:1.166
@@ -113,5 +113,5 @@ public:
         }
 
-        QValueList<SimpleVariable>& vars()
+        const QValueList<SimpleVariable>& vars() const
         {
                 return m_vars;
@@ -637,4 +637,5 @@ QStringList CppCodeCompletion::splitExpr
                 if ( ch == '.' )
                 {
+                        current += ch;
                         ADD_CURRENT();
                         ++index;
@@ -686,4 +687,5 @@ QStringList CppCodeCompletion::splitExpr
                 else if ( ch2 == "->" )
                 {
+                        current += ch2;
                         ADD_CURRENT();
                         index += 2;
@@ -699,36 +701,6 @@ QStringList CppCodeCompletion::splitExpr
 }
 
-void CppCodeCompletion::evaluateAccessOp( QString expr, SimpleContext* ctx )
-{
-        //Remove the vars that don't correspond to the member access operator
-        //that we are using.  
-        
-        //TODO: Take into account the de-reference operator...
-        
-        bool dotOp = expr.endsWith( "." );
-        bool arrowOp = expr.endsWith( "->" );
-        
-        while ( ctx )
-        {
-                QValueList<SimpleVariable> &vars = ctx->vars();
-                QValueList<SimpleVariable>::Iterator it = vars.begin();
-                for ( ; it != vars.end(); ++it )
-                {
-                        SimpleVariable & var = *it;
-                        if ( ( var.ptrList.count() && !arrowOp ) ||
-                             ( !var.ptrList.count() && !dotOp ) )
-                        {
-                                var.type = "";
-                        }
-                }
-                
-                ctx = ctx->prev();
-        }
-}
-
 QStringList CppCodeCompletion::evaluateExpression( QString expr, SimpleContext* ctx )
 {
-        evaluateAccessOp( expr, ctx );
-
         d->classNameList = typeNameList( m_pSupport->codeModel() );
 
@@ -810,4 +782,12 @@ QStringList CppCodeCompletion::evaluateE
         exprList.pop_front();
 
+        bool dotOp = currentExpr.endsWith( "." );
+        bool arrowOp = currentExpr.endsWith( "->" );
+        
+        if ( dotOp )
+                currentExpr.truncate( currentExpr.length() - 1 );
+        else if ( arrowOp )
+                currentExpr.truncate( currentExpr.length() - 2 );
+                
         int leftParen = currentExpr.find( "(" );
 
@@ -838,6 +818,14 @@ QStringList CppCodeCompletion::evaluateE
         {
                 // find the variable type in the current context
-                QStringList type = ctx->findVariable( currentExpr ).type;
-                if ( !type.isEmpty() )
+                SimpleVariable var = ctx->findVariable( currentExpr );
+                QStringList type = var.type;
+                
+                //Remove the vars that don't correspond to the member access operator
+                //that we are using.  
+                //TODO: Take into account the de-reference operator...
+                bool correctAccessOp = ( ( var.ptrList.count() && arrowOp ) ||
+                                         ( !var.ptrList.count() && dotOp ) );
+                
+                if ( !type.isEmpty() && correctAccessOp )
                         return evaluateExpressionInternal( exprList, type );
 

--- kdevelop/languages/cpp/cppcodecompletion.h  #1.56:1.57
@@ -68,5 +68,4 @@ public:
         QStringList splitExpression( const QString& text );
         QStringList typeOf( const QString& name, const QStringList& scope );
-        void evaluateAccessOp( QString expr, SimpleContext* ctx );
         QStringList evaluateExpression( QString expr, SimpleContext* ctx );
 


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

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