Clean Eclipse Index, it is out of sync with code

狂风中的少年 提交于 2019-12-28 02:26:04

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


delete only the .pdom file under .metadata.plugins\org.eclipse.cdt.core helps, I got the indexer screwed after upgrading Neon.2 to Neon.3 and this seems to solve the problem. (this comment already exists above but am not allowed to confirm it up there).




回答6:


Did you try adding -clean to the command line for the eclipse executable?




回答7:


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. worked for me




回答8:


I started with trying Josh Kelleys and mmmmms answers without any luck, but I finally fixed it by checking my include paths.

One way to see them are in the Project Explorer, expand project and there should be an entry "Includes". Inside that, check for a small yellow warning triangle on each include path. If that triangle is present eclipse most likely doesn't recognize the path.

The include paths are edited through right-clicking on "Your project" in the Project explorer, then choose "Properties" --> C/C++ General --> Paths and Symbols --> Includes.

I see three language options, Assembly, Gnu C, Gnu C++. Choose the correct one before starting to add paths (likely Gnu C++). After adding all the paths, -->Apply --> Ok and rebuild index if you're asked to.

My erroneous workspace paths looked like MyProject/MyProject/folder when it was supposed to be MyProject/folder.

For me the "Problems"-view is always slow to update, even after rebuilding index. To be sure that the error is still there, double-click the problems entry so that eclipse opens/reloads the file in question. This often seems necessary for me to update the "Problems" view.

I don't really know if it was eclipse or my scm that messed it up. Anyway, hope it helps someone!

I use Luna and builds with an external makefile.



来源:https://stackoverflow.com/questions/3008293/clean-eclipse-index-it-is-out-of-sync-with-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!