Browsing and Analysis
Browsing and Analysis
Source Insight provides many ways to locate symbols, and review symbolic information in your projects. This is one of Source Insight's important strengths.
This section describes briefly the Source Insight features that help you access symbol information.
Symbolic Parsing
Source Insight parses your project files while you edit. You can locate classes, methods, functions, and more without having to compile your files.
Once a file has been added to your project, the names and locations of the symbol definitions in the file are stored in the project's symbol database. The symbol definition can be found quickly using the several techniques. Remember, you can right-click on many objects in Source Insight to bring up the object's shortcut menu. Some of the following commands are on the shortcut menus.
Symbol Navigation Commands
These commands are the most commonly used commands to navigate to symbol definitions, or function callers.
Jump to Definition command
The Jump to Definition command jumps to the declaration of the symbol under the cursor. See “Jump To
Definition” on page 232. Type Alt+equal or Ctrl+click with the left mouse button to invoke the command. You
can also right-click on the symbol and use the shortcut menu to run this command.
Tip:
To jump to a definition, hold down Ctrl and click on its name.
After locating the symbol, the symbol's file is opened, displayed in a window, and the symbol name is selected. If you have more than one symbol with the same name in your project, Source Insight will ask you to select the one you want.
Note:
Another way to jump to a definition is to have the Context Window open. Let the Context Window show the definition. If you want to jump there, just double click on the Context Window.
Jump to Caller command
The Jump to Caller command jumps to the caller of the function under the cursor. See “Jump To Caller” on page 232. You can right-click on the symbol and use the shortcut menu to run this command. This only works
if the object under the cursor is a function name.
Refresh Relation Window command
This command causes the Relation Window to update to reflect the currently selected symbol. For example, if the Relation Window is setup to show function references and you have the cursor on a function name, then this command will make the Relation Window show all the references to the function. This command is
useful is you normally keep the Relation Window locked to prevent automatic updates. See “Relation Window” on page 297.
Browser Mode
The Edit > Browser Mode command toggles Source Insight's Browser-Mode. When Browser-Mode is on, your source code becomes read-only, and acts like a web browser. For example, single clicking on the name of a
function in a function call will jump to the function's definition. See “Browser Mode” on page 162.
72 Source Insight 4 User Guide
Browsing and Analysis
Project Symbol List Window
The Project Symbol List Window displays a list of all project symbols. You can type into the text box to perform prefix and name fragment name matching. The Project Window is a mode-less window. Therefore, as you select symbols in the Project Window, the Context Window and Relation Window will update and provide
information about the selected symbol. See “Project Windows” on page 48.
The Project Symbol Categories Window is a hierarchical view, where symbols are listed by category. For example, all global variables are grouped together; all structs are grouped together, and so on. For structured
types, such as classes, structs, and unions, the Project Window can expand them to show their members. See
“Project Symbol Categories” on page 273.
Call Trees and Reference Trees
The Relation Window is another Source Insight innovation that shows the relationship between the currently selected symbol and other things. The Relation Window can show function call trees, class hierarchies, structure members, reference trees, and more. It works in the background tracking what you are selecting and
showing relationship information automatically. See “Relation Window” on page 91.
Context Window
The Context Window is a Source Insight innovation that provides symbolic information automatically. It tracks what you are selecting and typing and shows you relevant symbol declarations automatically, while
you work. See “Context window” on page 88.
Command Line Symbol Access
You can jump to a symbol by using the -f <symbol> option on the Source Insight command line when you start Source Insight.
For example: sourceinsight4 -f myfunc
This will position to the symbol named "myfunc".
You can also simply give the name of the symbol on the command line without a special command option, as though it were a file name. In this case, Source Insight will try to determine whether the symbol you specified is either a file, or a parsed symbol. You can list as many symbols on the command line as you like, just as with file names.
For example: sourceinsight4 myfunc fcb init
This will open all files where the symbols "myfunc", "fcb", and "init" are located. See “Command Line Syntax” on page 127.
Finding References to Symbols
The Search > Lookup References command can be used to quickly find all references to the word in the current selection. For example, to find all calls to TextOut, put the insertion point inside of the TextOut identifier and run the Lookup References command. A Search Results window will be built which will list all references
found. See “Lookup References” on page 248.
The Relation Window can also be used to show references automatically to the word in the current selection.
See “Relation Window” on page 297.
The Project Search Bar and the Search > Search Project command can be used to search across your whole project, using a powerful keyword and name fragment based search. This is like an Internet search across your project.
Source Insight 4 User Guide 73
Browsing and Analysis
See “Search Project” on page 319.
See “Project Search Bar” on page 271.
Reference Highlights
Source Insight can automatically highlight references to the symbol at the cursor position. For example, you can click in a variable name, and all references to the variable will be highlighted. The references are context sensitive, so a symbol in a different scope will not get highlighted. This works for variables, class members, functions, and so on.
Figure 3.5 Example of reference highlights
You can enable this feature by selecting Options > File Type Options, then selecting the option "Highlight references to selected symbol".
Once enabled, if you click on a symbol name, all references to it in that file are highlighted. The highlight will only appear if more than one instance appears in the file.
To change the color or format of the highlight, select Options > Style Properties and edit the "Reference
Highlight" style. By default, it only changes the text and background colors.
Creating a Project Report
The Project Report command will create a report file containing a symbol cross-reference, and statistics
about the files in your project. See “Project Report” on page 279.
Smart Renaming
The Smart Rename command is a context-sensitive form of a global search & replace. It renames an identifier across all project files using a smart context-sensitive method. Source Insight's search index makes the search very fast. This is the easiest way to replace a single word identifier with a new string. In addition, you can have Source Insight produce a log of replacements in the Search Results window. Each replacement line
is listed, along with a source link to the location of each line that was changed. See “Smart Rename” on page 326.
74 Source Insight 4 User Guide
Browsing and Analysis
Comparing Files and Directories
Source Insight can compare two files and show differences. It can also compare two different directories.
Comparing Files
The Tools > Compare File command compares two files to show differences within the files. It shows two files side by side and highlights the differences. This is a fancy version of the diff
command. See “Compare Files”
on page 169. See “File Compare” on page 199.
The Tools > Compare with Backup File command compares the current file with a backup version of the same
file. See “Compare with Backup File” on page 170.
Comparing Directories
The Tools > Directory Compare command compares two file directories to show what files are different
between them. See “Directory Compare” on page 185.
Source Insight 4 User Guide 75