diff --git a/project/ContrabandConfig.scala b/project/ContrabandConfig.scala index f1bbd9d42..d9955fe0d 100644 --- a/project/ContrabandConfig.scala +++ b/project/ContrabandConfig.scala @@ -23,7 +23,7 @@ object ContrabandConfig { case "Map" | "Tuple2" | "scala.Tuple2" => { tpe => twoArgs(tpe).flatMap(getFormats) } case "Int" | "Long" => { _ => Nil } case "sbt.testing.Status" => { _ => "sbt.internal.testing.StatusFormats" :: Nil } - case "scala.json.ast.unsafe.JValue" => { _ => "sbt.internal.JValueFormat" :: Nil } + case "scala.json.ast.unsafe.JValue" => { _ => "sbt.internal.util.codec.JValueFormats" :: Nil } } /** Returns the list of formats required to encode the given `TpeRef`. */ diff --git a/protocol/src/main/contraband-scala/sbt/protocol/codec/EventMessageFormats.scala b/protocol/src/main/contraband-scala/sbt/protocol/codec/EventMessageFormats.scala index 0727e822c..8ca31e712 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/codec/EventMessageFormats.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/codec/EventMessageFormats.scala @@ -5,6 +5,6 @@ // DO NOT EDIT MANUALLY package sbt.protocol.codec import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder } -trait EventMessageFormats { self: sjsonnew.BasicJsonProtocol with sbt.protocol.codec.ChannelAcceptedEventFormats with sbt.protocol.codec.LogEventFormats with sbt.protocol.codec.ExecStatusEventFormats with sbt.internal.JValueFormat with sbt.protocol.codec.SettingQuerySuccessFormats with sbt.protocol.codec.SettingQueryFailureFormats => +trait EventMessageFormats { self: sjsonnew.BasicJsonProtocol with sbt.protocol.codec.ChannelAcceptedEventFormats with sbt.protocol.codec.LogEventFormats with sbt.protocol.codec.ExecStatusEventFormats with sbt.internal.util.codec.JValueFormats with sbt.protocol.codec.SettingQuerySuccessFormats with sbt.protocol.codec.SettingQueryFailureFormats => implicit lazy val EventMessageFormat: JsonFormat[sbt.protocol.EventMessage] = flatUnionFormat5[sbt.protocol.EventMessage, sbt.protocol.ChannelAcceptedEvent, sbt.protocol.LogEvent, sbt.protocol.ExecStatusEvent, sbt.protocol.SettingQuerySuccess, sbt.protocol.SettingQueryFailure]("type") } diff --git a/protocol/src/main/contraband-scala/sbt/protocol/codec/JsonProtocol.scala b/protocol/src/main/contraband-scala/sbt/protocol/codec/JsonProtocol.scala index f755ceb8c..3b92fc46c 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/codec/JsonProtocol.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/codec/JsonProtocol.scala @@ -11,7 +11,7 @@ trait JsonProtocol extends sjsonnew.BasicJsonProtocol with sbt.protocol.codec.ChannelAcceptedEventFormats with sbt.protocol.codec.LogEventFormats with sbt.protocol.codec.ExecStatusEventFormats - with sbt.internal.JValueFormat + with sbt.internal.util.codec.JValueFormats with sbt.protocol.codec.SettingQuerySuccessFormats with sbt.protocol.codec.SettingQueryFailureFormats with sbt.protocol.codec.EventMessageFormats diff --git a/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQueryResponseFormats.scala b/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQueryResponseFormats.scala index 9e0aebed9..73991945f 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQueryResponseFormats.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQueryResponseFormats.scala @@ -5,6 +5,6 @@ // DO NOT EDIT MANUALLY package sbt.protocol.codec import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder } -trait SettingQueryResponseFormats { self: sbt.internal.JValueFormat with sjsonnew.BasicJsonProtocol with sbt.protocol.codec.SettingQuerySuccessFormats with sbt.protocol.codec.SettingQueryFailureFormats => +trait SettingQueryResponseFormats { self: sbt.internal.util.codec.JValueFormats with sjsonnew.BasicJsonProtocol with sbt.protocol.codec.SettingQuerySuccessFormats with sbt.protocol.codec.SettingQueryFailureFormats => implicit lazy val SettingQueryResponseFormat: JsonFormat[sbt.protocol.SettingQueryResponse] = flatUnionFormat2[sbt.protocol.SettingQueryResponse, sbt.protocol.SettingQuerySuccess, sbt.protocol.SettingQueryFailure]("type") } diff --git a/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQuerySuccessFormats.scala b/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQuerySuccessFormats.scala index 431a23d71..d8966c84e 100644 --- a/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQuerySuccessFormats.scala +++ b/protocol/src/main/contraband-scala/sbt/protocol/codec/SettingQuerySuccessFormats.scala @@ -5,7 +5,7 @@ // DO NOT EDIT MANUALLY package sbt.protocol.codec import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder } -trait SettingQuerySuccessFormats { self: sbt.internal.JValueFormat with sjsonnew.BasicJsonProtocol => +trait SettingQuerySuccessFormats { self: sbt.internal.util.codec.JValueFormats with sjsonnew.BasicJsonProtocol => implicit lazy val SettingQuerySuccessFormat: JsonFormat[sbt.protocol.SettingQuerySuccess] = new JsonFormat[sbt.protocol.SettingQuerySuccess] { override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.protocol.SettingQuerySuccess = { jsOpt match { diff --git a/protocol/src/main/scala/sbt/internal/JValueFormat.scala b/protocol/src/main/scala/sbt/internal/JValueFormat.scala deleted file mode 100644 index d6f2a6dc9..000000000 --- a/protocol/src/main/scala/sbt/internal/JValueFormat.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2017 Lightbend Inc. - */ -package sbt -package internal - -import sjsonnew.{ JsonWriter => JW, JsonReader => JR, JsonFormat => JF, _ } -import scala.json.ast.unsafe._ - -trait JValueFormat { self: sjsonnew.BasicJsonProtocol => - implicit val JNullJF: JF[JNull.type] = new JF[JNull.type] { - def write[J](x: JNull.type, b: Builder[J]) = b.writeNull() - def read[J](j: Option[J], u: Unbuilder[J]) = JNull - } - - implicit val JBooleanJF: JF[JBoolean] = project(_.get, JBoolean(_)) - implicit val JStringJF: JF[JString] = project(_.value, JString(_)) - implicit val JNumberJF: JF[JNumber] = project(x => BigDecimal(x.value), (x: BigDecimal) => JNumber(x.toString)) - implicit val JArrayJF: JF[JArray] = project[JArray, Array[JValue]](_.value, JArray(_)) - - implicit lazy val JObjectJW: JW[JObject] = new JW[JObject] { - def write[J](x: JObject, b: Builder[J]) = { - b.beginObject() - x.value foreach (jsonField => JValueJW.addField(jsonField.field, jsonField.value, b)) - b.endObject() - } - } - - implicit lazy val JValueJW: JW[JValue] = new JW[JValue] { - def write[J](x: JValue, b: Builder[J]) = x match { - case x: JNull.type => JNullJF.write(x, b) - case x: JBoolean => JBooleanJF.write(x, b) - case x: JString => JStringJF.write(x, b) - case x: JNumber => JNumberJF.write(x, b) - case x: JArray => JArrayJF.write(x, b) - case x: JObject => JObjectJW.write(x, b) - } - } - - implicit lazy val JValueJR: JR[JValue] = new JR[JValue] { - def read[J](j: Option[J], u: Unbuilder[J]) = ??? // Is this even possible? with no Manifest[J]? - } - - implicit lazy val JValueJF: JF[JValue] = jsonFormat[JValue](JValueJR, JValueJW) -}