From 994a967977d962a69c947e3d037fb64c29a47164 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Mon, 9 Oct 2023 20:34:06 -0400 Subject: [PATCH 1/4] elm2 From c05573e96d06c1fbadbf5d95fb37bdc469f09ab7 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Mon, 9 Oct 2023 20:34:11 -0400 Subject: [PATCH 2/4] wip --- .../src/main/scala/generator/elm/Imports.scala | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/elm-generator/src/main/scala/generator/elm/Imports.scala b/elm-generator/src/main/scala/generator/elm/Imports.scala index 507702fa..06d33ddf 100644 --- a/elm-generator/src/main/scala/generator/elm/Imports.scala +++ b/elm-generator/src/main/scala/generator/elm/Imports.scala @@ -3,6 +3,7 @@ package generator.elm import scala.collection.concurrent.TrieMap case class Imports() { + private[this] val Wildcard = "*" private[this] val allAs: TrieMap[String, String] = TrieMap[String, String]() private[this] val exposingAll: TrieMap[String, Unit] = TrieMap[String, Unit]() @@ -14,7 +15,12 @@ case class Imports() { } def addExposingAll(name: String): Unit = { - exposingAll.put(name, ()) + exposingAll.put(name, Wildcard) + () + } + + def addExposing(name: String, exposing: String): Unit = { + exposingAll.put(name, exposing) () } @@ -23,7 +29,10 @@ case class Imports() { allAs.keysIterator.toSeq.sorted.map { name => s"import $name as ${allAs(name)}" } ++ exposingAll.keysIterator.toSeq.sorted.map { name => - s"import $name exposing (..)" + exposingAll.get(name) match { + case Wildcard => s"import $name exposing (..)" + case names => s"import $name exposing (${names})" + } } ).mkString("\n") } From 2bce880445e26e467459f964e0e9867207c189a4 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Tue, 10 Oct 2023 15:08:21 -0400 Subject: [PATCH 3/4] wip --- .../main/scala/generator/elm/Imports.scala | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/elm-generator/src/main/scala/generator/elm/Imports.scala b/elm-generator/src/main/scala/generator/elm/Imports.scala index 06d33ddf..7c6ddc43 100644 --- a/elm-generator/src/main/scala/generator/elm/Imports.scala +++ b/elm-generator/src/main/scala/generator/elm/Imports.scala @@ -3,9 +3,14 @@ package generator.elm import scala.collection.concurrent.TrieMap case class Imports() { - private[this] val Wildcard = "*" + private[this] sealed trait ExposingAllValue + private[this] object ExposingAllValue { + case object Wildcard extends ExposingAllValue + case class Types(types: Seq[String]) extends ExposingAllValue + } + private[this] val allAs: TrieMap[String, String] = TrieMap[String, String]() - private[this] val exposingAll: TrieMap[String, Unit] = TrieMap[String, Unit]() + private[this] val exposingAll: TrieMap[String, ExposingAllValue] = TrieMap[String, ExposingAllValue]() def addAs(name: String, as: String): Unit = { allAs.put(name, as).foreach { existing => @@ -15,12 +20,14 @@ case class Imports() { } def addExposingAll(name: String): Unit = { - exposingAll.put(name, Wildcard) + exposingAll.put(name, ExposingAllValue.Wildcard) () } - def addExposing(name: String, exposing: String): Unit = { - exposingAll.put(name, exposing) + def addExposing(name: String, types: String): Unit = addExposing(name, Seq(types)) + + def addExposing(name: String, types: Seq[String]): Unit = { + exposingAll.put(name, ExposingAllValue.Types(types)) () } @@ -29,9 +36,9 @@ case class Imports() { allAs.keysIterator.toSeq.sorted.map { name => s"import $name as ${allAs(name)}" } ++ exposingAll.keysIterator.toSeq.sorted.map { name => - exposingAll.get(name) match { - case Wildcard => s"import $name exposing (..)" - case names => s"import $name exposing (${names})" + exposingAll(name) match { + case ExposingAllValue.Wildcard => s"import $name exposing (..)" + case ExposingAllValue.Types(types) => s"import $name exposing (${types.mkString(", ")})" } } ).mkString("\n") From 46a5701b9aa39128902070507906c3b3551b9c4f Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Tue, 10 Oct 2023 15:08:45 -0400 Subject: [PATCH 4/4] wip --- elm-generator/src/main/scala/generator/elm/Imports.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elm-generator/src/main/scala/generator/elm/Imports.scala b/elm-generator/src/main/scala/generator/elm/Imports.scala index 7c6ddc43..dcafb54a 100644 --- a/elm-generator/src/main/scala/generator/elm/Imports.scala +++ b/elm-generator/src/main/scala/generator/elm/Imports.scala @@ -26,7 +26,7 @@ case class Imports() { def addExposing(name: String, types: String): Unit = addExposing(name, Seq(types)) - def addExposing(name: String, types: Seq[String]): Unit = { + private[this] def addExposing(name: String, types: Seq[String]): Unit = { exposingAll.put(name, ExposingAllValue.Types(types)) () }