23

How do I generate UML and diagrams for Kotlin code? I don't think getting the paid version of Intellij is an option for me. I have been trying Intellij plugins and I haven't found anything that works yet.

I would like to generate the diagrams and uml from the Kotlin code I have already written. A tool like this would save me a lot of time.

Thanks

Philip Nguyen
  • 871
  • 2
  • 10
  • 29

2 Answers2

12

you can click only on a package in the project tree and click "Show Diagram...". Also it generates diagram from the Java point of view (shows Java's signatures and facade classes)

enter image description here

Mehdi Ben Hamida
  • 893
  • 4
  • 16
  • 38
11

May be it help others.

Currently, existing class diagram generator like SimpleUML(You can download it from android studio plugin repository) is not able to create class diagram of Kotlin class. But you can use this plugin for Kotlin with little more effort.

Open activity class in android studio.

Go to tool -> Kotlin -> Show Kotlin Bytecode. New side tab will open and show byte code of selected activity class.

Click on top decompile of generated Kotlin bytecode which generate className.decompile.java class.

Click on class name and then right click on mouse. In many options click on 'add to simpleUML diagram'. Create new or add diagram in existing file.

If you face problem, let me know.

Note: - If you will install SimpleUML then it may create issue. Make sure you download SimpleUMLCE for working in the best way.

Sumit Kumar
  • 564
  • 6
  • 14
  • If you must not be so precise and want a good result this is the best solution i found since now – phemt.latd Jun 11 '19 at 15:39
  • Brilliant answer for simply generating UML diagrams from Kotlin code. The SimpleUMLCE plugin also works within Android Studio – Jadent Apr 30 '20 at 12:29
  • 2
    I found another way too is simply you can add fully qualified className in the class diagram created using simpleUMLCE. Then you don`t need to click on "Decompile" and right click and add decompile class name. – BinodNepali Jul 01 '20 at 10:07