Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse CDT move-file and rename-file refactoring?

Is there a way in Eclipse CDT to do the following automatic refactorings?

  1. move file: move a source/header file to another project folder and have every #include directive relative to the moved file automatically updated
  2. rename file: rename a source/header file and have every #include directive relative to the renamed file automatically updated

If there is no such feature in CDT, is there another tool for Linux that would easily let me do this?

Thank you very much.

like image 478
Francesco Feltrinelli Avatar asked Nov 18 '10 17:11

Francesco Feltrinelli


People also ask

How do I Rename a file in eclipse?

In Project Explorer view, right-click file to be renamed and select Refactor | Rename -or- select it and go to Refactor | Rename from the Menu Bar. A Rename File dialog will appear. Enter the file's new name.

Can you Rename projects in Eclipse?

To rename the project, simply right-click the project and select "Refactor/Rename...". Fill in the new name and click OK.

How do I change a file name in STS?

In the text editor, double-click on the class name to select it. Now do Alt-Shift-R (or right-click on selected text and select Refactor>Rename in the context menu) and rename the class, then click Enter/Return. The STS Refactor/Renaming wizard should take over and rename both the class and the file from there.


1 Answers

I have not been able to find either of these features in CDT 8.0. I would suggest putting in a feature request at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=CDT.

I just did a bunch of your item 2. (header file renaming, #include renaming, include-guard renaming). This took about 3 minutes using eclipse's Search and Replace. Not bad considering I've never done it before. Presumably this might have taken under a minute if "header file rename" was implemented in CDT. Not a big savings, in my book, esp when you consider how infrequently this is done. But then, I had to rename ~20 files. The semi-manual approach I used wouldn't scale as well as CDT refactor impl probably would.

like image 95
timblaktu Avatar answered Sep 21 '22 15:09

timblaktu