From 1103d48fb7bf6586f1609151bdcc74e27c9139d5 Mon Sep 17 00:00:00 2001 From: François Garillot Date: Wed, 11 Sep 2013 15:34:34 +0200 Subject: Add trait keeping comments across new Typer runs --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 7 ++++++- src/interactive/scala/tools/nsc/interactive/Global.scala | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3