Cross-referencing is a technique where Project Analyzer resolves the meaning of every word of code and records the location of every call, variable use and so on.
A reference has a source location (line in source code), a target location (such as procedure, variable or control) and type (read, write, call, event raise etc.). A reference usually forms a file dependency between the source and the target files.
To work out where a variable, constant, procedure, or other code construct is referenced in your code, bring up the References to window. You do it by right-clicking an item in the main screen. You can right-click:
You also get to this window via the References button in the Listings windows and Constants and Enums window.
Double-click a line to view the code location in hypertext. Click the report button to generate a report of the references.
Throw
statement. A reference of type "Data" usually indicates a Catch
block that catches this specific exception class.
If an exception class is never instantiated, it means that type of exception is never thrown. It is semi-dead code.Open this window by selecting References in the View menu.
This window lets you list references in several ways:
Set the Source and Target files and click
to display a list of references between these files. If the target is <Self>, references within the file itself are displayed. The <All> target means all references in the source file are displayed. Double-click a line to view the code location in hypertext.You can sort the references by clicking the column headers. Press the report buttons or Ctrl+R to get a listing of all the references currently displayed.
Data references | Explanation |
---|---|
Read | Read a variable, user-defined type field, constant or enum constant. |
Read (Nothing) | Read an object variable or field to determine if it is Nothing. Example: If x Is Nothing Then |
Write | Write a value to a variable or user-defined type field. |
Write+Read | First write to a variable, then read it in a single statement. Example: For x=1 To... |
Read+Write | First read a variable, then write to it in a single statement. Example: x+=1 |
Instantiate object | Instantiate an object of a class. |
Instantiate | Assign a newly instantiated object to a variable. Examples: Set x=New Class, Set x=CreateObject(...) |
Allocate | Allocate a dynamic array with ReDim . |
Clear | Clear a variable or an array. This is the equivalent of a Write with a "nothing" value. Examples: Set x=Nothing, Erase x |
Write handle | Write newly created API resource handle to a variable. This is a special case of a Write. |
Release | Read variable and release the API resource handle contained in it. This should be paired with Write handle. |
Pass ByRef |
Pass a variable by reference to another procedure. The target procedure may modify the variable. |
Pass ByRef |
Pass a variable by reference to another procedure. The target procedure does not modify the variable. |
Return value | Set the function return value. |
Address | Take the address of a procedure or a variable via AddressOf, StrPtr, VarPtr or ObjPtr. |
Call references | Explanation |
Call | Call a procedure. Property read and write are shown as a Call to the appropriate accessor (Set/Let/Get). |
Call late-bound | Call a procedure, late-bound. This call may (or may not) execute at run-time. It depends on the actual contents of the related late-bound object variable. |
Call Overloads | A call that is subject to Overloads, or Overrides Overloads, in that the call may go to several methods based on the data type of the parameter(s). (VB.NET) |
Call Overrides | A call to an Overrides method. The call may go to a method in several classes based on what class the object represents at run-time. (VB.NET) |
Raise | Raise an Event via RaiseEvent. |
Trigger | Trigger an event (Initialize event is triggered through As New ). |
Handles | Handle an Event with the Handles keyword. (VB.NET) |
AddHandler from/to | AddHandler statement adds a handler for an event. The execution goes like this: event → handler. From=event, to=handler. (VB.NET) |
Show | Show a form via the Show or ShowDialog method. |
Other references | Explanation |
Implements | Implements statement or keyword is used to implement an interface or its member. |
Inherits | A class Inherits another. (VB.NET) |
Data | Target is being used as a data type. Example: As MyClass . |
Use | Any other use, such as the use of a module name. |
Special: A structured write reference such as x.y=3 is treated as follows:
References | Happens when |
---|---|
read x, write y | x is an object and y is its member variable |
write x, write y | x is a variable defined "As MyType", y is a field in Type MyType (classic VB) |
read x, write y | x is a variable defined "As MyStructure", y is a field in Structure MyStructure (VB.NET) |