mirror of https://github.com/sbt/sbt.git
Drop aggregation in querying settings
This commit is contained in:
parent
2efacb8c46
commit
f09897ca29
|
|
@ -83,7 +83,7 @@ final class NetworkChannel(val name: String, connection: Socket, state: State) e
|
|||
import sbt.internal.util.complete.Parser
|
||||
|
||||
val extracted = Project extract state
|
||||
val keys = Parser.parse(req.setting, Act aggregatedKeyParser extracted)
|
||||
val key = Parser.parse(req.setting, Act scopedKeyParser extracted)
|
||||
|
||||
def getSettingValue[A](key: Def.ScopedKey[A]) =
|
||||
extracted.structure.data.get(key.scope, key.key)
|
||||
|
|
@ -94,23 +94,14 @@ final class NetworkChannel(val name: String, connection: Socket, state: State) e
|
|||
case x => Right(x)
|
||||
}
|
||||
|
||||
def zeroValues: Either[Vector[String], Vector[Any]] = Right(Vector.empty)
|
||||
def anyLeftsOrAllRights[A, B](acc: Either[Vector[A], Vector[B]], elem: Either[A, B]): Either[Vector[A], Vector[B]] =
|
||||
(acc, elem) match {
|
||||
case (Right(a), Right(x)) => Right(a :+ x)
|
||||
case (Right(_), Left(x)) => Left(Vector(x))
|
||||
case (Left(a), Right(_)) => Left(a)
|
||||
case (Left(a), Left(x)) => Left(a :+ x)
|
||||
}
|
||||
|
||||
val values = keys match {
|
||||
case Left(msg) => Left(s"Invalid programmatic input:" +: (msg.lines.toVector map (" " + _)))
|
||||
case Right(keys) => keys.map(getSettingValue(_)).foldLeft(zeroValues)(anyLeftsOrAllRights)
|
||||
val values = key match {
|
||||
case Left(msg) => Left(s"Invalid programmatic input: $msg")
|
||||
case Right(key) => Right(getSettingValue(key))
|
||||
}
|
||||
|
||||
val jsonValues = values match {
|
||||
case Left(errors) => errors
|
||||
case Right(values) => values map (_.toString)
|
||||
case Left(errors) => errors
|
||||
case Right(value) => value.toString
|
||||
}
|
||||
|
||||
StandardMain.exchange publishEventMessage SettingQueryResponse(jsonValues)
|
||||
|
|
|
|||
|
|
@ -5,28 +5,28 @@
|
|||
// DO NOT EDIT MANUALLY
|
||||
package sbt.protocol
|
||||
final class SettingQueryResponse private (
|
||||
val values: Vector[String]) extends sbt.protocol.EventMessage() with Serializable {
|
||||
val value: String) extends sbt.protocol.EventMessage() with Serializable {
|
||||
|
||||
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: SettingQueryResponse => (this.values == x.values)
|
||||
case x: SettingQueryResponse => (this.value == x.value)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (17 + values.##)
|
||||
37 * (17 + value.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"SettingQueryResponse(" + values + ")"
|
||||
"SettingQueryResponse(" + value + ")"
|
||||
}
|
||||
protected[this] def copy(values: Vector[String] = values): SettingQueryResponse = {
|
||||
new SettingQueryResponse(values)
|
||||
protected[this] def copy(value: String = value): SettingQueryResponse = {
|
||||
new SettingQueryResponse(value)
|
||||
}
|
||||
def withValues(values: Vector[String]): SettingQueryResponse = {
|
||||
copy(values = values)
|
||||
def withValue(value: String): SettingQueryResponse = {
|
||||
copy(value = value)
|
||||
}
|
||||
}
|
||||
object SettingQueryResponse {
|
||||
|
||||
def apply(values: Vector[String]): SettingQueryResponse = new SettingQueryResponse(values)
|
||||
def apply(value: String): SettingQueryResponse = new SettingQueryResponse(value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ implicit lazy val SettingQueryResponseFormat: JsonFormat[sbt.protocol.SettingQue
|
|||
jsOpt match {
|
||||
case Some(js) =>
|
||||
unbuilder.beginObject(js)
|
||||
val values = unbuilder.readField[Vector[String]]("values")
|
||||
val value = unbuilder.readField[String]("value")
|
||||
unbuilder.endObject()
|
||||
sbt.protocol.SettingQueryResponse(values)
|
||||
sbt.protocol.SettingQueryResponse(value)
|
||||
case None =>
|
||||
deserializationError("Expected JsObject but found None")
|
||||
}
|
||||
}
|
||||
override def write[J](obj: sbt.protocol.SettingQueryResponse, builder: Builder[J]): Unit = {
|
||||
builder.beginObject()
|
||||
builder.addField("values", obj.values)
|
||||
builder.addField("value", obj.value)
|
||||
builder.endObject()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type ExecStatusEvent implements EventMessage {
|
|||
}
|
||||
|
||||
type SettingQueryResponse implements EventMessage {
|
||||
values: [String]
|
||||
value: String!
|
||||
}
|
||||
|
||||
# enum Status {
|
||||
|
|
|
|||
Loading…
Reference in New Issue