Bug 560405 - Indexer indexes derived target folder (performance gain)
Summary: Indexer indexes derived target folder (performance gain)
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: Next   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-21 11:38 EST by jan baeyens CLA
Modified: 2020-02-22 16:23 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jan baeyens CLA 2020-02-21 11:38:16 EST
If you create .cpp or .h files in the target folder (I know why would you, still someone did) these are picked up by the indexer.
As the target folders are "derived" I would have thought these would not be picked up by the indexer.
Looking at possible duplicates I see this comment making the same observation.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=527173#c2

I assume derived code is not part of the "source code" and as such should not be picked up by the indexer. More importantly leaving out derived folders should improve indexer performance.
Comment 1 Jonah Graham CLA 2020-02-22 11:18:28 EST
There is a performance (and probable correctness) gain in doing this. However, I don't think the correct flag is derived, but rather whether the file is in what CDT considers a source folder.

Derived c and c++ files should be considered and indexed if they are source files, e.g. Lexer or parser output files. 

I think the issue in Bug 527173 comment 2 is about core build and therefore how core build identifies what is a source folder and not. IIUC the MBS is what today identifies what are source folders.

In comment 0, which build system are you referring to?
Comment 2 jan baeyens CLA 2020-02-22 14:01:14 EST
In my  case the prebuild command of MBS copied a .cpp file in ${projDir}/${config}/sketch.
Which I think is a really bad idea, but as usual not everybody agrees with me (more details in https://github.com/Sloeber/arduino-eclipse-plugin/issues/1143).
The indexer picked up the cpp file, and this resulted in a unresolved include which triggered Sloeber to add a library (read triggered Sloeber to resolve the unresolved include). All this is good and desired behaviour but I had not expected the indexer to pick up the cpp file so it was also "unexpected" behaviour to me.

I fully understand there are pro's and con's to parsing derived files. I personally would exclude them, but I'm biased because I don't use cpp file generating tools like lexer. 

If I really want to exclude ${projDir}/${config} from the indexer I can
simply exclude it from build. Looks a bit weird but this way I proved the indexer -by default- indexes derived resources.

I don't know how CDT distinguishes between source files and not source files. I thought that was based on the file extension and tags like derived and exclude from build.
Comment 3 Jonah Graham CLA 2020-02-22 16:23:23 EST
I agree - the indexer and the MBS should "agree". If builder does not consider files in ${projDir}/${config}/sketch as part of the project, neither should the indexer. I just don't agree that derived should be the universal flag for that. Of course in a sketch project it can be though.