Author Topic: Code-Completion sometimes can't deal with const in the right side.  (Read 5483 times)

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #1 on: September 01, 2009, 01:40:50 pm »
works fine here. :D
Can't reproduce this problem.
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.

Offline photon3108

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #2 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
}

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #3 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.
« Last Edit: September 04, 2009, 04:12:19 am by 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?

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #4 on: September 14, 2009, 11:29:49 am »
I can confirm this issue.It is relative to right const.
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?

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #5 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)
         {
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?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code-Completion sometimes can't deal with const in the right side.
« Reply #6 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.
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.