Implement withRank

This commit is contained in:
Eugene Yokota 2017-07-25 01:50:53 -04:00
parent ac7b1498a9
commit 467617a4b9
2 changed files with 13 additions and 0 deletions

View File

@ -82,6 +82,10 @@ object AttributeKey {
rank: Int): AttributeKey[T] =
make(name, Some(description), extend, rank)
private[sbt] def copyWithRank[T](a: AttributeKey[T], rank: Int): AttributeKey[T] =
make(a.label, a.description, a.extend, rank)(a.manifest, a.optJsonWriter)
private[this] def make[T](
name: String,
description0: Option[String],

View File

@ -86,6 +86,9 @@ sealed abstract class SettingKey[T]
import TupleSyntax._
set((this, other)(f), source)
}
final def withRank(rank: Int): SettingKey[T] =
SettingKey(AttributeKey.copyWithRank(key, rank))
}
/**
@ -149,6 +152,9 @@ sealed abstract class TaskKey[T]
import TupleSyntax._
set((this, other)((a, b) => (a, b) map f.tupled), source)
}
final def withRank(rank: Int): TaskKey[T] =
TaskKey(AttributeKey.copyWithRank(key, rank))
}
/**
@ -176,6 +182,9 @@ sealed trait InputKey[T]
final def transform(f: T => T, source: SourcePosition): Setting[InputTask[T]] =
set(scopedKey(_ mapTask { _ map f }), source)
final def withRank(rank: Int): InputKey[T] =
InputKey(AttributeKey.copyWithRank(key, rank))
}
/** Methods and types related to constructing settings, including keys, scopes, and initializations. */