Why UML diagrams do not show dependencies

Answered

I'm using IDEA to write a Java project. After finishing, I want to see the project's UML class diagram. I use the default UML support and enable all checkboxes under "Java Class", like screenshot below:

Then I open the diagram, but there's only two sizes of lines: blue lines show the inheritance relation between classes, and green lines show the implementation of interface. There's no dependencies (like usages), which should be white lines. I have enable the "show dependencies" button on the diagram toolbar, but nothing changes.

In fact the project do have many dependencies, like class BooksetFactory will create instances of class Other, OtherA, OtherS...I think these relations should have be shown in the diagram according to the UML convention. 

So what happens? Is there a bug? 

1
13 comments

Can't reproduce. Can you share a sample "Hello World" project where it could be reproduced? 

See also https://youtrack.jetbrains.com/issue/IDEA-177758

0
Avatar
Permanently deleted user

Konstantin Annikov

Has create a sample project with 3 java classes. In general:

  • Mainclass.main will create a Example1 instance
  • Mainclass.main will call public method Example1.f1
  • Mainclass.main will call public method Example1.callf2, which will create a instance of Example2, then call public method Example2.f2

In Mainclass.java:

public class Mainclass {
public static void main(String[] argv) {
Example1 exp1 = new Example1("Create a Example class 1 from Mainclass");
exp1.f1("Mainclass");
exp1.callf2();
}
}

In Example1.java:

public class Example1 {
private String attr;

public Example1(String str) {
System.out.println(str);
this.attr = str;
}

public void f1(String s) {
System.out.println("f1 called from " + s);
}

public void callf2() {
Example2 exp2 = new Example2("ttt");
exp2.f2("example class 1");
}
}

In Example2.java:

public class Example2 {
public Example2(String str) {
System.out.println(str);
}

public void f2(String s) {
System.out.println("f2 called from " + s);
}
}

Code screenshot as follows:

But UML diagram as follows:

No dependency at all. It does not show the <<create>> dependencies between Mainclass and Example1, or between Example1 and Example2. It also doesn't show the usage in which Example1 calls Example2's method.

1

UML diagram shows dependencies of 1 class only. You need to add other classes (Right-click on diagram | Add class to diagram). 

Here is the usability problem about that: https://youtrack.jetbrains.com/issue/IDEA-81834

0
Avatar
Permanently deleted user

Konstantin Annikov

Sorry but still can not understand. When I open the diagram of 1 class (like Mainclass above) and manually add other classes (Example1, Example2) by right-click, there's still no dependencies.

I find some UML diagrams created by other people using IDEA on the internet. I circle some lines in one diagram below; What I really want to know is, how can these white lines (showing dependencies, assocation, aggregation etc.) automatically generated in the diagram?

(this diagram is found in https://zhuanlan.zhihu.com/p/175122754)

0
Avatar
Permanently deleted user

Konstantin Annikov

Thank's for your attention. I've repeat what you do in the video, but still cannot show dependencies.

My video is here: https://youtu.be/PeGmfUW0X7k

0

What is the version of IntelliJ IDEA? 

As a general troubleshooting step, please:

1. Reproduce the issue in a brand new Java project (without Maven/Gradle etc)

2. Disable all custom plugins: https://www.jetbrains.com/help/idea/managing-plugins.html#disable-plugin

3. Reset settings to default via File | Manage IDE Settings | Restore Default Settings

0
Avatar
Permanently deleted user

Konstantin Annikov

The version copied from "Help -> About" menu:

IntelliJ IDEA 2020.3.2 (Ultimate Edition)
内部版本号 #IU-203.7148.57, 构建于 January 26, 2021
Licensed to Chiachiun Than
Subscription is active until September 6, 2021.
For educational use only.
运行时版本: 11.0.9.1+11-b1145.77 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 974M
Cores: 8
Non-Bundled Plugins: Statistic, com.intellij.zh, CheckStyle-IDEA, org.jetbrains.kotlin, Pythonid

Seems that the problem lies in your official Chinese(Simplified) Language Pack plugin (version 203.596). I reset the IDE settings and enable that plugin and the dependencies still cannot be shown; but after I disable it and restart IDE, the bug disappears. 

It's ok for me to use a pure English interface, however still hope to have a fix as soon as possible. You can report it to your plugin team. 

0

I can't either, it's not fixed yet

Runtime version: 11.0.13+7-b1751.25 amd64

1

Chinese ​(Simplified)​ Language Pack / 中文语言包

Version 223.143

0

2652127675 Please check if the problem reproduces in the latest build from https://www.jetbrains.com/idea/download . If the problem remains contact JetBrains support at https://intellij-support.jetbrains.com/hc/en-us/requests/new and provide a couple of screenshots showing your problem. Thank you!

0

Hi, I downloaded the ultimate Version for students today and came across the same problem. It is strange that nothing occur after I clicking the show dependencies button. Already reported the problem to your suggested link, hope to see how it goes soon.

0

Please sign in to leave a comment.