summaryrefslogtreecommitdiff
path: root/test/scaladoc
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-07-12 14:24:54 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-07-16 23:41:44 +0200
commita119ad1ae58723bd2e757ed331a536ff4ae49bdf (patch)
tree45692e87e13f0870f8b6f928b33ff6668cd46389 /test/scaladoc
parent891769fae541513d68ce7a8e84b7213472c333c9 (diff)
downloadscala-a119ad1ae58723bd2e757ed331a536ff4ae49bdf.tar.gz
scala-a119ad1ae58723bd2e757ed331a536ff4ae49bdf.tar.bz2
scala-a119ad1ae58723bd2e757ed331a536ff4ae49bdf.zip
SI-4360 Adds prefixes to scaladoc
This was a long-standing issue in scaladoc: It was unable to disambiguate between entries with the same name. One example is: immutable.Seq: trait Seq[+A] extends Iterable[A] with Seq[A] ... What's that? Seq extends Seq? No, immutable.Seq extends collection.Seq, but scaladoc was unable to show that. Now it does, depending on the template you're in. Prefixes are relative and can go back: -scala.collection.Seq has subclasses *immutable.Seq* and *mutable.Seq* -scala.immutable.Seq extends *collection.Seq* Unfortunately the price we pay for this is high, a 20% slowdown in scaladoc. This is why there is a new flag called -no-prefixes that disables the prefixes in front of types. Btw, it also fixes the notorious "booleanValue: This member is added by an implicit conversion from Boolean to Boolean ...". That's now java.lang.Boolean, so it becomes clear. Conflicts: src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
Diffstat (limited to 'test/scaladoc')
-rw-r--r--test/scaladoc/resources/SI-4360.scala42
-rw-r--r--test/scaladoc/resources/implicits-scopes-res.scala2
-rw-r--r--test/scaladoc/resources/package-object-res.scala2
-rw-r--r--test/scaladoc/run/SI-3314.scala14
-rw-r--r--test/scaladoc/run/SI-4360.check1
-rw-r--r--test/scaladoc/run/SI-4360.scala48
-rw-r--r--test/scaladoc/run/implicits-scopes.scala6
-rw-r--r--test/scaladoc/scalacheck/CommentFactoryTest.scala4
8 files changed, 106 insertions, 13 deletions
diff --git a/test/scaladoc/resources/SI-4360.scala b/test/scaladoc/resources/SI-4360.scala
new file mode 100644
index 0000000000..8e8b96afd5
--- /dev/null
+++ b/test/scaladoc/resources/SI-4360.scala
@@ -0,0 +1,42 @@
+package scala.test.scaladoc.prefix {
+ package pack1 {
+
+ class A {
+ class Z
+ }
+
+ class B extends A
+
+ package a {
+ class C
+ }
+
+ package b {
+ class C
+ }
+
+ package c {
+ class C
+
+ class L extends pack2.Z
+
+ class TEST {
+ // test inherited classes
+ def fooCA(x: pack1.A#Z) = 1
+ def fooCB(x: pack1.B#Z) = 1
+ def fooCS(x: pack2.Z#Z) = 1
+ def fooCL(x: L#Z) = 1
+ // test in packages
+ def fooPA(x: pack1.a.C) = 1
+ def fooPB(x: pack1.b.C) = 1
+ def fooPC(x: pack1.c.C) = 1
+ }
+
+ class A extends pack1.A
+ }
+ }
+
+ package pack2 {
+ class Z extends pack1.A
+ }
+} \ No newline at end of file
diff --git a/test/scaladoc/resources/implicits-scopes-res.scala b/test/scaladoc/resources/implicits-scopes-res.scala
index aaeb43f95b..c675a645bd 100644
--- a/test/scaladoc/resources/implicits-scopes-res.scala
+++ b/test/scaladoc/resources/implicits-scopes-res.scala
@@ -22,7 +22,7 @@ package test2 {
package classes {
class A
class B { def b = "" }
- object test { /* (new A).b won't compile */ }
+ object test { (new A).b }
}
}
diff --git a/test/scaladoc/resources/package-object-res.scala b/test/scaladoc/resources/package-object-res.scala
index 17d5c0a499..f1f714dd1f 100644
--- a/test/scaladoc/resources/package-object-res.scala
+++ b/test/scaladoc/resources/package-object-res.scala
@@ -1,4 +1,4 @@
-/** This package have A and B.
+/** This package has A and B.
*/
package test {
trait A { def hi = "hello" }
diff --git a/test/scaladoc/run/SI-3314.scala b/test/scaladoc/run/SI-3314.scala
index 665223098a..3b5c658078 100644
--- a/test/scaladoc/run/SI-3314.scala
+++ b/test/scaladoc/run/SI-3314.scala
@@ -48,15 +48,15 @@ object Test extends ScaladocModelTest {
val WeekDayInObject = test2._object("WeekDayObject")._member("WeekDay")
val expected = List(
- ("isWorkingDay1", "Value", ValueInClass),
- ("isWorkingDay2", "Value", ValueInClass),
- ("isWorkingDay3", "Value", ValueInTrait),
- ("isWorkingDay4", "Value", ValueInTrait),
- ("isWorkingDay5", "Value", ValueInObject),
+ ("isWorkingDay1", "WeekDayClass.Value", ValueInClass),
+ ("isWorkingDay2", "WeekDayClass.Value", ValueInClass),
+ ("isWorkingDay3", "WeekDayTrait.Value", ValueInTrait),
+ ("isWorkingDay4", "WeekDayTrait.Value", ValueInTrait),
+ ("isWorkingDay5", "WeekDayObject.Value", ValueInObject),
("isWorkingDay6", "WeekDay", WeekDayInObject),
- ("isWorkingDay7", "Value", ValueInObject),
+ ("isWorkingDay7", "WeekDayObject.Value", ValueInObject),
("isWorkingDay8", "WeekDay", WeekDayInObject),
- ("isWorkingDay9", "Value", ValueInObject))
+ ("isWorkingDay9", "WeekDayObject.Value", ValueInObject))
for ((method, name, ref) <- expected) {
assert(doc._method(method).valueParams(0)(0).resultType.name == name,
diff --git a/test/scaladoc/run/SI-4360.check b/test/scaladoc/run/SI-4360.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/SI-4360.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/SI-4360.scala b/test/scaladoc/run/SI-4360.scala
new file mode 100644
index 0000000000..3abc61c267
--- /dev/null
+++ b/test/scaladoc/run/SI-4360.scala
@@ -0,0 +1,48 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def resourceFile = "SI-4360.scala"
+
+ // no need for special settings
+ def scaladocSettings = ""
+
+ def testModel(rootPackage: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ // just need to check the member exists, access methods will throw an error if there's a problem
+ val base = rootPackage._package("scala")._package("test")._package("scaladoc")._package("prefix")
+
+ val TEST = base._package("pack1")._package("c")._class("TEST")
+ val fooCA = TEST._method("fooCA")
+ val fooCB = TEST._method("fooCB")
+ val fooCS = TEST._method("fooCS")
+ val fooCL = TEST._method("fooCL")
+ val fooPA = TEST._method("fooPA")
+ val fooPB = TEST._method("fooPB")
+ val fooPC = TEST._method("fooPC")
+
+ val expected = List(
+ (fooCA, "Z", 1),
+ (fooCB, "B.Z", 1),
+ (fooCS, "pack2.Z.Z", 1),
+ (fooCL, "L.Z", 1),
+ (fooPA, "a.C", 1),
+ (fooPB, "b.C", 1),
+ (fooPC, "C", 1)
+ )
+
+ for ((method, name, refs) <- expected) {
+ assert(method.valueParams(0)(0).resultType.name == name,
+ method.valueParams(0)(0).resultType.name + " == " + name + " (in " + method.qualifiedName + ")")
+ assert(method.valueParams(0)(0).resultType.refEntity.size == refs,
+ method.valueParams(0)(0).resultType.refEntity.size + " == " + refs + " (in " + method.qualifiedName + ")")
+ }
+
+ val A = base._package("pack1")._package("c")._class("A")
+ assert(A.linearizationTypes(0).name == "pack1.A", A.linearizationTypes(0).name + " == pack1.A")
+ assert(A.linearizationTypes(0).refEntity.size == 1, A.linearizationTypes(0).refEntity.size + " == 1")
+ }
+} \ No newline at end of file
diff --git a/test/scaladoc/run/implicits-scopes.scala b/test/scaladoc/run/implicits-scopes.scala
index 7b9e80e148..d91deba326 100644
--- a/test/scaladoc/run/implicits-scopes.scala
+++ b/test/scaladoc/run/implicits-scopes.scala
@@ -24,7 +24,7 @@ object Test extends ScaladocModelTest {
val test1 = base._package("test1")
val A = test1._class("A")
- conv = A._conversion(test1.qualifiedName + ".package.toB") // the .package means it's the package object
+ conv = A._conversion(test1.qualifiedName + ".toB")
assert(conv.members.length == 1)
assert(conv.constraints.length == 0)
}
@@ -36,7 +36,9 @@ object Test extends ScaladocModelTest {
val classes = test2._package("classes")
val A = classes._class("A")
- assert(A._conversions(test2.qualifiedName + ".toB").isEmpty)
+ conv = A._conversion(test2.qualifiedName + ".toB")
+ assert(conv.members.length == 1)
+ assert(conv.constraints.length == 0)
}
//// test3 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/test/scaladoc/scalacheck/CommentFactoryTest.scala b/test/scaladoc/scalacheck/CommentFactoryTest.scala
index b576ba5544..b7869d5bf4 100644
--- a/test/scaladoc/scalacheck/CommentFactoryTest.scala
+++ b/test/scaladoc/scalacheck/CommentFactoryTest.scala
@@ -10,7 +10,7 @@ import scala.tools.nsc.doc.model.diagram._
class Factory(val g: Global, val s: doc.Settings)
extends doc.model.ModelFactory(g, s) {
- thisFactory: Factory with ModelFactoryImplicitSupport with DiagramFactory with CommentFactory with doc.model.TreeFactory =>
+ thisFactory: Factory with ModelFactoryImplicitSupport with ModelFactoryTypeSupport with DiagramFactory with CommentFactory with doc.model.TreeFactory =>
def strip(c: Comment): Option[Inline] = {
c.body match {
@@ -31,7 +31,7 @@ object Test extends Properties("CommentFactory") {
val settings = new doc.Settings((str: String) => {})
val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings)
val g = new Global(settings, reporter)
- (new Factory(g, settings) with ModelFactoryImplicitSupport with DiagramFactory with CommentFactory with doc.model.TreeFactory)
+ (new Factory(g, settings) with ModelFactoryImplicitSupport with ModelFactoryTypeSupport with DiagramFactory with CommentFactory with doc.model.TreeFactory)
}
def parse(src: String, dst: Inline) = {