FreeRTOS and Eclipse Indexer for >5K Lines Source Files

Eclipse has a great built-in source code parser and browser (aka ‘Indexer’). It is basically a built-in compiler which parses the source files and assists the user with code completion and navigation help, making Eclipse this awesome productivity tool. On the downside this background parsing could potentially slow down things, and therefore Eclipse has some default settings to prevent this. Unfortunately, the FreeRTOS Kernel ‘tasks.c’ file is above-and-beyond of a ‘sane’ source file and will hit the default limits: as a result the ‘tasks.c’ file is not indexed and things like ‘Open Declaration‘ might not work for the file ‘tasks.c’.

Open Declaration

Open Declaration

The issue is that the FreeRTOS file ‘tasks.c’ is huge: over 5000 lines of code!

💡 my rule of thumb is: if a source file is well above 1000 lines, it is better to think about to split it off into smaller modules.

More than 5000 Lines for tasks.c

More than 5000 Lines for tasks.c

Why would this be a problem? Well, Eclipse has a built-in limit (Scalability) to avoid indexing files too large and to affect performance. You can see this if you open the Outline view:

Outline View Disabled due scalability

Outline View Disabled due scalability

But there is an easy solution: click on that link or go directly to the Scalability preference. The usual default setting is 5000 lines, so increase that to say 6000:

Increased Scalability for more than 5000 lines of code

Increased Scalability for more than 5000 lines of code

Press Apply, do not forget to close tasks.c (if open) and open the file again with the Outline view open: now it shall show all the symbols for it:

Outline View for tasks.c

Outline View for tasks.c

Now Indexing, symbol browsing, or jumping to declaration works for tasks.c :-).

This does not only apply for FreeRTOS tasks.c, but for any huge files going beyond the 5000 lines scalability setting: such huge files are not a problem for Eclipse (I have seen software stacks with >10k lines of code in a single file!), it is only that the 5K setting kicks in. But now you know as for everything in Eclipse: there is a setting for it. A good indication to check if the Indexer is working is using the Outline View.

Happy Indexing 🙂

Links

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.