Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean Eclipse Index, it is out of sync with code

I'm using Eclipse with C++ code via linked resources on Linux. The code analysis index seems to be corrupted (Goto definition lands the cursor close to, but not on, the definition) Refreshing resources doesn't fix it, neither does restarting Eclipse.

Is there a way to flush the index and rebuild it?

like image 787
Vincent Scheib Avatar asked Jun 09 '10 17:06

Vincent Scheib


4 Answers

Right-click on your project, go under the Index submenu, and choose either "Rebuild," "Update with modified files," or "Freshen all files."

I don't know the difference between those three options, but one of "Update with modified files" or "Freshen all files" usually fixes it for me.

Also, I'm sure you've already done this, but make sure that you're running the latest version of the Eclipse CDT. Current versions seem to have much more reliable indexing than previous versions.

like image 61
Josh Kelley Avatar answered Oct 31 '22 16:10

Josh Kelley


From http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg10390.html, the differences between "Rebuild," "Update with modified files," or "Freshen all files":

Rebuild: Works for entire projects, only. Clears the index and indexes the files from scratch. When cancelled it leaves you with an empty or partial index.

Update with Modified Files: Works on a resource selection. Checks on individual files whether the timestamp or the scanner-config has been changed and updates the index for the changed files.

Freshen All Files: Works on a resource selection. Updates the selected files in the index. The index is not cleared, it is safe to cancel the operation.

like image 30
Stephen Avatar answered Oct 31 '22 16:10

Stephen


Go to your project properties -> C++ general -> Indexer.

  • Do this with 'project specific settings',
    (or on 'Configure Workspace Settings...').
  • Deselect 'Enable Indexer' hit Apply.
  • Select 'Enable Indexer' hit Apply.

This should completely wipe out and rebuild the index.

like image 21
TheAnvil Avatar answered Oct 31 '22 15:10

TheAnvil


Neither of the above worked for me (Eclipse Indigo), index still broken and refusing to rebuild properly. Until applied this one:

http://slsam2.blogspot.com/2012/02/eclipse-cdt-index-not-working.html

The crucial bit of the linked post is this:

Eclipse no longer treats your project as a C++ project. Choose menu File/New/Convert to a C/C++ project. It takes a while to index the source code.

I still wonder how Eclipse can uncontrollably shoot itself in the foot like that. I suspect that installing additional packages can trigger it. Perhaps JavaScript support in my case.

like image 17
Pavel Zdenek Avatar answered Oct 31 '22 16:10

Pavel Zdenek