Skip to content

Commit c53c115

Browse files
committed
Add indication that paramList takes implicit arguments
1 parent c05d628 commit c53c115

File tree

9 files changed

+36
-12
lines changed

9 files changed

+36
-12
lines changed

dottydoc/js/src/html/Member.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ trait MemberLayout {
8383
span(
8484
cls := "param-list",
8585
"(",
86-
xs.flatMap { tr =>
86+
span(cls := "is-implicit no-left-margin", if (xs.isImplicit) "implicit " else ""),
87+
xs.list.flatMap { tr =>
8788
Seq(
8889
span(cls := "param-name", tr.title).render,
8990
span(cls := "type-separator no-left-margin", if (tr.isByName) ": =>" else ":").render,

dottydoc/js/src/model/entities.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,16 @@ trait Object extends Class
7272
@ScalaJSDefined
7373
trait Trait extends Class
7474

75+
@ScalaJSDefined
76+
trait ParamList extends sjs.Object {
77+
val list: sjs.Array[NamedReference]
78+
val isImplicit: Boolean
79+
}
80+
7581
@ScalaJSDefined
7682
trait Def extends Entity with Modifiers with ReturnValue {
7783
val typeParams: sjs.Array[String]
78-
val paramLists: sjs.Array[sjs.Array[NamedReference]]
84+
val paramLists: sjs.Array[ParamList]
7985
}
8086

8187
@ScalaJSDefined

dottydoc/jvm/resources/index.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ div.member-definition > span+span {
128128
margin-left: 10px;
129129
}
130130

131-
div.member-definition > span.member-name {
131+
div.member-definition > span.member-name,
132+
div.member-definition > span.member-param-list span.is-implicit {
132133
color: #458;
133134
font-weight: 600;
134135
}

dottydoc/jvm/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class LinkReturnTypes extends DocMiniPhase with TypeLinker {
2929
class LinkParamListTypes extends DocMiniPhase with TypeLinker {
3030
override def transformDef(implicit ctx: Context) = { case df: DefImpl =>
3131
val newParamLists = for {
32-
list <- df.paramLists
32+
ParamListImpl(list, isImplicit) <- df.paramLists
3333
newList = list.map(linkReference(df, _, ctx.base.packages[Package].toMap))
34-
} yield newList.asInstanceOf[List[NamedReference]]
34+
} yield ParamListImpl(newList.asInstanceOf[List[NamedReference]], isImplicit)
3535

3636
df.copy(paramLists = newParamLists)
3737
}

dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ object json {
3939
}
4040
}
4141

42+
implicit class ParamListJson(val plist: ParamList) extends AnyVal {
43+
def json: String =
44+
s"""{"list":${plist.list.map(_.json).mkString("[",",","]")},"isImplicit":${plist.isImplicit.json}}"""
45+
}
46+
4247
private def refToJson(ref: Reference): String = ref match {
4348
case ref: TypeReference =>
4449
s"""{"title":${ref.title.json},"tpeLink":${ref.tpeLink.json},"paramLinks":${ref.paramLinks.map(_.json).mkString("[",",","]")},"kind":"TypeReference"}"""
@@ -71,7 +76,7 @@ object json {
7176
case ent: Object =>
7277
s"""{"name":${ent.name.json},"members":${ent.members.map(_.json).mkString("[",",","]")},"modifiers":${ent.modifiers.map(_.json).mkString("[",",","]")},"path":${ent.path.map(_.json).mkString("[",",","]")},"superTypes":${ent.superTypes.map(_.json).mkString("[",",","]")},${ent.comment.map(_.json).fold("")(cmt => s""""comment":$cmt,""")}"kind":"object"}"""
7378
case ent: Def =>
74-
s"""{"name":${ent.name.json},"modifiers":${ent.modifiers.map(_.json).mkString("[",",","]")},"path":${ent.path.map(_.json).mkString("[",",","]")},"returnValue":${ent.returnValue.json},"typeParams":${ent.typeParams.map(_.json).mkString("[",",","]")},"paramLists":${ent.paramLists.map{ xs =>xs.map(_.json).mkString("[",",","]")}.mkString("[",",","]")},${ent.comment.map(_.json).fold("")(cmt => s""""comment":$cmt,""")}"kind":"def"}"""
79+
s"""{"name":${ent.name.json},"modifiers":${ent.modifiers.map(_.json).mkString("[",",","]")},"path":${ent.path.map(_.json).mkString("[",",","]")},"returnValue":${ent.returnValue.json},"typeParams":${ent.typeParams.map(_.json).mkString("[",",","]")},"paramLists":${ent.paramLists.map(_.json).mkString("[",",","]")},${ent.comment.map(_.json).fold("")(cmt => s""""comment":$cmt,""")}"kind":"def"}"""
7580
case ent: Val =>
7681
s"""{"name":${ent.name.json},"modifiers":${ent.modifiers.map(_.json).mkString("[",",","]")},"path":${ent.path.map(_.json).mkString("[",",","]")},"returnValue":${ent.returnValue.json},${ent.comment.map(_.json).fold("")(cmt => s""""comment":$cmt,""")}"kind":"val"}"""
7782
}

dottydoc/jvm/src/dotty/tools/dottydoc/util/mutate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object setters {
2424
case _ => ()
2525
}
2626

27-
def setParamLists(ent: Entity, refs: List[List[NamedReference]]) = ent match {
27+
def setParamLists(ent: Entity, refs: List[ParamList]) = ent match {
2828
case x: DefImpl => x.paramLists = refs
2929
case _ => ()
3030
}

dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/entities.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ trait ReturnValue {
5151
def returnValue: Reference
5252
}
5353

54+
trait ParamList {
55+
def list: List[NamedReference]
56+
def isImplicit: Boolean
57+
}
58+
5459
trait Package extends Entity with Members {
5560
val kind = "package"
5661

@@ -74,7 +79,7 @@ trait Object extends Entity with Modifiers with SuperTypes with Members {
7479
}
7580

7681
trait Def extends Entity with Modifiers with TypeParams with ReturnValue {
77-
def paramLists: List[List[NamedReference]]
82+
def paramLists: List[ParamList]
7883
val kind = "def"
7984
}
8085

dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import dotc.ast.Trees._
1616

1717
object factories {
1818
import dotty.tools.dotc.ast.tpd._
19+
import dotty.tools.dottydoc.model.internal.ParamListImpl
1920
import DottyFlags._
2021

2122
type TypeTree = dotty.tools.dotc.ast.Trees.Tree[Type]
@@ -131,19 +132,19 @@ object factories {
131132
case _ => Nil
132133
}
133134

134-
def paramLists(tpe: Type)(implicit ctx: Context): List[List[NamedReference]] = tpe match {
135+
def paramLists(tpe: Type)(implicit ctx: Context): List[ParamList] = tpe match {
135136
case pt: PolyType =>
136137
paramLists(pt.resultType)
137138

138139
case mt: MethodType =>
139-
mt.paramNames.zip(mt.paramTypes).map { case (name, tpe) =>
140+
ParamListImpl(mt.paramNames.zip(mt.paramTypes).map { case (name, tpe) =>
140141
NamedReference(
141142
name.decode.toString,
142143
returnType(tpe),
143144
isByName = tpe.isInstanceOf[ExprType],
144145
isRepeated = tpe.isRepeatedParam
145146
)
146-
} :: paramLists(mt.resultType)
147+
}, mt.isImplicit) :: paramLists(mt.resultType)
147148

148149
case annot: AnnotatedType => paramLists(annot.tpe)
149150
case (_: PolyParam | _: RefinedType | _: TypeRef | _: ThisType |

dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/internal.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ object internal {
6464
path: List[String],
6565
var returnValue: Reference,
6666
var typeParams: List[String] = Nil,
67-
var paramLists: List[List[NamedReference]] = Nil,
67+
var paramLists: List[ParamList] = Nil,
6868
var comment: Option[Comment] = None
6969
) extends Def with Impl
7070

@@ -75,4 +75,9 @@ object internal {
7575
var returnValue: Reference,
7676
var comment: Option[Comment] = None
7777
) extends Val with Impl
78+
79+
final case class ParamListImpl(
80+
list: List[NamedReference],
81+
isImplicit: Boolean
82+
) extends ParamList
7883
}

0 commit comments

Comments
 (0)