When browsing a codebase, you often want to view the definition of a particular class, method, or variable. However, sometimes you want to do the reverse; you want to see where a particular class, method, or variable is used. Typically this involves using your editor’s text search, or a command line tool, such as
ack. Unfortunately, text searches may return false positives, such as log file data, or similarly named constructs. The problem is that you want to search code not text.
RubyMine has text search, but it also includes a powerful, code-based usage search. Usage search is smarter than text search, because RubyMine is aware of code constructs such as classes, methods, and variables. This results in a more accurate search; allowing you to quickly view and navigate actual usages. In this post, we’ll explore RubyMine’s usage search on OS X.
To find where a particular class, method, variable (instance or local), or parameter is used, place your cursor on it, and press
alt/option + F7. Results will be displayed in the Find tool window.
command + alt/option + Up/Down navigates the results. Use
F4 to jump to the source code of a particular usage.
Recent usage search results can be viewed again with
command + E.
Find Usages in File
By default, find usages is scoped to the entire project. To scope it to the current file, use
command + F7.
command + G and
command + shift + G navigate the results.
command + alt/option + F7 can be used to show usages inline. Instead of displaying usages in the Find tool window, they appear in a pop-up window.
RubyMine’s usage search demonstrates an advantage an IDE has over a text editor. By being aware of code constructs, such as classes, methods, and variables, IDEs can offer powerful tools that allow you to quickly and accurately explore a codebase.
About the Author