Skip to content

Commit

Permalink
Add varargs variant for builders
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg committed Jul 11, 2020
1 parent d0b5acd commit b52c634
Show file tree
Hide file tree
Showing 92 changed files with 248 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ object Printer {
es.map(e => (" " * indent) + formatExpr(indent + 2)(e)).mkString("{\n", "\n", "\n}")
case ExprTree.Null =>
"null"
case ExprTree.`:_*`(e) =>
s"${formatExpr(indent)(e)} :_*"
case ExprTree.Ref(value) =>
formatQN(value)
case ExprTree.StringLit(value) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class TreeTransformation { self =>
s match {
case ExprTree.Null =>
ExprTree.Null
case ExprTree.`:_*`(e) =>
ExprTree.`:_*`(visitExprTree(childrenScope)(e))
case ExprTree.Val(name, value) =>
ExprTree.Val(name, visitExprTree(childrenScope)(value))
case ExprTree.Throw(expr) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ object MemberToProp {
case x: Prop.Normal => x.allVariants
case _ => Empty
}
case TypeRef(QualifiedName.Array, IArray.exactlyOne(t), _) =>
IArray(
Prop.Variant(
TypeRef.Repeated(t, NoComments),
e => Call(Ref(QualifiedName.Array), IArray(IArray(`:_*`(e)))),
isRewritten = true,
extendsAnyVal = false,
),
)
case _ => Empty
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ package object flavours {

def nameFor(tpe: TypeRef): String =
tpe match {
case tr if Name.Internal(tr.name) => tr.targs.map(nameFor).mkString("")
case other => other.name.unescaped
case TypeRef(QualifiedName.REPEATED, _, _) => "Varargs"
case tr if Name.Internal(tr.name) => tr.targs.map(nameFor).mkString("")
case other => other.name.unescaped
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ object ExprTree {
case class BinaryOp(one: ExprTree, op: String, two: ExprTree) extends ExprTree
case class Block(expressions: IArray[ExprTree]) extends ExprTree
case class Call(function: ExprTree, params: IArray[IArray[Arg]]) extends ExprTree
case class `:_*`(e: ExprTree) extends ExprTree
case class If(pred: ExprTree, ifTrue: ExprTree, ifFalse: Option[ExprTree]) extends ExprTree
case class Lambda(params: IArray[ParamTree], body: ExprTree) extends ExprTree
case class New(expr: TypeRef, params: IArray[ExprTree]) extends ExprTree
Expand Down
2 changes: 1 addition & 1 deletion tests/chart.js/check/c/chart_dot_js/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "chart_dot_js"
version := "0.0-unknown-e484e7"
version := "0.0-unknown-63d1fa"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ object ChartData {
x
}
@scala.inline
def setLabelsVarargs(value: (String | js.Array[String])*): Self = this.set("labels", js.Array(value :_*))
@scala.inline
def setLabels(value: js.Array[String | js.Array[String]]): Self = this.set("labels", value.asInstanceOf[js.Any])
@scala.inline
def deleteLabels: Self = this.set("labels", js.undefined)
Expand Down
2 changes: 1 addition & 1 deletion tests/commander/check/c/commander/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "commander"
version := "2.15.1-7393d6"
version := "2.15.1-a82110"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ object ParseOptionsResult {
x
}
@scala.inline
def setArgsVarargs(value: String*): Self = this.set("args", js.Array(value :_*))
@scala.inline
def setArgs(value: js.Array[String]): Self = this.set("args", value.asInstanceOf[js.Any])
@scala.inline
def setUnknownVarargs(value: String*): Self = this.set("unknown", js.Array(value :_*))
@scala.inline
def setUnknown(value: js.Array[String]): Self = this.set("unknown", value.asInstanceOf[js.Any])
}

Expand Down
2 changes: 1 addition & 1 deletion tests/numjs/check/n/ndarray/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "ndarray"
version := "0.0-unknown-2ebd0c"
version := "0.0-unknown-d41b11"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ object ndarray {
@scala.inline
def setT(value: ndarray[T]): Self = this.set("T", value.asInstanceOf[js.Any])
@scala.inline
def setDataVarargs(value: T*): Self = this.set("data", js.Array(value :_*))
@scala.inline
def setData(value: Data[T]): Self = this.set("data", value.asInstanceOf[js.Any])
}

Expand Down
4 changes: 2 additions & 2 deletions tests/numjs/check/n/numjs/build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
organization := "org.scalablytyped"
name := "numjs"
version := "0.0-unknown-b064a6"
version := "0.0-unknown-5afa38"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "ndarray" % "0.0-unknown-2ebd0c",
"org.scalablytyped" %%% "ndarray" % "0.0-unknown-d41b11",
"org.scalablytyped" %%% "std" % "0.0-unknown-a0c14e")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "componentstest"
version := "0.0-unknown-7b1cf5"
version := "0.0-unknown-6f7945"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "react-bootstrap"
version := "0.32-755c07"
version := "0.32-718358"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ object ButtonGroup {
@scala.inline
def defaultChecked(value: Boolean): this.type = set("defaultChecked", value.asInstanceOf[js.Any])
@scala.inline
def defaultValueVarargs(value: String*): this.type = set("defaultValue", js.Array(value :_*))
@scala.inline
def defaultValue(value: String | js.Array[String]): this.type = set("defaultValue", value.asInstanceOf[js.Any])
@scala.inline
def defer(value: Boolean): this.type = set("defer", value.asInstanceOf[js.Any])
Expand Down Expand Up @@ -778,6 +780,8 @@ object ButtonGroup {
@scala.inline
def useMap(value: String): this.type = set("useMap", value.asInstanceOf[js.Any])
@scala.inline
def valueVarargs(value: String*): this.type = set("value", js.Array(value :_*))
@scala.inline
def value(value: String | js.Array[String] | Double): this.type = set("value", value.asInstanceOf[js.Any])
@scala.inline
def vertical(value: Boolean): this.type = set("vertical", value.asInstanceOf[js.Any])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "react-contextmenu"
version := "2.13.0-122518"
version := "2.13.0-9699ef"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "react-dropzone"
version := "10.1.10-bac3c0"
version := "10.1.10-04c4c6"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ object ReactDropzone {
extends AnyVal
with StBuildingComponent[Ref with js.Object] {
@scala.inline
def acceptVarargs(value: String*): this.type = set("accept", js.Array(value :_*))
@scala.inline
def accept(value: String | js.Array[String]): this.type = set("accept", value.asInstanceOf[js.Any])
@scala.inline
def children(value: /* state */ DropzoneState => CallbackTo[Element]): this.type = set("children", js.Any.fromFunction1((t0: /* state */ DropzoneState) => value(t0).runNow()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ object DropzoneOptions {
x
}
@scala.inline
def setAcceptVarargs(value: String*): Self = this.set("accept", js.Array(value :_*))
@scala.inline
def setAccept(value: String | js.Array[String]): Self = this.set("accept", value.asInstanceOf[js.Any])
@scala.inline
def deleteAccept: Self = this.set("accept", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "react-select"
version := "0.0-unknown-395eb2"
version := "0.0-unknown-c72f42"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "react"
version := "16.9.2-a88e75"
version := "16.9.2-0e9f42"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ object AllHTMLAttributes {
@scala.inline
def deleteUseMap: Self = this.set("useMap", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ object ButtonHTMLAttributes {
@scala.inline
def deleteType: Self = this.set("type", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ object DataHTMLAttributes {
x
}
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ object HTMLAttributes {
@scala.inline
def deleteDefaultChecked: Self = this.set("defaultChecked", js.undefined)
@scala.inline
def setDefaultValueVarargs(value: String*): Self = this.set("defaultValue", js.Array(value :_*))
@scala.inline
def setDefaultValue(value: String | js.Array[String]): Self = this.set("defaultValue", value.asInstanceOf[js.Any])
@scala.inline
def deleteDefaultValue: Self = this.set("defaultValue", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ object InputHTMLAttributes {
@scala.inline
def deleteType: Self = this.set("type", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ object LiHTMLAttributes {
x
}
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ object MeterHTMLAttributes {
@scala.inline
def deleteOptimum: Self = this.set("optimum", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ object Mixin {
@scala.inline
def deleteGetInitialState: Self = this.set("getInitialState", js.undefined)
@scala.inline
def setMixinsVarargs(value: (Mixin[P, S])*): Self = this.set("mixins", js.Array(value :_*))
@scala.inline
def setMixins(value: js.Array[Mixin[P, S]]): Self = this.set("mixins", value.asInstanceOf[js.Any])
@scala.inline
def deleteMixins: Self = this.set("mixins", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ object OptionHTMLAttributes {
@scala.inline
def deleteSelected: Self = this.set("selected", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ object ParamHTMLAttributes {
@scala.inline
def deleteName: Self = this.set("name", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ object ProgressHTMLAttributes {
@scala.inline
def deleteMax: Self = this.set("max", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ object SelectHTMLAttributes {
@scala.inline
def deleteSize: Self = this.set("size", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ object TextareaHTMLAttributes {
@scala.inline
def deleteRows: Self = this.set("rows", js.undefined)
@scala.inline
def setValueVarargs(value: String*): Self = this.set("value", js.Array(value :_*))
@scala.inline
def setValue(value: String | js.Array[String] | Double): Self = this.set("value", value.asInstanceOf[js.Any])
@scala.inline
def deleteValue: Self = this.set("value", js.undefined)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
organization := "org.scalablytyped"
name := "semantic-ui-react"
version := "0.0-unknown-d20874"
version := "0.0-unknown-6724d4"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "1.7.0",
"com.olvind" %%% "scalablytyped-runtime" % "2.1.0",
"org.scalablytyped" %%% "react" % "16.9.2-a88e75",
"org.scalablytyped" %%% "react" % "16.9.2-0e9f42",
"org.scalablytyped" %%% "std" % "0.0-unknown-1edc23")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials")
Expand Down
Loading

0 comments on commit b52c634

Please sign in to comment.