Tools to understand new code: Find

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.

Find References

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 MaxAngleDegrees from 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:

find_maxang

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 CParticleBoxEmitter::deserializeAttributes
  • This method is called from CParticleSystemSceneNode::deserializeAttributes
  • It’s also polymorphic and might be called from CSceneLoaderIrr::readSceneNode

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.

Find Symbol

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:

find_mgr

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.

Summary

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.

Learn More

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.

Visual Assist supports Visual Studio Community 2013

Yesterday, Microsoft announced Visual Studio Community 2013—a terrific addition to its lineup of IDEs. In addition to being fully featured, Visual Studio Community 2013 provides access to the Visual Studio extensibility ecosystem, including to Visual Assist. This extensibility should appeal to every user of the non-extensible Express Edition.

vsCommunity2013

If you install Visual Studio Community 2013, any build of Visual Assist numbered 2001 or greater will install to your IDE. If you are new to Visual Studio or migrating from an Express Edition, find out if you qualify for an Academic or Personal License of Visual Assist. The audiences for these licenses of Visual Assist overlap the targeted audience of Visual Studio Community 2013.

And to the multitude of developers who have asked us to make Visual Assist work in the Express Edition, we finally have a positive answer.

Visual Assist build 2052 is available

It’s not often one gets to write “introduce” twice in a sentence, but here goes: Visual Assist introduces Introduce Variable.

Introduce Variable, a powerful refactoring for C/C++ and C#, replaces an expression with a meaningfully named variable. In classic Visual Assist style, the UI to Introduce Variable is simple and understated:

  1. Select an expression to replace
  2. Invoke Introduce Variable, e.g. from the Quick Refactoring Menu (Shift+Alt+Q)
  3. Decide to replace just the selection, or also the occurrences that follow
  4. Specify a signature in the dialog that opens

Introduce Variable makes an educated guess at the intended scope of the new variable, adding braces to your code if necessary. Default type and name are reckoned from your selection.

introduceVariableDialog

Other improvements in Visual Assist build 2052 focus on navigation: new filters make searching for symbols faster, Goto Member jumps from more places, and Goto Related makes it easier to jump within a class and to constructors.

Visual Assist build 2052 requires software maintenance through 2014.11.05.

Learn more about Introduce Variable, check out the complete list of what’s new, or download the installer.