From 7991aeb5b676d408fd8749e10f63bf8a9ccb7943 Mon Sep 17 00:00:00 2001
From: Etienne Kneuss <ekneuss@gmail.com>
Date: Mon, 1 Jun 2015 13:49:33 +0200
Subject: [PATCH] Report file name in errors/warnings

Multiple-file benchmarks are getting common nowadays, so we report the
files corresponding to the error to help debugging. File should be
relative to the CWD, when possible, absolute otherwise.
---
 src/main/scala/leon/Reporter.scala | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/main/scala/leon/Reporter.scala b/src/main/scala/leon/Reporter.scala
index b326f5146..32a920716 100644
--- a/src/main/scala/leon/Reporter.scala
+++ b/src/main/scala/leon/Reporter.scala
@@ -113,10 +113,24 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
     case DEBUG(_) => "["+Console.MAGENTA          +" Debug  "+Console.RESET+"]"
   }
 
+  def smartPos(p: Position): String = {
+    if (p == NoPosition) {
+      ""
+    } else {
+      val target = p.file.getAbsolutePath()
+      val here   = new java.io.File(".").getAbsolutePath().stripSuffix(".")
+      val diff   = target.stripPrefix(here)
+
+      val filePos = diff+":"
+
+      filePos + p + ": "
+    }
+  }
+
   def emit(msg: Message) = {
     val posString = if (msg.position != NoPosition) { msg.position+": " } else { "" }
 
-    println(reline(severityToPrefix(msg.severity), posString + msg.msg.toString))
+    println(reline(severityToPrefix(msg.severity), smartPos(msg.position) + msg.msg.toString))
     printLineContent(msg.position)
   }
 
-- 
GitLab