Skip to content

Commit 4683e5d

Browse files
committed
Implement methods in tasty positions
1 parent cfb0059 commit 4683e5d

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

compiler/src/dotty/tools/dotc/tasty/internal/Position.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,16 @@ package dotty.tools.dotc.tasty.internal
33
import dotty.tools.dotc.util.SourcePosition
44

55
private[tasty] class Position(val pos: SourcePosition) extends scala.tasty.Position {
6+
override def firstOffset = pos.start
7+
override def lastOffset = pos.end
8+
9+
override def sourceFile = pos.source.file.path
10+
11+
override def startLine = pos.startLine
12+
override def endLine = pos.endLine
13+
14+
override def startColumn = pos.startColumn
15+
override def endColumn = pos.endColumn
16+
617
override def toString: String = s"Position(${pos.line}, ${pos.column})"
718
}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
package scala.tasty
22

3-
trait Position
3+
trait Position {
4+
def firstOffset: Int
5+
def lastOffset: Int
6+
7+
def sourceFile: String
8+
9+
def startLine: Int
10+
def startColumn: Int
11+
def endLine: Int
12+
def endColumn: Int
13+
}

tests/pos/tasty/definitions.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ object definitions {
2525

2626
// ====== Positions ==================================
2727

28-
case class Position(firstOffset: Int, lastOffset: Int)
28+
case class Position(firstOffset: Int, lastOffset: Int, sourceFile: String) {
29+
def startLine: Int = ???
30+
def startColumn: Int = ???
31+
def endLine: Int = ???
32+
def endColumn: Int = ???
33+
}
2934

3035
trait Positioned {
3136
def pos: Position = ???

0 commit comments

Comments
 (0)