diff options
author | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2011-03-31 12:59:56 +0000 |
---|---|---|
committer | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2011-03-31 12:59:56 +0000 |
commit | daa3b19439e5c40b4c16a36fcdbabf58431f2f2e (patch) | |
tree | 8fc28009a8a0f12fbc9a47393371270472a922ab | |
parent | e94a62622d9121bc55e0a4f16df68b5b94625570 (diff) | |
download | scala-daa3b19439e5c40b4c16a36fcdbabf58431f2f2e.tar.gz scala-daa3b19439e5c40b4c16a36fcdbabf58431f2f2e.tar.bz2 scala-daa3b19439e5c40b4c16a36fcdbabf58431f2f2e.zip |
[scaladoc] Don't link to syntetic companion.
4 files changed, 45 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 8b6564c27c..8185b29246 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -277,7 +277,7 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { } ++ { tpl.companion match { case Some(companion) if (isSelf && !isReduced) => - if (companion.visibility.isPublic) { + if (companion.visibility.isPublic && companion.inSource != None) { <div class="block"> go to: <a href={relativeLinkTo(companion)}>companion</a> </div> diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index a7f22e94ff..5d7b1d1214 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -163,7 +163,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory templatesCache += (sym -> this) lazy val definitionName = optimize(inDefinitionTemplates.head.qualifiedName + "." + name) override def toRoot: List[DocTemplateImpl] = this :: inTpl.toRoot - def inSource = if (sym.sourceFile != null) Some((sym.sourceFile, sym.pos.line)) else None + def inSource = + if (sym.sourceFile != null && ! sym.isSynthetic) + Some((sym.sourceFile, sym.pos.line)) + else + None + def sourceUrl = { def fixPath(s: String) = s.replaceAll("\\" + java.io.File.separator, "/") val assumedSourceRoot: String = { diff --git a/test/scaladoc/resources/Trac4325.scala b/test/scaladoc/resources/Trac4325.scala new file mode 100644 index 0000000000..ffb968d571 --- /dev/null +++ b/test/scaladoc/resources/Trac4325.scala @@ -0,0 +1,5 @@ +case class WithSynthetic + +case class WithObject +object WithObject + diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala index 46267bff3f..0c9f7ff48d 100644 --- a/test/scaladoc/scala/html/HtmlFactoryTest.scala +++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala @@ -178,4 +178,37 @@ object Test extends Properties("HtmlFactory") { case _ => false } } + + property("Trac #4325 - files") = { + val files = createTemplates("Trac4325.scala") + + files.get("WithSynthetic.html") != None && + files.get("WithSynthetic$.html") == None && + files.get("WithObject.html") != None && + files.get("WithObject$.html") != None + } + + property("Trac #4325 - Don't link to syntetic companion") = { + val files = createTemplates("Trac4325.scala") + + files("WithSynthetic.html") match { + case node: scala.xml.Node => { + val s = node.toString + ! s.contains("""go to: <a href="WithSynthetic$.html">companion</a>""") + } + case _ => false + } + } + + property("Trac #4325 - Link to companion") = { + val files = createTemplates("Trac4325.scala") + + files("WithObject.html") match { + case node: scala.xml.Node => { + val s = node.toString + s.contains("""go to: <a href="WithObject$.html">companion</a>""") + } + case _ => false + } + } } |