CLion 2021.1 Help

Code hierarchies

Build hierarchies

In CLion, you can build the following hierarchies:

  • Type hierarchies show parent and children classes of a class. To build a type hierarchy, select the desired class in the Project tool window or in the editor and call Navigate | Type Hierarchy from the main menu (or just press Ctrl+H).

    Type hierarchy
  • Call hierarchies show callers (supertypes) or callees (subtypes) of a method (Navigate | Call Hierarchy).

    Call hierarchy
  • Imports hierarchies show where the current file is included and track all files included in the current file. To build an import hierarchy, open the file in the editor or select it in the Project view, and choose Navigate | Imports Hierarchy from the main menu.

    Import hierarchy

When built, a hierarchy can be 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.

View hierarchies

Once built, hierarchies can be brought up for close examination in the Hierarchy tool window(View | Tool Windows | Hierarchy). Note that the Hierarchy tool window is not shown when there are no hierarchies to display.

Do one of the following:

  • Right-click the currently displayed tab, and choose Select Next Tab/ Select Previous Tab on the context menu.

  • Use the Alt+Right and Alt+Left keyboard shortcuts.

  • Click the currently displayed tab, and choose the next tab to display.

    Toggle between views

    To show ascending or descending hierarchy (callee vs. caller methods, parent vs. children classes etc.), use the toolbar of the Hierarchy tool window:

    • Click Icons hierarchy supertypes to show supertypes.

    • Click Icons hierarchy subtypes to show subtypes.

      View structure of a file

      You can examine the structure of the file currently opened in the editor using the Structure tool window or the Structure popup. By default, CLion shows all the classes and functions presented in the current file.

      To have other members displayed, click the corresponding buttons on the toolbar of the Structure tool window. You can also have class members shown in the Project tool window.

      View the file structure

      To view the Structure tool window:

      • Call View | Tool Windows | Structure from the main menu.

      • Press Alt+7.

      To view the Structure popup:

      • Press Ctrl+F12.

      • Call Navigate | File Structure from the main menu.

      File Structure popup

        Display inherited members

        • Click Show inherited on the toolbar of the Structure tool window.

        By default, CLion shows only methods, constants, and fields defined in the current class. If shown, inherited members are displayed gray.

        Last modified: 08 March 2021