summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala6
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala8
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/Entity.scala1
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala22
4 files changed, 27 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
index 1efb56d716..014dee3b20 100644
--- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
@@ -200,6 +200,12 @@ abstract class HtmlPage { thisPage =>
xml.Text(string)
}
+ def typesToHtml(tpess: List[model.TypeEntity], hasLinks: Boolean, sep: NodeSeq): NodeSeq = tpess match {
+ case Nil => NodeSeq.Empty
+ case tpe :: Nil => typeToHtml(tpe, hasLinks)
+ case tpe :: tpes => typeToHtml(tpe, hasLinks) ++ sep ++ typesToHtml(tpes, hasLinks, sep)
+ }
+
/** Returns the HTML code that represents the template in `tpl` as a hyperlinked name. */
def templateToHtml(tpl: TemplateEntity) = tpl match {
case dTpl: DocTemplateEntity =>
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index 1f95f09329..d49ce07e43 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -223,6 +223,14 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
}
} ++
{ mbr match {
+ case dtpl: DocTemplateEntity if (isSelf && !dtpl.linearizationTypes.isEmpty) =>
+ <div class="block">
+ linear super types: { typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) }
+ </div>
+ case _ => NodeSeq.Empty
+ }
+ } ++
+ { mbr match {
case dtpl: DocTemplateEntity if (isSelf && !dtpl.subClasses.isEmpty) =>
<div class="block">
known subclasses: { templatesToHtml(dtpl.subClasses, xml.Text(", ")) }
diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
index bfe46441d2..f655be7b8c 100644
--- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
@@ -68,6 +68,7 @@ trait DocTemplateEntity extends TemplateEntity with MemberEntity {
def parentType: Option[TypeEntity]
def parentTemplates: List[TemplateEntity]
def linearization: List[TemplateEntity]
+ def linearizationTypes: List[TypeEntity]
def subClasses: List[DocTemplateEntity]
def members: List[MemberEntity]
def templates: List[DocTemplateEntity]
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index db57318f70..dc84023e6a 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -63,7 +63,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory
def isClass = sym.isClass && !sym.isTrait
def isObject = sym.isModule && !sym.isPackage
def isRootPackage = false
- def selfType = if (sym.thisSym eq sym) None else Some(makeType(sym.thisSym.typeOfThis))
+ def selfType = if (sym.thisSym eq sym) None else Some(makeType(sym.thisSym.typeOfThis, this))
}
/** Provides a default implementation for instances of the `WeakTemplateEntity` type. It must be instantiated as a
@@ -160,18 +160,20 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory
def parentTemplates = sym.info.parents map { x: Type => makeTemplate(x.typeSymbol) }
def parentType =
if (sym.isPackage) None else
- Some(makeType(RefinedType(sym.tpe.parents filter (_ != ScalaObjectClass.tpe), EmptyScope)))
+ Some(makeType(RefinedType(sym.tpe.parents filter (_ != ScalaObjectClass.tpe), EmptyScope), inTpl))
val linearization = {
- sym.info.parents map { prt =>
- makeTemplate(prt.typeSymbol) match {
+ val tpls = sym.ancestors filter { _ != ScalaObjectClass } map { makeTemplate(_) }
+ tpls map {
case dtpl: DocTemplateImpl => dtpl.registerSubClass(this)
case _ =>
- }
}
- sym.ancestors filter (_ != ScalaObjectClass) map { makeTemplate(_) }
+ tpls
+ }
+ def linearizationTypes = {
+ ((sym.info.baseClasses filter (_ != ScalaObjectClass)) map { cls => makeType(sym.info.baseType(cls), this) }).tail
}
private lazy val subClassesCache = mutable.Buffer.empty[DocTemplateEntity]
- def registerSubClass(sc: DocTemplateEntity) = {
+ def registerSubClass(sc: DocTemplateEntity): Unit = {
assert(subClassesCache != null)
subClassesCache += sc
}
@@ -427,14 +429,14 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory
}
/** */
- def makeType(aType: Type, seeInTpl: => TemplateImpl, dclSym: Symbol): TypeEntity = {
+ def makeType(aType: Type, inTpl: => TemplateImpl, dclSym: Symbol): TypeEntity = {
def ownerTpl(sym: Symbol): Symbol =
if (sym.isClass || sym.isModule || sym == NoSymbol) sym else ownerTpl(sym.owner)
- makeType(aType.asSeenFrom(seeInTpl.sym.thisType, ownerTpl(dclSym)))
+ makeType(aType.asSeenFrom(inTpl.sym.thisType, ownerTpl(dclSym)), inTpl)
}
/** */
- def makeType(aType: Type): TypeEntity =
+ def makeType(aType: Type, inTpl: => TemplateImpl): TypeEntity =
new TypeEntity {
private val nameBuffer = new StringBuilder
private var refBuffer = new immutable.TreeMap[Int, (TemplateEntity, Int)]