Fixing the Eclipse Index


One of the greatest features in Eclipse is the Indexer: it parses automatically my code in the background. It creates all the needed information so I can browse around my sources. I can use the Open Declaration context menu in the source code:

Open Declaration Context Menu

Open Declaration Context Menu

Another way is to click into the variable/include/etc and press the F3 key. Or to hold the CTRL key pressed and hover over it with the cursor to hyperlink it:

Hyperlinking with the CTRL key pressed

Hyperlinking with the CTRL key pressed

The Indexer knows as well my macros and grays out things if not active or disabled. But sometimes things simply look wrong: I know that my macro is enabled, but the editor still shows it grayed out?

Wrong Indexer? Macro block igrayed out.....

Wrong Indexer? Macro block grayed out…..

I’m sure that I have defined PL_HAS_TEMPERATURE in my header file, and I properly have included it. Still eclipse thinks it is not defined or not set to one?

One first thing I try is to rebuild the index. For this I select the project and select the menu Index > Rebuild:

Rebuilding the Index

Rebuilding the Index

This usually fixes things for me.

If not, then there is a problem with the project or workspace settings for the Indexer: the project settings for the Indexer are accessible in the project properties. The workspace settings are found in Window > Preferences > C/C++ > Indexer:

Indexer settings with disabled heuristics and using active build configuration

Indexer settings with disabled heuristics and using active build configuration

What I have found out is that ‘Allow heuristic resolution of includes‘ is causing inaccurate results. As in my example above,the indexer is not correctly using the includes if heuristics are enabled. The solutions is to disable heuristics.

The other setting is for the active build configuration: I make sure I have ‘Use active build configuration‘ enabled. That way the Indexer is switching the data base based on the build configuration too.

With these options the result is now correct:

Fixed Indexer: showing macro correctly

Fixed Indexer: showing macro correctly

Happy Indexing :-)

5 thoughts on “Fixing the Eclipse Index

  1. Pingback: Eclipse Editor Scalability | MCU on Eclipse

  2. Pingback: Compiler Defines and Eclipse Editor Highlighting | MCU on Eclipse

  3. Pingback: Top 10 Customization of Eclipse Settings | MCU on Eclipse

  4. Nice, that didn’t solve my problem but it pointed me in the right direction. I was seeing a lot of my symbols not showing up as being indexed. Some of my class types would be green and some would stay black.

    Solution:
    Increase the Cache Limits in the same window as listed in the article. We have a rather large C++ project that was exceeding the cache limit.

    Like

    • ah, that might explain a similar problem I had: I used to rebuild the index to solve it. I have many projects in my workspace, some with shared folders and linked files. It looks like increasing the cache limits solved that problem :-)

      Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s