summaryrefslogtreecommitdiff
path: root/src/scaladoc
diff options
context:
space:
mode:
authorEugene Vigdorchik <eugene.vigdorchik@gmail.com>2013-04-28 18:58:24 +0400
committerEugene Vigdorchik <eugene.vigdorchik@gmail.com>2013-05-17 11:02:09 +0400
commitadd19e6839c8238d4ce173006287b399b7958f22 (patch)
tree93f43bc64bf304eaf8c502ac1d7a05079da0c978 /src/scaladoc
parent005a08d38a344c506ef2715bacac61bd56624402 (diff)
downloadscala-add19e6839c8238d4ce173006287b399b7958f22.tar.gz
scala-add19e6839c8238d4ce173006287b399b7958f22.tar.bz2
scala-add19e6839c8238d4ce173006287b399b7958f22.zip
No longer cache all subclass templates.
Instead only cache direct subclasses and compute all known subclasses as a transitive closure.
Diffstat (limited to 'src/scaladoc')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala25
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/Entity.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala43
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 }
}