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
- 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
- Do one of the following:
- In the Find tool window, explore search results. Use the
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 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:
- Create an interface, an abstract class that implements it, and two classes that extend the abstract
class:
- Create an interface
MyInterface
with afoo()
method. - Create an abstract class
MyAbstractClass
that implementsMyInterface
. - Create a class
MyClass
that extendsMyAbstractClass
and implement thefoo()
method required by the interface and overrides the methods of the parent class. - Create a class
MyClassWithDelegate
that extendsMyClass
and implementfoo()
with a delegate. - Create variables
$b
and$c
that callfoo()
fromMyClass
andMyClassWithDelegate
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();
- Create an interface
- From
MyInterface
, invoke Find Usages forfoo()
by pressing Alt+F7 or choosing on the main menu. By default, IntelliJ IDEA shows only delegates to the super method and method calls: - To find also the methods that implement or override the base method, click
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 extendMyInterface
: