summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Vigdorchik <eugene.vigdorchik@gmail.com>2012-11-18 19:26:52 +0400
committerEugene Vigdorchik <eugene.vigdorchik@gmail.com>2012-11-18 19:26:52 +0400
commitdb0bf8f406c35ecee038e297dc58b109e0baef04 (patch)
treeacc7571c1375f1897b09a2b3f8f11523649e3f88
parent2d62ab248d07f10fd89a68b12565259ca861e1e9 (diff)
downloadscala-db0bf8f406c35ecee038e297dc58b109e0baef04.tar.gz
scala-db0bf8f406c35ecee038e297dc58b109e0baef04.tar.bz2
scala-db0bf8f406c35ecee038e297dc58b109e0baef04.zip
Restore the opimization apparently lost after merge.
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 8dd7e7801e..3ae1210ebf 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -493,28 +493,16 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
def inheritanceDiagram = makeInheritanceDiagram(this)
def contentDiagram = makeContentDiagram(this)
- def groupSearch[T](extractor: Comment => T, default: T): T = {
- // query this template
- if (comment.isDefined) {
- val entity = extractor(comment.get)
- if (entity != default) return entity
+ def groupSearch[T](extractor: Comment => Option[T]): Option[T] = {
+ val comments = comment +: linearizationTemplates.collect { case dtpl: DocTemplateImpl => dtpl.comment }
+ comments.flatten.map(extractor).flatten.headOption orElse {
+ Option(inTpl) flatMap (_.groupSearch(extractor))
}
- // query linearization
- if (!sym.isPackage)
- for (tpl <- linearizationTemplates.collect{ case dtpl: DocTemplateImpl if dtpl!=this => dtpl}) {
- val entity = tpl.groupSearch(extractor, default)
- if (entity != default) return entity
- }
- // query inTpl, going up the ownerChain
- if (inTpl != null)
- inTpl.groupSearch(extractor, default)
- else
- default
}
- def groupDescription(group: String): Option[Body] = groupSearch(_.groupDesc.get(group), if (group == defaultGroup) defaultGroupDesc else None)
- def groupPriority(group: String): Int = groupSearch(_.groupPrio.get(group) match { case Some(prio) => prio; case _ => 0 }, if (group == defaultGroup) defaultGroupPriority else 0)
- def groupName(group: String): String = groupSearch(_.groupNames.get(group) match { case Some(name) => name; case _ => group }, if (group == defaultGroup) defaultGroupName else group)
+ def groupDescription(group: String): Option[Body] = groupSearch(_.groupDesc.get(group)) orElse { if (group == defaultGroup) defaultGroupDesc else None }
+ def groupPriority(group: String): Int = groupSearch(_.groupPrio.get(group)) getOrElse { if (group == defaultGroup) defaultGroupPriority else 0 }
+ def groupName(group: String): String = groupSearch(_.groupNames.get(group)) getOrElse { if (group == defaultGroup) defaultGroupName else group }
}
abstract class PackageImpl(sym: Symbol, inTpl: PackageImpl) extends DocTemplateImpl(sym, inTpl) with Package {