<commit_before>/* sbt -- Simple Build Tool
 * Copyright 2008 <NAME>, <NAME>
 */
package sbt

trait TaskManager{
	def task(action : => Option[String]) = 
		new Task(None, Nil, false, action);
	/** An interactive task is one that is not executed across all dependent projects when
	* it is called directly.  The dependencies of the task are still invoked across all dependent
	* projects, however. */
	def interactiveTask(action: => Option[String]) = new Task(None, Nil, true, action)

	class Task(val description : Option[String], val dependencies : List[Task], val interactive: Boolean,
		action : => Option[String]) extends Dag[Task]
	{
		checkTaskDependencies(dependencies)
		
		def dependsOn(tasks : Task*) =
		{
			val dependencyList = tasks.toList
			checkTaskDependencies(dependencyList)
			new Task(description, dependencies ::: dependencyList, interactive, action)
		}
		def describedAs(description : String) = new Task(Some(description), dependencies, interactive, action);
		private def invoke = action;

		final def run = {
			// This is a foldr, but it has the right laziness properties
			def invokeList(tasks : List[Task]) : Option[String] = tasks match {
				case Nil => None;
				case task::more => task.invoke.orElse(invokeList(more)) 
			}
			invokeList(topologicalSort);
		}
		final def runDependenciesOnly =
		{
			// This is a fold, but it has the right laziness properties
			def invokeList(tasks : List[Task]) : Option[String] =
				tasks match
				{
					case Nil => None
					case task :: ignoreSelf :: Nil => task.invoke
					case task :: more => task.invoke.orElse(invokeList(more))
				}
			invokeList(topologicalSort)
		}

		def &&(that : Task) =
			new Task(None, dependencies ::: that.dependencies, interactive || that.interactive, this.invoke.orElse(that.invoke))
	}
	
	private def checkTaskDependencies(dependencyList: List[Task])
	{
		val nullDependencyIndex = dependencyList.findIndexOf(_ == null)
		require(nullDependencyIndex < 0, "Dependency (at index " + nullDependencyIndex + ") was null.  This may be an initialization issue or a circular dependency.")
	}
}<commit_msg>A few comments for TaskManager<commit_after>/* sbt -- Simple Build Tool
 * Copyright 2008 <NAME>, <NAME>
 */
package sbt

trait TaskManager{
	/** Creates a task that executes the given action when invoked.*/
	def task(action : => Option[String]) = 
		new Task(None, Nil, false, action);
	/** An interactive task is one that is not executed across all dependent projects when
	* it is called directly.  The dependencies of the task are still invoked across all dependent
	* projects, however. */
	def interactiveTask(action: => Option[String]) = new Task(None, Nil, true, action)

	class Task(val description : Option[String], val dependencies : List[Task], val interactive: Boolean,
		action : => Option[String]) extends Dag[Task]
	{
		checkTaskDependencies(dependencies)
		
		/** Creates a new task, identical to this task, except with the additional dependencies specified.*/
		def dependsOn(tasks : Task*) =
		{
			val dependencyList = tasks.toList
			checkTaskDependencies(dependencyList)
			new Task(description, dependencies ::: dependencyList, interactive, action)
		}
		/** Creates a new task, identical to this task, except with the given description.*/
		def describedAs(description : String) = new Task(Some(description), dependencies, interactive, action);
		private def invoke = action;

		final def run = {
			// This is a foldr, but it has the right laziness properties
			def invokeList(tasks : List[Task]) : Option[String] = tasks match {
				case Nil => None;
				case task::more => task.invoke.orElse(invokeList(more)) 
			}
			invokeList(topologicalSort);
		}
		final def runDependenciesOnly =
		{
			// This is a fold, but it has the right laziness properties
			def invokeList(tasks : List[Task]) : Option[String] =
				tasks match
				{
					case Nil => None
					case task :: ignoreSelf :: Nil => task.invoke
					case task :: more => task.invoke.orElse(invokeList(more))
				}
			invokeList(topologicalSort)
		}

		def &&(that : Task) =
			new Task(None, dependencies ::: that.dependencies, interactive || that.interactive, this.invoke.orElse(that.invoke))
	}
	
	private def checkTaskDependencies(dependencyList: List[Task])
	{
		val nullDependencyIndex = dependencyList.findIndexOf(_ == null)
		require(nullDependencyIndex < 0, "Dependency (at index " + nullDependencyIndex + ") was null.  This may be an initialization issue or a circular dependency.")
	}
}
{'fraction_non_alphanumeric': 0.10769915442812639, 'fraction_numerical': 0.0022251891410769915, 'mean_word_length': 4.067643742953777, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1349846', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1228, 'n_words': 433}