summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-19 05:41:43 -0700
committerJason Zaugg <jzaugg@gmail.com>2013-09-19 05:41:43 -0700
commitf6fcc4431f272c707d49de68add532c452dd4b0f (patch)
tree6e71d6b4788f29456fa76516f77797071b41f8f6
parent7f3a7a4e39642f03f3fc32467c14ea718036cf6c (diff)
parent1103d48fb7bf6586f1609151bdcc74e27c9139d5 (diff)
downloadscala-f6fcc4431f272c707d49de68add532c452dd4b0f.tar.gz
scala-f6fcc4431f272c707d49de68add532c452dd4b0f.tar.bz2
scala-f6fcc4431f272c707d49de68add532c452dd4b0f.zip
Merge pull request #2941 from huitseeker/less-destructive-docComments-reset
Cautiously give PC more control over docComments table
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala7
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala13
3 files changed, 27 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index f2e5c9b1eb..7cf2f8559b 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -18,8 +18,14 @@ trait DocComments { self: Global =>
val cookedDocComments = mutable.HashMap[Symbol, String]()
- /** The raw doc comment map */
- val docComments = mutable.HashMap[Symbol, DocComment]()
+ /** The raw doc comment map
+ *
+ * In IDE, background compilation runs get interrupted by
+ * reloading new sourcefiles. This is weak to avoid
+ * memleaks due to the doc of their cached symbols
+ * (e.g. in baseTypeSeq) between periodic doc reloads.
+ */
+ val docComments = mutable.WeakHashMap[Symbol, DocComment]()
def clearDocComments() {
cookedDocComments.clear()
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 55268b1e1a..5c8f1bd1c7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -43,12 +43,17 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
final val shortenImports = false
+ // allows override of the behavior of the resetTyper method w.r.t comments
+ def resetDocComments() = {
+ clearDocComments()
+ }
+
def resetTyper() {
//println("resetTyper called")
resetContexts()
resetImplicits()
transformed.clear()
- clearDocComments()
+ resetDocComments()
}
object UnTyper extends Traverser {
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index bc6df9eb25..736a1e68c4 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -18,6 +18,19 @@ import scala.tools.nsc.typechecker.Analyzer
import symtab.Flags.{ACCESSOR, PARAMACCESSOR}
import scala.annotation.{ elidable, tailrec }
import scala.language.implicitConversions
+import scala.tools.nsc.typechecker.Typers
+
+/**
+ * This trait allows the IDE to have an instance of the PC that
+ * does not clear the comments table at every new typer run (those
+ * being many and close between in this context).
+ */
+
+trait CommentPreservingTypers extends Typers {
+ self: Analyzer =>
+
+ override def resetDocComments() = {}
+}
trait InteractiveScaladocAnalyzer extends InteractiveAnalyzer with ScaladocAnalyzer {
val global : Global