The Find Usages option in MPLAB® X IDE opens a dialog box for searching open or active projects for usages of classes, structures, variables, macros, functions, or files within the project's source code. The results of the search displayed in the Usages window permit fast navigation to key search points in the project source. Find Usages application and caveats are presented here.
Accessing Find Usages
There are three ways of accessing the Find Usages functionality of MPLAB X:
Method 1: Edit Menu | Method 2: Class Dialog | Method 3: Source Window Right Click |
---|---|---|
ALT + F7 can also be used to initiate Find Usages.
Find Usages Scope
Once Find Usages is selected for the appropriate portion of code (i.e., classes, structures, variables, macros, functions, or files), select the appropriate scope. The scope refers to whether a specific project (or all the open projects) is searched. In the following screenshot, the cursor is on a BLMedia_LoadFile() function call when Find Usages is invoked.
Running Find Usages
Click Find to run the utility and display the locations where the selection was used in the Usages window.
An example of the results is shown below. In this case, a header file called USB.h was used:
Usage Window Buttons
These buttons are located on the left-hand side of the Usages window:
Refresh | Expand/Collapse Tree | Logical View | Physical View | Previous Occurence | Next Occurrence |
---|---|---|---|---|---|
- Refresh button re-runs the Find Usages utility.
- Expand/Collapse Tree button compresses/decompressed the +/- for each node of the results.
- Logical View button organizes the results tree to match the logical project window organization.
- Physical View button organizes the results tree to match the physical arrangement of the files (e.g., .inc file hierarchy on the hard drive).
- Previous/Next Occurrence buttons move through the find usages results in the source editor.
General Find Usages Caveats
Moving through usages is difficult when the Usages window is minimized (meaning not pinned). When the Usages window is not pinned, it disappears each time a different usage is selected. For this reason, select Pin at the top right of the Usages window to make browsing between instances simpler.
Do not select Minimize Window.
The cursor location and text selection can confuse Find Usages and may result in errors such as "Find Usages Cannot Be Applied In this Context" and "The original element being refactored is not available." For this reason, it may be beneficial to use Find Usages within the Classes dialog shown in Accessing Find Usages section. The first screenshot shows the result from running Find Usages on whitespace on a blank line while the second shows the results from running Find Usages on a commented configuration macro: