Source code hierarchy
PyCharm enables you to examine the hierarchy of classes, methods, and calls in the Hierarchy tool window, and explore the structure of source files in the Structure tool window.
Both the Hierarchy and the Structure tool windows are available from the menu.
the Hierarchy tool window only becomes available, when a hierarchy is built.
Hierarchies are built in themenu.
In this part:
With PyCharm, you can examine the hierarchy of classes, methods, and calls and explore the structure of source files.
Type hierarchies show parent and child classes of a class.
Call hierarchies show callers (supertypes) or callees (subtypes) of a method.
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
Select the desired class in the Project tool window or open it in the editor.
From the main menu, selector just press Ctrl+H.
Build a call hierarchy
Open the file in the editor and place the caret at the declaration or usage of the desired method.
Alternatively, select the desired method in the Project tool window.
From the main menu, selector press Ctrl+Alt+H.
Retain a hierarchy tab
In the Hierarchy tool window, click the Pin Tab button on the toolbar.
Open the Hierarchy tool window
Make sure, you have already built hierarchies to show, see Building hierarchies above.
Selectfrom the main menu.
Navigate between the tabs
Click the currently displayed tab, and select the next one to display from the list.
Toggle between views
With PyCharm, you can build and explore ascending or descending hierarchies, that is, callee or caller methods, parent or children classes, and so on.
Click or to show caller methods or callee methods respectively.
Hierarchy tool window buttons
Shows both the parent and child classes of the selected class, which is marked with an arrow in the tree of results.
| Depending on the hierarchy type: |
Depending on the hierarchy type:
Sorts all elements within a tree alphabetically.
Use this list to limit the scope of the current hierarchy:
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.
Shows all updated classes or class structures.
Moves to a file and a section in a source code that corresponds to the selected node in the hierarchy tree.
Expands all nodes.
Locks the current tab from closing and reusing. Results of the next command are displayed in a new tab.
Exports a hierarchy into a text file. You can specify a location for this file.
Closes the tool window.