Incorrectly thinks a variable is global when renaming [message #1857193] |
Mon, 23 January 2023 12:44  |
Eclipse User |
|
|
|
I have a bunch of simple PHP files that produce reports, none of them include each other. Any global variables they use from includes is denoted by a comment at the top of the file. Renaming a variable in one renames it in all of them because PDT thinks the variable is global. I never need to rename a variable across an entire project and it would be quite nice to have an option to limit the refactor to the current file, even if it has to be on the rename dialog. I first noticed this issue in the 12-2021 build. Updated to the 12-2022 build and the issue is still there. My current work around is find/replace because deselecting all the other files in the rename dialog is very time consuming.
I now have several files with variable names that make no sense because I did not notice this behavior until several weeks later.
|
|
|
Re: Incorrectly thinks a variable is global when renaming [message #1857200 is a reply to message #1857193] |
Tue, 24 January 2023 06:45  |
Eclipse User |
|
|
|
I working on a huge code base written many years ago. We're trying to implement multi-threading and I'm incharge of cleaning up global variables (sigh!)
My strategy is to move all global variables to a class, and then individual threads will use instances of that class and the globals will be accessed through class instance and -> operator.
In first go, I've compiled a list of global variables using nm by finding B and D group object names. The list is not complete, and incase of static variables, I don't get file and line number info.
The second stage is even more messy, I've to replace all globals in the code base with classinstance->global_name pattern. I'm using cscope Change text string for this. The problem is that in case of some globals, their name is also being used locally inside functions, and thus cscope is replacing them as well.
|
|
|
Powered by
FUDForum. Page generated in 0.04327 seconds