In my previous post as a guest contributor, I talked about moving between declaration and implementation of various symbols: methods, classes, variables… and even include files. The functionality helps a lot, but there are other tools in Visual Assist that we definitely need to know. This time, let’s have a look at some find commands in Visual Assist.
As in my last post, I will use Irrlicht Engine as my example project.
With Go To, we can jump from declaration to implementation smoothly. This is nice, but unfortunately, life is not that easy. Usually when we see an interesting variable or function, we would like to see not only its declaration or implementation, but how and where is it used.
Previously, we were curious about
CParticleBoxEmitter.cpp. We know than it’s a 32-bit integer variable used to generate rotations. But, where it is actually initialized?
With Visual Assist, press Shift+Alt+F (the default shortcut for its Find References) and you will see a dialog like this:
The window lists places where our variable is used. It seems that the variable is loaded from a settings file.
The basic list is, of course, nothing special—Visual Studio has a similar feature. But with Visual Assist, we have more benefits:
- You can see a context of each line in a tooltip
- You can view only Read or Write references
- As with most Visual Assist tools, it works faster than the equivalent in Visual Studio. (Also, I’ve found that the results with Visual Assist are a bit more narrow.)
We can extend our search and go further:
MaxAngleDegrees is deserialized in
- This method is called from
- It’s also polymorphic and might be called from
We can even track the whole system of loading scene nodes. We can now see the flow of this functionality. Without Find References, it would be very problematic.
Tip: You can also use Find References in File to, as the name suggests, see references to a symbol in the file you are actually in.
Finding references for a given symbol is very useful, but what if you do not know an exact name? Maybe you just have some basic idea of what you want to find.
For instance, in Irrlicht Engine, we might want to see the implementation and an interface of a scene manager. Find References would not work well this time because we don’t have a reference. You could use the normal search box of Visual Studio, but you will probably end up with too many symbols and lines to check.
In this instance, you can use Find Symbol (Shift+Alt+S by default) in Visual Assist. Find Symbol opens a dialog box with all symbols from the current solution (and even third-party libraries!) I typed “manager scene” in the edit control of my dialog and got the following:
As you can see, “manager scene” is related to several different classes. We can double-click the most interesting object and go to its definition.
The Find Symbol dialog supports more advanced options as well, like searching only in classes (this will skip defines and free functions) or extending your search to files outside your solution.
Find Symbol is definitely much more convenient that the common search dialog of Visual Studio.
Our tool bag now contains two very important items: Go To and Find. We can now easily search for various symbols in solutions, easily go to their implementation/declarations. And with the Find commands, we are able to search for all occurrences of a given symbol and create a story of how it is used in a project.
You can learn more about the Find commands in the documentation for Visual Assist:
This article was contributed by Bartlomiej Filipek, who writes at Code And Graphics — a technical blog about C++ and OpenGL.