Bug 500020 - CDT indexer does not notice changes to header files referenced from other projects
Summary: CDT indexer does not notice changes to header files referenced from other pro...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 9.0.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-20 05:55 EDT by Derek Foster CLA
Modified: 2020-09-04 15:18 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Derek Foster CLA 2016-08-20 05:55:37 EDT
In my workspace, I have multiple C/C++ projects. For the sake of discussion, consider them to be projects A, B, and C, such that projects B and C include header files from project A, and also list project A as a project dependency.

If I make changes to a header file in project A, then when I hit Ctrl-S ("Save"), the modified header, as well as source files in project A which depend on that modified header, automatically get reindexed by the CDT indexing engine. However, projects B and C which also depend on that header file do not automatically get reindexed. Unless I anticipate the problem and right-click projects B and C in the project explorer, and select "Index -> Rebuild" (or in some rare cases, "Index -> Update Modified Files" is sufficient), the projects still seem to act as if they reference a copy of the pre-modification version of the header file, at least as far as searches are concerned. This is a problem, because the header file no longer actually contains those old contents.

This behavior can sometimes result in bizarre results if I later do searches on items contained in the modified header file: items in the search pane may highlight parts of my header file incorrectly, or may take me to the wrong locations in it if I doubleclick on them. Features like "find references" on items in the header file may work or not work depending on which project I invoke them from. ("not work" typically means taking me to a location somewhat near where it was supposed to, but not necessarily to the right line of code or to text which is aligned with the syntax in the file.)

The only way I have found to reliably fix the situation is to select all three projects and execute "Index -> Rebuild". Since these are moderately large projects, this reindexing is a lengthy and painful operation to have to perform on a regular basis (such as every time I modify a header file in project A).

I would like to never have to explicitly perform manual reindexing, and for Eclipse to automatically reindex modified files and files that depend on them when necessary. In order for this to happen, Eclipse needs to understand that a header file can be referenced from a project which does not contain it, and that for the purpose of indexing, this dependent project's view of the header file should be considered to be modified (and hence need reindexing) whenever the header file itself is modified.

Please make Eclipse projects aware that if projects B and C depend, directly or indirectly, on project A, that modifying header files in project A should also trigger reindexing in those header files as they appears in projects B and C, as well as in any source files in those projects which reference the modified header file.

This is one of my top complaints when using CDT. The workspace I usually use has around 25 projects in it, so I am encountering this problem very frequently. It is a constant irritation to have to keep manually reindexing projects and then waiting for several minutes for the indexer to finish. I would really love for this problem to go away. I was hoping that the Eclipse Neon release (including CDT Version: 9.0.0.201606062011) would fix this problem, but since it hasn't, I am filing this bug report.

Note that this bug report seems very similar to bug #310837. However, that is marked as "resolved, fixed" in CDT version 7.0, and I have definitely still been observing the problem as of version 9.0.
Comment 1 Nathan Ridge CLA 2016-08-20 20:16:25 EDT
I can confirm that I see this problem as well, although in my experience, "Index -> Update with Modified Files" on the dependent project is generally sufficient to resolve it, and since that's fairly quick compared to "Index -> Rebuild", I haven't found this to be that big of a deal.

I do agree that it would be nice if the updating just happened automatically.