Find Usages

The Find Usages option in MPLAB X 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 3 ways of accessing the Find Usages functionality of MPLAB X shown below:

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

As shown in the above screenshots, 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 is searched or all open projects. In the screenshot below 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

The buttons on the left hand side of the Usages Window have the following functionality.

Refresh Expand/Collapse Tree Logical View Physical View Previous Occurance Next Occurrance
  • Refresh re-runs the Find Usages utility.
  • Expand/Collapse Tree compresses/decompressed the +/- for each node of the results.
  • Logical View organizes the results tree to match the logical project window organization.
  • Physical View organizes the results tree to match the physical arrangement of the files. (For example, .inc file hierarchy on the hard drive)
  • Previous/Next Occurrence moves 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:


At the top right of the Usages window instead of


At the top right of the Usages window to make browsing between instances simpler.

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 Class Dialog shown in step 1. 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:


20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
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.