Skip to content

Feature Request: Show all overrides of a virtual method #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SteveWolligandt opened this issue Apr 2, 2025 · 3 comments
Open

Feature Request: Show all overrides of a virtual method #71

SteveWolligandt opened this issue Apr 2, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@SteveWolligandt
Copy link

SteveWolligandt commented Apr 2, 2025

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

@p00f p00f added the enhancement New feature or request label Apr 2, 2025
@p00f
Copy link
Owner

p00f commented Apr 2, 2025

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

@HighCommander4
Copy link

@SteveWolligandt
Copy link
Author

I found out that this can be done with the plugin "Trouble".
@HighCommander4, it is probably using what you are suggesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants