8000 Merge pull request #1722 from vigdorchik/ide.api · scala/scala@a6f10cf · GitHub
[go: up one dir, main page]

Skip to content

Commit a6f10cf

Browse files
committed
Merge pull request #1722 from vigdorchik/ide.api
Extract base scaladoc functionality for the IDE.
2 parents 59c2649 + e5e6d67 commit a6f10cf

36 files changed

+664
-496
lines changed

src/compiler/scala/tools/nsc/ast/DocComments.scala

Lines changed: 20 additions & 19 deletions
8B5B
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ import scala.collection.mutable
1919
*/
2020
trait DocComments { self: Global =>
2121

22-
var cookedDocComments = Map[Symbol, String]()
22+
val cookedDocComments = mutable.HashMap[Symbol, String]()
2323

2424
/** The raw doc comment map */
2525
val docComments = mutable.HashMap[Symbol, DocComment]()
2626

27+
def clearDocComments() {
28+
cookedDocComments.clear()
29+
docComments.clear()
30+
defs.clear()
31+
}
32+
2733
/** Associate comment with symbol `sym` at position `pos`. */
2834
def docComment(sym: Symbol, docStr: String, pos: Position = NoPosition) =
2935
if ((sym ne null) && (sym ne NoSymbol))
@@ -55,25 +61,20 @@ trait DocComments { self: Global =>
5561
* If a symbol does not have a doc comment but some overridden version of it does,
5662
* the doc comment of the overridden version is copied instead.
5763
*/
58-
def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.get(sym) match {
59-
case Some(comment) =>
60-
comment
61-
case None =>
62-
val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
64+
def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.getOrElseUpdate(sym, {
65+
val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
6366
else DocComment(docStr).template
64-
val comment = superComment(sym) match {
65-
case None =>
66-
if (ownComment.indexOf("@inheritdoc") != -1)
67-
reporter.warning(sym.pos, "The comment for " + sym +
68-
" contains @inheritdoc, but no parent comment is available to inherit from.")
69-
ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
70-
case Some(sc) =>
71-
if (ownComment == "") sc
72-
else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
73-
}
74-
cookedDocComments += (sym -> comment)
75-
comment
76-
}
67+
superComment(sym) match {
68+
case None =>
69+
if (ownComment.indexOf("@inheritdoc") != -1)
70+
reporter.warning(sym.pos, "The comment for " + sym +
71+
" contains @inheritdoc, but no parent comment is available to inherit from.")
72+
ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
73+
case Some(sc) =>
74+
if (ownComment == "") sc
75+
else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
76+
}
77+
})
7778

7879
/** The cooked doc comment of symbol `sym` after variable expansion, or "" if missing.
7980
*

src/compiler/scala/tools/nsc/doc/DocFactory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
8080
with model.ModelFactoryImplicitSupport
8181
with model.ModelFactoryTypeSupport
8282
with model.diagram.DiagramFactory
83-
with model.comment.CommentFactory
83+
with model.CommentFactory
8484
with model.TreeFactory
8585
with model.MemberLookup {
8686
override def templateShouldDocument(sym: compiler.Symbol, inTpl: DocTemplateImpl) =

0 commit comments

Comments
 (0)
0