Skip to content

Instantly share code, notes, and snippets.

@benjaminjackman
Created February 3, 2010 08:57
Show Gist options
  • Save benjaminjackman/293488 to your computer and use it in GitHub Desktop.
Save benjaminjackman/293488 to your computer and use it in GitHub Desktop.
diff --git a/src/main/scala/sbt/Compile.scala b/src/main/scala/sbt/Compile.scala
index aaaab2d..21f5ef6 100644
--- a/src/main/scala/sbt/Compile.scala
+++ b/src/main/scala/sbt/Compile.scala
@@ -261,9 +261,28 @@ final class LoggerReporter(maximumErrors: Int, log: Logger) extends scala.tools.
case NoPosition => log.log(level, msg)
case FakePos(fmsg) => log.log(level, fmsg+" "+msg)
case _ =>
- val sourcePrefix = pos.source.map(_.file.path).getOrElse("")
- val lineNumberString = pos.line.map(line => ":" + line + ":").getOrElse(":") + " "
- log.log(level, sourcePrefix + lineNumberString + msg)
+ //Attempts to turn a path into a guesstimated canonical class name
+ def canonicalClassName(path: String): String =
+ path.replaceAll("""/""", ".").replaceAll("""\\""", ".").
+ replaceAll(""".*src\.(main|test)\.scala\.*""", "").replaceAll("""\.scala""", "")
+
+ val fullPath = pos.source.map(_.file.path).getOrElse("")
+ val fileName = pos.source.map(_.file.name).getOrElse("")
+ val lineNumStr = pos.line.map(_.toString).getOrElse("0")
+ val fileLineStr = "(" + fileName + ":" + lineNumStr + ")"
+ //Here we essentially fake a bad method name for the time
+ //being this will allow programs that highlight on stacktrace
+ //elements to hopefully highlight on this entry...
+ val badMethod = canonicalClassName(fullPath) match {
+ case "" => ""
+ case canClass => {
+ //Drop this down a line to preserve horizontal space
+ "\n" + " at " + canClass + ".unknown"
+ }
+ }
+
+ //probably should make the format of this output fully customizable
+ log.log(level, "[" + fullPath + "]" + badMethod + fileLineStr + "\n" + msg)
if (!pos.line.isEmpty)
{
val lineContent = pos.lineContent.stripLineEnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment