Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: wuyihao on February 10, 2010, 05:01:37 am

Title: About "Find declaration of" and "Find implementation of"
Post by: wuyihao 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.
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: blueshake on February 10, 2010, 05:04:36 am
Test code,please.
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: wuyihao on February 10, 2010, 05:06:48 am
Of course,I did.And it passed
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: ollydbg on February 10, 2010, 05:09:57 am
Please paste your code fragment then other guys can test and help you.  :D
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: wuyihao 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!!!
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: ollydbg 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.
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: killerbot on February 10, 2010, 07:10:13 am
can we make it work ?
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: ollydbg 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!!!

Title: Re: About "Find declaration of" and "Find implementation of"
Post by: wuyihao on February 10, 2010, 02:18:56 pm
I see.Thank you!
But actually,I don't really understand what you mean.
Title: Re: About "Find declaration of" and "Find implementation of"
Post by: blueshake on February 11, 2010, 04:24:24 am
mean that it is not a bug. :D