Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » refactoring fails in cmake generated projects(In cmake generated projects the source of the main project is also linked in subprojects. That seems to cause refactoring to fail horribly.)
refactoring fails in cmake generated projects [message #1847517] Sat, 30 October 2021 10:19 Go to next message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 16
Registered: April 2020
Junior Member
When I let cmake generate an eclipse project from a checkout I face severe problems with refactoring.

I am using this to generate:
cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_VERSION=4.18 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j4 PATH_TO_REPOSITORY "${@:1}"


That will create a working project. However, the src of the main project is also linked in the subprojects (I have some depencies checked out from other repos).

When I am trying to refactor a class/function/variable name I mostly get a preview dialog in which some (not all) of the files are shown twice. Once from the main source and once from the source linked in the subprojects. Sometimes the preview dialog does not show. If that happens or if I happen to forget to uncheck one of the subproject sources, the refactoring goes horribly wrong (and this is not an overstatement).

I can just guess that eclipse is remembering the file pointer positions of each occurence and once you hit OK, it doesn't check what it's doing anymore. The result is something like this:

before refactoring:
void OldAndHopelesslyLongFunctionName(int a, int b) {
  int c;
  ...
}


expected result:
void NewName(int a, int b) {
  int c;
  ...
}


actual result:
void Newt c;
  ...
}


What's making this even more frustrating is that eclipse will automatically safe the refactored result without any chance of undoing.

Is there anyway around it? Maybe by just changing the cmake call or by adjusting the eclipse settings?

Kind regards
Re: refactoring fails in cmake generated projects [message #1847520 is a reply to message #1847517] Sat, 30 October 2021 11:09 Go to previous messageGo to next message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 16
Registered: April 2020
Junior Member
I've forgot to mention: When I delete the link in the subprojects it solves the issue until the next build after that the link is recreated.

Now it seems the cmake option -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE fixes that recreation. I've tried that option before but back then, I just deleted the cmake cache and not the link. That's why I thought it didn't help.

I think doing both (deleting the existing link and adding the option) fixed the issue.

I want to remark that the refactoring behaviour still seems a bit dangerous to me. I'm not denying that my setup was the reason for this issue but maybe the refactorer could have handled it in a better way (for example by detecting that it tried to change the very same file twice).

I think the issue is solved for me. Otherwise I'll get back to you.

Sorry to bother
Re: refactoring fails in cmake generated projects [message #1847528 is a reply to message #1847520] Sun, 31 October 2021 01:46 Go to previous message
Ravenous Bugblatterbeast is currently offline Ravenous BugblatterbeastFriend
Messages: 16
Registered: April 2020
Junior Member
Sorry again. I was wrong. ISSUE IS NOT SOLVED!

At some point (I think it was when I had to clean the cmake cache because I changed some warning levels) the link has been recreated and once again I didn't notice it and fell for the trap.
Previous Topic:indexer not working on *.cpp files
Next Topic:"terminated" message
Goto Forum:
  


Current Time: Mon Sep 26 12:48:04 GMT 2022

Powered by FUDForum. Page generated in 0.26116 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top