Find Usages

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
Find%20Usages%20Edit%20Menu%20Selection.png Find%20Usages%20Class%20Selectoin.png Find%20Usages%20Source%20Selection.png

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.

Find%20Usages%20Scope%20Screen.png

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:

Find%20Usages%20Results.png

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.png
Expand%20or%20Collapse%20Tree.png
Logical%20View.png
Physical%20View.png
Find%20Previous%20Occurance.png
Find%20Next%20Occurance.png
  • 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.

Pin%20Icon.png

Do not select Minimize Window.

Minimize%20Icon.png

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:

Find%20Usages%20Cannot%20Be%20Applied%20In%20This%20Context.png
The%20original%20element%20being%20refactored%20is%20not%20available.png
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.