Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on July 24, 2010, 11:08:14 am

Title: reparse header file will lost all the implementation information
Post by: ollydbg on July 24, 2010, 11:08:14 am
I have found that the mechanism of remove files in the Tokenstree has a big problem. I guess this problem exist for a long time, both in trunk and cc_branch. I have recently confined it in ccbranch.

For example, I have a simple project contains only one cpp and h file.
h file
Code
class TestStruct
{
    int aaaaa;

    int Test();
};

cpp file:
Code

#include "main.h"
int TestStruct::Test(){

}

Now, if we are editing the "header file", then this file will be "reparsed" in real-time mode.

When one file is reparsed, the tokenstree firstly remove the header file( all the tokens belong to that file will be removed), then the header file get reparsed.

The problem is: when header file was removed from Tokenstree, all the function implementation information will be removed too, thus, the some token information in cpp file are lost.

I debug the CC, and found the reason:

1, when delete a token, tokenstree check if the token is belong to some file else, if yes, the token will not be deleted.
2, when a token is deleted, all its child token will be deleted.

Now, see the Token "class TestStruct", it is purely belong to the header file, so, this Token and its children are deleted. As a result, we lost the token "function int TestStruct::Test()".

That's why sometimes, we edit the header file, and "goto implementation of some function" failed. :D

Currently, we don't have some ways to solve this. the only way is: when the header file need to reparsed, the associated cpp file will forced to reparse again.  :D
Title: Re: reparse header file will lost all the implementation information
Post by: MortenMacFly on July 25, 2010, 10:00:10 am
Currently, we don't have some ways to solve this. the only way is: when the header file need to reparsed, the associated cpp file will forced to reparse again.  :D
...or disabling re-parsing in real-time?
Title: Re: reparse header file will lost all the implementation information
Post by: ollydbg on July 25, 2010, 10:04:05 am
I personally prefer we do not need to "delete tokens" when we do a "reparse", we just parse the file again. Because once a token need to be added, it firstly check if already exists, if yes, only some information like( line number ....) will be updated. :D
Title: Re: reparse header file will lost all the implementation information
Post by: Loaden on July 25, 2010, 10:27:02 am
I personally prefer we do not need to "delete tokens" when we do a "reparse", we just parse the file again. Because once a token need to be added, it firstly check if already exists, if yes, only some information like( line number ....) will be updated. :D
I personally think, we need find the reason!
And some times, we need delete a token true.