diff options
Diffstat (limited to 'src')
3 files changed, 32 insertions, 40 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala index 63509de4b5..c5ccc06cf9 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala @@ -15,6 +15,7 @@ import model._ import model.diagram._ import scala.xml.{ NodeSeq, Text, UnprefixedAttribute } import scala.language.postfixOps +import scala.collection.mutable. { Set, HashSet } import model._ import model.diagram._ @@ -636,13 +637,23 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } val subclasses = mbr match { - case dtpl: DocTemplateEntity if isSelf && !isReduced && dtpl.allSubClasses.nonEmpty => - <div class="toggleContainer block"> - <span class="toggle">Known Subclasses</span> - <div class="subClasses hiddenContent">{ - templatesToHtml(dtpl.allSubClasses.sortBy(_.name), scala.xml.Text(", ")) - }</div> - </div> + case dtpl: DocTemplateEntity if isSelf && !isReduced => + val subs: Set[DocTemplateEntity] = HashSet.empty + def transitive(dtpl: DocTemplateEntity) { + for (sub <- dtpl.directSubClasses if !(subs contains sub)) { + subs add sub + transitive(sub) + } + } + transitive(dtpl) + if (subs.nonEmpty) + <div class="toggleContainer block"> + <span class="toggle">Known Subclasses</span> + <div class="subClasses hiddenContent">{ + templatesToHtml(subs.toList.sortBy(_.name), scala.xml.Text(", ")) + }</div> + </div> + else NodeSeq.Empty case _ => NodeSeq.Empty } diff --git a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala index 924f203a59..6932f01e9a 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala @@ -258,10 +258,6 @@ trait DocTemplateEntity extends MemberTemplateEntity { * This template's linearization contains all of its direct and indirect super-types. */ def linearizationTypes: List[TypeEntity] - /** All class, trait and object templates for which this template is a direct or indirect super-class or super-trait. - * Only templates for which documentation is available in the universe (`DocTemplateEntity`) are listed. */ - def allSubClasses: List[DocTemplateEntity] - /** All class, trait and object templates for which this template is a *direct* super-class or super-trait. * Only templates for which documentation is available in the universe (`DocTemplateEntity`) are listed. */ def directSubClasses: List[DocTemplateEntity] diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index 60406f4401..5b91ef2ba5 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -277,14 +277,14 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { override def linkTarget: DocTemplateImpl = this override def toRoot: List[DocTemplateImpl] = this :: inTpl.toRoot - protected def inSourceFromSymbol(symbol: Symbol) = - if (symbol.sourceFile != null && ! symbol.isSynthetic) - Some((symbol.sourceFile, symbol.pos.line)) + protected def reprSymbol: Symbol = sym + + def inSource = + if (reprSymbol.sourceFile != null && ! reprSymbol.isSynthetic) + Some((reprSymbol.sourceFile, reprSymbol.pos.line)) else None - def inSource = inSourceFromSymbol(sym) - def sourceUrl = { def fixPath(s: String) = s.replaceAll("\\" + java.io.File.separator, "/") val assumedSourceRoot = fixPath(settings.sourcepath.value) stripSuffix "/" @@ -306,20 +306,10 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { else None } - protected def linearizationFromSymbol(symbol: Symbol): List[(TemplateEntity, TypeEntity)] = { - symbol.ancestors map { ancestor => - val typeEntity = makeType(symbol.info.baseType(ancestor), this) - val tmplEntity = makeTemplate(ancestor) match { - case tmpl: DocTemplateImpl => tmpl registerSubClass this ; tmpl - case tmpl => tmpl - } - (tmplEntity, typeEntity) - } - } - - lazy val linearization = linearizationFromSymbol(sym) - def linearizationTemplates = linearization map { _._1 } - def linearizationTypes = linearization map { _._2 } + lazy val (linearizationTemplates, linearizationTypes) = + reprSymbol.ancestors map { ancestor => + (makeTemplate(ancestor), makeType(reprSymbol.info.baseType(ancestor), this)) + } unzip /* Subclass cache */ private lazy val subClassesCache = ( @@ -330,8 +320,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { if (subClassesCache != null) subClassesCache += sc } - def allSubClasses = if (subClassesCache == null) Nil else subClassesCache.toList - def directSubClasses = allSubClasses.filter(_.parentTypes.map(_._1).contains(this)) + def directSubClasses = if (subClassesCache == null) Nil else subClassesCache.toList /* Implcitly convertible class cache */ private var implicitlyConvertibleClassesCache: mutable.ListBuffer[(DocTemplateImpl, ImplicitConversionImpl)] = null @@ -387,10 +376,10 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { members :::= memberSymsLazy.map(modelCreation.createLazyTemplateMember(_, this)) - // compute linearization to register subclasses - linearization outgoingImplicitlyConvertedClasses + for (pt <- sym.info.parents; parentTemplate <- findTemplateMaybe(pt.typeSymbol)) parentTemplate registerSubClass this + // the members generated by the symbols in memberSymsEager PLUS the members from the usecases val allMembers = ownMembers ::: ownMembers.flatMap(_.useCaseOf).distinct implicitsShadowing = makeShadowingTable(allMembers, conversions, this) @@ -472,12 +461,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { abstract class PackageImpl(sym: Symbol, inTpl: PackageImpl) extends DocTemplateImpl(sym, inTpl) with Package { override def inTemplate = inTpl override def toRoot: List[PackageImpl] = this :: inTpl.toRoot - override lazy val (inSource, linearization) = { - val representive = sym.info.members.find { - s => s.isPackageObject - } getOrElse sym - (inSourceFromSymbol(representive), linearizationFromSymbol(representive)) - } + override def reprSymbol = sym.info.members.find (_.isPackageObject) getOrElse sym + def packages = members collect { case p: PackageImpl if !(droppedPackages contains p) => p } } |