Skip to content

Commit

Permalink
Merge pull request #549 from lukaszwawrzyk/warnings-cleanup
Browse files Browse the repository at this point in the history
Some warnings cleanup
  • Loading branch information
jvican authored Jun 14, 2018
2 parents ae02d7e + 08fb864 commit 182356e
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class InteractiveConsoleInterface(
val poutWriter: PrintWriter = new PrintWriter(outWriter)

val interpreter: IMain =
new IMain(compilerSettings, replReporter(compilerSettings, new PrintWriter(outWriter))) {
def lastReq: Request = prevRequestList.last
}
new IMain(compilerSettings, replReporter(compilerSettings, new PrintWriter(outWriter)))

def interpret(line: String, synthetic: Boolean): InteractiveConsoleResponse = {
clearBuffer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package xsbt
import xsbti.Logger
import scala.tools.nsc.interpreter.IMain
import scala.tools.nsc.interpreter.shell.{ ILoop, ShellConfig, ReplReporterImpl }
import scala.tools.nsc.reporters.Reporter
import scala.tools.nsc.{ GenericRunnerCommand, Settings }

class ConsoleInterface {
Expand Down Expand Up @@ -52,8 +51,12 @@ class ConsoleInterface {
} else
super.createInterpreter(interpreterSettings)

for ((id, value) <- bindNames zip bindValues)
intp.beQuietDuring(intp.bind(id, value.asInstanceOf[AnyRef].getClass.getName, value))
for ((id, value) <- bindNames zip bindValues) {
intp.beQuietDuring {
intp.bind(id, value.asInstanceOf[AnyRef].getClass.getName, value)
()
}
}

if (!initialCommands.isEmpty)
intp.interpret(initialCommands)
Expand All @@ -69,6 +72,7 @@ class ConsoleInterface {
}

loop.run(compilerSettings)
()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import sbt.internal.util.ConsoleLogger
import sbt.io.{ IO, RichFile }
import xsbt.ZincBenchmark.CompilationInfo
import xsbti._
import xsbti.compile.{ IncOptions, SingleOutput }
import xsbti.compile.SingleOutput

import scala.util.Try

Expand Down Expand Up @@ -352,6 +352,7 @@ case class BenchmarkProject(
gitClient.right.flatMap(Git.checkout(_, hash)).right.map(_ => tempDir)
}

// Left for compatibility
import ZincBenchmark.TryEnrich
def writeBuildInfo(projectDir: File, sharedDir: File): WriteBuildInfo = {
def persistBuildInfo(subproject: String, stateFile: File): Result[Unit] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ object ClasspathUtilities {

/** Returns all entries in 'classpath' that correspond to a compiler plugin.*/
private[sbt] def compilerPlugins(classpath: Seq[File], isDotty: Boolean): Iterable[File] = {
import collection.JavaConversions._
import collection.JavaConverters._
val loader = new URLClassLoader(Path.toURLs(classpath))
val metaFile = if (isDotty) "plugin.properties" else "scalac-plugin.xml"
loader.getResources(metaFile).toList.flatMap(asFile(true))
loader.getResources(metaFile).asScala.toList.flatMap(asFile(true))
}

/** Converts the given URL to a File. If the URL is for an entry in a jar, the File for the jar is returned. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class FilteredReporter(
val transformedPos: Position = positionMapper(position)
val problem = InterfaceUtil.problem(category, transformedPos, message, severity)
allProblems += problem
()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import sbt.util.LogExchange
import sbt.util.{ Level => SbtLevel }
import xsbti.{ Position, Reporter, ReporterConfig }

import scala.util.matching.Regex

object ReporterManager {
import java.util.concurrent.atomic.AtomicInteger
private val idGenerator: AtomicInteger = new AtomicInteger
Expand Down Expand Up @@ -75,8 +73,6 @@ object ReporterManager {
case _ => new LoggedReporter(maxErrors, logger, posMapper)
}
} else {
implicit def scalaPatterns(patterns: Array[java.util.regex.Pattern]): Array[Regex] =
patterns.map(_.pattern().r)
val fileFilters = config.fileFilters().map(_.toScala)
val msgFilters = config.msgFilters().map(_.toScala)
logger match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import scala.sys.process.ProcessLogger
* @param cwd The current working directory of the Javac process, used when parsing Filenames.
*/
final class JavacLogger(log: sbt.util.Logger, reporter: Reporter, cwd: File) extends ProcessLogger {
private var out: ListBuffer[String] = new ListBuffer()
private var err: ListBuffer[String] = new ListBuffer()
private val out: ListBuffer[String] = new ListBuffer()
private val err: ListBuffer[String] = new ListBuffer()

def out(s: => String): Unit =
synchronized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class JavaProcessLoggerSpec extends UnitSpec {

errorLogger.messages shouldBe Map.empty
reporter.problems.length shouldBe 2
()
}

def logSeparateSemanticErrors(): Unit = {
Expand All @@ -56,6 +57,7 @@ class JavaProcessLoggerSpec extends UnitSpec {

errorLogger.messages shouldBe Map.empty
reporter.problems.length shouldBe 2
()
}

def logUnparsableErrors(): Unit = {
Expand All @@ -71,5 +73,6 @@ class JavaProcessLoggerSpec extends UnitSpec {
.messages(Level.Warn)(0)
.contains("javadoc: error - invalid flag: -target") shouldBe true
errorLogger.messages(Level.Warn)(1).contains("javadoc exited with exit code -1") shouldBe true
()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private[inc] class APIDiff {
private final val DELETION_COLOR = ANSI_RED
private final val ADDITION_COLOR = ANSI_GREEN

@tailrec private def splitTokens(str: String, acc: List[String] = Nil): List[String] = {
@tailrec private def splitTokens(str: String, acc: List[String]): List[String] = {
if (str == "") {
acc.reverse
} else {
Expand Down Expand Up @@ -165,8 +165,10 @@ private[inc] class APIDiff {
def build(x: Array[String], y: Array[String], builder: mutable.ArrayBuilder[Patch]): Unit = {
if (x.isEmpty) {
builder += Inserted(y.mkString)
()
} else if (y.isEmpty) {
builder += Deleted(x.mkString)
()
} else if (x.length == 1 || y.length == 1) {
needlemanWunsch(x, y, builder)
} else {
Expand Down Expand Up @@ -251,6 +253,7 @@ private[inc] class APIDiff {
}
}
builder ++= alignment
()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private[inc] class MemberRefInvalidator(log: Logger, logRecompileOnMacro: Boolea
new InvalidateUnconditionally(memberRef)
case NamesChange(_, modifiedNames) if modifiedNames.in(UseScope.Implicit).nonEmpty =>
new InvalidateUnconditionally(memberRef)
case NamesChange(modifiedClass, modifiedNames) =>
case NamesChange(_, modifiedNames) =>
new NameHashFilteredInvalidator(usedNames, memberRef, modifiedNames, isScalaClass)
}

Expand All @@ -77,6 +77,7 @@ private[inc] class MemberRefInvalidator(log: Logger, logRecompileOnMacro: Boolea
}
}

// Left for compatibility
private class InvalidateDueToMacroDefinition(memberRef: Relation[String, String])
extends (String => Set[String]) {
def apply(from: String): Set[String] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package internal
package inc

import java.io.File
import java.net.URLClassLoader
import java.util.concurrent.Callable

import sbt.internal.inc.classpath.ClasspathUtilities
Expand Down Expand Up @@ -134,7 +133,6 @@ private[sbt] object ZincComponentCompiler {

override def fetchScalaInstance(scalaVersion: String,
logger: xsbti.Logger): xsbti.compile.ScalaInstance = {
import sbt.io.Path.toURLs
val scalaArtifacts = getScalaArtifacts(scalaVersion, logger)
val scalaCompiler = scalaArtifacts.compiler
val scalaLibrary = scalaArtifacts.library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import xsbti.{ Problem, T2 }

object BinaryAnalysisFormatSpecification
extends Properties("BinaryAnalysisFormat")
with BinaryAnalysisFormatSpecification {
with BinaryAnalysisFormatSpecificationHelpers {

property("Write and read empty Analysis") = {
checkAnalysis(Analysis.empty)
Expand Down Expand Up @@ -47,7 +47,7 @@ object BinaryAnalysisFormatSpecification

}

trait BinaryAnalysisFormatSpecification { self: Properties =>
trait BinaryAnalysisFormatSpecificationHelpers { self: Properties =>
val storeApis = true
def RootFilePath: String = "/dummy"
def dummyOutput = new xsbti.compile.SingleOutput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import xsbti.compile.analysis.ReadWriteMappers

object BinaryMappersSpecification
extends Properties("BinaryMappers")
with BinaryAnalysisFormatSpecification {
with BinaryAnalysisFormatSpecificationHelpers {

override def RootFilePath = "/tmp/localProject"
private final val mappers: ReadWriteMappers =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package sbt.internal.inc

import org.scalatest.exceptions.TestFailedException
import sbt.internal.inc
import sbt.internal.scripted._
import sbt.internal.inc.BatchScriptRunner.States

Expand Down
1 change: 1 addition & 0 deletions zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BaseCompilerSpec extends BridgeProviderSpecification {
val sourceFile = baseLocation.resolve(source)
val text = Files.readAllLines(sourceFile).asScala.mkString("\n")
Files.write(sourceFile, Seq(change(text)).asJava)
()
}

def dependsOnJarFrom(other: ProjectSetup): ProjectSetup = {
Expand Down

0 comments on commit 182356e

Please sign in to comment.