mirror of https://github.com/sbt/sbt.git
2.9 compatibility fixes
This commit is contained in:
parent
60d9355b54
commit
b7f92ae07f
|
|
@ -106,6 +106,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se
|
|||
//wrap tree in object objectName { def WrapValName = <tree> }
|
||||
def augment(parser: global.syntaxAnalyzer.UnitParser, imports: Seq[Tree], tree: Tree, tpt: Tree, objectName: String): Tree =
|
||||
{
|
||||
val emptyTypeName = nme.EMPTY.toTypeName
|
||||
def emptyPkg = parser.atPos(0, 0, 0) { Ident(nme.EMPTY_PACKAGE_NAME) }
|
||||
def emptyInit = DefDef(
|
||||
NoMods,
|
||||
|
|
@ -113,7 +114,7 @@ final class Eval(optionsNoncp: Seq[String], classpath: Seq[File], mkReporter: Se
|
|||
Nil,
|
||||
List(Nil),
|
||||
TypeTree(),
|
||||
Block(List(Apply(Select(Super("", ""), nme.CONSTRUCTOR), Nil)), Literal(Constant(())))
|
||||
Block(List(Apply(Select(Super(emptyTypeName, emptyTypeName), nme.CONSTRUCTOR), Nil)), Literal(Constant(())))
|
||||
)
|
||||
|
||||
def method = DefDef(NoMods, WrapValName, Nil, Nil, tpt, tree)
|
||||
|
|
|
|||
|
|
@ -39,115 +39,6 @@ final class OutputWrapperStream(out: Output) extends java.io.OutputStream
|
|||
def write(b: Int) = out.writeByte(b.toByte)
|
||||
}
|
||||
|
||||
object SourceFormat2 extends Format[Source]
|
||||
{
|
||||
private[this] final val StructureFields = 3
|
||||
private[this] final val ClassFields = 2
|
||||
|
||||
private[this]def toMap[T](a: Seq[T]): Map[T, Int] = a.zipWithIndex.toMap
|
||||
|
||||
def reads(in: Input): Source =
|
||||
{
|
||||
var pending: List[Lazy[_]] = Nil
|
||||
def forcePending() = pending foreach { _.get }
|
||||
|
||||
def lzyC[T <: AnyRef](i: Int, off: Int): Lazy[T] = lzy { getData[T](i, off, classData, ClassFields) }
|
||||
def lzyS[T <: AnyRef](i: Int, off: Int): Lazy[T] = lzy { getData[T](i, off, structureData, StructureFields) }
|
||||
def getData[T <: AnyRef](i: Int, off: Int, backing: Array[AnyRef], fields: Int): T = backing(i*fields+off).asInstanceOf[T]
|
||||
def lzy[T <: AnyRef](t: => T): Lazy[T] =
|
||||
{
|
||||
val z = SafeLazy(t)
|
||||
pending ::= z
|
||||
z
|
||||
}
|
||||
|
||||
val structureCount = read[Int](in)
|
||||
|
||||
lazy val refs: References = new References {
|
||||
def structure(id: Int) = structures(id)
|
||||
def classLike(id: Int) = classes(id)
|
||||
def id(s: Structure) = noID()
|
||||
def id(s: ClassLike) = noID()
|
||||
def noID() = error("References only for reading")
|
||||
}
|
||||
lazy val formats = new DefaultAPIFormats()(refs)
|
||||
import formats._
|
||||
|
||||
lazy val classesStrict = read[Array[(DefinitionType, Array[TypeParameter], String, Access, Modifiers, Array[Annotation])]](in)
|
||||
|
||||
// shells for types that can be cyclic. The actual contents are filled in after the shells are constructed so that
|
||||
// the contents can have cyclic references
|
||||
lazy val structures = Array.tabulate(structureCount)(i => new xsbti.api.Structure( lzyS(i,0), lzyS(i,1), lzyS(i,2) ) )
|
||||
lazy val classes = Array.tabulate(classesStrict.size) { i =>
|
||||
val c = classesStrict(i)
|
||||
new xsbti.api.ClassLike( c._1, lzyC(i,0), lzyC(i,1), c._2, c._3, c._4, c._5, c._6 )
|
||||
}
|
||||
|
||||
def readFlat[T <: Product](implicit r: Reads[Array[T]]): Array[AnyRef] =
|
||||
read[Array[T]](in)(r).flatMap(_.productIterator.asInstanceOf[Iterator[AnyRef]].toTraversable)
|
||||
|
||||
lazy val structureData = readFlat[(Array[Type], Array[Definition], Array[Definition])]
|
||||
lazy val classData = readFlat[(Type, Structure)]
|
||||
|
||||
// order is important here, we are forcing in the correct order
|
||||
classesStrict; // read the strict contents of ClassLikes
|
||||
structures; // force the Structure shells to be constructed
|
||||
classes; // force the ClassLike shells to be constructed, filling in the strict parts now and deferring the lazy parts
|
||||
structureData; // force loading the lazy contents of Structures
|
||||
classData; // force loading the lazy contents of ClassLikes
|
||||
|
||||
forcePending() // force the shells to be filled in
|
||||
read[Source](in)
|
||||
}
|
||||
|
||||
def writes(out: Output, s: Source)
|
||||
{
|
||||
val (structures, classes) = getStructures(s)
|
||||
val structuresMap = toMap(structures)
|
||||
val classesMap = toMap(classes)
|
||||
implicit val references = new References {
|
||||
def id(s: Structure) = structuresMap(s)
|
||||
def id(s: ClassLike) = classesMap(s)
|
||||
def noID() = error("References only for writing")
|
||||
def structure(id: Int) = noID()
|
||||
def classLike(id: Int) = noID()
|
||||
}
|
||||
val formats = new DefaultAPIFormats
|
||||
import formats._
|
||||
|
||||
val expandedStructures = structures map { s => (s.parents, s.declared, s.inherited)}
|
||||
// TODO: type parameters and annotations might need to be lazy as well
|
||||
val expandedClassesStrict = classes map { c => (c.definitionType, c.typeParameters, c.name, c.access, c.modifiers, c.annotations) }
|
||||
val expandedClassesLazy = classes map { c => (c.selfType, c.structure) }
|
||||
|
||||
write(out, structures.size )
|
||||
write(out, expandedClassesStrict)
|
||||
write(out, expandedStructures)
|
||||
write(out, expandedClassesLazy)
|
||||
write(out, s)
|
||||
}
|
||||
|
||||
def getStructures(s: Source): (Array[Structure], Array[ClassLike]) =
|
||||
{
|
||||
val structures = new mutable.HashSet[Structure]
|
||||
val classes = new mutable.HashSet[ClassLike]
|
||||
val search = new Visit {
|
||||
override def visitStructure0(s: Structure)
|
||||
{
|
||||
structures += s
|
||||
super.visitStructure0(s)
|
||||
}
|
||||
override def visitClass0(c: ClassLike)
|
||||
{
|
||||
classes += c
|
||||
super.visitClass0(c: ClassLike)
|
||||
}
|
||||
}
|
||||
search.visit(s)
|
||||
(structures.toArray, classes.toArray)
|
||||
}
|
||||
}
|
||||
|
||||
trait References {
|
||||
def id(s: Structure): Int
|
||||
def id(s: ClassLike): Int
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ object IvyActions
|
|||
val map = rawMap.asInstanceOf[java.util.Map[ArtifactDownloadReport,java.util.Set[String]]]
|
||||
val confMap = new collection.mutable.HashMap[String, Seq[File]]
|
||||
|
||||
import collection.JavaConversions.{asScalaMap,asScalaSet}
|
||||
import collection.JavaConversions._
|
||||
for( (report, all) <- map; retrieved <- all; val file = new File(retrieved); conf <- report.getArtifact.getConfigurations)
|
||||
confMap.put(conf, file +: confMap.getOrElse(conf, Nil))
|
||||
confMap.toMap
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ object Scoped
|
|||
}
|
||||
private val ssToSK = new (ScopedSetting ~> ScopedKey) { def apply[T](sk: ScopedSetting[T]) = new ScopedKey(sk.scope, sk.key) }
|
||||
private val stToSK = new (ScopedTask ~> ScopedTaskKey) { def apply[T](st: ScopedTask[T]) = new ScopedKey(st.scope, st.key) }
|
||||
private type ScopedTaskKey[T] = ScopedKey[Task[T]]
|
||||
type ScopedTaskKey[T] = ScopedKey[Task[T]]
|
||||
}
|
||||
|
||||
final class Apply2[A,B](t2: (ScopedSetting[A], ScopedSetting[B])) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue