diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-05-17 15:40:55 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-05-17 15:40:55 -0700 |
commit | 1084273a5c784784d0d17b037e609d59024d213a (patch) | |
tree | 5137855fc4acdce59b4c3b4f08321591652ba0cc | |
parent | 9553c6fce751a74a1b25a43eb235bb20b4a5ba0b (diff) | |
parent | 12a130da7c220c1084e99a0b32774bedf5e50efd (diff) | |
download | scala-1084273a5c784784d0d17b037e609d59024d213a.tar.gz scala-1084273a5c784784d0d17b037e609d59024d213a.tar.bz2 scala-1084273a5c784784d0d17b037e609d59024d213a.zip |
Merge pull request #2530 from kzys/jira-6424
SI-6424 Scaladoc: Use mapNodes.get(_) to avoid NoSuchElementException
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala | 34 |
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) { |