C++ Clean Eclipse Index,它与代码不同步

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3008293/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:46:12  来源:igfitidea点击:

Clean Eclipse Index, it is out of sync with code

c++eclipseeclipse-cdt

提问by Vincent Scheib

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.

我通过 Linux 上的链接资源将 Eclipse 与 C++ 代码一起使用。代码分析索引似乎已损坏(Goto 定义使光标靠近但未在定义上)刷新资源并不能修复它,重新启动 Eclipse 也不能。

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

有没有办法刷新索引并重建它?

回答by Josh Kelley

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.

另外,我确定您已经这样做了,但请确保您正在运行最新版本的 Eclipse CDT。当前版本似乎比以前的版本具有更可靠的索引。

回答by Stephen

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

http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg10390.html 中,“重建”、“使用修改后的文件更新”或“刷新所有文件”之间的区别:

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.

重建:仅适用于整个项目。清除索引并从头开始索引文件。取消后,它会为您留下空索引或部分索引。

使用修改后的文件更新:适用于资源选择。检查单个文件是否已更改时间戳或扫描仪配置并更新已更改文件的索引。

刷新所有文件:适用于资源选择。更新索引中的选定文件。索引没有被清除,取消操作是安全的。

回答by TheAnvil

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

转到您的项目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.
  • 使用'project specific settings',
    (或 on 'Configure Workspace Settings...')执行此操作。
  • 取消选择'Enable Indexer'命中Apply
  • 选择'Enable Indexer'命中Apply

This should completely wipe out and rebuild the index.

这应该完全清除并重建索引。

回答by Pavel Zdenek

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

以上都不适合我(Eclipse Indigo),索引仍然损坏并且拒绝正确重建。直到应用这个:

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

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.

Eclipse 不再将您的项目视为 C++ 项目。选择菜单File/New/Convert to a C/C++ project。索引源代码需要一段时间。

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.

我仍然想知道 Eclipse 怎么会像这样不受控制地用脚射击自己。我怀疑安装其他软件包会触发它。就我而言,也许 JavaScript 支持。

回答by Shay Perlstein

delete onlythe .pdomfile 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).

删除.metadata.plugins\org.eclipse.cdt.core 下的.pdom文件有帮助,在将 Neon.2 升级到 Neon.3 后我搞砸了索引器,这似乎解决了问题。(此评论已存在于上方,但不允许在此处确认)。

回答by Chris Dennett

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

您是否尝试将 -clean 添加到 eclipse 可执行文件的命令行中?

回答by kibrom

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

Eclipse 不再将您的项目视为 C++ 项目。选择菜单 File/New/Convert to a C/C++ project。索引源代码需要一段时间。为我工作

回答by Schaki

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

我开始尝试 Josh Kelleys 和 mmmmms 的答案但没有任何运气,但我最终通过检查我的包含路径来修复它。

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.

通过在项目资源管理器中右键单击“您的项目”,然后选择“属性”--> C/C++ 常规--> 路径和符号--> 包含来编辑包含路径。

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 --> Okand rebuild index if you're asked to.

我看到了三种语言选项,Assembly、Gnu C、Gnu C++。在开始添加路径之前选择正确的路径(可能是 Gnu C++)。添加所有路径后,--> 应用--> 确定并根据要求重建索引。

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

当它应该是MyProject/folder时,我错误的工作区路径看起来像MyProject/ 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.

对我来说,即使在重建索引之后,“问题”视图也总是更新缓慢。要确保错误仍然存​​在,请双击问题条目,以便 eclipse 打开/重新加载有问题的文件。这对我来说似乎经常需要更新“问题”视图。

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

我真的不知道是日食还是我的 scm 搞砸了。无论如何,希望它可以帮助某人!

I use Luna and builds with an external makefile.

我使用 Luna 并使用外部 makefile 进行构建。

回答by radsdau

I found that I had the global indexer set to 'Use the build configuration specified in the project's indexer settings', and the project's indexer set to NOT use project specific indexer settings. Regardless, it was using the same fixed configuration for the indexer regardless of which configuration I had selected. The fix: Window-Preferences, C/C++, Indexer. Select "Use active build configuration" in section "Build configuration for the indexer".

我发现我将全局索引器设置为“使用项目索引器设置中指定的构建配置”,并且项目的索引器设置为不使用项目特定的索引器设置。无论如何,无论我选择哪种配置,它都为索引器使用相同的固定配置。修复:窗口首选项、C/C++、索引器。在“为索引器构建配置”部分中选择“使用活动构建配置”。

Happy days.

快乐的时光。