diff options
author | Den Shabalin <den.shabalin@gmail.com> | 2013-09-20 13:28:42 +0200 |
---|---|---|
committer | Den Shabalin <den.shabalin@gmail.com> | 2013-10-14 13:30:48 +0200 |
commit | d7aae49f8ff7ccc6c1a588fc116e8c37fdb9e849 (patch) | |
tree | 8eed37ced2cf2c043cf637a72d137cd7d0f14cdd | |
parent | c676ec25a321f9fd23de83bf02ed8d6c15ba7e62 (diff) | |
download | scala-d7aae49f8ff7ccc6c1a588fc116e8c37fdb9e849.tar.gz scala-d7aae49f8ff7ccc6c1a588fc116e8c37fdb9e849.tar.bz2 scala-d7aae49f8ff7ccc6c1a588fc116e8c37fdb9e849.zip |
refactor out range position utility constructors
This will help to re-use same logic for creating range positions even
if atPos isn't used to assign position to the tree.
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index efc630f27a..b1fcb67a9f 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -302,6 +302,8 @@ self => def freshTypeName(prefix: String): TypeName def o2p(offset: Int): Position def r2p(start: Int, mid: Int, end: Int): Position + def r2p(start: Int, mid: Int): Position = r2p(start, mid, in.lastOffset max start) + def r2p(offset: Int): Position = r2p(offset, offset) /** whether a non-continuable syntax error has been seen */ private var lastErrorOffset : Int = -1 @@ -699,8 +701,8 @@ self => /* ---------- TREE CONSTRUCTION ------------------------------------------- */ - def atPos[T <: Tree](offset: Int)(t: T): T = atPos(r2p(offset, offset, in.lastOffset max offset))(t) - def atPos[T <: Tree](start: Int, point: Int)(t: T): T = atPos(r2p(start, point, in.lastOffset max start))(t) + def atPos[T <: Tree](offset: Int)(t: T): T = atPos(r2p(offset))(t) + def atPos[T <: Tree](start: Int, point: Int)(t: T): T = atPos(r2p(start, point))(t) def atPos[T <: Tree](start: Int, point: Int, end: Int)(t: T): T = atPos(r2p(start, point, end))(t) def atPos[T <: Tree](pos: Position)(t: T): T = global.atPos(pos)(t) |