From 7d8458ff50f56cee13698ce933a295090680d11e Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 20 Jul 2016 10:21:26 +0200 Subject: Add support for repeated parameters in producer --- dottydoc/js/src/model/references.scala | 6 ++++++ .../jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala | 2 +- dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala | 2 +- .../scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala | 2 +- .../src/main/scala/dotty/tools/dottydoc/model/factories.scala | 9 ++++++++- 5 files changed, 17 insertions(+), 4 deletions(-) (limited to 'dottydoc') diff --git a/dottydoc/js/src/model/references.scala b/dottydoc/js/src/model/references.scala index 7cd396e94..051251b68 100644 --- a/dottydoc/js/src/model/references.scala +++ b/dottydoc/js/src/model/references.scala @@ -42,6 +42,7 @@ trait NamedReference extends Reference { val title: String val ref: Reference val isByName: Boolean + val isRepeated: Boolean } @ScalaJSDefined @@ -55,6 +56,11 @@ trait FunctionReference extends Reference { val returnValue: Reference } +@ScalaJSDefined +trait TupleReference extends Reference { + val args: sjs.Array[Reference] +} + /** Materializable links */ @ScalaJSDefined sealed trait MaterializableLink extends sjs.Object { diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala index a6d474c8f..d05d1acbd 100644 --- a/dottydoc/jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala +++ b/dottydoc/jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala @@ -57,7 +57,7 @@ trait TypeLinker extends MemberLookup { rv.copy(left = linkReference(ent, left, packs), right = linkReference(ent, right, packs)) case rv @ AndTypeReference(left, right) => rv.copy(left = linkReference(ent, left, packs), right = linkReference(ent, right, packs)) - case rv @ NamedReference(_, ref, _) => rv.copy(ref = linkReference(ent, ref, packs)) + case rv @ NamedReference(_, ref, _, _) => rv.copy(ref = linkReference(ent, ref, packs)) case _ => rv } } diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala index 52bb9d36c..3618d325f 100644 --- a/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala +++ b/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala @@ -49,7 +49,7 @@ object json { case ref: BoundsReference => s"""{"low":${refToJson(ref.low)},"high":${refToJson(ref.high)},"kind":"BoundsReference"}""" case ref: NamedReference => - s"""{"title":${ref.title.json},"ref":${refToJson(ref.ref)},"isByName":${ref.isByName.json},"kind":"NamedReference"}""" + s"""{"title":${ref.title.json},"ref":${refToJson(ref.ref)},"isByName":${ref.isByName.json},"isRepeated":${ref.isRepeated.json},"kind":"NamedReference"}""" case ref: ConstantReference => s"""{"title":${ref.title.json},"kind": "ConstantReference"}""" case ref: FunctionReference => diff --git a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala index b8918c493..ef8343d77 100644 --- a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala +++ b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala @@ -105,5 +105,5 @@ final case class OrTypeReference(left: Reference, right: Reference) extends Refe final case class AndTypeReference(left: Reference, right: Reference) extends Reference final case class FunctionReference(args: List[Reference], returnValue: Reference) extends Reference final case class BoundsReference(low: Reference, high: Reference) extends Reference -final case class NamedReference(title: String, ref: Reference, isByName: Boolean = false) extends Reference +final case class NamedReference(title: String, ref: Reference, isByName: Boolean = false, isRepeated: Boolean = false) extends Reference final case class ConstantReference(title: String) extends Reference diff --git a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala index a48f6d9b0..bd38701d9 100644 --- a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala +++ b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala @@ -50,6 +50,8 @@ object factories { } def returnType(t: Type)(implicit ctx: Context): Reference = { + val defn = ctx.definitions + def typeRef(name: String, query: String = "", params: List[Reference] = Nil) = { val realQuery = if (query != "") query else name TypeReference(name, UnsetLink(name, realQuery), params) @@ -123,7 +125,12 @@ object factories { case mt: MethodType => mt.paramNames.zip(mt.paramTypes).map { case (name, tpe) => - NamedReference(name.decode.toString, returnType(tpe), tpe.isInstanceOf[ExprType]) + NamedReference( + name.decode.toString, + returnType(tpe), + isByName = tpe.isInstanceOf[ExprType], + isRepeated = tpe.isRepeatedParam + ) } :: paramLists(mt.resultType) case annot: AnnotatedType => paramLists(annot.tpe) -- cgit v1.2.3