Permalink
Browse files

Merge pull request #1722 from vigdorchik/ide.api

Extract base scaladoc functionality for the IDE.
  • Loading branch information...
2 parents 59c2649 + e5e6d67 commit a6f10cf7f4245f2dfcf2fef5fab5255b6fca119f @adriaanm adriaanm committed Dec 12, 2012
Showing with 664 additions and 496 deletions.
  1. +20 −19 src/compiler/scala/tools/nsc/ast/DocComments.scala
  2. +1 −1 src/compiler/scala/tools/nsc/doc/DocFactory.scala
  3. +51 −181 ...compiler/scala/tools/nsc/doc/{model/comment/CommentFactory.scala → base/CommentFactoryBase.scala}
  4. +15 −0 src/compiler/scala/tools/nsc/doc/base/LinkTo.scala
  5. +230 −0 src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala
  6. +1 −1 src/compiler/scala/tools/nsc/doc/{model → base}/comment/Body.scala
  7. +1 −2 src/compiler/scala/tools/nsc/doc/{model → base}/comment/Comment.scala
  8. +5 −4 src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala
  9. +0 −1 src/compiler/scala/tools/nsc/doc/html/page/Source.scala
  10. +3 −0 src/compiler/scala/tools/nsc/doc/html/page/Template.scala
  11. +1 −1 src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala
  12. +114 −0 src/compiler/scala/tools/nsc/doc/model/CommentFactory.scala
  13. +1 −1 src/compiler/scala/tools/nsc/doc/model/Entity.scala
  14. +0 −24 src/compiler/scala/tools/nsc/doc/model/LinkTo.scala
  15. +14 −211 src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala
  16. +7 −26 src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
  17. +1 −3 src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
  18. +3 −3 src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala
  19. +1 −1 src/compiler/scala/tools/nsc/doc/model/TypeEntity.scala
  20. +1 −2 src/compiler/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala
  21. +1 −2 src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
  22. +50 −0 src/compiler/scala/tools/nsc/interactive/Doc.scala
  23. +1 −0 src/compiler/scala/tools/nsc/interactive/Global.scala
  24. +2 −1 src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala
  25. +2 −1 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  26. +1 −1 src/partest/scala/tools/partest/ScaladocModelTest.scala
  27. +48 −0 test/files/presentation/doc.check
  28. +71 −0 test/files/presentation/doc.scala
  29. +1 −0 test/files/presentation/doc/src/Test.scala
  30. +4 −1 test/files/presentation/memory-leaks/MemoryLeaksTest.scala
  31. +2 −1 test/scaladoc/run/SI-191-deprecated.scala
  32. +2 −1 test/scaladoc/run/SI-191.scala
  33. +2 −1 test/scaladoc/run/SI-3314.scala
  34. +2 −1 test/scaladoc/run/SI-5235.scala
  35. +4 −3 test/scaladoc/run/links.scala
  36. +1 −2 test/scaladoc/scalacheck/CommentFactoryTest.scala
@@ -19,11 +19,17 @@ import scala.collection.mutable
*/
trait DocComments { self: Global =>
- var cookedDocComments = Map[Symbol, String]()
+ val cookedDocComments = mutable.HashMap[Symbol, String]()
/** The raw doc comment map */
val docComments = mutable.HashMap[Symbol, DocComment]()
+ def clearDocComments() {
+ cookedDocComments.clear()
+ docComments.clear()
+ defs.clear()
+ }
+
/** Associate comment with symbol `sym` at position `pos`. */
def docComment(sym: Symbol, docStr: String, pos: Position = NoPosition) =
if ((sym ne null) && (sym ne NoSymbol))
@@ -55,25 +61,20 @@ trait DocComments { self: Global =>
* If a symbol does not have a doc comment but some overridden version of it does,
* the doc comment of the overridden version is copied instead.
*/
- def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.get(sym) match {
- case Some(comment) =>
- comment
- case None =>
- val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
+ def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.getOrElseUpdate(sym, {
+ val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
else DocComment(docStr).template
- val comment = superComment(sym) match {
- case None =>
- if (ownComment.indexOf("@inheritdoc") != -1)
- reporter.warning(sym.pos, "The comment for " + sym +
- " contains @inheritdoc, but no parent comment is available to inherit from.")
- ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
- case Some(sc) =>
- if (ownComment == "") sc
- else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
- }
- cookedDocComments += (sym -> comment)
- comment
- }
+ superComment(sym) match {
+ case None =>
+ if (ownComment.indexOf("@inheritdoc") != -1)
+ reporter.warning(sym.pos, "The comment for " + sym +
+ " contains @inheritdoc, but no parent comment is available to inherit from.")
+ ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
+ case Some(sc) =>
+ if (ownComment == "") sc
+ else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
+ }
+ })
/** The cooked doc comment of symbol `sym` after variable expansion, or "" if missing.
*
@@ -80,7 +80,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
with model.ModelFactoryImplicitSupport
with model.ModelFactoryTypeSupport
with model.diagram.DiagramFactory
- with model.comment.CommentFactory
+ with model.CommentFactory
with model.TreeFactory
with model.MemberLookup {
override def templateShouldDocument(sym: compiler.Symbol, inTpl: DocTemplateImpl) =
Oops, something went wrong.

0 comments on commit a6f10cf

Please sign in to comment.