Skip to content

Commit

Permalink
Use identity and remove unnecessary param
Browse files Browse the repository at this point in the history
This does not change semantics.
  • Loading branch information
jvican committed Jun 20, 2017
1 parent 866d9fd commit fd0d2d5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class AnalyzingCompiler(
val compArgs = new CompilerArguments(scalaInstance, classpathOptions)
val arguments = compArgs(Nil, classpath, None, options)
val output = CompileOutput(singleOutput)
val reporter = new LoggerReporter(maximumErrors, log, p => p)
val reporter = new LoggerReporter(maximumErrors, log)
val progress = Optional.empty[CompileProgress]
compile(sources, changes, arguments.toArray, output, callback, reporter, cache, log, progress)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ object LoggerReporter {
lazy val problemStringFormats: ProblemStringFormats = new ProblemStringFormats {}
}

class LoggerReporter(maximumErrors: Int,
logger: ManagedLogger,
sourcePositionMapper: Position => Position = { p =>
p
})
extends Reporter {
class LoggerReporter(
maximumErrors: Int,
logger: ManagedLogger,
sourcePositionMapper: Position => Position = identity[Position]
) extends Reporter {
val positions = new mutable.HashMap[PositionKey, Severity]
val count = new EnumMap[Severity, Int](classOf[Severity])
private[this] val allProblems = new mutable.ListBuffer[Problem]
Expand All @@ -75,6 +74,7 @@ class LoggerReporter(maximumErrors: Int,
positions.clear()
allProblems.clear()
}

def hasWarnings = count.get(Warn) > 0
def hasErrors = count.get(Error) > 0
def problems: Array[Problem] = allProblems.toArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ case class ProjectStructure(
// to specify it in the incremental option property file (this is the default for sbt)
val incOptionsFile = baseDirectory / "incOptions.properties"
val (incOptions, scalacOptions) = loadIncOptions(incOptionsFile)
val reporter = new LoggerReporter(maxErrors, scriptedLog, identity)
val reporter = new LoggerReporter(maxErrors, scriptedLog)
val extra = Array(t2(("key", "value")))
val setup = compiler.setup(lookup,
skip = false,
Expand Down
2 changes: 1 addition & 1 deletion zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BaseCompilerSpec extends BridgeProviderSpecification {
val cs = compiler.compilers(si, ClasspathOptionsUtil.boot, None, sc)

val lookup = MockedLookup(Function.const(Optional.empty[CompileAnalysis]))
val reporter = new LoggerReporter(maxErrors, log, identity)
val reporter = new LoggerReporter(maxErrors, log)
val extra = Array(InterfaceUtil.t2(("key", "value")))

var lastCompiledUnits: Set[String] = Set.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MultiProjectIncrementalSpec extends BridgeProviderSpecification {
def externalClassFileManager: Optional[ClassFileManager] = Optional.empty()
})

val reporter = new LoggerReporter(maxErrors, log, identity)
val reporter = new LoggerReporter(maxErrors, log)
val setup = compiler.setup(lookup,
skip = false,
cacheFile,
Expand Down

0 comments on commit fd0d2d5

Please sign in to comment.