IntelliJ IDEA 2017.1 Help

Finding Usages in Project

IntelliJ IDEA provides different search options depending on whether you are searching for usages of a class, method, field, parameter, or throw statements, and extends search for usages to the files in supported languages. For example, in CSS, XML and HTML files you can search for the usages of styles, classes, tags and attributes.

Search for usages extends to the Cucumber step definitions as well.

Explore search results in the Find tool window.

Finding usages of a symbol in a project

  1. Select a symbol to find usages for. To do that, place the caret within the desired symbol in the editor, or click the symbol in the Project tool window. You can also select symbol in the UML Class diagram
  2. Do one of the following:
    • On the main menu, choose Edit | Find | Find Usages
    • Choose Find Usages on the context menu
    • Press Alt+F7.
  3. In the Find tool window, explore search results. Use the commonfilter button to represent search results in meaningful groups by type of usage.

While analyzing the search results, you can at any time open the search options dialog box by clicking click /help/img/idea/2017.1/settings1.png in the Find tool window or by pressing Ctrl+Shift+Alt+F7.

Finding usages of implemented and overridden methods

In the PHP context, IntelliJ IDEA also applies the Find Usages functionality to implemented and overridden methods. Consider the following example:

  1. Create an interface, an abstract class that implements it, and two classes that extend the abstract class:
    1. Create an interface MyInterface with a foo() method.
    2. Create an abstract class MyAbstractClass that implements MyInterface.
    3. Create a class MyClass that extends MyAbstractClass and implement the foo() method required by the interface and overrides the methods of the parent class.
    4. Create a class MyClassWithDelegate that extends MyClass and implement foo() with a delegate.
    5. Create variables $b and $c that call foo() from MyClass and MyClassWithDelegate respectively:
    <?php interface MyInterface { //press Alt-F7 on foo() here public function foo(); } abstract class MyAbstractClass implements MyInterface { public function foo () { // TODO: Implement foo() method. } } class MyClass extends MyAbstractClass { public function foo() { parent::foo(); // TODO: Change the automatically generated stub echo "foo"; } } class MyClassWithDelegate extends MyClass { public function foo() { foo(); } } $b = new MyClass(); $b->foo(); $c = new MyClassWithDelegate(); $c->foo();
  2. From MyInterface, invoke Find Usages for foo() by pressing Alt+F7 or choosing Edit | Find | Find Usages on the main menu. By default, IntelliJ IDEA shows only delegates to the super method and method calls:
  3. To find also the methods that implement or override the base method, click /help/img/idea/2017.1/settings1.png in the Find tool window. Then in the Find Usages. Method Options dialog that opens, select the Include overloaded methods check box and click Find. As a result, all the usages of the foo() method are found in all the classes that implement or extend MyInterface:

See Also



Last modified: 18 July 2017