From 4a8c42488174710bb71e351a27e5e9c51320c65b Mon Sep 17 00:00:00 2001 From: Jason Pickens Date: Tue, 9 Mar 2021 14:56:13 +1300 Subject: [PATCH 1/2] Fix reference to package members --- .../scala2plantuml/DiagramModifications.scala | 5 ++--- .../scala2plantuml/MethodParameterTests.scala | 20 +++++++++++++++++++ .../examples/methodparameters/Foo.scala | 6 ++++++ .../examples/methodparameters/package.scala | 6 ++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala create mode 100644 core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/Foo.scala create mode 100644 core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/package.scala diff --git a/core/src/main/scala/nz/co/bottech/scala2plantuml/DiagramModifications.scala b/core/src/main/scala/nz/co/bottech/scala2plantuml/DiagramModifications.scala index 2438988..11bebe3 100644 --- a/core/src/main/scala/nz/co/bottech/scala2plantuml/DiagramModifications.scala +++ b/core/src/main/scala/nz/co/bottech/scala2plantuml/DiagramModifications.scala @@ -129,7 +129,6 @@ private[scala2plantuml] object DiagramModifications { assert(names.isEmpty) def typeParameterSymbols(parameters: Seq[TypeParameter]): Seq[String] = parameters.flatMap(parameter => parameter.symbol +: parameter.parentSymbols) - // TODO: This might be overkill. All the symbols we care about should be types. def elementSymbols(element: ClassDiagramElement): Seq[String] = element match { case typ: Type => typ.symbol +: typ.parentSymbols ++: typeParameterSymbols(typ.typeParameters) @@ -146,8 +145,8 @@ private[scala2plantuml] object DiagramModifications { symbolName(parameter.symbol) +: parameter.parentSymbols.map(symbolName) } elementName +: typeParameterNames - case member: Member => Seq(member.symbol -> member.displayName) - case _: Aggregation => Seq.empty + case member: Member => Seq(member.symbol -> member.displayName) + case aggregation: Aggregation => Seq(symbolName(aggregation.aggregator), symbolName(aggregation.aggregated)) } } val newNames = options.naming match { diff --git a/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala b/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala new file mode 100644 index 0000000..109433e --- /dev/null +++ b/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala @@ -0,0 +1,20 @@ +package nz.co.bottech.scala2plantuml + +import utest.{TestSuite, Tests, test} + +object MethodParameterTests extends TestSuite with ClassDiagramTests { + + override protected val exampleDir: String = "methodparameters" + + val tests: Tests = Tests { + test("parameter with type alias") { + success( + "Foo.", + """class Foo { + | + {static} {method} foo + |} + |Foo o-- "package$Bar"""".stripMargin + ) + } + } +} diff --git a/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/Foo.scala b/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/Foo.scala new file mode 100644 index 0000000..7582738 --- /dev/null +++ b/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/Foo.scala @@ -0,0 +1,6 @@ +package nz.co.bottech.scala2plantuml.examples.methodparameters + +object Foo { + + def foo(bar: Bar): String = bar +} diff --git a/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/package.scala b/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/package.scala new file mode 100644 index 0000000..8f7b091 --- /dev/null +++ b/core/src/test/scala/nz/co/bottech/scala2plantuml/examples/methodparameters/package.scala @@ -0,0 +1,6 @@ +package nz.co.bottech.scala2plantuml.examples + +package object methodparameters { + + type Bar = String +} From 23427f6d25a7f164526bc20f7e727eabbfdaae2f Mon Sep 17 00:00:00 2001 From: Jason Pickens Date: Tue, 9 Mar 2021 14:58:06 +1300 Subject: [PATCH 2/2] Fix formatting --- .../nz/co/bottech/scala2plantuml/MethodParameterTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala b/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala index 109433e..bf552d8 100644 --- a/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala +++ b/core/src/test/scala/nz/co/bottech/scala2plantuml/MethodParameterTests.scala @@ -1,6 +1,6 @@ package nz.co.bottech.scala2plantuml -import utest.{TestSuite, Tests, test} +import utest.{test, TestSuite, Tests} object MethodParameterTests extends TestSuite with ClassDiagramTests {