Eclipse有两个C / C ++索引器(fast& full):有什么区别? [英] Eclipse has two C/C++ indexers (fast & full): what's the difference?

查看:176
本文介绍了Eclipse有两个C / C ++索引器(fast& full):有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse CDT为C / C ++代码(Preferences> C / C ++> Indexer)提供了两个索引器。有没有人知道这两者之间有什么区别?



帮助文件不是完全启发:


CDT支持
附加索引器的贡献,其中2个索引器
提供默认CDT
版本:




  • 快速C / C ++索引器:提供最快的索引功能 -
    声明和交叉引用
    信息,这是推荐的
    索引器


  • 全C / C ++索引器:以
    性能为代价,提供更精确的索引
    功能 - 声明和
    交叉引用信息。



em>准确:它是否索引更多的东西,如果是这样的话?

解决方案

这是摘录描述他们的解析和索引的CDT页面( CDT / designs /解析概述)。它给出了一个很好的描述,差异是什么,快速索引器可以失败的地方:


解析和绑定解决方案是
缓慢的过程,这是一个问题
,因为用户期望代码编辑
功能,如内容帮助是
快。因此,CDT将
绑定信息存储在
命令中的名为index或PDOM
(Persisted Document Object Model)的磁盘
缓存中,以便能够提供
快速响应用户请求的功能。



构建索引涉及解析
所有项目中的代码,解决
所有的绑定和将
绑定到索引。索引是
,然后每次
,用户编辑文件时逐步更新。



旧版本的CDT支持三个
不同的索引模式,快速
索引,完整的索引和没有
索引。默认设置为
快速索引器,因为索引
大型项目可能是一个耗时的
进程。
快速和完全索引器之间的区别是
快速索引器将跳过已经解析一次的头文件

,而完整的索引器将始终为
每次包含
时,重新解析头文件。然而,重要的是
了解完整的索引器,
尽管它的名字,仍然不完全
准确。



当一个头文件包含在
源文件中,它受到
点定义的任何
宏的约束。一些库头使用宏
结合预处理器
条件(#ifdefs)到部分
包含头文件。有时这样的
a头文件在一个项目中包含超过
一次,如果
的标头依赖的宏是不同的
每次包含标题然后
标题的不同部分可能包含在不同源文件中的

在这种情况下,两个索引器都不会在
中准确,因为它首次遇到
时只会
索引头。



完整索引器将重新解析已经遇到的标题
,但是
将不会重新索引它们。因此,
包含头的源文件可能会更准确地解析
,但是
标题本身只会被编入
一次。完整的索引器比快速索引器要慢许多
,因为
的额外解析,但是
只是略微更准确。对于
这个原因,完全索引器不是
推荐,并已从
中删除当前版本的CDT。



每个项目都有与它相关联的单个PDOM
。 PDOM作为平面二进制文件存储在磁盘上的
上。
索引器将仅索引源文件包含
的标题,因此如果
项目中有一个.h文件,
不包含任何.c或
.cpp文件,那么通常它不会得到
索引。然而,有一个偏好
设置用于索引
项目中的所有文件。



Eclipse CDT provides two indexers for C/C++ code (Preferences > C/C++ > Indexer). Does anybody know what the exact difference is between these two?

The help file isn't exactly enlightening:

"CDT supports the contribution of additional indexers, with 2 indexers being provided with the default CDT release:

  • Fast C/C++ Indexer : provides fastest indexing capabilities - both declarations and cross reference information. This is the recommended indexer.

  • Full C/C++ Indexer : provides even more accurate indexing capabilities at the cost of performance - both declarations and cross reference information."

What does it mean to be more accurate: does it index more things, and if so which ones?

解决方案

Here is an excerpt from the CDT page describing their parsing and indexing(CDT/designs/Overview of Parsing). It gives a pretty good description of what the differences are and where the fast indexer can fail:

Parsing and binding resolution is a slow process, this is a problem because the user expects code editing features such as content assist to be fast. For this reason CDT stores binding information in an on-disk cache called "the index" or "the PDOM" (Persisted Document Object Model) in order to be able to provide features that respond quickly to user requests.

Building the index involves parsing all the code in a project, resolving all the bindings and writing those bindings to the index. The index is then incrementally updated every time the user edits a file.

Older versions of CDT support three different indexing modes, fast indexing, full indexing and no indexing. The default setting being the fast indexer because indexing a large project can be a time consuming process. The difference between the fast and full indexers is that the fast indexer will skip header files that have already been parsed once, while the full indexer will always re-parse a header file every time it is included. However it is important to understand that the full indexer, despite its name, is still not fully accurate.

When a header file is included in a source file it is subject to any macros that have been defined at that point. Some library headers use macros in conjunction with preprocessor conditionals (#ifdefs) to partially include a header file. Sometimes such a header file is included more than once in a project, if the macros that the header depends on are different each time the header is included then different parts of the header may be included in different source files. Neither indexer will be accurate in this scenario because it will only index the header the first time it is encountered.

The Full indexer will re-parse headers it has already encountered, but it will not re-index them. Therefore source files that include a header may be parsed more accurately, but the header itself will only be indexed the one time. The full indexer is much slower than the fast indexer because of the extra parsing it does, but it is only marginally more accurate. For this reason the Full indexer is not recommended and has been removed from the current version of CDT.

Each project has a single PDOM associated with it. The PDOM is stored on disk as a flat binary file. The indexer will only index headers that are included by source files, so if there is a .h file in the project that is not being included by any .c or .cpp file, then normally it won’t get indexed. However there is a preference setting for indexing all files in the project.

这篇关于Eclipse有两个C / C ++索引器(fast& full):有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆