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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ website/build/bloop-gh-pages/
node_modules/
package-lock.json
.metals/
**/metals.sbt
*.lock
benchmark-bridge/corpus/
19 changes: 5 additions & 14 deletions backend/src/main/scala/bloop/BloopClassFileManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import bloop.io.AbsolutePath
import bloop.io.ParallelOps
import bloop.io.ParallelOps.CopyMode
import bloop.io.{Paths => BloopPaths}
import bloop.reporter.Reporter
import bloop.tracing.BraveTracer

import monix.eval.Task
Expand Down Expand Up @@ -210,7 +209,7 @@ final class BloopClassFileManager(
backgroundTasksWhenNewSuccessfulAnalysis.+=(
(
clientExternalClassesDir: AbsolutePath,
clientReporter: Reporter,
_,
clientTracer: BraveTracer
) => {
clientTracer.traceTaskVerbose("copy new products to external classes dir") { _ =>
Expand All @@ -220,7 +219,6 @@ final class BloopClassFileManager(
newClassesDir,
clientExternalClassesDir.underlying,
inputs.ioScheduler,
inputs.logger,
enableCancellation = false
)
.map { walked =>
Expand Down Expand Up @@ -248,20 +246,14 @@ final class BloopClassFileManager(

// Delete all compilation products generated in the new classes directory
val deleteNewDir = Task { BloopPaths.delete(AbsolutePath(newClassesDir)); () }.memoize
backgroundTasksForFailedCompilation.+=(
(
clientExternalClassesDir: AbsolutePath,
clientReporter: Reporter,
clientTracer: BraveTracer
) => {
clientTracer.traceTask("delete class files after")(_ => deleteNewDir)
}
)
backgroundTasksForFailedCompilation.+=((_, _, clientTracer: BraveTracer) => {
clientTracer.traceTask("delete class files after")(_ => deleteNewDir)
})

backgroundTasksForFailedCompilation.+=(
(
clientExternalClassesDir: AbsolutePath,
clientReporter: Reporter,
_,
clientTracer: BraveTracer
) =>
Task.defer {
Expand All @@ -282,7 +274,6 @@ final class BloopClassFileManager(
Paths.get(readOnlyClassesDirPath),
clientExternalClassesDir.underlying,
inputs.ioScheduler,
inputs.logger,
enableCancellation = false
)
.map(_ => ())
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/scala/bloop/BloopClasspathEntryLookup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class BloopClasspathEntryLookup(
case null =>
if (entry.isDirectory()) entryHash -> new DirectoryDefinesClass(entry)
else entryHash -> computeDefinesClassForJar
case current @ (cachedHash, cachedDefinesClass) =>
case current @ (cachedHash, _) =>
if (entryHash.hash() == cachedHash.hash()) current
else entryHash -> computeDefinesClassForJar
}
Expand Down Expand Up @@ -106,7 +106,7 @@ final class BloopClasspathEntryLookup(
}

private def subDirectory(base: File, parts: Seq[String]): File =
(base /: parts)((b, p) => new File(b, p))
parts.foldLeft(base) { (b, p) => new File(b, p) }

private def components(className: String): (Seq[String], String) = {
assume(!className.isEmpty)
Expand Down
11 changes: 1 addition & 10 deletions backend/src/main/scala/bloop/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import bloop.util.CacheHashCode
import bloop.util.UUIDUtil

import monix.eval.Task
import monix.execution.CancelableFuture
import monix.execution.Scheduler
import sbt.internal.inc.Analysis
import sbt.internal.inc.ConcreteAnalysisContents
Expand Down Expand Up @@ -338,13 +337,6 @@ object Compiler {
Setup.create(lookup, skip, cacheFile, compilerCache, incOptions, reporter, progress, empty)
}

def runAggregateTasks(tasks: List[Task[Unit]]): CancelableFuture[Unit] = {
Task
.gatherUnordered(tasks)
.map(_ => ())
.runAsync(compileInputs.ioScheduler)
}

val start = System.nanoTime()
val scalaInstance = compileInputs.scalaInstance
val classpathOptions = compileInputs.classpathOptions
Expand Down Expand Up @@ -442,11 +434,10 @@ object Compiler {
readOnlyClassesDir,
clientClassesDir.underlying,
compileInputs.ioScheduler,
compileInputs.logger,
enableCancellation = false
)

lastCopy.map { fs =>
lastCopy.map { _ =>
clientLogger.debug(
s"Finished copying classes from $readOnlyClassesDir to $clientClassesDir"
)
Expand Down
4 changes: 1 addition & 3 deletions backend/src/main/scala/bloop/CompilerCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ final class CompilerCache(
componentProvider,
Some(Paths.getCacheDirectory("bridge-cache").toFile),
bridgeSources,
retrieveDir.toFile,
logger,
scheduler
logger
)
}
}
Expand Down
11 changes: 5 additions & 6 deletions backend/src/main/scala/bloop/DependencyResolution.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object DependencyResolution {
logger: Logger,
resolveSources: Boolean = false,
additionalRepos: Seq[Repository] = Nil
)(implicit ec: scala.concurrent.ExecutionContext): Array[AbsolutePath] = {
): Array[AbsolutePath] = {
resolveWithErrors(artifacts, logger, resolveSources, additionalRepos) match {
case Right(paths) => paths
case Left(error) => throw error
Expand All @@ -54,15 +54,15 @@ object DependencyResolution {
logger: Logger,
resolveSources: Boolean = false,
additionalRepositories: Seq[Repository] = Nil
)(implicit ec: scala.concurrent.ExecutionContext): Either[CoursierError, Array[AbsolutePath]] = {
): Either[CoursierError, Array[AbsolutePath]] = {
val dependencies = artifacts.map { artifact =>
import artifact._
logger.debug(s"Resolving $organization:$module:$version")(DebugFilter.All)
val baseDep = coursierapi.Dependency.of(organization, module, version)
if (resolveSources) baseDep.withClassifier("sources")
else baseDep
}
resolveDependenciesWithErrors(dependencies, logger, resolveSources, additionalRepositories)
resolveDependenciesWithErrors(dependencies, resolveSources, additionalRepositories)
}

/**
Expand All @@ -77,11 +77,10 @@ object DependencyResolution {
*/
def resolveDependenciesWithErrors(
dependencies: Seq[coursierapi.Dependency],
logger: Logger,
resolveSources: Boolean = false,
additionalRepositories: Seq[Repository] = Nil
)(implicit ec: scala.concurrent.ExecutionContext): Either[CoursierError, Array[AbsolutePath]] = {
var fetch = coursierapi.Fetch
): Either[CoursierError, Array[AbsolutePath]] = {
val fetch = coursierapi.Fetch
.create()
.withDependencies(dependencies: _*)
if (resolveSources)
Expand Down
11 changes: 4 additions & 7 deletions backend/src/main/scala/bloop/ScalaInstance.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ final class ScalaInstance private (

object ScalaInstance {
import bloop.io.AbsolutePath
import scala.concurrent.ExecutionContext

private[ScalaInstance] val bootClassLoader: ClassLoader = {
if (!scala.util.Properties.isJavaAtLeast("9")) null
Expand Down Expand Up @@ -170,7 +169,7 @@ object ScalaInstance {
scalaVersion: String,
allJars: Seq[AbsolutePath],
logger: Logger
)(implicit ec: ExecutionContext): ScalaInstance = {
): ScalaInstance = {
val jarsKey = allJars.map(_.underlying).sortBy(_.toString).toList
if (allJars.nonEmpty) {
def newInstance = {
Expand All @@ -197,7 +196,7 @@ object ScalaInstance {
scalaName: String,
scalaVersion: String,
logger: Logger
)(implicit ec: ExecutionContext): ScalaInstance = {
): ScalaInstance = {
def resolveInstance: ScalaInstance = {
val allPaths = DependencyResolution.resolve(
List(DependencyResolution.Artifact(scalaOrg, scalaName, scalaVersion)),
Expand Down Expand Up @@ -237,9 +236,7 @@ object ScalaInstance {
* happen to be so strict as to prevent getting the location from the protected
* domain.
*/
def scalaInstanceForJavaProjects(
logger: Logger
)(implicit ec: ExecutionContext): Option[ScalaInstance] = {
def scalaInstanceForJavaProjects(logger: Logger): Option[ScalaInstance] = {
lazy val tempDirectory = Files.createTempDirectory("bloop-scala-instance")
implicit val filter = DebugFilter.Compilation
def findLocationForClazz(clazz: Class[_], jarName: String): Option[Path] = {
Expand All @@ -249,7 +246,7 @@ object ScalaInstance {

try Some(Paths.get(expectedPath))
catch {
case t: java.nio.file.FileSystemNotFoundException =>
case _: java.nio.file.FileSystemNotFoundException =>
// When bloop is bootstrapped by coursier, jars are available from resources instead
logger.debug(
s"Load jar from resource because scheme '${expectedPath.getScheme}' has no file system provider"
Expand Down
8 changes: 4 additions & 4 deletions backend/src/main/scala/bloop/io/ClasspathHasher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object ClasspathHasher {
}
} catch {
// Can happen when a file doesn't exist, for example
case monix.execution.misc.NonFatal(t) => BloopStamps.emptyHash(path)
case monix.execution.misc.NonFatal(_) => BloopStamps.emptyHash(path)
}
classpathHashes(idx) = hash
hashingPromises.remove(path, p)
Expand Down Expand Up @@ -152,7 +152,7 @@ object ClasspathHasher {
}
}

tracer.traceTaskVerbose("computing hashes") { tracer =>
tracer.traceTaskVerbose("computing hashes") { _ =>
val acquiredByOtherTasks = new mutable.ListBuffer[Task[Unit]]()
val acquiredByThisHashingProcess = new mutable.ListBuffer[AcquiredTask]()

Expand Down Expand Up @@ -189,7 +189,7 @@ object ClasspathHasher {

val initEntries = Task {
classpath.zipWithIndex.foreach {
case t @ (absoluteEntry, idx) =>
case (absoluteEntry, idx) =>
acquireHashingEntry(absoluteEntry.underlying, idx)
}
}.doOnCancel(Task { isCancelled.compareAndSet(false, true); () })
Expand All @@ -198,7 +198,7 @@ object ClasspathHasher {
val acquiredTask = Observable.fromIterable(acquiredByThisHashingProcess)

val cancelableAcquiredTask = Task.create[Unit] { (scheduler, cb) =>
val (out, consumerSubscription) = parallelConsumer.createSubscriber(cb, scheduler)
val (out, _) = parallelConsumer.createSubscriber(cb, scheduler)
val _ = acquiredTask.subscribe(out)
Cancelable { () =>
isCancelled.compareAndSet(false, true); ()
Expand Down
5 changes: 1 addition & 4 deletions backend/src/main/scala/bloop/io/ParallelOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import java.util.concurrent.ConcurrentHashMap

import scala.concurrent.Promise

import bloop.logging.Logger

import monix.eval.Task
import monix.execution.Cancelable
import monix.execution.Scheduler
Expand Down Expand Up @@ -67,7 +65,6 @@ object ParallelOps {
origin: Path,
target: Path,
scheduler: Scheduler,
logger: Logger,
enableCancellation: Boolean
): Task[FileWalk] = Task.defer {
val isCancelled = AtomicBoolean(false)
Expand Down Expand Up @@ -192,7 +189,7 @@ object ParallelOps {
if (!changedMetadata) ()
else copy(replaceExisting = true)
// Can happen when the file does not exist, replace in that case
case Failure(t: IOException) => copy(replaceExisting = true)
case Failure(_: IOException) => copy(replaceExisting = true)
case Failure(t) => throw t
}
case CopyMode.NoReplace =>
Expand Down
1 change: 0 additions & 1 deletion backend/src/main/scala/bloop/logging/ProcessLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ProcessLogger(underlying: Logger, process: Process) {
private[this] val processErr = process.getErrorStream

def start(): Unit = {
implicit val ctx: DebugFilter = DebugFilter.All
underlying.printDebug("Starting to log output from process...")
new StreamLogger(underlying.info, processOut).start()
new StreamLogger(underlying.error, processErr).start()
Expand Down
18 changes: 18 additions & 0 deletions backend/src/main/scala/bloop/logging/Slf4jAdapter.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package bloop.logging

import scala.annotation.nowarn

import org.slf4j.Marker
import org.slf4j.{Logger => Slf4jLogger}

Expand All @@ -26,8 +28,11 @@ final class Slf4jAdapter[L <: Logger](logger: L) extends Slf4jLogger {
override def debug(marker: Marker, format: String, arg: scala.Any): Unit =
logger.debug(arg.toString)

@nowarn("msg=parameter value format in method debug is never used")
override def debug(format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.debug(a.toString))

@nowarn("msg=parameter value (marker|format) in method debug is never used")
override def debug(marker: Marker, format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.debug(a.toString))

Expand Down Expand Up @@ -55,8 +60,11 @@ final class Slf4jAdapter[L <: Logger](logger: L) extends Slf4jLogger {
logger.error(arg1.toString); logger.error(arg2.toString)
}

@nowarn("msg=parameter value format in method error is never used")
override def error(format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.error(a.toString))

@nowarn("msg=parameter value (marker|format) in method error is never used")
override def error(marker: Marker, format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.error(a.toString))

Expand All @@ -69,8 +77,11 @@ final class Slf4jAdapter[L <: Logger](logger: L) extends Slf4jLogger {
override def warn(marker: Marker, format: String, arg: scala.Any): Unit =
logger.warn(arg.toString)

@nowarn("msg=parameter value format in method warn is never used")
override def warn(format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.warn(a.toString))

@nowarn("msg=parameter value (marker|format) in method warn is never used")
override def warn(marker: Marker, format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.warn(a.toString))

Expand All @@ -87,8 +98,12 @@ final class Slf4jAdapter[L <: Logger](logger: L) extends Slf4jLogger {
override def trace(marker: Marker, msg: String): Unit = logger.debug(msg)
override def trace(marker: Marker, format: String, arg: scala.Any): Unit =
logger.debug(arg.toString)

@nowarn("msg=parameter value format in method trace is never used")
override def trace(format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.debug(a.toString))

@nowarn("msg=parameter value (marker|format) in method trace is never used")
override def trace(marker: Marker, format: String, argArray: AnyRef*): Unit =
argArray.foreach(a => logger.debug(a.toString))

Expand Down Expand Up @@ -126,8 +141,11 @@ final class Slf4jAdapter[L <: Logger](logger: L) extends Slf4jLogger {
override def info(msg: String): Unit = logger.info(msg)
override def info(format: String, arg: scala.Any): Unit = logger.info(arg.toString)

@nowarn("msg=parameter value format in method info is never used")
override def info(format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.info(a.toString))

@nowarn("msg=parameter value (marker|format) in method info is never used")
override def info(marker: Marker, format: String, arguments: AnyRef*): Unit =
arguments.foreach(a => logger.info(a.toString))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package bloop.reporter

import scala.annotation.nowarn

import bloop.io.Environment.lineSeparator

/**
Expand All @@ -24,6 +26,7 @@ class DefaultReporterFormat(reporter: Reporter) extends ReporterFormat(reporter)
colored(reporter.config.sourcePathColor, filePath) + s"$line$column"
}

@nowarn("msg=parameter value endColumn in anonymous function is never used")
protected def formatSource(problem: Problem): Option[String] = {
val richFormatSource = {
for {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/scala/bloop/reporter/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ object Reporter {
def groupProblemsByFile(ps: List[ProblemPerPhase]): Map[File, List[ProblemPerPhase]] = {
val problemsPerFile = mutable.HashMap[File, List[ProblemPerPhase]]()
ps.foreach {
case pp @ ProblemPerPhase(p, phase) =>
case pp @ ProblemPerPhase(p, _) =>
InterfaceUtil.toOption(p.position().sourceFile).foreach { file =>
val newProblemsPerFile = pp :: problemsPerFile.getOrElse(file, Nil)
problemsPerFile.+=(file -> newProblemsPerFile)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/scala/bloop/tracing/BraveTracer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class BraveTracer private (
} finally {
try newTracer.terminate()
catch {
case NonFatal(t) => ()
case NonFatal(_) => ()
}
}
} else {
Expand Down Expand Up @@ -101,7 +101,7 @@ final class BraveTracer private (
def terminate(): Unit = this.synchronized {
// Guarantee we never throw, even though brave APIs should already
try closeCurrentSpan()
catch { case t: Throwable => () }
catch { case _: Throwable => () }
}

/**
Expand Down
Loading