aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/util/SourcePosition.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-05-10 16:48:47 +0200
committerMartin Odersky <odersky@gmail.com>2013-05-10 16:52:43 +0200
commitaad2d3a71f65e1b542bbfafbf387394331a270ee (patch)
tree20b71bc654557cd02d3a965d87afdf1a76a2cfa1 /src/dotty/tools/dotc/util/SourcePosition.scala
parent5ec2199c4966404d462eb866533dc0589fe7f239 (diff)
downloaddotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.tar.gz
dotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.tar.bz2
dotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.zip
Refactored and augmented source positions.
Also Implemented ConsoleReporter formatting.
Diffstat (limited to 'src/dotty/tools/dotc/util/SourcePosition.scala')
-rw-r--r--src/dotty/tools/dotc/util/SourcePosition.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/util/SourcePosition.scala b/src/dotty/tools/dotc/util/SourcePosition.scala
new file mode 100644
index 000000000..769aa87c4
--- /dev/null
+++ b/src/dotty/tools/dotc/util/SourcePosition.scala
@@ -0,0 +1,19 @@
+package dotty.tools.dotc.util
+
+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 line: Int = source.offsetToLine(point)
+ def column: Int = source.column(point)
+}
+
+/** A sentinel for a non-existing source position */
+object NoSourcePosition extends SourcePosition(NoSource, NoPosition)
+