Code::Blocks Forums

User forums => Help => Topic started by: photon3108 on August 30, 2009, 03:42:44 pm

Title: Code-Completion sometimes can't deal with const in the right side.
Post by: photon3108 on August 30, 2009, 03:42:44 pm
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
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: ollydbg on September 01, 2009, 01:40:50 pm
works fine here. :D
Can't reproduce this problem.
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: photon3108 on September 04, 2009, 03:30:40 am
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
}
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: blueshake on September 04, 2009, 04:10:27 am
just wait for some time ,I will check into it after my computer back.
or you can have a try with cc-branch.
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: blueshake on September 14, 2009, 11:29:49 am
I can confirm this issue.It is relative to right const.
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: blueshake on September 15, 2009, 07:11:57 am
I got the reason why the right const don't work.
here is the reason:
for these codes,
Code
ClassB const & b_1, 
when the parser meet const ,it clear the m_Str;
see codes in void ParserThread::DoParse() in parserthread.cpp
Code
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.
Code
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)
         {
Title: Re: Code-Completion sometimes can't deal with const in the right side.
Post by: ollydbg on September 21, 2009, 04:40:14 pm
Quote
I 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.