News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Code-Completion sometimes can't deal with const in the right side.

Started by photon3108, August 30, 2009, 03:42:44 PM

Previous topic - Next topic

photon3108

If I declare a member function "int const & get_number( int const & index )" in header

file and define it in source code file, when I use them at another file, Code-Completion

can't rise well.


Actually, I don't know what makes this problem, is const in the right side or not.

Does someone has the same problems, too? How to solve it?

Thanks

ollydbg

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

photon3108

C::B v.5716

I can't reproduce this problem, too. In fact, Code-Completion often doesn't wrok for

me, but I can't find the rules of these problems. I suspect "const" in the right side of

data type because I often see it when these problems happened.

for example,

void ClassA::function( ClassB const & b_1,
                              ClassB & b_2 )
{
    // The problem happened here.
    b_1.xxxxxx

    // Code-Completion works well here.
    b_2.xxxxxx
}

blueshake

just wait for some time ,I will check into it after my computer back.
or you can have a try with cc-branch.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

blueshake

I got the reason why the right const don't work.
here is the reason:
for these codes,
ClassB const & b_1,
when the parser meet const ,it clear the m_Str;
see codes in void ParserThread::DoParse() in parserthread.cpp
else if (token==ParserConsts::kw_const)
        {
            m_Str.Clear();
        }

as we known, m_Str stored the variable type,and if const is in
the right position and the parser clear the m_Str,the varible type will become
nothing ,that's why cc don't work.
I think the parser should do nothing when it meet const.
here is the patch.
Index: plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- plugins/codecompletion/parser/parserthread.cpp (revision 5784)
+++ plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -455,7 +455,7 @@
         }
         else if (token==ParserConsts::kw_const)
         {
-            m_Str.Clear();
+            //m_Str.Clear();
         }
         else if (token==ParserConsts::kw_extern)
         {
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

ollydbg

QuoteI think the parser should do nothing when it meet const.
Hi, You just comment out the related code, so the parser will skip all the "const".
Can we find a more convenient way?
I personally think skipping "const" is not a good manner.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.