clangd_extensions.nvim
clangd_extensions.nvim copied to clipboard
Feature Request: Show all overrides of a virtual method
Hi, I thought that querying a list of all overridden methods of a virtual method would be pretty nice. For example when having this code base:
class Base {
public:
virtual void foo() = 0;
};
class Impl1 : public Base {
public:
void foo() { std::cout << "In Impl1\n"; } override
};
class Impl2 : public Base {
public:
void foo() { std::cout << "In Impl2\n"; } override
};
When the cursor is on any foo declaration / definition and executing :ClangdShowOverrides this could open a new split in which you would get something like this:
Base::foo()
- Impl1::foo()
- Impl2::foo()
As in :ClangdTypeHierarchy you could jump to definition by hovering any line.
Thanks, Steve
I can think of one way to implement this: use reference container to find out the class in which the function declaration is, get its type hierarchy, ask for the ASTs of all the types in the hierarchy (the response to the typeHierarchy requests contains the location), and look at every CXXMethod in the AST to find a function which matches the name and signature.
I'm trying to think of something smarter
https://neovim.io/doc/user/lsp.html#vim.lsp.buf.implementation() should accomplish this
I found out that this can be done with the plugin "Trouble". @HighCommander4, it is probably using what you are suggesting.