IntelliJ IDEA 2018.2 Help

Class diagram

IntelliJ IDEA lets you generate a diagram on a package in your project. Such diagrams always reflect the structure of actual classes and methods in your application.

View diagram on a package

  1. In the Project tool window, right-click a package for which you want to create a diagram and select Diagrams | Show Diagrams (Ctrl+Shift+Alt+U).

  2. In the list that opens, select Java Class Diagram. IntelliJ IDEA generates a UML diagram for classes and their dependencies.

Analyze class diagram

After you have generated a diagram, press E to expand the package to see classes and their connections. To collapse them press C.

You can easily distinguish between public and private classes, since they have their own modifiers icons nodes c public for public and icons nodes c private for private.

If you want to see the list of methods, fields, and other code elements, select the appropriate icon on the diagram toolbar located on top of the diagram editor.

diagram editor
The lists are displayed based on the visibility scope uml support resources icons visibility which you can change. For example, if you want to see only protected methods, select the protected option from the drop-down list. IntelliJ IDEA displays such methods with a modifier (key icons nodes c protected image) next to it.

You can click the uml support resources icons dependencies icon to see class dependencies. IntelliJ IDEA follows the UML conventions in showing relationships between the classes.

class dependencies

When you click through classes in the graph, IntelliJ IDEA greys out classes that do not reside in the same package. This might be helpful, when you generate a diagram on a package that contains inner packages.

different packages

Manage class diagram

The context menu in the diagram editor provides the ability to perform different tasks while you work with diagrams. You can view members of the class, add new, delete the existing ones, see implementations, check parent classes, perform basic refactoring, add notes, etc.

Add an existing class to a diagram

  1. Press Space to add an existing class to your diagram.

  2. In the search field that opens, start typing a name of the class you want to add. IntelliJ IDEA displays the list of suggestions. If you want to add a class that is out of the project scope, select the Include non-project items option.

Add new members to a class

You can perform some forward engineering while in the diagram editor.

  1. In the diagram editor, right-click anywhere and from the context menu, select New and a code element you want to create.

  2. Depending on what you have selected, IntelliJ IDEA opens the appropriate dialog where you specify the necessary information for creating the new element.

IntelliJ IDEA adds the item to your diagram as well as to your project tree.

View implementations and parent classes

You can view implementations and parent classes in your diagram. If IntelliJ IDEA finds more than one parent class or implementation, it displays a list of appropriate items. Select the one you need to see the connections between the parent and its children.

  1. In the diagram editor, select an item for which you want to see implementations or parent classes.

  2. Right-click the items and from the context menu, select the Show Implementations(Ctrl+Alt+B) or Show Parents(Ctrl+Alt+P) respectively.

Configure diagram settings

You can configure the diagram settings, so that you have certain options available to you by default when you create your diagram.

  1. Press Ctrl+Alt+S to open Settings | Preferences dialog.

  2. From the options on the left, select Tools | Diagrams.

  3. From the options on the right, select options that you want to see by default and click OK to save your changes.

Last modified: 20 November 2018