diff options
Diffstat (limited to 'src/dotty/tools/dotc/util/SourcePosition.scala')
-rw-r--r-- | src/dotty/tools/dotc/util/SourcePosition.scala | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/util/SourcePosition.scala b/src/dotty/tools/dotc/util/SourcePosition.scala index 9e02841f2..fa7a4650d 100644 --- a/src/dotty/tools/dotc/util/SourcePosition.scala +++ b/src/dotty/tools/dotc/util/SourcePosition.scala @@ -5,19 +5,24 @@ import Positions.{Position, NoPosition} /** A source position is comprised of a position in a source file */ case class SourcePosition(source: SourceFile, pos: Position) { - def point: Int = pos.point - def start: Int = pos.start - def end: Int = pos.end def exists = pos.exists - def lineContents: String = source.lineContents(point) + def lineContent: String = source.lineContent(point) + def point: Int = pos.point /** The line of the position, starting at 0 */ def line: Int = source.offsetToLine(point) - /** The column of the position, starting at 0 */ def column: Int = source.column(point) + def start: Int = pos.start + def startLine: Int = source.offsetToLine(start) + def startColumn: Int = source.column(start) + + def end: Int = pos.end + def endLine: Int = source.offsetToLine(end) + def endColumn: Int = source.column(end) + override def toString = if (source.exists) s"${source.file}:${line + 1}" else s"(no source file, offset = ${pos.point})" |