diff options
author | Paul Phillips <paulp@improving.org> | 2011-04-07 07:31:02 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-04-07 07:31:02 +0000 |
commit | f8f09796e884e62a5562efcf8c1e0f49eaa97c49 (patch) | |
tree | 937edee858dc437aee7b1a0400a6d922658894ae /src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala | |
parent | 6a204df670a118be6a31676ed26a20a6408e2ab6 (diff) | |
download | scala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.tar.gz scala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.tar.bz2 scala-f8f09796e884e62a5562efcf8c1e0f49eaa97c49.zip |
Deleted SourcelessComments.
Nothing and Null with improved documentation of their particulars
and convinced scaladoc to parse them without leaving scalac
institutionalized. Now rather than seeing our hardcoded documentation
strings bitrot in a shadowy flight from classes which do not exist, we
are championing the cause of the innocent and powerless. Nothing and
Null aren't above the law!
So now any responsible party can fire up their text editor and go to
town on Nothing.scala. As I'm sure they will. Review by malayeri.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 4edfa83a0d..405da29a57 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -17,7 +17,7 @@ import model.{ RootPackage => RootPackageEntity } class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory: ModelFactory with CommentFactory with TreeFactory => import global._ - import definitions.{ ObjectClass, ScalaObjectClass, RootPackage, EmptyPackage, NothingClass, AnyClass, AnyRefClass } + import definitions.{ ObjectClass, ScalaObjectClass, RootPackage, EmptyPackage, NothingClass, AnyClass, AnyValClass, AnyRefClass } private var droppedPackages = 0 def templatesCount = templatesCache.size - droppedPackages @@ -25,6 +25,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory private var modelFinished = false private var universe: Universe = null + private lazy val noSubclassCache = Set(AnyClass, AnyRefClass, ObjectClass, ScalaObjectClass) + /** */ def makeModel: Option[Universe] = { val universe = new Universe { thisUniverse => @@ -160,6 +162,9 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory * * All non-package members (including other templates, as full templates). */ abstract class DocTemplateImpl(sym: Symbol, inTpl: => DocTemplateImpl) extends MemberImpl(sym, inTpl) with TemplateImpl with HigherKindedImpl with DocTemplateEntity { //if (inTpl != null) println("mbr " + sym + " in " + (inTpl.toRoot map (_.sym)).mkString(" > ")) + if (settings.verbose.value) + inform("Creating doc template for " + sym) + templatesCache += (sym -> this) lazy val definitionName = optimize(inDefinitionTemplates.head.qualifiedName + "." + name) override def toRoot: List[DocTemplateImpl] = this :: inTpl.toRoot @@ -192,33 +197,40 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory else None } def parentType = { - if (sym.isPackage) None else { + if (sym.isPackage || sym == AnyClass) None else { val tps = (sym.tpe.parents filter (_ != ScalaObjectClass.tpe)) map { _.asSeenFrom(sym.thisType, sym) } Some(makeType(RefinedType(tps, EmptyScope), inTpl)) } } val linearization: List[(TemplateEntity, TypeEntity)] = { - val acs = sym.ancestors filter { _ != ScalaObjectClass } - val tps = acs map { cls => makeType(sym.info.baseType(cls), this) } - val tpls = acs map { makeTemplate(_) } - tpls map { - case dtpl: DocTemplateImpl => dtpl.registerSubClass(this) - case _ => + val acs = sym.ancestors filterNot (_ == ScalaObjectClass) + val tps = acs map (cls => makeType(sym.info.baseType(cls), this)) + val tpls = acs map makeTemplate + + tpls foreach { + case dtpl: DocTemplateImpl => dtpl.registerSubClass(this) + case _ => } tpls zip tps } def linearizationTemplates = linearization map { _._1 } def linearizationTypes = linearization map { _._2 } - private lazy val subClassesCache = mutable.Buffer.empty[DocTemplateEntity] + + private lazy val subClassesCache = ( + if (noSubclassCache(sym)) null + else mutable.ListBuffer[DocTemplateEntity]() + ) def registerSubClass(sc: DocTemplateEntity): Unit = { - assert(subClassesCache != null) - subClassesCache += sc + if (subClassesCache != null) + subClassesCache += sc } - def subClasses = subClassesCache.toList + def subClasses = if (subClassesCache == null) Nil else subClassesCache.toList + protected lazy val memberSyms = // Only this class's constructors are part of its members, inherited constructors are not. sym.info.members.filter(s => localShouldDocument(s) && (!s.isConstructor || s.owner == sym)) + val members = memberSyms flatMap (makeMember(_, this)) val templates = members collect { case c: DocTemplateEntity => c } val methods = members collect { case d: Def => d } |