From 1c63847a3dd2db2067ad5883173daed0233e6873 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Fri, 27 Jan 2012 17:51:13 +0400 Subject: [PATCH] More cleanup. --- main/Build.scala | 2 +- main/Project.scala | 11 ++++++----- util/collection/Settings.scala | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/main/Build.scala b/main/Build.scala index c3c26bce6..6ab7bb043 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -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 diff --git a/main/Project.scala b/main/Project.scala index d4d7d94bb..db053c732 100755 --- a/main/Project.scala +++ b/main/Project.scala @@ -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 "" diff --git a/util/collection/Settings.scala b/util/collection/Settings.scala index 1c5634c1c..01c3d5e2f 100644 --- a/util/collection/Settings.scala +++ b/util/collection/Settings.scala @@ -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) =