Author Topic: About "Find declaration of" and "Find implementation of"  (Read 6932 times)

Offline wuyihao

  • Single posting newcomer
  • *
  • Posts: 4
About "Find declaration of" and "Find implementation of"
« on: February 10, 2010, 05:01:37 am »
Why does Code::Blocks often can't find the right one or can't even find anything?But there should have been a right one.I found it by searching in files.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: About "Find declaration of" and "Find implementation of"
« Reply #1 on: February 10, 2010, 05:04:36 am »
Test code,please.
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 wuyihao

  • Single posting newcomer
  • *
  • Posts: 4
Re: About "Find declaration of" and "Find implementation of"
« Reply #2 on: February 10, 2010, 05:06:48 am »
Of course,I did.And it passed

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: About "Find declaration of" and "Find implementation of"
« Reply #3 on: February 10, 2010, 05:09:57 am »
Please paste your code fragment then other guys can test and help you.  :D
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 wuyihao

  • Single posting newcomer
  • *
  • Posts: 4
Re: About "Find declaration of" and "Find implementation of"
« Reply #4 on: February 10, 2010, 05:18:54 am »
Code
int main()
{
    int n;
    n = 2;
    return 0;
}

It's simple,isn't it?But when I click the "Find the declaration of "n".It says,"Not found: N".Why?
Thank you!!!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: About "Find declaration of" and "Find implementation of"
« Reply #5 on: February 10, 2010, 05:39:15 am »
Ok, because n is a local variable, so, the parser in CodeCompletion didn't record it in the TokenTree.
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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5513
Re: About "Find declaration of" and "Find implementation of"
« Reply #6 on: February 10, 2010, 07:10:13 am »
can we make it work ?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: About "Find declaration of" and "Find implementation of"
« Reply #7 on: February 10, 2010, 07:27:20 am »
can we make it work ?

Yes, but that will increase the parsing time, also, we have many many local variables which have the same name....  
Currently, function implementation body was just skipped by the parser.

Anyway, Parsing the function body is just like parsing "class declaration". for example:

Code
void main(){

int a;
int b;
}

So, we have "three tokens" here: "main", "a" , "b" (both "a" and "b" have a parent pointer pointing to "main").


Then only time we parse the function body was when we are doing the "autocompletion stage", at this time, we need to collect the "local tokens", but we only parse the function body where our caret locates. Once we move to another function body, the "local tokens" will be regenerated when we do a "autocompletion stage".

New idea:
According to the real time parse theme, why not collect and update the "local tokens" in real-time? if the local tokens were collected already, we don't need to parse the local blocks when doing "autocompletion stage" any more. Using this method, we don't increase the batch parsing time. Really good idea!!!

« Last Edit: February 10, 2010, 07:29:45 am by 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.

Offline wuyihao

  • Single posting newcomer
  • *
  • Posts: 4
Re: About "Find declaration of" and "Find implementation of"
« Reply #8 on: February 10, 2010, 02:18:56 pm »
I see.Thank you!
But actually,I don't really understand what you mean.
« Last Edit: February 10, 2010, 02:28:30 pm by wuyihao »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: About "Find declaration of" and "Find implementation of"
« Reply #9 on: February 11, 2010, 04:24:24 am »
mean that it is not a bug. :D
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?