Source code hierarchy | IntelliJ IDEA (original) (raw)

With IntelliJ IDEA, you can examine the hierarchy of classes, methods, and calls and explore the structure of source files.

Analyzing Code Hierarchies

When built, a hierarchy can be immediately viewed and examined in the Hierarchy tool window. By default, every new built hierarchy overwrites the contents of the current tab. You can retain the current tab and have the next hierarchy built in a new one.

Build a type hierarchy

  1. Select the desired class in the Project tool window or open it in the editor.
  2. In the main menu, go to or just press Ctrl+H.
    Class hierarchy shown in the Hierarchy Tool Window

Different colors of elements stand for different scopes to which these files belong. For example, green by default is used for tests. For more information, refer to Associate scopes with colors.

Build a method hierarchy

  1. Open the file in the editor and place the caret at the declaration of the desired method.
    Alternatively, select the desired method in the Project tool window.
  2. Go to or press Ctrl+Shift+H.

Build a call hierarchy

  1. Open a file in the editor and place the caret at the declaration or usage of the desired method or a field.
    Alternatively, select the desired method or the field in the Project tool window.
  2. In the main menu, go to or press Ctrl+Alt+H.

Retain a hierarchy tab

View hierarchies

Open the Hierarchy tool window

  1. Make sure, you have already built hierarchies to show, see Building hierarchies above.
  2. Select from the main menu.

Toggle between views

Item Description Available In
the Class Hierarchy button Shows both the parent and child classes of the selected class, which is marked with an arrow in the tree of results. Class hierarchies
the Caller Hierarchy toolbar button Depending on the hierarchy type: Class hierarchies: shows the hierarchy of each supertype of the current class.Call hierarchies: shows the callers of the selected method. Class hierarchiesCall hierarchies
the Callee Hierarchy button Depending on the hierarchy type:Class hierarchies: shows all classes that extend the selected class.Call hierarchies: shows the callees of the selected method. Class hierarchiesCall hierarchies
the Sort Alphabetically button Sorts all elements within a tree alphabetically. All hierarchies
Scope Use this list to limit the scope of the current hierarchy:Project: traces usages of the method across the project.Test: traces usages of the method across the test classes.All: traces usages of the method across the project and the libraries.This class: limits the scope to the current class.In addition to the preconfigured scopes, you can define your own one. To define a scope, select Configure from the list and define the required scope in the Scopes dialog. Call hierarchies
In a method hierarchy, the tree views of the following classes are available:the Plus icon: the method is defined.the Minus icon: the method is defined only in the superclass.the Exclamation mark icon: the method must be defined because the class is not abstract.
the Refresh button Shows all updated classes or class structures. All hierarchies
the Navigate with Single Click button Moves to a file and a section in a source code that corresponds to the selected node in the hierarchy tree. All hierarchies
the Expand All button Expands all nodes. All hierarchies
the Pin button Locks the current tab from closing and reusing. Results of the next command are displayed in a new tab. All hierarchies
the Export to Text File Exports a hierarchy into a text file. You can specify a location for this file. All hierarchies
the Close button Closes the tool window. All hierarchies

Last modified: 14 October 2024