mirror of https://github.com/sbt/sbt.git
Merge pull request #370 from vigdorchik/introduce_range_positions
Remember the range for settings read from .sbt files
This commit is contained in:
commit
79caa03093
|
|
@ -0,0 +1,20 @@
|
|||
package sbt
|
||||
|
||||
sealed trait SourcePosition
|
||||
|
||||
sealed trait FilePosition {
|
||||
def path: String
|
||||
def startLine: Int
|
||||
}
|
||||
|
||||
case object NoPosition extends SourcePosition
|
||||
|
||||
final case class LinePosition(path: String, startLine: Int) extends SourcePosition with FilePosition
|
||||
|
||||
final case class LineRange(start: Int, end: Int) {
|
||||
def shift(n: Int) = new LineRange(start + n, end + n)
|
||||
}
|
||||
|
||||
final case class RangePosition(path: String, range: LineRange) extends SourcePosition with FilePosition {
|
||||
def startLine = range.start
|
||||
}
|
||||
|
|
@ -255,14 +255,10 @@ trait Init[Scope]
|
|||
def mapKey(g: MapScoped): Setting[T] = new Setting(g(key), init, pos)
|
||||
def mapInit(f: (ScopedKey[T], T) => T): Setting[T] = new Setting(key, init(t => f(key,t)), pos)
|
||||
def mapConstant(g: MapConstant): Setting[T] = new Setting(key, init mapConstant g, pos)
|
||||
def withPos(pos: SourceCoord) = new Setting(key, init, pos)
|
||||
def withPos(pos: SourcePosition) = new Setting(key, init, pos)
|
||||
override def toString = "setting(" + key + ") at " + pos
|
||||
}
|
||||
|
||||
sealed trait SourcePosition
|
||||
case object NoPosition extends SourcePosition
|
||||
final case class SourceCoord(fileName: String, line: Int) extends SourcePosition
|
||||
|
||||
// mainly for reducing generated class count
|
||||
private[this] def validateReferencedT(g: ValidateRef) =
|
||||
new (Initialize ~> ValidatedInit) { def apply[T](i: Initialize[T]) = i validateReferenced g }
|
||||
|
|
|
|||
Loading…
Reference in New Issue