Author Topic: reparse header file will lost all the implementation information  (Read 4376 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5339
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: reparse header file will lost all the implementation information
« Reply #1 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?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5339
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: reparse header file will lost all the implementation information
« Reply #2 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
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: reparse header file will lost all the implementation information
« Reply #3 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.