diff options
author | Paul Phillips <paulp@improving.org> | 2013-02-10 10:40:27 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-02-10 10:40:27 -0800 |
commit | 0084849f7c8ab5195ffdd17c984c7738b51a1089 (patch) | |
tree | a0e298d1618eabf449844d62ecec2c45624f3269 /test/files/presentation | |
parent | 7dfbf07a89b6daac0dddf004fff512e8c9e325b4 (diff) | |
parent | f784fbfbce7c1426fe90706f11096ea1b826e88c (diff) | |
download | scala-0084849f7c8ab5195ffdd17c984c7738b51a1089.tar.gz scala-0084849f7c8ab5195ffdd17c984c7738b51a1089.tar.bz2 scala-0084849f7c8ab5195ffdd17c984c7738b51a1089.zip |
Merge commit 'f784fbfbce' into merge-210
* commit 'f784fbfbce':
Add a request to presentation compiler to fetch doc comment information.
Refactor scaladoc base functionality to allow it to be mixed in with Global in the IDE.
Conflicts:
src/compiler/scala/tools/nsc/interactive/Doc.scala
Diffstat (limited to 'test/files/presentation')
-rw-r--r--[-rwxr-xr-x] | test/files/presentation/doc.check | 1 | ||||
-rwxr-xr-x | test/files/presentation/doc/doc.scala (renamed from test/files/presentation/doc.scala) | 52 |
2 files changed, 37 insertions, 16 deletions
diff --git a/test/files/presentation/doc.check b/test/files/presentation/doc.check index 62b3bfc2e3..e33756773d 100755..100644 --- a/test/files/presentation/doc.check +++ b/test/files/presentation/doc.check @@ -1,3 +1,4 @@ +reload: Test.scala 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))))))))) diff --git a/test/files/presentation/doc.scala b/test/files/presentation/doc/doc.scala index 4b0d6baa1f..475d92b861 100755 --- a/test/files/presentation/doc.scala +++ b/test/files/presentation/doc/doc.scala @@ -1,5 +1,5 @@ import scala.tools.nsc.doc -import scala.tools.nsc.doc.base.LinkTo +import scala.tools.nsc.doc.base._ import scala.tools.nsc.doc.base.comment._ import scala.tools.nsc.interactive._ import scala.tools.nsc.interactive.tests._ @@ -28,12 +28,33 @@ object Test extends InteractiveTest { |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 - + override lazy val compiler = { + new { + override val settings = { + prepareSettings(Test.this.settings) + Test.this.settings + } + } with Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase { + val global: this.type = this def chooseLink(links: List[LinkTo]): LinkTo = links.head + def internalLink(sym: Symbol, site: Symbol) = None + def toString(link: LinkTo) = link.toString + + def getComment(sym: Symbol, source: SourceFile) = { + val docResponse = new Response[(String, String, Position)] + askDocComment(sym, sym.owner, source, docResponse) + docResponse.get.left.toOption flatMap { + case (expanded, raw, pos) => + if (expanded.isEmpty) + None + else + Some(ask { () => parseAtSymbol(expanded, raw, pos, Some(sym.owner)) }) + } + } } + } + + override def runDefaultTests() { for (i <- 1 to tags.length) { val markedText = text(i) val idx = markedText.indexOf(caret) @@ -52,18 +73,17 @@ object Test extends InteractiveTest { 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") + compiler.getComment(sym, batch) match { + case None => println("Got no doc comment") + case Some(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") + println(str) } - case None => reporter.println("Couldn't find a typedTree") + case None => println("Couldn't find a typedTree") } } } |