summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/DocComments.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-20 12:58:03 -0800
committerPaul Phillips <paulp@improving.org>2012-12-20 14:47:50 -0800
commit106ca1b6767c60912b6726eeb1d435f6e22a025f (patch)
treec3c4c9a0d988720973b69f196c04e781e6e3f767 /src/compiler/scala/tools/nsc/ast/DocComments.scala
parenta313fa1d2c03d49fa7bc2a5f9c1886c48e08aab6 (diff)
parent9ddb4cf41f9832e46fa1109d96fc6708c4586c53 (diff)
downloadscala-106ca1b6767c60912b6726eeb1d435f6e22a025f.tar.gz
scala-106ca1b6767c60912b6726eeb1d435f6e22a025f.tar.bz2
scala-106ca1b6767c60912b6726eeb1d435f6e22a025f.zip
Merge remote-tracking branch 'origin/2.10.x' into merge-2.10.x
* origin/2.10.x: (31 commits) Implicit vars should have non-implicit setters. Deprecate `scala.tools.nsc.Phases` because it's dead-code. scaladoc Template: remove duplicate code and several usages of Option.get. adds scala-reflect.jar to MIMA in ant Test showing the absence of a forward reference update mailmap Remove dead code from `Global`. Cleanup MemberLookup. Better explain ambiguous link targets. typedIdent no longer destroys attachments fixes incorrect handling of Annotated in lazy copier simplifies checkBounds Recurse into instantiations when stripping type vars. Extract base scaladoc functionality for the IDE. Expand pattern match position tests. SI-6288 Remedy ill-positioned extractor binding. SI-6288 Fix positioning of label jumps SI-6288 Position argument of unapply Fixes SI-6758: force LazyAnnnotationInfo for DefDef and TypeDef SI-6795 Simplify errors related to "abstract override" on type members SI-6795 Adds negative check for "abstract override" on types in traits ... Conflicts: .mailmap src/compiler/scala/tools/nsc/Global.scala src/compiler/scala/tools/nsc/ast/DocComments.scala src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala src/compiler/scala/tools/nsc/doc/html/page/Source.scala src/compiler/scala/tools/nsc/doc/html/page/Template.scala src/compiler/scala/tools/nsc/doc/model/LinkTo.scala src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala src/compiler/scala/tools/nsc/typechecker/Typers.scala src/reflect/scala/reflect/runtime/JavaMirrors.scala test/scaladoc/run/links.scala
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/DocComments.scala')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index 023f3c229c..c9bf131b79 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -16,11 +16,22 @@ 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))
+ docComments += (sym -> DocComment(docStr, pos))
+
/** The raw doc comment of symbol `sym`, as it appears in the source text, "" if missing.
*/
def rawDocComment(sym: Symbol): String =
@@ -47,25 +58,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.
*