Permalink
Browse files

JPS: transfer SBT debug messages from compile server

  • Loading branch information...
1 parent f345aec commit 24b03624b9c14589d4e4032e65364d32ddc54ad3 @pavelfatin pavelfatin committed Feb 11, 2013
@@ -22,6 +22,7 @@ import _root_.scala.util.control.Exception._
import org.jetbrains.jps.incremental.ModuleLevelBuilder.{OutputConsumer, ExitCode}
import local.LocalServer
import remote.RemoteServer
+import com.intellij.openapi.diagnostic.{Logger => JpsLogger}
/**
* @author Pavel Fatin
@@ -133,6 +134,8 @@ class ScalaBuilder extends ModuleLevelBuilder(BuilderCategory.TRANSLATOR) {
}
object ScalaBuilder {
+ val Log = JpsLogger.getInstance(classOf[ScalaBuilder])
+
// Cached local localServer
private var cachedServer: Option[Server] = None
@@ -238,6 +241,10 @@ private class IdeClient(compilerName: String,
context.processMessage(new ProgressMessage(formattedText, done.getOrElse(-1.0F)))
}
+ def debug(text: String) {
+ ScalaBuilder.Log.info(text)
+ }
+
def generated(source: File, module: File, name: String) {
invalidateBoundForms(source)
val target = sourceToTarget(source).getOrElse {
@@ -31,6 +31,8 @@ trait Client {
def progress(text: String, done: Option[Float] = None)
+ def debug(text: String)
+
def generated(source: File, module: File, name: String)
def deleted(module: File)
@@ -11,7 +11,6 @@ import sbt.inc.{Analysis, AnalysisStore, Locate}
import xsbti._
import org.jetbrains.jps.incremental.messages.BuildMessage.Kind
import xsbti.api.SourceAPI
-import com.intellij.openapi.diagnostic.{Logger => JpsLogger}
/**
* @author Pavel Fatin
@@ -70,20 +69,6 @@ class CompilerImpl(javac: JavaCompiler, scalac: Option[AnalyzingCompiler], fileT
}
}
-private object CompilerImpl {
- private val Log = JpsLogger.getInstance(classOf[CompilerImpl])
-
- private val MaxLineLength = 500
-
- private def trim(line: String) =
- if (line.length > MaxLineLength) line.substring(0, MaxLineLength) + "..." else line
-
- def log(message: String) {
- val lines = message.split('\n').map(CompilerImpl.trim)
- CompilerImpl.Log.info("\n\n" + lines.mkString("\n") + "\n")
- }
-}
-
private class ClientLogger(client: Client) extends Logger {
def error(msg: F0[String]) {
client.error(msg())
@@ -98,15 +83,22 @@ private class ClientLogger(client: Client) extends Logger {
}
def debug(msg: F0[String]) {
- // TODO remove SBT debug messages logging later
- CompilerImpl.log(msg().trim)
+ val lines = msg().trim.split('\n').map(ClientLogger.trim)
+ client.debug("\n\n" + lines.mkString("\n") + "\n")
}
def trace(exception: F0[Throwable]) {
client.trace(exception())
}
}
+private object ClientLogger {
+ private val MaxLineLength = 500
+
+ private def trim(line: String) =
+ if (line.length > MaxLineLength) line.substring(0, MaxLineLength) + "..." else line
+}
+
private class ClientProgress(client: Client) extends CompileProgress {
def startUnit(phase: String, unitPath: String) {
val unitName = new File(unitPath).getName
@@ -15,14 +15,17 @@ class ClientEventProcessor(client: Client) {
case ProgressEvent(text, done) =>
client.progress(text, done)
+ case DebugEvent(text) =>
+ client.debug(text)
+
+ case TraceEvent(message, lines) =>
+ client.trace(new ServerException(message, lines))
+
case GeneratedEvent(source, module, name) =>
client.generated(source, module, name)
case DeletedEvent(module) =>
client.deleted(module)
-
- case TraceEvent(message, lines) =>
- client.trace(new ServerException(message, lines))
}
}
}
@@ -34,10 +34,12 @@ object Event {
case class MessageEvent(kind: Kind, text: String, source: Option[File], line: Option[Long], column: Option[Long]) extends Event
-case class TraceEvent(message: String, lines: Array[String]) extends Event
-
case class ProgressEvent(text: String, done: Option[Float]) extends Event
+case class DebugEvent(text: String) extends Event
+
+case class TraceEvent(message: String, lines: Array[String]) extends Event
+
case class GeneratedEvent(source: File, module: File, name: String) extends Event
case class DeletedEvent(module: File) extends Event
@@ -25,6 +25,10 @@ class EventGeneratingClient(listener: Event => Unit, canceled: => Boolean) exten
listener(ProgressEvent(text, done))
}
+ def debug(text: String) {
+ listener(DebugEvent(text))
+ }
+
def generated(source: File, module: File, name: String) {
listener(GeneratedEvent(source, module, name))
}

0 comments on commit 24b0362

Please sign in to comment.