T O P I C R E V I E W |
mnicolella |
Posted - Aug 26 2013 : 1:14:17 PM I think this might be a built-in VS feature, but currently if I go to Solution Explorer, expand a header file, right click on a class, I can select "Derived Types" which gives me a tree view of every class that inherits from the selected type.
I'd like this extended so I can select a virtual function and it can show me a tree view of all classes in the hierarchy that override the function.
I'd also like the reverse - show me all classes in the hierarchy that *don't* override a particular virtual function - this can help track down bugs if you have a case that every class 'should' override it.
|
5 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Aug 26 2013 : 10:01:59 PM What are you looking to do with Find References? Looking for all code that mentions the items being searched for is the purpose of Find References, so for a class this does include member function implementations.
You can remove the #include lines by right clicking in the Find References Results window and turning Off "Comment and string references", which should help a bit.
Depending on what you are doing, you could try highlighting the file cpp file that contains the class member implementations and pressing Delete, to remove this file, and all references inside the file from the results list, thus manually filtering it. |
mnicolella |
Posted - Aug 26 2013 : 5:24:56 PM Cool, found that. BTW I'm using VS2012.
It would be nice if there were more filters on the Find References page. Currently it looks like it just looks for every line of code that mentions the type, but i would like filters to turn on/off:
when looking for references to "Foo" - member function implementations ie void Foo:Method() { - #include lines ie "#include "Foo.h"" - variable declarations ie Foo* foo; - inheritance ie void Bar : public Foo {
|
feline |
Posted - Aug 26 2013 : 4:29:02 PM I was hoping you were not using deep hierarchies, but it was a slim hope.
For the right click menu, use "Refactor (VA X) -> Find References", or use the Shift+Right click menu, especially if you are using VC6. |
mnicolella |
Posted - Aug 26 2013 : 3:29:56 PM I understand abstract virtual functions, but that doesn't help dealing with deep hierarchies
Thanks for the tip about Find References - is there a way to include this in the right-click context menu? The 'find all references' that appears there brings me to the VS 'find symbol results', not the VAX version |
feline |
Posted - Aug 26 2013 : 3:06:22 PM If you run Find References on the function, in the base class, and right click in the Find References Results window and turn On "Inherited and overridden references" then VA will list the derived, overridden functions.
Unfortunately this won't show you functions that have not been overridden, but if you want to enforce this in C++ you can use abstract virtual functions in the base class, and these functions can even be given a default implementation which can be called in the derived class. This way the compiler will catch any functions that were not overridden.
http://stackoverflow.com/questions/2089083/pure-virtual-function-with-implementation |
|
|