cquery
cquery copied to clipboard
Index only files from compile_commands.json
How does cquery act for source files which are not included in compile_commands.json? I noticed that when I'm opening such files, cquery generates a lot of diagnostics (probably by compiling without arguments) which pollute "problems" window.
I know about indexer's and diagostics' blacklist options but wouldn't it be much easier to just have an options to disable indexing for any source file not listed in compile_commands.json, and for any header file which is not included by any listed file.
cquery currently always indexes files that are opened in the editor. The blacklist is meant for maintaining performance on large projects, when not everything can be indexed.
I see. Are there any architectural limitations of vscode or cquery that prevent adding of such option? Will you accept PR?
BTW, I've played a bit with blacklist options and I can't say they work for me (I can file a new issue for that, if needed). I want to exclude all sources in tests directories and all headers in 3rdparty directories from indexing and showing diagnostics, so I've added the following in my settings:
"cquery.index.blacklist": [
".*/tests/.*",
],
"cquery.diagnostics.blacklist": [
".*/3rdparty/.*",
],
Now I still get tests indexed whenever I open them, though all diagnostics go away when I close those files.
But some headers in 3rdparty show some weird diagnostics, probably from partial compilations during editing and these don't go away which is very annoying.
Should diagnostics' blacklist option prevent them from appearing no matter what?
Yes, PRs for this are welcome (including a config option). I haven't played with the blacklists in a while and there have been some changes in those files; I would not be surprised if there are issues. I'n actively working on getting E2E testing in a better situation so we don't have these type of regressions :)
@jacobdufault I'd like to fix this, but after a couple hours poking around, I don't see any simple way to make it happen, and my understanding of the code is still incomplete. Any guidance would be appreciated.
You should be able to add a config option in config.h[1], and then handle that config in ShouldIgnoreFileForIndexing[2]
1: https://github.com/cquery-project/cquery/blob/master/src/config.h 2: https://github.com/cquery-project/cquery/blob/master/src/message_handler.cc#L285-L287