summaryrefslogtreecommitdiff
path: root/test/scaladoc/resources
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-06-13 16:35:58 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2012-07-02 13:34:15 +0200
commitfba65513d1195b162f958a5c25124958d6e7ea52 (patch)
treeb55ee54ca836e8236fe3cec5980b12a692152f29 /test/scaladoc/resources
parentc11427c13e85ba6fb210c1f05724c21c8aeb4be3 (diff)
downloadscala-fba65513d1195b162f958a5c25124958d6e7ea52.tar.gz
scala-fba65513d1195b162f958a5c25124958d6e7ea52.tar.bz2
scala-fba65513d1195b162f958a5c25124958d6e7ea52.zip
Scaladoc class diagrams part 1
This commit contains model changes required for adding class diagrams to scaladoc. It also contains an improved implicit shadowing computation, which hides the shadowed implicitly inherited members from the main view and gives instructions on how to access them. This is joint work with Damien Obrist (@damienobrist) on supporting diagram generation in scaladoc, as part of Damien's semester project in the LAMP laborarory at EPFL. The full history is located at: https://github.com/damienobrist/scala/tree/feature/diagrams-dev Commit summary: - diagrams model - diagram settings (Settings.scala, ScalaDoc.scala) - diagram model object (Entity.scala, Diagram.scala) - model: tracking direct superclasses and subclasses, implicit conversions from and to (ModelFactory.scala) - diagram object computation (DiagramFactory.scala, DocFactory.scala) - capacity to filter diagrams (CommentFactory.scala, DiagramDirectiveParser.scala) - diagram statistics object (DiagramStats.scala) - delayed link evaluation (Body.scala, Comment.scala) - tests - improved implicits shadowing information - model shadowing computation (ModelFactoryImplicitSupport.scala, Entity.scala) - html generation for shadowing information (Template.scala) - tests Also fixes an issue reported by @dragos, where single-line comment expansion would lead to the comment disappearing. Review by @kzys, @pedrofurla. Adapted to the new model and fixed a couple of problems: - duplicate implicit conversions in StringAdd/StringFormat - incorrect implicit conversion signature (from X to X) Conflicts: src/compiler/scala/tools/nsc/doc/Settings.scala src/compiler/scala/tools/nsc/doc/html/page/Template.scala src/compiler/scala/tools/nsc/doc/model/Entity.scala src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
Diffstat (limited to 'test/scaladoc/resources')
-rw-r--r--test/scaladoc/resources/implicits-ambiguating-res.scala72
-rw-r--r--test/scaladoc/resources/implicits-base-res.scala16
-rw-r--r--test/scaladoc/resources/implicits-elimination-res.scala6
3 files changed, 85 insertions, 9 deletions
diff --git a/test/scaladoc/resources/implicits-ambiguating-res.scala b/test/scaladoc/resources/implicits-ambiguating-res.scala
new file mode 100644
index 0000000000..6ed51366cb
--- /dev/null
+++ b/test/scaladoc/resources/implicits-ambiguating-res.scala
@@ -0,0 +1,72 @@
+/**
+ * Test scaladoc implicits distinguishing -- supress all members by implicit conversion that are shadowed by the
+ * class' own members
+ *
+ * {{{
+ * scala> class A { def foo(t: String) = 4 }
+ * defined class A
+ *
+ * scala> class B { def foo(t: Any) = 5 }
+ * defined class B
+ *
+ * scala> implicit def AtoB(a:A) = new B
+ * AtoB: (a: A)B
+ *
+ * scala> val a = new A
+ * a: A = A@28f553e3
+ *
+ * scala> a.foo("T")
+ * res1: Int = 4
+ *
+ * scala> a.foo(4)
+ * res2: Int = 5
+ * }}}
+ */
+package scala.test.scaladoc.implicits.ambiguating
+import language.implicitConversions // according to SIP18
+
+/** - conv1-5 should be ambiguous
+ * - conv6-7 should not be ambiguous
+ * - conv8 should be ambiguous
+ * - conv9 should be ambiguous
+ * - conv10 and conv11 should not be ambiguous */
+class A[T]
+/** conv1-9 should be the same, conv10 should be ambiguous, conv11 should be okay */
+class B extends A[Int]
+/** conv1-9 should be the same, conv10 and conv11 should not be ambiguous */
+class C extends A[Double]
+ /** conv1-9 should be the same, conv10 should not be ambiguous while conv11 should be ambiguous */
+class D extends A[AnyRef]
+
+class X[T] {
+ def conv1: AnyRef = ???
+ def conv2: T = ???
+ def conv3(l: Int): AnyRef = ???
+ def conv4(l: AnyRef): AnyRef = ???
+ def conv5(l: AnyRef): String = ???
+ def conv6(l: String)(m: String): AnyRef = ???
+ def conv7(l: AnyRef)(m: AnyRef): AnyRef = ???
+ def conv8(l: AnyRef): AnyRef = ???
+ def conv9(l: String): AnyRef = ???
+ def conv10(l: T): T = ???
+ def conv11(l: T): T = ???
+}
+
+class Z[T] {
+ def conv1: AnyRef = ???
+ def conv2: T = ???
+ def conv3(p: Int): AnyRef = ???
+ def conv4(p: AnyRef): String = ???
+ def conv5(p: AnyRef): AnyRef = ???
+ def conv6(p: String, q: String): AnyRef = ???
+ def conv7(p: AnyRef, q: AnyRef): AnyRef = ???
+ def conv8(p: String): AnyRef = ???
+ def conv9(p: AnyRef): AnyRef = ???
+ def conv10(p: Int): T = ???
+ def conv11(p: String): T = ???
+}
+
+object A {
+ implicit def AtoX[T](a: A[T]) = new X[T]
+ implicit def AtoZ[T](a: A[T]) = new Z[T]
+}
diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala
index 65d7bdf67c..d6c0332c10 100644
--- a/test/scaladoc/resources/implicits-base-res.scala
+++ b/test/scaladoc/resources/implicits-base-res.scala
@@ -16,8 +16,9 @@ trait MyNumeric[R]
* def convToManifestA(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double
* def convToMyNumericA(x: T) // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope
* def convToNumericA(x: T) // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope
- * def convToPimpedA(x: Bar[Foo[T]]) // pimpA5: no constraints
- * def convToPimpedA(x: S) // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar
+ * def convToPimpedA(x: Bar[Foo[T]]) // pimpA5: no constraints, SHADOWED
+ * def convToPimpedA(x: S) // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar, SHADOWED
+ * def convToPimpedA(x: T) // pimpA0: with no constraints, SHADOWED
* def convToTraversableOps(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double
* // should not be abstract!
* }}}
@@ -52,9 +53,10 @@ object A {
* def convToManifestA(x: Double) // pimpA7: no constraints
* def convToMyNumericA(x: Double) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope
* def convToNumericA(x: Double) // pimpA1: no constraintsd
- * def convToPimpedA(x: Bar[Foo[Double]]) // pimpA5: no constraints
+ * def convToPimpedA(x: Bar[Foo[Double]]) // pimpA5: no constraints, SHADOWED
+ * def convToPimpedA(x: Double) // pimpA0: no constraints, SHADOWED
* def convToTraversableOps(x: Double) // pimpA7: no constraints
- * // should not be abstract!
+ * // should not be abstract!
* }}}
*/
class B extends A[Double]
@@ -68,7 +70,8 @@ object B extends A
* def convToIntA(x: Int) // pimpA2: no constraints
* def convToMyNumericA(x: Int) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope
* def convToNumericA(x: Int) // pimpA1: no constraints
- * def convToPimpedA(x: Bar[Foo[Int]]) // pimpA5: no constraints
+ * def convToPimpedA(x: Int) // pimpA0: no constraints, SHADOWED
+ * def convToPimpedA(x: Bar[Foo[Int]]) // pimpA5: no constraints, SHADOWED
* }}}
*/
class C extends A[Int]
@@ -81,7 +84,8 @@ object C extends A
* {{{
* def convToMyNumericA(x: String) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope
* def convToNumericA(x: String) // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope
- * def convToPimpedA(x: Bar[Foo[String]]) // pimpA5: no constraints
+ * def convToPimpedA(x: Bar[Foo[String]]) // pimpA5: no constraints, SHADOWED
+ * def convToPimpedA(x: String) // pimpA0: no constraints, SHADOWED
* }}}
*/
class D extends A[String]
diff --git a/test/scaladoc/resources/implicits-elimination-res.scala b/test/scaladoc/resources/implicits-elimination-res.scala
index b23667440c..5f7135c9e8 100644
--- a/test/scaladoc/resources/implicits-elimination-res.scala
+++ b/test/scaladoc/resources/implicits-elimination-res.scala
@@ -2,13 +2,13 @@
* Testing scaladoc implicits elimination
*/
package scala.test.scaladoc.implicits.elimination {
-
+
import language.implicitConversions // according to SIP18
/** No conversion, as B doesn't bring any member */
class A
class B { class C; trait V; type T; }
- object A {
- implicit def toB(a: A): B = null
+ object A {
+ implicit def toB(a: A): B = null
}
}