From 3c855b38976df73e8b1500bf85aaad06287d2350 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Sun, 11 Aug 2024 14:40:08 +0200 Subject: [PATCH] Graphviz: eliminate duplicate arrows This ensures that at most one arrow is drawn for every source and destination pair. Duplicate arrows add no information value and only make the diagram cluttered. For example, see https://github.com/kaitai-io/kaitai_struct_formats/blob/e533644618670a3b94be687253b0bf11a051640c/common/bcd.ksy, which used to generate many duplicate arrows with the same source and destination. It looks much cleaner now. --- .../main/scala/io/kaitai/struct/GraphvizClassCompiler.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala b/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala index 7a2482687..2b1126907 100644 --- a/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala +++ b/shared/src/main/scala/io/kaitai/struct/GraphvizClassCompiler.scala @@ -8,7 +8,7 @@ import io.kaitai.struct.languages.components.{LanguageCompiler, LanguageCompiler import io.kaitai.struct.precompile.CalculateSeqSizes import io.kaitai.struct.translators.RubyTranslator -import scala.collection.mutable.ListBuffer +import scala.collection.mutable.{ListBuffer, LinkedHashSet} class GraphvizClassCompiler(classSpecs: ClassSpecs, topClass: ClassSpec) extends AbstractCompiler { import GraphvizClassCompiler._ @@ -17,7 +17,7 @@ class GraphvizClassCompiler(classSpecs: ClassSpecs, topClass: ClassSpec) extends val provider = new ClassTypeProvider(classSpecs, topClass) val translator = new RubyTranslator(provider) - val links = ListBuffer[(String, String, String)]() + val links = LinkedHashSet[(String, String, String)]() val extraClusterLines = new StringLanguageOutputWriter(indent) def nowClass: ClassSpec = provider.nowClass