Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ object ClassToAPI {
}

/** TODO: over time, ClassToAPI should switch the majority of access to the classfile parser */
private[this] def classFileForClass(c: Class[?]): ClassFile =
private def classFileForClass(c: Class[?]): ClassFile =
classfile.Parser.apply(IO.classfileLocation(c), Logger.Null)

@inline private[this] def lzyS[T <: AnyRef](t: T): xsbti.api.Lazy[T] = SafeLazyProxy.strict(t)
@inline private def lzyS[T <: AnyRef](t: T): xsbti.api.Lazy[T] = SafeLazyProxy.strict(t)
@inline final def lzy[T <: AnyRef](t: => T): xsbti.api.Lazy[T] = SafeLazyProxy(t)
private[this] def lzy[T <: AnyRef](t: => T, cmap: ClassMap): xsbti.api.Lazy[T] = {
private def lzy[T <: AnyRef](t: => T, cmap: ClassMap): xsbti.api.Lazy[T] = {
val s = lzy(t)
cmap.lz += s
s
Expand Down Expand Up @@ -551,7 +551,7 @@ object ClassToAPI {
}

// sbt/zinc#389: Ignore nulls coming from generic parameter types of lambdas
private[this] def ignoreNulls[T](genericTypes: Array[T]): Array[T] =
private def ignoreNulls[T](genericTypes: Array[T]): Array[T] =
genericTypes.filter(_ != null)

def referenceP(t: ParameterizedType): api.Parameterized = {
Expand Down Expand Up @@ -599,30 +599,30 @@ object ClassToAPI {
val Throws = reference("scala.throws")
val NothingRef = reference("scala.Nothing")

private[this] def PrimitiveNames =
private def PrimitiveNames =
Seq("boolean", "byte", "char", "short", "int", "long", "float", "double")
private[this] def PrimitiveMap = PrimitiveNames.map(j => (j, j.capitalize)) :+ ("void" -> "Unit")
private[this] val PrimitiveRefs = PrimitiveMap.map {
private def PrimitiveMap = PrimitiveNames.map(j => (j, j.capitalize)) :+ ("void" -> "Unit")
private val PrimitiveRefs = PrimitiveMap.map {
case (n, sn) => (n, reference("scala." + sn))
}.toMap
def primitive(name: String): api.Type = PrimitiveRefs(name)

private[this] def returnType(f: Field): Type = f.getGenericType
private[this] def returnType(m: Method): Type = m.getGenericReturnType
private[this] def exceptionTypes(c: Constructor[?]): Array[Type] = c.getGenericExceptionTypes
private def returnType(f: Field): Type = f.getGenericType
private def returnType(m: Method): Type = m.getGenericReturnType
private def exceptionTypes(c: Constructor[?]): Array[Type] = c.getGenericExceptionTypes

private[this] def exceptionTypes(m: Method): Array[Type] = m.getGenericExceptionTypes
private def exceptionTypes(m: Method): Array[Type] = m.getGenericExceptionTypes

private[this] def parameterTypes(m: Method): Array[Type] =
private def parameterTypes(m: Method): Array[Type] =
ignoreNulls(m.getGenericParameterTypes)

private[this] def parameterTypes(c: Constructor[?]): Array[Type] =
private def parameterTypes(c: Constructor[?]): Array[Type] =
ignoreNulls(c.getGenericParameterTypes)

private[this] def typeParameterTypes[T](m: Constructor[T]): Array[TypeVariable[Constructor[T]]] =
private def typeParameterTypes[T](m: Constructor[T]): Array[TypeVariable[Constructor[T]]] =
m.getTypeParameters
private[this] def typeParameterTypes[T](m: Class[T]): Array[TypeVariable[Class[T]]] =
private def typeParameterTypes[T](m: Class[T]): Array[TypeVariable[Class[T]]] =
m.getTypeParameters
private[this] def typeParameterTypes(m: Method): Array[TypeVariable[Method]] =
private def typeParameterTypes(m: Method): Array[TypeVariable[Method]] =
m.getTypeParameters
}
6 changes: 3 additions & 3 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/APIUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object APIUtil {
c.structure.parents.flatMap(Discovery.simpleName)
.contains("java.lang.annotation.Annotation")

private[this] class HasMacro extends Visit {
private class HasMacro extends Visit {
var hasMacro = false

// Don't visit inherited definitions since we consider that a class
Expand Down Expand Up @@ -106,7 +106,7 @@ object APIUtil {
}
private val emptyModifiers =
new Modifiers(false, false, false, false, false, false, false, false)
private[this] val emptyType = EmptyType.of()
private val emptyType = EmptyType.of()
private val emptyTypeLzy = lzy(emptyType: Type)
private val emptyDefs = Array.empty[Definition]
private val emptyClassDefs = Array.empty[ClassDefinition]
Expand Down Expand Up @@ -142,5 +142,5 @@ object APIUtil {
emptyClassLikeTemplate.typeParameters,
)

private[this] def lzy[T <: AnyRef](t: T): Lazy[T] = SafeLazyProxy.strict(t)
private def lzy[T <: AnyRef](t: T): Lazy[T] = SafeLazyProxy.strict(t)
}
78 changes: 39 additions & 39 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ final class HashAPI private (
import scala.collection.mutable
import MurmurHash3.{ mix, stringHash, unorderedHash }

private[this] val visitedStructures = visitedMap[Structure]
private[this] val visitedClassLike = visitedMap[ClassLike]
private[this] def visitedMap[T] = new mutable.HashMap[T, List[Hash]]
private[this] def visit[T](map: mutable.Map[T, List[Hash]], t: T)(hashF: T => Unit): Unit = {
private val visitedStructures = visitedMap[Structure]
private val visitedClassLike = visitedMap[ClassLike]
private def visitedMap[T] = new mutable.HashMap[T, List[Hash]]
private def visit[T](map: mutable.Map[T, List[Hash]], t: T)(hashF: T => Unit): Unit = {
map.put(t, hash :: map.getOrElse(t, Nil)) match {
case Some(x :: _) => extend(x)
case _ =>
Expand All @@ -93,45 +93,45 @@ final class HashAPI private (
}
}

private[this] final val ValHash = 1
private[this] final val VarHash = 2
private[this] final val DefHash = 3
private[this] final val ClassDefHash = 4
private[this] final val TypeDeclHash = 5
private[this] final val TypeAliasHash = 6
private final val ValHash = 1
private final val VarHash = 2
private final val DefHash = 3
private final val ClassDefHash = 4
private final val TypeDeclHash = 5
private final val TypeAliasHash = 6

private[this] final val PublicHash = 30
private[this] final val ProtectedHash = 31
private[this] final val PrivateHash = 32
private[this] final val UnqualifiedHash = 33
private[this] final val ThisQualifierHash = 34
private[this] final val IdQualifierHash = 35
private final val PublicHash = 30
private final val ProtectedHash = 31
private final val PrivateHash = 32
private final val UnqualifiedHash = 33
private final val ThisQualifierHash = 34
private final val IdQualifierHash = 35

private[this] final val IdPathHash = 20
private[this] final val SuperHash = 21
private[this] final val ThisPathHash = 22
private final val IdPathHash = 20
private final val SuperHash = 21
private final val ThisPathHash = 22

private[this] final val ValueParamsHash = 40
private[this] final val ClassPendingHash = 41
private[this] final val StructurePendingHash = 42
private final val ValueParamsHash = 40
private final val ClassPendingHash = 41
private final val StructurePendingHash = 42

private[this] final val EmptyTypeHash = 51
private[this] final val ParameterRefHash = 52
private[this] final val SingletonHash = 53
private[this] final val ProjectionHash = 54
private[this] final val ParameterizedHash = 55
private[this] final val AnnotatedHash = 56
private[this] final val PolymorphicHash = 57
private[this] final val ConstantHash = 58
private[this] final val ExistentialHash = 59
private[this] final val StructureHash = 60
private final val EmptyTypeHash = 51
private final val ParameterRefHash = 52
private final val SingletonHash = 53
private final val ProjectionHash = 54
private final val ParameterizedHash = 55
private final val AnnotatedHash = 56
private final val PolymorphicHash = 57
private final val ConstantHash = 58
private final val ExistentialHash = 59
private final val StructureHash = 60

private[this] val ClassHash = 70
private val ClassHash = 70

private[this] final val TrueHash = 97
private[this] final val FalseHash = 98
private final val TrueHash = 97
private final val FalseHash = 98

private[this] var hash: Hash = 0
private var hash: Hash = 0

final def hashString(s: String): Unit = extend(stringHash(s))
final def hashBoolean(b: Boolean): Unit = extend(if (b) TrueHash else FalseHash)
Expand Down Expand Up @@ -421,11 +421,11 @@ final class HashAPI private (
else hashStructure0NoDefs
}

private[this] final val hashStructure0WithDefsTrait = (s: Structure) =>
private final val hashStructure0WithDefsTrait = (s: Structure) =>
hashStructure0(s, includeDefinitions = true, isTrait = true)
private[this] final val hashStructure0WithDefs = (s: Structure) =>
private final val hashStructure0WithDefs = (s: Structure) =>
hashStructure0(s, includeDefinitions = true, isTrait = false)
private[this] final val hashStructure0NoDefs = (s: Structure) =>
private final val hashStructure0NoDefs = (s: Structure) =>
hashStructure0(s, includeDefinitions = false, isTrait = false)

def hashStructure0(structure: Structure, includeDefinitions: Boolean, isTrait: Boolean): Unit = {
Expand Down
4 changes: 2 additions & 2 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
import SameAPI._

private val pending = new mutable.HashSet[AnyRef]
private[this] val debugEnabled = java.lang.Boolean.getBoolean("xsbt.api.debug")
private val debugEnabled = java.lang.Boolean.getBoolean("xsbt.api.debug")
def debug(flag: Boolean, msg: => String): Boolean = {
if (debugEnabled && !flag) println(msg)
flag
Expand Down Expand Up @@ -343,7 +343,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) {
def sameStructure(a: Structure, b: Structure): Boolean =
samePending(a, b)(sameStructureDirect)

private[this] def samePending[T](a: T, b: T)(f: (T, T) => Boolean): Boolean =
private def samePending[T](a: T, b: T)(f: (T, T) => Boolean): Boolean =
if (pending add ((a, b))) f(a, b) else true

def sameStructureDirect(a: Structure, b: Structure): Boolean = {
Expand Down
4 changes: 2 additions & 2 deletions internal/zinc-apiinfo/src/main/scala/xsbt/api/Visit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import xsbti.api._
import scala.collection.mutable

class Visit {
private[this] val visitedStructures = new mutable.HashSet[Structure]
private[this] val visitedClassLike = new mutable.HashSet[ClassLike]
private val visitedStructures = new mutable.HashSet[Structure]
private val visitedClassLike = new mutable.HashSet[ClassLike]

def visitAPI(c: ClassLike): Unit = {
visitDefinition(c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class AnalysisFormatBenchmark {
}

class NullSerializer extends Serializer {
private[this] val strings = mutable.HashMap.empty[String, String]
private[this] var _count = 0
private val strings = mutable.HashMap.empty[String, String]
private var _count = 0
def count: Int = _count
def startBlock(name: String): Unit = _count += 1
def startArray(name: String, length: Int): Unit = _count += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private[sbt] object JavaAnalyze {
}
}

private[this] def urlAsFile(url: URL, log: Logger, finalJarOutput: Option[Path]): Option[Path] =
private def urlAsFile(url: URL, log: Logger, finalJarOutput: Option[Path]): Option[Path] =
try urlAsFile(url, finalJarOutput)
catch {
case e: Exception =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ object ScalaInstance {
def allJars(scalaHome: File): Seq[File] =
IO.listFiles(scalaLib(scalaHome)).toIndexedSeq.filter(f => !excludeList(f.getName))

private[this] def scalaLib(scalaHome: File): File =
private def scalaLib(scalaHome: File): File =
new File(scalaHome, "lib")

private[this] val excludeList: Set[String] = Set(
private val excludeList: Set[String] = Set(
"scala-actors.jar",
"scalacheck.jar",
"scala-partest.jar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class ClassLoaderCache(private val abstractClassLoaderCache: AbstractClass

private final class ClassLoaderCacheImpl(val commonParent: ClassLoader)
extends AbstractClassLoaderCache {
private[this] val delegate =
private val delegate =
new HashMap[List[File], Reference[CachedClassLoader]]

/**
Expand Down Expand Up @@ -94,7 +94,7 @@ private final class ClassLoaderCacheImpl(val commonParent: ClassLoader)
delegate.clear()
}

private[this] def getFromReference(
private def getFromReference(
files: List[File],
stamps: List[Long],
existingRef: Reference[CachedClassLoader],
Expand All @@ -105,7 +105,7 @@ private final class ClassLoaderCacheImpl(val commonParent: ClassLoader)
else
get(files, stamps, existingRef.get, mkLoader)

private[this] def get(
private def get(
files: List[File],
stamps: List[Long],
existing: CachedClassLoader,
Expand All @@ -116,7 +116,7 @@ private final class ClassLoaderCacheImpl(val commonParent: ClassLoader)
} else
existing.loader

private[this] def newEntry(
private def newEntry(
files: List[File],
stamps: List[Long],
mkLoader: () => ClassLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class ClasspathFilter(parent: ClassLoader, root: ClassLoader, classpath: S
| cp = $classpath
|)""".stripMargin

private[this] val directories: Seq[Path] = classpath.toSeq.filter { p =>
private val directories: Seq[Path] = classpath.toSeq.filter { p =>
!p.toString.endsWith(".jar") && Files.isDirectory(p)
}
override def loadClass(className: String, resolve: Boolean): Class[?] = {
Expand All @@ -88,12 +88,12 @@ final class ClasspathFilter(parent: ClassLoader, root: ClassLoader, classpath: S
else
throw new ClassNotFoundException(className)
}
private[this] def fromClasspath(c: Class[?]): Boolean = {
private def fromClasspath(c: Class[?]): Boolean = {
val codeSource = c.getProtectionDomain.getCodeSource
(codeSource eq null) ||
onClasspath(codeSource.getLocation)
}
private[this] def onClasspath(src: URL): Boolean =
private def onClasspath(src: URL): Boolean =
(src eq null) || (
ClasspathUtil.asFile(src).headOption match {
case Some(f) =>
Expand All @@ -113,7 +113,7 @@ final class ClasspathFilter(parent: ClassLoader, root: ClassLoader, classpath: S
if (us ne null) us.asScala.filter(onClasspath).asJavaEnumeration else null
}

@tailrec private[this] def includeLoader(c: ClassLoader, base: ClassLoader): Boolean =
@tailrec private def includeLoader(c: ClassLoader, base: ClassLoader): Boolean =
(base ne null) &&
(c ne null) &&
((c eq base) || includeLoader(c.getParent, base))
Expand Down Expand Up @@ -184,24 +184,24 @@ trait NativeCopyLoader extends ClassLoader {
protected val config: NativeCopyConfig
import config._

private[this] val mapped = new collection.mutable.HashMap[String, String]
private val mapped = new collection.mutable.HashMap[String, String]

override protected def findLibrary(name: String): String =
synchronized { mapped.getOrElseUpdate(name, findLibrary0(name)) }

private[this] def findLibrary0(name: String): String = {
private def findLibrary0(name: String): String = {
val mappedName = System.mapLibraryName(name)
val explicit = explicitLibraries.iterator.filter(_.getFileName.toString == mappedName)
val search = searchPaths.iterator flatMap relativeLibrary(mappedName)
val combined = explicit ++ search
if (combined.hasNext) copy(combined.next()) else null
}
private[this] def relativeLibrary(mappedName: String)(base: Path): Seq[Path] = {
private def relativeLibrary(mappedName: String)(base: Path): Seq[Path] = {
val f = base.resolve(mappedName)
if (Files.isRegularFile(f)) f :: Nil
else Nil
}
private[this] def copy(f: Path): String = {
private def copy(f: Path): String = {
val target = tempDirectory.resolve(f.getFileName.toString)
Files.copy(f, target, StandardCopyOption.REPLACE_EXISTING)
target.toAbsolutePath.toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DualLoader(
/** Concatenates `a` and `b` into a single `Enumeration`.*/
final class DualEnumeration[T](a: Enumeration[T], b: Enumeration[T]) extends Enumeration[T] {
// invariant: current.hasMoreElements or current eq b
private[this] var current = if (a.hasMoreElements) a else b
private var current = if (a.hasMoreElements) a else b
def hasMoreElements = current.hasMoreElements
def nextElement = {
val element = current.nextElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object RawURL {
def apply(file: String)(value: => InputStream): URL =
new URL("raw", null, -1, file, new RawStreamHandler(value))

private[this] final class RawStreamHandler(value: => InputStream) extends URLStreamHandler {
private final class RawStreamHandler(value: => InputStream) extends URLStreamHandler {
override protected def openConnection(url: URL, p: Proxy): URLConnection =
openConnection(url)
override protected def openConnection(url: URL): URLConnection =
Expand Down
Loading
Loading