Skip to content
Snippets Groups Projects
Commit 61b0e4fe authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Positioned debug versions

parent dca86959
No related branches found
No related tags found
No related merge requests found
......@@ -74,23 +74,23 @@ abstract class Reporter(val debugSections: Set[DebugSection]) {
(debugMask & section.mask) == section.mask
}
def ifDebug(body: (Any => Unit) => Any)(implicit section: DebugSection) = {
def ifDebug(pos: Position, body: (Any => Unit) => Any)(implicit section: DebugSection) = {
if (isDebugEnabled) {
body( { (msg: Any) => emit(account(Message(DEBUG(section), NoPosition, msg))) } )
body( { (msg: Any) => emit(account(Message(DEBUG(section), pos, msg))) } )
}
}
def whenDebug(section: DebugSection)(body: (Any => Unit) => Any) {
def whenDebug(pos: Position, section: DebugSection)(body: (Any => Unit) => Any) {
if (isDebugEnabled(section)) {
body( { (msg: Any) => emit(account(Message(DEBUG(section), NoPosition, msg))) } )
body( { (msg: Any) => emit(account(Message(DEBUG(section), pos, msg))) } )
}
}
def debug(pos: Position, msg: => Any)(implicit section: DebugSection): Unit = {
ifDebug{ debug =>
ifDebug(pos, debug =>
debug(msg)
}(section)
)(section)
}
......@@ -103,6 +103,10 @@ abstract class Reporter(val debugSections: Set[DebugSection]) {
final def internalError(msg: Any) : Nothing = internalError(NoPosition, msg)
final def internalAssertion(cond : Boolean, msg: Any) : Unit = internalAssertion(cond,NoPosition, msg)
final def debug(msg: => Any)(implicit section: DebugSection): Unit = debug(NoPosition, msg)
final def ifDebug(body: (Any => Unit) => Any)(implicit section: DebugSection): Unit =
ifDebug(NoPosition, body)
final def whenDebug(section: DebugSection)(body: (Any => Unit) => Any): Unit =
whenDebug(NoPosition, section)(body)
}
class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSections) {
......@@ -130,8 +134,6 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
}
def emit(msg: Message) = {
val posString = if (msg.position != NoPosition) { msg.position+": " } else { "" }
println(reline(severityToPrefix(msg.severity), smartPos(msg.position) + msg.msg.toString))
printLineContent(msg.position)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment