Skip to content

Commit 1de4b24

Browse files
committed
Move smartPos function to use it in Stainless
1 parent 8709899 commit 1de4b24

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/main/scala/inox/Reporter.scala

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package inox
44

55
import utils._
6+
import Position.smartPos
67

78
abstract class DebugSection(val name: String)
89

@@ -166,20 +167,6 @@ class DefaultReporter(debugSections: Set[DebugSection]) extends Reporter(debugSe
166167
case DEBUG(_) => "["+Console.MAGENTA +" Debug "+Console.RESET+"]"
167168
}
168169

169-
def smartPos(p: Position): String = {
170-
if (p == NoPosition) {
171-
""
172-
} else {
173-
val target = p.file.getAbsolutePath()
174-
val here = new java.io.File(".").getAbsolutePath().stripSuffix(".")
175-
val diff = target.stripPrefix(here)
176-
177-
val filePos = diff+":"
178-
179-
filePos + p + ": "
180-
}
181-
}
182-
183170
def emit(msg: Message) = synchronized {
184171
println(reline(severityToPrefix(msg.severity), smartPos(msg.position) + msg.msg.toString))
185172
printLineContent(msg.position, false)

src/main/scala/inox/utils/Positions.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ abstract class Position extends Ordered[Position] {
3535
}
3636

3737
object Position {
38+
39+
def smartPos(p: Position): String = {
40+
if (p == NoPosition) {
41+
""
42+
} else {
43+
val target = p.file.getAbsolutePath()
44+
val here = new java.io.File(".").getAbsolutePath().stripSuffix(".")
45+
val diff = target.stripPrefix(here)
46+
47+
val filePos = diff+":"
48+
49+
filePos + p + ": "
50+
}
51+
}
52+
3853
def between(a: Position, b: Position): Position = {
3954
if (a.file == b.file) {
4055
if (a.line == b.line && a.col == b.col) {

0 commit comments

Comments
 (0)