summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2012-12-12 15:05:47 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2012-12-12 15:05:47 -0800
commita6f10cf7f4245f2dfcf2fef5fab5255b6fca119f (patch)
treecbad4b40dc2e471234dad0fec55a643f9bbdae93 /test
parent59c2649ae074364a9a2d171d58d47612c92bf1c1 (diff)
parente5e6d673cf669e3c9a7643aedd02213e4f7bbddf (diff)
downloadscala-a6f10cf7f4245f2dfcf2fef5fab5255b6fca119f.tar.gz
scala-a6f10cf7f4245f2dfcf2fef5fab5255b6fca119f.tar.bz2
scala-a6f10cf7f4245f2dfcf2fef5fab5255b6fca119f.zip
Merge pull request #1722 from vigdorchik/ide.api
Extract base scaladoc functionality for the IDE.
Diffstat (limited to 'test')
-rwxr-xr-xtest/files/presentation/doc.check48
-rwxr-xr-xtest/files/presentation/doc.scala71
-rwxr-xr-xtest/files/presentation/doc/src/Test.scala1
-rw-r--r--test/files/presentation/memory-leaks/MemoryLeaksTest.scala5
-rwxr-xr-xtest/scaladoc/run/SI-191-deprecated.scala3
-rwxr-xr-xtest/scaladoc/run/SI-191.scala3
-rw-r--r--test/scaladoc/run/SI-3314.scala3
-rw-r--r--test/scaladoc/run/SI-5235.scala3
-rw-r--r--test/scaladoc/run/links.scala7
-rw-r--r--test/scaladoc/scalacheck/CommentFactoryTest.scala3
10 files changed, 137 insertions, 10 deletions
diff --git a/test/files/presentation/doc.check b/test/files/presentation/doc.check
new file mode 100755
index 0000000000..62b3bfc2e3
--- /dev/null
+++ b/test/files/presentation/doc.check
@@ -0,0 +1,48 @@
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:
+@since:
+@todo:
+@note:
+@see:
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(1), Text(.)))), Text(0, 09/07/2012))))))
+@since:
+@todo:
+@note:
+@see:
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(1), Text(.)))), Text(0, 09/07/2012))))))
+@since:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(2), Text(.)))), Text(10))))))
+@todo:
+@note:
+@see:
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(1), Text(.)))), Text(0, 09/07/2012))))))
+@since:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(2), Text(.)))), Text(10))))))
+@todo:Body(List(Paragraph(Chain(List(Summary(Text(this method is unsafe)))))))
+@note:
+@see:
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(1), Text(.)))), Text(0, 09/07/2012))))))
+@since:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(2), Text(.)))), Text(10))))))
+@todo:Body(List(Paragraph(Chain(List(Summary(Text(this method is unsafe)))))))
+@note:Body(List(Paragraph(Chain(List(Summary(Text(Don't inherit!)))))))
+@see:
+body:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(This is a test comment), Text(.)))), Text(
+))))))
+@example:Body(List(Paragraph(Chain(List(Summary(Monospace(Text("abb".permutations = Iterator(abb, bab, bba)))))))))
+@version:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(1), Text(.)))), Text(0, 09/07/2012))))))
+@since:Body(List(Paragraph(Chain(List(Summary(Chain(List(Text(2), Text(.)))), Text(10))))))
+@todo:Body(List(Paragraph(Chain(List(Summary(Text(this method is unsafe)))))))
+@note:Body(List(Paragraph(Chain(List(Summary(Text(Don't inherit!)))))))
+@see:Body(List(Paragraph(Chain(List(Summary(Text(some other method)))))))
diff --git a/test/files/presentation/doc.scala b/test/files/presentation/doc.scala
new file mode 100755
index 0000000000..4b0d6baa1f
--- /dev/null
+++ b/test/files/presentation/doc.scala
@@ -0,0 +1,71 @@
+import scala.tools.nsc.doc
+import scala.tools.nsc.doc.base.LinkTo
+import scala.tools.nsc.doc.base.comment._
+import scala.tools.nsc.interactive._
+import scala.tools.nsc.interactive.tests._
+import scala.tools.nsc.util._
+import scala.tools.nsc.io._
+
+object Test extends InteractiveTest {
+ override val settings: doc.Settings = docSettings
+
+ val tags = Seq(
+ "@example `\"abb\".permutations = Iterator(abb, bab, bba)`",
+ "@version 1.0, 09/07/2012",
+ "@since 2.10",
+ "@todo this method is unsafe",
+ "@note Don't inherit!",
+ "@see some other method"
+ )
+
+ val comment = "This is a test comment."
+ val caret = "<caret>"
+
+ def text(nTags: Int) =
+ """|/** %s
+ |
+ | * %s */
+ |trait Commented {}
+ |class User(c: %sCommented)""".stripMargin.format(comment, tags take nTags mkString "\n", caret)
+
+ override def main(args: Array[String]) {
+ val documenter = new Doc(settings) {
+ val global: compiler.type = compiler
+
+ def chooseLink(links: List[LinkTo]): LinkTo = links.head
+ }
+ for (i <- 1 to tags.length) {
+ val markedText = text(i)
+ val idx = markedText.indexOf(caret)
+ val fileText = markedText.substring(0, idx) + markedText.substring(idx + caret.length)
+ val source = sourceFiles(0)
+ val batch = new BatchSourceFile(source.file, fileText.toCharArray)
+ val reloadResponse = new Response[Unit]
+ compiler.askReload(List(batch), reloadResponse)
+ reloadResponse.get.left.toOption match {
+ case None =>
+ reporter.println("Couldn't reload")
+ case Some(_) =>
+ val treeResponse = new compiler.Response[compiler.Tree]
+ val pos = compiler.rangePos(batch, idx, idx, idx)
+ compiler.askTypeAt(pos, treeResponse)
+ treeResponse.get.left.toOption match {
+ case Some(tree) =>
+ val sym = tree.tpe.typeSymbol
+ documenter.retrieve(sym, sym.owner) match {
+ case Some(HtmlResult(comment)) =>
+ import comment._
+ val tags: List[(String, Iterable[Body])] =
+ List(("@example", example), ("@version", version), ("@since", since.toList), ("@todo", todo), ("@note", note), ("@see", see))
+ val str = ("body:" + body + "\n") +
+ tags.map{ case (name, bodies) => name + ":" + bodies.mkString("\n") }.mkString("\n")
+ reporter.println(str)
+ case Some(_) => reporter.println("Got unexpected result")
+ case None => reporter.println("Got no result")
+ }
+ case None => reporter.println("Couldn't find a typedTree")
+ }
+ }
+ }
+ }
+}
diff --git a/test/files/presentation/doc/src/Test.scala b/test/files/presentation/doc/src/Test.scala
new file mode 100755
index 0000000000..fcc1554994
--- /dev/null
+++ b/test/files/presentation/doc/src/Test.scala
@@ -0,0 +1 @@
+object Test \ No newline at end of file
diff --git a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
index a5533a623a..159097cc10 100644
--- a/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
+++ b/test/files/presentation/memory-leaks/MemoryLeaksTest.scala
@@ -5,6 +5,7 @@ import java.util.Calendar
import scala.tools.nsc.interactive.tests._
import scala.tools.nsc.util._
import scala.tools.nsc.io._
+import scala.tools.nsc.doc
/** This test runs the presentation compiler on the Scala compiler project itself and records memory consumption.
*
@@ -24,6 +25,8 @@ import scala.tools.nsc.io._
object Test extends InteractiveTest {
final val mega = 1024 * 1024
+ override val settings: doc.Settings = docSettings
+
override def execute(): Unit = memoryConsumptionTest()
def batchSource(name: String) =
@@ -120,4 +123,4 @@ object Test extends InteractiveTest {
r.totalMemory() - r.freeMemory()
}
-} \ No newline at end of file
+}
diff --git a/test/scaladoc/run/SI-191-deprecated.scala b/test/scaladoc/run/SI-191-deprecated.scala
index 746aa9c598..4ed24ff8d1 100755
--- a/test/scaladoc/run/SI-191-deprecated.scala
+++ b/test/scaladoc/run/SI-191-deprecated.scala
@@ -1,5 +1,6 @@
import scala.tools.nsc.doc.model._
-import scala.tools.nsc.doc.model.comment._
+import scala.tools.nsc.doc.base._
+import scala.tools.nsc.doc.base.comment._
import scala.tools.partest.ScaladocModelTest
import java.net.{URI, URL}
import java.io.File
diff --git a/test/scaladoc/run/SI-191.scala b/test/scaladoc/run/SI-191.scala
index 0fb28145c3..6fb5339d66 100755
--- a/test/scaladoc/run/SI-191.scala
+++ b/test/scaladoc/run/SI-191.scala
@@ -1,5 +1,6 @@
import scala.tools.nsc.doc.model._
-import scala.tools.nsc.doc.model.comment._
+import scala.tools.nsc.doc.base._
+import scala.tools.nsc.doc.base.comment._
import scala.tools.partest.ScaladocModelTest
import java.net.{URI, URL}
import java.io.File
diff --git a/test/scaladoc/run/SI-3314.scala b/test/scaladoc/run/SI-3314.scala
index fe220b08af..c856fe46a8 100644
--- a/test/scaladoc/run/SI-3314.scala
+++ b/test/scaladoc/run/SI-3314.scala
@@ -1,3 +1,4 @@
+import scala.tools.nsc.doc.base._
import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
@@ -88,4 +89,4 @@ object Test extends ScaladocModelTest {
assert(bar.valueParams(0)(0).resultType.name == "(AnyRef { type Lambda[X] <: Either[A,X] })#Lambda[String]",
bar.valueParams(0)(0).resultType.name + " == (AnyRef { type Lambda[X] <: Either[A,X] })#Lambda[String]")
}
-} \ No newline at end of file
+}
diff --git a/test/scaladoc/run/SI-5235.scala b/test/scaladoc/run/SI-5235.scala
index 6295fc7786..c6b7922bb8 100644
--- a/test/scaladoc/run/SI-5235.scala
+++ b/test/scaladoc/run/SI-5235.scala
@@ -1,3 +1,4 @@
+import scala.tools.nsc.doc.base._
import scala.tools.nsc.doc.model._
import scala.tools.nsc.doc.model.diagram._
import scala.tools.partest.ScaladocModelTest
@@ -84,4 +85,4 @@ object Test extends ScaladocModelTest {
assert(mcReverseType.refEntity(0)._1 == LinkToTpl(MyCollection),
mcReverse.qualifiedName + "'s return type has a link to " + MyCollection.qualifiedName)
}
-} \ No newline at end of file
+}
diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala
index 0c67857e1c..fde24edb2a 100644
--- a/test/scaladoc/run/links.scala
+++ b/test/scaladoc/run/links.scala
@@ -1,3 +1,4 @@
+import scala.tools.nsc.doc.base._
import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
@@ -23,9 +24,9 @@ object Test extends ScaladocModelTest {
val base = rootPackage._package("scala")._package("test")._package("scaladoc")._package("links")
val TEST = base._object("TEST")
- val memberLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToMember])
- val templateLinks = countLinks(TEST.comment.get, _.link.isInstanceOf[LinkToTpl])
+ 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 == 6, templateLinks + " == 6 (the template links in object TEST)")
}
-} \ No newline at end of file
+}
diff --git a/test/scaladoc/scalacheck/CommentFactoryTest.scala b/test/scaladoc/scalacheck/CommentFactoryTest.scala
index 5e3141bdc0..96174d29d1 100644
--- a/test/scaladoc/scalacheck/CommentFactoryTest.scala
+++ b/test/scaladoc/scalacheck/CommentFactoryTest.scala
@@ -3,8 +3,7 @@ import org.scalacheck.Prop._
import scala.tools.nsc.Global
import scala.tools.nsc.doc
-import scala.tools.nsc.doc.model._
-import scala.tools.nsc.doc.model.comment._
+import scala.tools.nsc.doc.base.comment._
import scala.tools.nsc.doc.model._
import scala.tools.nsc.doc.model.diagram._