From e3a2d0bc4b1931aa311da0305d12ae7ec00d5e2d Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Wed, 10 Oct 2012 09:27:02 +0200 Subject: SI-6501 Scaladoc will correctly link to @templated members --- src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala | 13 +++++++------ test/scaladoc/resources/links.scala | 3 +++ test/scaladoc/run/links.scala | 5 ++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala index 09020ae24a..1c783a7d2c 100644 --- a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala +++ b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala @@ -124,12 +124,13 @@ trait MemberLookup { private def createLinks(syms: List[(Symbol, Symbol)]): List[LinkTo] = syms.flatMap { case (sym, owner) => - if (sym.isClass || sym.isModule || sym.isTrait || sym.isPackage) - findTemplateMaybe(sym) map (LinkToTpl(_)) - else - findTemplateMaybe(owner) flatMap { inTpl => - inTpl.members find (_.asInstanceOf[EntityImpl].sym == sym) map (LinkToMember(_, inTpl)) - } + findTemplateMaybe(sym) match { + case Some(tpl) => LinkToTpl(tpl) :: Nil + case None => + findTemplateMaybe(owner) flatMap { inTpl => + inTpl.members find (_.asInstanceOf[EntityImpl].sym == sym) map (LinkToMember(_, inTpl)) + } + } } private def lookupInTemplate(pos: Position, members: List[String], container: Symbol): List[(Symbol, Symbol)] = { diff --git a/test/scaladoc/resources/links.scala b/test/scaladoc/resources/links.scala index 0986b4ea90..bd69665357 100644 --- a/test/scaladoc/resources/links.scala +++ b/test/scaladoc/resources/links.scala @@ -4,6 +4,8 @@ // SI-4224 "Wiki-links should support method targets" // SI-3695 "support non-fully-qualified type links in scaladoc comments" // SI-6487 "Scaladoc can't link to inner classes" +// SI-6495 "Scaladoc won't pick up group name, priority and description from owner chain" +// SI-6501 "Scaladoc won't link to a @template type T as a template but as a member" package scala.test.scaladoc.links { import language.higherKinds class C @@ -56,6 +58,7 @@ package scala.test.scaladoc.links { * - [[#localMethod object TEST -> localMethod]] (should exercise Java-style links to empty members) * - [[ImOutside class ImOutside (check correct lookup in EmptyPackage)]] * - [[ImOutside.Inner#foo class ImOutside#class Inner#method foo (check correct lookup in EmptyPackage)]] + * - [[ImOutside.T class ImOutside#type T (check correct linking to templates)]] * - [[ImOutside.T#foo class ImOutside#type T#method foo (check correct interaction between @template and links)]] */ object TEST { diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala index 0f3e749dea..0c67857e1c 100644 --- a/test/scaladoc/run/links.scala +++ b/test/scaladoc/run/links.scala @@ -5,6 +5,9 @@ import scala.tools.partest.ScaladocModelTest // SI-4497 "Links in ScalaDoc - Spec and implementation unsufficient" // SI-4224 "Wiki-links should support method targets" // SI-3695 "support non-fully-qualified type links in scaladoc comments" +// SI-6487 "Scaladoc can't link to inner classes" +// SI-6495 "Scaladoc won't pick up group name, priority and description from owner chain" +// SI-6501 "Scaladoc won't link to a @template type T as a template but as a member" object Test extends ScaladocModelTest { override def resourceFile = "links.scala" @@ -23,6 +26,6 @@ object Test extends ScaladocModelTest { val memberLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToMember]) val templateLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToTpl]) assert(memberLinks == 17, memberLinks + " == 17 (the member links in object TEST)") - assert(templateLinks == 5, templateLinks + " == 5 (the template links in object TEST)") + assert(templateLinks == 6, templateLinks + " == 6 (the template links in object TEST)") } } \ No newline at end of file -- cgit v1.2.3