Bug 527582 - Renaming or moving a header file malforms header #includes
Summary: Renaming or moving a header file malforms header #includes
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 9.3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-21 16:52 EST by David Leeds CLA
Modified: 2021-11-08 11:25 EST (History)
3 users (show)

See Also:


Attachments
sample project (99.25 KB, application/zip)
2017-11-30 08:41 EST, Martin Oberhuber CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Leeds CLA 2017-11-21 16:52:00 EST
When I rename a header (.h) file in a C project, the #includes referring to that header file are not only updated, but they are changed to relative paths, which is NOT desirable.

For example, renaming foo.h to bar.h, might change #include <foo.h> to #include "../../../bar.h"

Fix:
Be aware of library (<...>) style header includes vs. relative path ("...") style header includes.
* For library style includes, change the name only (even if the file changes directories), e.g. #include <foo.h> to #include <bar.h>.
* For relative path style header includes, update the full path for moves and renames.  E.g. #include "../foo.h" to #include "../../bar.h".

This may be the same issue as Bug 491638, which has not been resolved for ~1.5 years.
Comment 1 Martin Oberhuber CLA 2017-11-30 08:41:46 EST
Created attachment 271714 [details]
sample project

Using cdt-9.4 (Oxygen.2rc2), I also noticed that #include "foo" is changed into #include <bar> when renaming the file from foo to bar.

Steps to reproduce:
1. Import attached project on Linux
2. Right-click memberdefs.h and rename to bar.h
--> The #include "" style is changed to an #include <> style, 
    which may break the code.