diff --git a/frontend/src/main.scala b/frontend/src/main.scala index 2ab9cdd..6ccf17c 100644 --- a/frontend/src/main.scala +++ b/frontend/src/main.scala @@ -29,7 +29,7 @@ case class JobAttributes( val jobAttributes = Var(Option.empty[JobAttributes]) - val text = Var(SaveState.readString(SaveState.TEXT_KEY)) + val text = Var(SaveState.readString(SaveState.TEXT_KEY, DEFAULT_TEXT)) val generations = Var( SaveState.readString(SaveState.GENERATIONS_KEY).toIntOption.getOrElse(100) @@ -287,3 +287,33 @@ def renderStats(stats: Stats) = div( li(cls := "ml-2", strong(job.id.toString), " : ", job.hearbeat) ) ) + +val DEFAULT_TEXT = + """ + abstract class MemberDefTraverser extends Traverser { + def onMember(defn: MemberDef): Unit + + private var depth: Int = 0 + private def lower[T](body: => T): T = { + depth += 1 + try body finally depth -= 1 + } + def currentDepth = depth + + /** Prune this tree and all trees beneath it. Can be overridden. */ + def prune(md: MemberDef): Boolean = ( + md.mods.isSynthetic + || md.mods.isParamAccessor + || nme.isConstructorName(md.name) + || (md.name containsName nme.ANON_CLASS_NAME) + ) + + override def traverse(t: Tree): Unit = t match { + case md: MemberDef if prune(md) => + case md @ PackageDef(_, stats) => traverseTrees(stats) + case md: ImplDef => onMember(md) ; lower(traverseTrees(md.impl.body)) + case md: ValOrDefDef => onMember(md) ; lower(traverse(md.rhs)) + case _ => super.traverse(t) + } + } +"""