Source code hierarchy
With GoLand, you can examine the hierarchy of types, methods, and calls and explore the structure of source files.
Build hierarchies
Type hierarchies show what interfaces are implemented by the type and what types implement the interface.
Call hierarchies show callers or callees of a method or a function.
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 type or interface in the editor.
In the main menu, go to
or just press Control+H.
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 call hierarchy
Open a file in the editor and place the caret at the declaration or usage of the desired method or a function.
In the main menu, go to
or press Control+Alt+H.
Retain a hierarchy tab
In the Hierarchy tool window, click the Pin Tab button on the toolbar.
Viewing hierarchies
Open the Hierarchy tool window
Make sure, you have already built hierarchies to show, see Building hierarchies above.
Select
from the main menu.
Navigate between the tabs
Click the currently displayed tab and select the next one to display from the list.
Switch between callers and callees
With GoLand, you can build and explore ascending or descending hierarchies, that is, callee or caller methods, parent or children types, and so on.
Click or to show caller methods or callee methods respectively.
Hierarchy tool window buttons
Item | Description | Available In |
---|---|---|
Depending on the hierarchy type:
| All hierarchies | |
Depending on the hierarchy type:
| All hierarchies | |
Sorts all elements within a tree alphabetically. | Type hierarchies | |
Scope | 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. | Call hierarchies |
Searches for calls of the selected method in all structures that implement this interface method. By default, you see a list of calls for the selected method only in the current structure. | Call hierarchies | |
Shows all updated types or type structures. | All hierarchies | |
Moves to a file and a section in a source code that corresponds to the selected node in the hierarchy tree. | All hierarchies | |
Expands all nodes. | All hierarchies | |
Expands all nodes of the hierarchy tree. | All hierarchies | |
Locks the current tab from closing and reusing. Results of the next command are displayed in a new tab. | All hierarchies | |
Exports a hierarchy into a text file. You can specify a location for this file. | All hierarchies | |
Closes the tool window. | All hierarchies |