shorten toString for task Info, correct it for Incomplete

This commit is contained in:
Mark Harrah 2010-09-12 22:41:02 -04:00
parent 5017e326c1
commit 62b30c0156
2 changed files with 8 additions and 2 deletions

View File

@ -12,7 +12,7 @@ object Incomplete extends Enumeration {
def show(i: Incomplete, traces: Boolean): String = def show(i: Incomplete, traces: Boolean): String =
{ {
val exceptions = allExceptions(i) val exceptions = allExceptions(i)
val traces = exceptions.map(_.getStackTrace).mkString("\n") val traces = exceptions.map(ex => ex.getStackTrace.mkString(ex.toString + "\n\t", "\n\t", "\n"))
val causeStr = if(i.causes.isEmpty) "" else (i.causes.length + " cause(s)") val causeStr = if(i.causes.isEmpty) "" else (i.causes.length + " cause(s)")
"Incomplete (" + show(i.tpe) + ") " + i.message.getOrElse("") + causeStr + "\n" + traces "Incomplete (" + show(i.tpe) + ") " + i.message.getOrElse("") + causeStr + "\n" + traces
} }

View File

@ -28,6 +28,7 @@ object Task
final case class Task[T](info: Info[T], work: Action[T]) final case class Task[T](info: Info[T], work: Action[T])
{ {
def original = info.original getOrElse this def original = info.original getOrElse this
override def toString = info.name orElse original.info.name getOrElse ("Task(" + info + ", " + work + ")")
} }
/** `original` is used during transformation only.*/ /** `original` is used during transformation only.*/
final case class Info[T](attributes: AttributeMap = AttributeMap.empty, original: Option[Task[T]] = None) final case class Info[T](attributes: AttributeMap = AttributeMap.empty, original: Option[Task[T]] = None)
@ -41,6 +42,11 @@ final case class Info[T](attributes: AttributeMap = AttributeMap.empty, original
def setImplied(i: Boolean) = set(Implied, i) def setImplied(i: Boolean) = set(Implied, i)
def set[T](key: AttributeKey[T], value: T) = copy(attributes = this.attributes.put(key, value)) def set[T](key: AttributeKey[T], value: T) = copy(attributes = this.attributes.put(key, value))
override def toString =
if(attributes.isEmpty && original.isEmpty)
"_"
else
attributes.toString + (original match { case Some(o) => ", original: " + o; case None => "" })
} }
object Info object Info
{ {