aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/util/SourcePosition.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-02-24 23:50:34 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-02-25 00:31:18 +0100
commit94b41d5c491878543288af1bedb4daf57226ca07 (patch)
tree0a2b6a019415ea3ce35b2eb826161c5aa41c6973 /src/dotty/tools/dotc/util/SourcePosition.scala
parent0eecb7189188e6ce379b8840749abb1e0241035b (diff)
downloaddotty-94b41d5c491878543288af1bedb4daf57226ca07.tar.gz
dotty-94b41d5c491878543288af1bedb4daf57226ca07.tar.bz2
dotty-94b41d5c491878543288af1bedb4daf57226ca07.zip
Small API changes in preparation for dotty-interfaces
- Rename Diagnostic#msg to message, this is nicer for a public API - Rename SourceFile#lineContents and SourcePosition#lineContents to lineContent, the former is not grammatically correct. - Add some convenience methods to SourcePosition.
Diffstat (limited to 'src/dotty/tools/dotc/util/SourcePosition.scala')
-rw-r--r--src/dotty/tools/dotc/util/SourcePosition.scala15
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})"