Skip to content

Commit

Permalink
Bump to sbt-datatype 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Jul 16, 2016
1 parent e83dcfa commit f872f9c
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 72 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Scripted._
// import StringUtilities.normalize
import com.typesafe.tools.mima.core._, ProblemFilters._

def baseVersion = "1.0.0-X1"
def baseVersion = "1.0.0-X2-SNAPSHOT"
def internalPath = file("internal")

lazy val scalaVersions = Seq(scala210, scala211)
Expand Down Expand Up @@ -194,6 +194,7 @@ lazy val zincCompileCore = (project in internalPath / "zinc-compile-core").
// the analysis compiler phases and passed back to sbt. The API structures are defined in a simple
// format from which Java sources are generated by the sbt-datatype plugin.
lazy val compilerInterface = (project in internalPath / "compiler-interface").
enablePlugins(DatatypePlugin).
settings(
minimalSettings,
// javaOnlySettings,
Expand Down
19 changes: 10 additions & 9 deletions internal/compiler-bridge/src-2.10/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class ExtractAPI[GlobalType <: Global](
build(resultType, typeParams, valueParameters)
case returnType =>
val retType = processType(in, dropConst(returnType))
new xsbti.api.Def(valueParameters.reverse.toArray, retType, typeParams,
simpleName(s), getAccess(s), getModifiers(s), annotations(in, s))
new xsbti.api.Def(simpleName(s), getAccess(s), getModifiers(s), annotations(in, s),
typeParams, valueParameters.reverse.toArray, retType)
}
}
def parameterS(s: Symbol): xsbti.api.MethodParameter = {
Expand All @@ -263,11 +263,11 @@ class ExtractAPI[GlobalType <: Global](
build(t, Array(), Nil)
}
private def hasDefault(s: Symbol) = s != NoSymbol && s.hasFlag(Flags.DEFAULTPARAM)
private def fieldDef[T](in: Symbol, s: Symbol, keepConst: Boolean, create: (xsbti.api.Type, String, xsbti.api.Access, xsbti.api.Modifiers, Array[xsbti.api.Annotation]) => T): T =
private def fieldDef[T](in: Symbol, s: Symbol, keepConst: Boolean, create: (String, xsbti.api.Access, xsbti.api.Modifiers, Array[xsbti.api.Annotation], xsbti.api.Type) => T): T =
{
val t = dropNullary(viewer(in).memberType(s))
val t2 = if (keepConst) t else dropConst(t)
create(processType(in, t2), simpleName(s), getAccess(s), getModifiers(s), annotations(in, s))
create(simpleName(s), getAccess(s), getModifiers(s), annotations(in, s), processType(in, t2))
}
private def dropConst(t: Type): Type = t match {
case ConstantType(constant) => constant.tpe
Expand All @@ -291,10 +291,10 @@ class ExtractAPI[GlobalType <: Global](
val as = annotations(in, s)

if (s.isAliasType)
new xsbti.api.TypeAlias(processType(in, tpe), typeParams, name, access, modifiers, as)
new xsbti.api.TypeAlias(name, access, modifiers, as, typeParams, processType(in, tpe))
else if (s.isAbstractType) {
val bounds = tpe.bounds
new xsbti.api.TypeDeclaration(processType(in, bounds.lo), processType(in, bounds.hi), typeParams, name, access, modifiers, as)
new xsbti.api.TypeDeclaration(name, access, modifiers, as, typeParams, processType(in, bounds.lo), processType(in, bounds.hi))
} else
error("Unknown type member" + s)
}
Expand Down Expand Up @@ -558,8 +558,9 @@ class ExtractAPI[GlobalType <: Global](
val tParams = typeParameters(in, sym) // look at class symbol
val selfType = lzy(this.selfType(in, sym))
def constructClass(structure: xsbti.api.Lazy[Structure]): ClassLike = {
new xsbti.api.ClassLike(defType, selfType, structure, emptyStringArray,
childrenOfSealedClass, topLevel, tParams, name, acc, modifiers, anns) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
new xsbti.api.ClassLike(name, acc, modifiers, anns,
defType, selfType, structure, emptyStringArray,
childrenOfSealedClass, topLevel, tParams) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
}
val info = viewer(in).memberInfo(sym)
val structure = lzy(structureWithInherited(info, sym))
Expand All @@ -568,7 +569,7 @@ class ExtractAPI[GlobalType <: Global](
allNonLocalClassesInSrc += classWithMembers

val classDef = new xsbti.api.ClassLikeDef(
defType, tParams, name, acc, modifiers, anns
name, acc, modifiers, anns, tParams, defType
) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
classDef
}
Expand Down
19 changes: 10 additions & 9 deletions internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class ExtractAPI[GlobalType <: Global](
build(resultType, typeParams, valueParameters)
case returnType =>
val retType = processType(in, dropConst(returnType))
new xsbti.api.Def(valueParameters.reverse.toArray, retType, typeParams,
simpleName(s), getAccess(s), getModifiers(s), annotations(in, s))
new xsbti.api.Def(simpleName(s), getAccess(s), getModifiers(s), annotations(in, s),
typeParams, valueParameters.reverse.toArray, retType)
}
}
def parameterS(s: Symbol): xsbti.api.MethodParameter = {
Expand All @@ -263,11 +263,11 @@ class ExtractAPI[GlobalType <: Global](
build(t, Array(), Nil)
}
private def hasDefault(s: Symbol) = s != NoSymbol && s.hasFlag(Flags.DEFAULTPARAM)
private def fieldDef[T](in: Symbol, s: Symbol, keepConst: Boolean, create: (xsbti.api.Type, String, xsbti.api.Access, xsbti.api.Modifiers, Array[xsbti.api.Annotation]) => T): T =
private def fieldDef[T](in: Symbol, s: Symbol, keepConst: Boolean, create: (String, xsbti.api.Access, xsbti.api.Modifiers, Array[xsbti.api.Annotation], xsbti.api.Type) => T): T =
{
val t = dropNullary(viewer(in).memberType(s))
val t2 = if (keepConst) t else dropConst(t)
create(processType(in, t2), simpleName(s), getAccess(s), getModifiers(s), annotations(in, s))
create(simpleName(s), getAccess(s), getModifiers(s), annotations(in, s), processType(in, t2))
}
private def dropConst(t: Type): Type = t match {
case ConstantType(constant) => constant.tpe
Expand All @@ -291,10 +291,10 @@ class ExtractAPI[GlobalType <: Global](
val as = annotations(in, s)

if (s.isAliasType)
new xsbti.api.TypeAlias(processType(in, tpe), typeParams, name, access, modifiers, as)
new xsbti.api.TypeAlias(name, access, modifiers, as, typeParams, processType(in, tpe))
else if (s.isAbstractType) {
val bounds = tpe.bounds
new xsbti.api.TypeDeclaration(processType(in, bounds.lo), processType(in, bounds.hi), typeParams, name, access, modifiers, as)
new xsbti.api.TypeDeclaration(name, access, modifiers, as, typeParams, processType(in, bounds.lo), processType(in, bounds.hi))
} else
error("Unknown type member" + s)
}
Expand Down Expand Up @@ -558,8 +558,9 @@ class ExtractAPI[GlobalType <: Global](
val tParams = typeParameters(in, sym) // look at class symbol
val selfType = lzy(this.selfType(in, sym))
def constructClass(structure: xsbti.api.Lazy[Structure]): ClassLike = {
new xsbti.api.ClassLike(defType, selfType, structure, emptyStringArray,
childrenOfSealedClass, topLevel, tParams, name, acc, modifiers, anns) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
new xsbti.api.ClassLike(name, acc, modifiers, anns,
defType, selfType, structure, emptyStringArray,
childrenOfSealedClass, topLevel, tParams) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
}
val info = viewer(in).memberInfo(sym)
val structure = lzy(structureWithInherited(info, sym))
Expand All @@ -568,7 +569,7 @@ class ExtractAPI[GlobalType <: Global](
allNonLocalClassesInSrc += classWithMembers

val classDef = new xsbti.api.ClassLikeDef(
defType, tParams, name, acc, modifiers, anns
name, acc, modifiers, anns, tParams, defType
) // use original symbol (which is a term symbol when `c.isModule`) for `name` and other non-classy stuff
classDef
}
Expand Down
10 changes: 5 additions & 5 deletions internal/compiler-interface/src/main/datatype/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Definition",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"fields": [
{
"name": "name",
Expand All @@ -29,13 +29,13 @@
"name": "ClassDefinition",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"types": [
{
"name": "FieldLike",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"fields": [
{
"name": "tpe",
Expand All @@ -62,7 +62,7 @@
"name": "ParameterizedDefinition",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"fields": [
{
"name": "typeParameters",
Expand Down Expand Up @@ -103,7 +103,7 @@
"name": "TypeMember",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",

"types": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "ClassfileManagerType",
"namespace": "xsbti.compile",
"target": "Java",
"type": "protocol",
"type": "interface",
"types": [
{
"name": "DeleteImmediatelyManagerType",
Expand Down Expand Up @@ -263,7 +263,7 @@
"name": "CompileAnalysis",
"namespace": "xsbti.compile",
"target": "Java",
"type": "protocol",
"type": "interface",
"doc": [
"Represents the analysis of an incremental compilation."
]
Expand Down
24 changes: 12 additions & 12 deletions internal/compiler-interface/src/main/datatype/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"name": "Access",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",

"types": [
{
Expand All @@ -141,7 +141,7 @@
"name": "Qualified",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"fields": [
{
"name": "qualifier",
Expand Down Expand Up @@ -170,7 +170,7 @@
"name": "Qualifier",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",
"types": [
{
"name": "Unqualified",
Expand Down Expand Up @@ -306,8 +306,8 @@
"name": "Variance",
"namespace": "xsbti.api",
"target": "Java",
"type": "enumeration",
"types": [
"type": "enum",
"symbols": [
"Contravariant",
"Covariant",
"Invariant"
Expand All @@ -317,8 +317,8 @@
"name": "ParameterModifier",
"namespace": "xsbti.api",
"target": "Java",
"type": "enumeration",
"types": [
"type": "enum",
"symbols": [
"Repeated",
"Plain",
"ByName"
Expand All @@ -328,8 +328,8 @@
"name": "DefinitionType",
"namespace": "xsbti.api",
"target": "Java",
"type": "enumeration",
"types": [
"type": "enum",
"symbols": [
"Trait",
"ClassDef",
"Module",
Expand All @@ -352,7 +352,7 @@
"name": "PathComponent",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",

"types": [
{
Expand Down Expand Up @@ -396,8 +396,8 @@
],
"namespace": "xsbti.api",
"target": "Java",
"type": "enumeration",
"types": [
"type": "enum",
"symbols": [
{
"name": "DependencyByMemberRef",
"doc": [
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler-interface/src/main/datatype/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"name": "Type",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",

"types": [
{
"name": "SimpleType",
"namespace": "xsbti.api",
"target": "Java",
"type": "protocol",
"type": "interface",

"types": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ object ClassToAPI {
val name = classCanonicalName(c)
val tpe = if (Modifier.isInterface(c.getModifiers)) Trait else ClassDef
lazy val (static, instance) = structure(c, enclPkg, cmap)
val cls = new api.ClassLike(tpe, strict(Empty), lzy(instance, cmap), emptyStringArray, children.toArray,
topLevel, typeParameters(typeParameterTypes(c)), name, acc, mods, annots)
val clsDef = new api.ClassLikeDef(tpe, typeParameters(typeParameterTypes(c)), name, acc, mods, annots)
val stat = new api.ClassLike(Module, strict(Empty), lzy(static, cmap), emptyStringArray, emptyTypeArray,
topLevel, emptyTypeParameterArray, name, acc, mods, annots)
val statDef = new api.ClassLikeDef(Module, emptyTypeParameterArray, name, acc, mods, annots)
val cls = new api.ClassLike(name, acc, mods, annots, tpe, strict(Empty), lzy(instance, cmap), emptyStringArray, children.toArray,
topLevel, typeParameters(typeParameterTypes(c)))
val clsDef = new api.ClassLikeDef(name, acc, mods, annots, typeParameters(typeParameterTypes(c)), tpe)
val stat = new api.ClassLike(name, acc, mods, annots, Module, strict(Empty), lzy(static, cmap), emptyStringArray, emptyTypeArray,
topLevel, emptyTypeParameterArray)
val statDef = new api.ClassLikeDef(name, acc, mods, annots, emptyTypeParameterArray, Module)
val defs = cls :: stat :: Nil
val defsEmptyMembers = clsDef :: statDef :: Nil
cmap.memo(name) = defsEmptyMembers
Expand Down Expand Up @@ -188,9 +188,9 @@ object ClassToAPI {
}
val tpe = specificTpe.getOrElse(fieldTpe)
if (mods.isFinal) {
new api.Val(tpe, name, accs, mods, annots)
new api.Val(name, accs, mods, annots, tpe)
} else {
new api.Var(tpe, name, accs, mods, annots)
new api.Var(name, accs, mods, annots, tpe)
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ object ClassToAPI {
val pa = (paramAnnots, paramTypes, isVarArg).zipped map { case (a, p, v) => parameter(a, p, v) }
val params = new api.ParameterList(pa, false)
val ret = retType match { case Some(rt) => reference(rt); case None => Empty }
new api.Def(Array(params), ret, typeParameters(tps), name, access(mods, enclPkg), modifiers(mods), annotations(annots) ++ exceptionAnnotations(exceptions))
new api.Def(name, access(mods, enclPkg), modifiers(mods), annotations(annots) ++ exceptionAnnotations(exceptions), typeParameters(tps), Array(params), ret)
}

def exceptionAnnotations(exceptions: Array[Type]): Array[api.Annotation] =
Expand Down
9 changes: 5 additions & 4 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/APIUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ object APIUtil {
{
val savedAnnotations = Discovery.defAnnotations(c.structure, (_: Any) => true).toArray[String]
val struct = minimizeStructure(c.structure, c.definitionType == DefinitionType.Module)
new ClassLike(c.definitionType, lzy(emptyType), lzy(struct), savedAnnotations, c.childrenOfSealedClass,
c.topLevel, c.typeParameters, c.name, c.access, c.modifiers, c.annotations)
new ClassLike(c.name, c.access, c.modifiers, c.annotations,
c.definitionType, lzy(emptyType), lzy(struct), savedAnnotations, c.childrenOfSealedClass,
c.topLevel, c.typeParameters)
}

def minimizeStructure(s: Structure, isModule: Boolean): Structure =
Expand All @@ -75,8 +76,8 @@ object APIUtil {
private val emptyModifiers = new Modifiers(false, false, false, false, false, false, false, false)
private val emptyStructure = new Structure(lzy(Array.empty), lzy(Array.empty), lzy(Array.empty))
def emptyClassLike(name: String, definitionType: DefinitionType): ClassLike =
new xsbti.api.ClassLike(definitionType, lzy(emptyType), lzy(emptyStructure), Array.empty, Array.empty, true,
Array.empty, name, new Public, emptyModifiers, Array.empty)
new xsbti.api.ClassLike(name, new Public, emptyModifiers, Array.empty,
definitionType, lzy(emptyType), lzy(emptyStructure), Array.empty, Array.empty, true, Array.empty)

private[this] def lzy[T <: AnyRef](t: T): Lazy[T] = SafeLazy.strict(t)

Expand Down
Loading

0 comments on commit f872f9c

Please sign in to comment.