mirror of https://github.com/sbt/sbt.git
Move some things from terms to imports
This commit is contained in:
parent
43eec230e6
commit
6211e8d7da
|
|
@ -9,19 +9,14 @@ import java.io.File
|
||||||
import java.net.{ URI, URL }
|
import java.net.{ URI, URL }
|
||||||
import scala.{ collection => sc }, sc.{ immutable => sci }, sci.{ Seq => sciSeq }
|
import scala.{ collection => sc }, sc.{ immutable => sci }, sci.{ Seq => sciSeq }
|
||||||
import sbt.librarymanagement.LibraryManagementCodec._
|
import sbt.librarymanagement.LibraryManagementCodec._
|
||||||
import sjsonnew._
|
import sjsonnew.{ JsonFormat => JF }
|
||||||
|
|
||||||
/** A registry of JsonFormat instances.
|
/** A registry of JsonFormat instances.
|
||||||
*
|
*
|
||||||
* Used to lookup, given a value of type 'A', its 'JsonFormat[A]' instance.
|
* Used to lookup, given a value of type 'A', its 'JsonFormat[A]' instance.
|
||||||
*/
|
*/
|
||||||
object JsonFormatRegistry {
|
object JsonFormatRegistry {
|
||||||
type MF[A] = Manifest[A]
|
@inline def ?[A](implicit z: A): A = z
|
||||||
type JF[A] = JsonFormat[A]
|
|
||||||
type CTag[A] = scala.reflect.ClassTag[A]
|
|
||||||
|
|
||||||
@inline def ?[A](implicit z: A): A = z
|
|
||||||
@inline def classTag[A: CTag]: CTag[A] = ?
|
|
||||||
|
|
||||||
val UnitJF: JF[Unit] = ?
|
val UnitJF: JF[Unit] = ?
|
||||||
val BooleanJF: JF[Boolean] = ?
|
val BooleanJF: JF[Boolean] = ?
|
||||||
|
|
@ -38,8 +33,8 @@ object JsonFormatRegistry {
|
||||||
val URIJF: JF[URI] = ?
|
val URIJF: JF[URI] = ?
|
||||||
val URLJF: JF[URL] = ?
|
val URLJF: JF[URL] = ?
|
||||||
|
|
||||||
def cast[A](z: JsonFormat[_]): JsonFormat[A] = z.asInstanceOf[JsonFormat[A]]
|
def cast[A](z: JF[_]): JF[A] = z.asInstanceOf[JF[A]]
|
||||||
def castAndWrap[A](z: JsonFormat[_]): Option[JsonFormat[A]] = Some(cast(z))
|
def castAndWrap[A](z: JF[_]): Option[JF[A]] = Some(cast(z))
|
||||||
|
|
||||||
// TODO: Any way to de-duplify here?
|
// TODO: Any way to de-duplify here?
|
||||||
def tuple1JF[A: Manifest]: Option[JF[ Tuple1[A]]] = lookup(manifest[A]) map { implicit elemJF: JF[A] => ? }
|
def tuple1JF[A: Manifest]: Option[JF[ Tuple1[A]]] = lookup(manifest[A]) map { implicit elemJF: JF[A] => ? }
|
||||||
|
|
@ -92,7 +87,7 @@ object JsonFormatRegistry {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
def lookup[A: Manifest]: Option[JsonFormat[A]] = manifest[A] match {
|
def lookup[A: Manifest]: Option[JF[A]] = manifest[A] match {
|
||||||
case Manifest.Unit => castAndWrap[A]( UnitJF)
|
case Manifest.Unit => castAndWrap[A]( UnitJF)
|
||||||
case Manifest.Boolean => castAndWrap[A](BooleanJF)
|
case Manifest.Boolean => castAndWrap[A](BooleanJF)
|
||||||
case Manifest.Byte => castAndWrap[A]( ByteJF)
|
case Manifest.Byte => castAndWrap[A]( ByteJF)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue