aboutsummaryrefslogtreecommitdiff
path: root/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model
diff options
context:
space:
mode:
Diffstat (limited to 'dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model')
-rw-r--r--dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala2
-rw-r--r--dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala38
2 files changed, 21 insertions, 19 deletions
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 691661ac5..b8918c493 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
@@ -103,5 +103,7 @@ sealed trait Reference
final case class TypeReference(title: String, tpeLink: MaterializableLink, paramLinks: List[Reference]) extends Reference
final case class OrTypeReference(left: Reference, right: Reference) extends Reference
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 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 8453b528f..a48f6d9b0 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
@@ -55,25 +55,23 @@ object factories {
TypeReference(name, UnsetLink(name, realQuery), params)
}
- def expandTpe(t: Type, params: List[MaterializableLink] = Nil): Reference = t match {
- case ref @ RefinedType(parent, rn, info) => {
- val paramName = (info match {
- case ta: TypeAlias if ta.alias.isInstanceOf[NamedType] =>
- ta.alias.asInstanceOf[NamedType].name.show
- case _ => rn.show
- }).split("\\$").last
- val param = UnsetLink(paramName, paramName)
- expandTpe(parent, param :: params)
- }
- case HKApply(tycon, args) =>
- def paramName: Type => String = { tpe =>
- (tpe match {
- case ta: TypeAlias if ta.alias.isInstanceOf[NamedType] =>
- ta.alias.asInstanceOf[NamedType].name.show
- case _ => tpe.show
- }).split("\\$").last
- }
- expandTpe(tycon, args.map(paramName).map(x => UnsetLink(x,x)))
+ def expandTpe(t: Type, params: List[Reference] = Nil): Reference = t match {
+ case tl: TypeLambda =>
+ //FIXME: should be handled correctly
+ // example, in `Option`:
+ //
+ // {{{
+ // def companion: GenericCompanion[collection.Iterable]
+ // }}}
+ //
+ // Becomes: def companion: [+X0] -> collection.Iterable[X0]
+ typeRef(tl.show + " (not handled)")
+ case AppliedType(tycon, args) =>
+ FunctionReference(args.init.map(expandTpe(_, Nil)), expandTpe(args.last))
+ case ref @ RefinedType(parent, rn, info) =>
+ expandTpe(parent) //FIXME: will be a refined HK, aka class Foo[X] { def bar: List[X] } or similar
+ case ref @ HKApply(tycon, args) =>
+ expandTpe(tycon, args.map(expandTpe(_, params)))
case TypeRef(_, n) =>
val name = n.decode.toString.split("\\$").last
typeRef(name, params = params)
@@ -83,6 +81,8 @@ object factories {
OrTypeReference(expandTpe(left), expandTpe(right))
case AndType(left, right) =>
AndTypeReference(expandTpe(left), expandTpe(right))
+ case tb @ TypeBounds(lo, hi) =>
+ BoundsReference(expandTpe(lo), expandTpe(hi))
case AnnotatedType(tpe, _) =>
expandTpe(tpe)
case ExprType(tpe) =>