diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2011-02-04 19:01:03 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2011-02-04 19:01:03 +0000 |
commit | 2d0e42041a7b3aedc3e2d0ccaacf87715bb3037b (patch) | |
tree | 4f31d2082ee51da8cc92f161588238b10fd3e287 /src | |
parent | 5905acc722ffd760996abc2478dda12cced44846 (diff) | |
download | scala-2d0e42041a7b3aedc3e2d0ccaacf87715bb3037b.tar.gz scala-2d0e42041a7b3aedc3e2d0ccaacf87715bb3037b.tar.bz2 scala-2d0e42041a7b3aedc3e2d0ccaacf87715bb3037b.zip |
[scaladoc] Scaladoc no longer crashes upon real...
[scaladoc] Scaladoc no longer crashes upon realising there is nothing to
document. Closes #3928. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/DocFactory.scala | 13 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala | 23 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala index 13a2fe0508..c8a6e279ff 100644 --- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala @@ -4,8 +4,8 @@ package scala.tools.nsc package doc import reporters.Reporter -import util.NoPosition import java.lang.ClassNotFoundException +import util.{Position, NoPosition} /** A documentation processor controls the process of generating Scala documentation, which is as follows. * @@ -53,9 +53,14 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor assert(settings.docformat.value == "html") if (!reporter.hasErrors) { val modelFactory = (new model.ModelFactory(compiler, settings) with model.comment.CommentFactory with model.TreeFactory) - val madeModel = Some(modelFactory.makeModel) - println("model contains " + modelFactory.templatesCount + " documentable templates") - madeModel + modelFactory.makeModel match { + case Some(madeModel) => + println("model contains " + modelFactory.templatesCount + " documentable templates") + Some(madeModel) + case None => + println("no documentable class found in compilation units") + None + } } else None } diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index a034006a5c..7b8115b4c1 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -26,16 +26,17 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory private var universe: Universe = null /** */ - def makeModel: Universe = { - val universe = new Universe { thisUniverse => - thisFactory.universe = thisUniverse - val settings = thisFactory.settings - val rootPackage = - makeRootPackage getOrElse { throw new Error("no documentable class found in compilation units") } + def makeModel: Option[Universe] = { + makeRootPackage map { rootPack => + val universe = new Universe { thisUniverse => + thisFactory.universe = thisUniverse + val settings = thisFactory.settings + val rootPackage = rootPack + } + modelFinished = true + thisFactory.universe = null + universe } - modelFinished = true - thisFactory.universe = null - universe } /** */ @@ -419,8 +420,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory else None else Some(new NonTemplateMemberImpl(bSym, inTpl) with Val { - override def isLazyVal = true - }) + override def isLazyVal = true + }) else if (bSym.isGetter && bSym.accessed.isMutable) Some(new NonTemplateMemberImpl(bSym, inTpl) with Val { override def isVar = true |