Support “Find references” in C code in Builder

Something I really miss in Builder is a way to search my entire project for the identifier under the cursor. In Vim with fugitive.vim installed, with the cursor over an identifier, I type:

:Ggrep <Ctrl-R><Ctrl-w><enter>

where Ctrl+R Ctrl-W inserts the word under the cursor into the command line. This places the result of git grep for the symbol into the quickfix buffer, which I can then navigate through. (I use [q and ]q from unimpaired.vim.) In the past I had something similar set up with cscope which was fancier and knew how to search for call-sites versus function pointers etc.

I believe that, in languages where it is supported, right-clicking the identifier and choosing “Find references” should open a list of occurrences of the identifier. Sadly, I have never seen this working. In C projects, as far as I can understand this is because it is implemented in terms of IdeSymbolResolverInterface.find_references_async whose only non-trivial implementation is in ide-lsp-symbol-resolver.c which is only used when speaking to an LSP language server; but support for using clangd as an LSP is disabled out of the box in favour of gnome-builder-clang (which is much faster but has a different featureset).

I wonder whether a better fallback than showing an error when the menu item is activated for an unsupported language might be to do a global search in the project for the symbol under the cursor? That way for simple cases of the flat namespace of C symbols it would actually work pretty well, despite being low-tech.

(Of course it would be even nicer to teach gnome-builder-clang to do a libclang-based search.)

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.