From 6d0c2c8d33b67f4d81039c3d5553f03b3b2cf6c6 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Tue, 24 Jan 2012 13:32:21 +0400 Subject: [PATCH] Change SourcePosition definition + minor cleanup. --- main/Project.scala | 8 +++++--- util/collection/Settings.scala | 12 ++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/main/Project.scala b/main/Project.scala index 13063de78..d4d7d94bb 100755 --- a/main/Project.scala +++ b/main/Project.scala @@ -274,12 +274,14 @@ 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 => - if (c.settings exists (_.pos ne NoPosition)) { - val header = if (c.settings forall (_.pos ne NoPosition)) "Defined at:" else "Some of the definition places:" + val posDefined = c.settings filter (_.pos ne NoPosition) + 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 + (c.settings filter (_.pos ne NoPosition) map fmt mkString ("\n\t", "\n\t", "\n")) + header + (posDefined map fmt mkString ("\n\t", "\n\t", "\n")) } else "" } getOrElse "" diff --git a/util/collection/Settings.scala b/util/collection/Settings.scala index fe97313f2..1c5634c1c 100644 --- a/util/collection/Settings.scala +++ b/util/collection/Settings.scala @@ -259,16 +259,8 @@ trait Init[Scope] override def toString = "setting(" + key + ") at " + pos } - trait SourcePosition { - def fileName: String - def line: Int - } - - case object NoPosition extends SourcePosition { - override def fileName = throw new UnsupportedOperationException("NoPosition") - override def line = throw new UnsupportedOperationException("NoPosition") - } - + sealed trait SourcePosition + case object NoPosition extends SourcePosition case class SourceCoord(fileName: String, line: Int) extends SourcePosition // mainly for reducing generated class count