summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKato Kazuyoshi <kato.kazuyoshi@gmail.com>2013-05-15 00:05:45 +0900
committerKato Kazuyoshi <kato.kazuyoshi@gmail.com>2013-05-15 00:39:04 +0900
commit12a130da7c220c1084e99a0b32774bedf5e50efd (patch)
tree075d5ed002289646f2465e2f76d9c04d9f59feda /src
parent76b872475f0e8b847ccda1000db8f815c69deacb (diff)
downloadscala-12a130da7c220c1084e99a0b32774bedf5e50efd.tar.gz
scala-12a130da7c220c1084e99a0b32774bedf5e50efd.tar.bz2
scala-12a130da7c220c1084e99a0b32774bedf5e50efd.zip
SI-6424 Scaladoc: Use mapNodes.get(_) to avoid NoSuchElementException
Use mapNodes.get(_) instead of mapNodes(_) to avoid NoSuchElementException.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
index 175b4a6472..cb54a739bf 100644
--- a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
@@ -117,18 +117,27 @@ trait DiagramFactory extends DiagramDirectiveParser {
case d: TemplateEntity if ((!diagramFilter.hideInheritedNodes) || (d.inTemplate == pack)) => d
}
+ def listSuperClasses(member: MemberTemplateImpl) = {
+ // TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to add nodes to diagrams.
+ (pack.sym, member.sym) match {
+ case (ScalaPackage, NullClass) =>
+ List(makeTemplate(AnyRefClass))
+ case (ScalaPackage, NothingClass) =>
+ (List(NullClass) ::: ScalaValueClasses) map { makeTemplate(_) }
+ case _ =>
+ member.parentTypes map {
+ case (template, tpe) => template
+ } filter {
+ nodesAll.contains(_)
+ }
+ }
+ }
+
// for each node, add its subclasses
for (node <- nodesAll if !classExcluded(node)) {
node match {
case dnode: MemberTemplateImpl =>
- var superClasses = dnode.parentTypes.map(_._1).filter(nodesAll.contains(_))
-
- // TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to add nodes to diagrams.
- if (pack.sym == ScalaPackage)
- if (dnode.sym == NullClass)
- superClasses = List(makeTemplate(AnyRefClass))
- else if (dnode.sym == NothingClass)
- superClasses = (List(NullClass) ::: ScalaValueClasses).map(makeTemplate(_))
+ val superClasses = listSuperClasses(dnode)
if (!superClasses.isEmpty) {
nodesShown += dnode
@@ -150,7 +159,14 @@ trait DiagramFactory extends DiagramDirectiveParser {
None
else {
val nodes = nodesAll.filter(nodesShown.contains(_)).flatMap(mapNodes.get(_))
- val edges = edgesAll.map(pair => (mapNodes(pair._1), pair._2.map(mapNodes(_)))).filterNot(pair => pair._2.isEmpty)
+ val edges = edgesAll.map {
+ case (entity, superClasses) => {
+ (mapNodes(entity), superClasses flatMap { mapNodes.get(_) })
+ }
+ } filterNot {
+ case (node, superClassNodes) => superClassNodes.isEmpty
+ }
+
val diagram =
// TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to change the diagrams.
if (pack.sym == ScalaPackage) {