Change SourcePosition definition + minor cleanup.

This commit is contained in:
Eugene Vigdorchik 2012-01-24 13:32:21 +04:00
parent aafa6a0740
commit 6d0c2c8d33
2 changed files with 7 additions and 13 deletions

View File

@ -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 ""

View File

@ -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