Skip to content

Commit

Permalink
Adopt delegating reporter to new scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmulder committed Oct 10, 2016
1 parent d490f7d commit 550c643
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions bridge/src/main/scala/xsbt/DelegatingReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package xsbt
import dotty.tools._
import dotc._
import reporting._
import reporting.diagnostic.MessageContainer
import reporting.diagnostic.messages
import core.Contexts._

import xsbti.{Maybe, Position}
Expand All @@ -16,19 +18,19 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter

override def printSummary(implicit ctx: Context): Unit = delegate.printSummary()

def doReport(d: Diagnostic)(implicit ctx: Context): Unit = {
val severity =
d match {
case _: Reporter.Error => xsbti.Severity.Error
case _: Reporter.Warning => xsbti.Severity.Warn
def doReport(cont: MessageContainer)(implicit ctx: Context): Unit = {
val severity =
cont match {
case _: messages.Error => xsbti.Severity.Error
case _: messages.Warning => xsbti.Severity.Warn
case _ => xsbti.Severity.Info
}
val pos =
if (d.pos.exists) Some(d.pos)
val pos =
if (cont.pos.exists) Some(cont.pos)
else None

val file =
if (d.pos.source.file.exists) Option(d.pos.source.file.file)
val file =
if (cont.pos.source.file.exists) Option(cont.pos.source.file.file)
else None

val offset0 = pos.map(_.point)
Expand All @@ -43,16 +45,16 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter
def sourcePath: Maybe[String] = maybe(file.map(_.getPath))
}

delegate.log(position, d.message, severity)
delegate.log(position, cont.message, severity)
}

private[this] def maybe[T](opt: Option[T]): Maybe[T] = opt match {
private[this] def maybe[T](opt: Option[T]): Maybe[T] = opt match {
case None => Maybe.nothing[T]
case Some(s) => Maybe.just[T](s)
}
import java.lang.{ Integer => I }
private[this] def maybeInt(opt: Option[Int]): Maybe[I] = opt match {
private[this] def maybeInt(opt: Option[Int]): Maybe[I] = opt match {
case None => Maybe.nothing[I]
case Some(s) => Maybe.just[I](s)
}
}
}

0 comments on commit 550c643

Please sign in to comment.