More cleanup.

This commit is contained in:
Eugene Vigdorchik 2012-01-27 17:51:13 +04:00
parent 6d0c2c8d33
commit 1c63847a3d
3 changed files with 9 additions and 8 deletions

View File

@ -140,7 +140,7 @@ object EvaluateConfigurations
}
loader => {
val coord = SourceCoord(name, line + 1)
result.getValue(loader).asInstanceOf[Project.SettingsDefinition].settings map (_ setPos coord)
result.getValue(loader).asInstanceOf[Project.SettingsDefinition].settings map (_ withPos coord)
}
}
private[this] def isSpace = (c: Char) => Character isWhitespace c

View File

@ -274,14 +274,15 @@ object Project extends Init[Scope] with ProjectExtra
}
val comp = compiled(structure.settings, actual)(structure.delegates, structure.scopeLocal, display)
val definedAt = comp get scoped map { c =>
val posDefined = c.settings filter (_.pos ne NoPosition)
def fmt(s: Setting[_]) = s.pos match {
case SourceCoord(fileName, line) => Some(fileName + ":" + line)
case NoPosition => None
}
val posDefined = c.settings.map(fmt).flatten
if (posDefined.size > 0) {
val header = if (posDefined.size == c.settings.size) "Defined at:" else
"Some of the defining occurrences:"
def fmt(s: Setting[_]) = s.pos match {
case SourceCoord(fileName, line) => fileName + ":" + line
}
header + (posDefined map fmt mkString ("\n\t", "\n\t", "\n"))
header + (posDefined mkString ("\n\t", "\n\t", "\n"))
} else ""
} getOrElse ""

View File

@ -255,13 +255,13 @@ 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 setPos(pos: SourceCoord) = new Setting(key, init, pos)
def withPos(pos: SourceCoord) = new Setting(key, init, pos)
override def toString = "setting(" + key + ") at " + pos
}
sealed trait SourcePosition
case object NoPosition extends SourcePosition
case class SourceCoord(fileName: String, line: Int) extends SourcePosition
final case class SourceCoord(fileName: String, line: Int) extends SourcePosition
// mainly for reducing generated class count
private[this] def validateReferencedT(g: ValidateRef) =