From e0ac454f652ea9561e9d1da2895d985d388dcc00 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 21 Sep 2010 22:02:26 -0400 Subject: [PATCH] tailrec annotation and shorten constant name in Watched --- main/Watched.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/Watched.scala b/main/Watched.scala index 3b15f38b7..437948848 100644 --- a/main/Watched.scala +++ b/main/Watched.scala @@ -4,6 +4,7 @@ package sbt import CommandSupport.FailureWall + import annotation.tailrec trait Watched { @@ -15,21 +16,21 @@ trait Watched object Watched { - val ContinuousCompilePollDelaySeconds = 1 + val PollDelaySeconds = 1 def isEnter(key: Int): Boolean = key == 10 || key == 13 def watched(p: Project): Seq[Watched] = MultiProject.topologicalSort(p).collect { case w: Watched => w } def sourcePaths(p: Project): PathFinder = (Path.emptyPathFinder /: watched(p))(_ +++ _.watchPaths) def executeContinuously(project: Project with Watched, s: State, in: Input): State = { - def shouldTerminate: Boolean = (System.in.available > 0) && (project.terminateWatch(System.in.read()) || shouldTerminate) + @tailrec def shouldTerminate: Boolean = (System.in.available > 0) && (project.terminateWatch(System.in.read()) || shouldTerminate) val sourcesFinder = sourcePaths(project) val watchState = s get ContinuousState getOrElse WatchState.empty if(watchState.count > 0) System.out.println(watchState.count + ". Waiting for source changes... (press enter to interrupt)") - val (triggered, newWatchState) = SourceModificationWatch.watch(sourcesFinder, ContinuousCompilePollDelaySeconds, watchState)(shouldTerminate) + val (triggered, newWatchState) = SourceModificationWatch.watch(sourcesFinder, PollDelaySeconds, watchState)(shouldTerminate) if(triggered) (in.arguments :: FailureWall :: in.line :: s).put(ContinuousState, newWatchState)