aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-08-02 14:26:16 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-08-19 15:37:32 +0200
commit98b61dd22c1aebaecbe27e86aa9e98abff4971c6 (patch)
tree20ba1615e6d1a431cb460d772f02473b68dee1c8 /src/dotty/tools/dotc
parent553f9b20a10a16ff0348733c0af936cb36148fd5 (diff)
downloaddotty-98b61dd22c1aebaecbe27e86aa9e98abff4971c6.tar.gz
dotty-98b61dd22c1aebaecbe27e86aa9e98abff4971c6.tar.bz2
dotty-98b61dd22c1aebaecbe27e86aa9e98abff4971c6.zip
Fix #25: move doc related structures to `DocBase`
To access `DocBase`: `ctx.docbase.docstring(...)`
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala12
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 7490a62cc..cd76fe88b 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -532,6 +532,9 @@ object Contexts {
/** The symbol loaders */
val loaders = new SymbolLoaders
+ /** Documentation base */
+ val docbase = new DocBase
+
/** The platform, initialized by `initPlatform()`. */
private var _platform: Platform = _
@@ -568,8 +571,10 @@ object Contexts {
def squashed(p: Phase): Phase = {
allPhases.find(_.period.containsPhaseId(p.id)).getOrElse(NoPhase)
}
+ }
- val _docstrings: mutable.Map[Symbol, Comment] =
+ class DocBase {
+ private[this] val _docstrings: mutable.Map[Symbol, Comment] =
mutable.Map.empty
def docstring(sym: Symbol): Option[Comment] = _docstrings.get(sym)
@@ -577,6 +582,11 @@ object Contexts {
def addDocstring(sym: Symbol, doc: Option[Comment]): Unit =
doc.map(d => _docstrings += (sym -> d))
+ /*
+ * Dottydoc places instances of `Package` in this map - but we do not want
+ * to depend on `dottydoc` for the compiler, as such this is defined as a
+ * map of `String -> AnyRef`
+ */
private[this] val _packages: mutable.Map[String, AnyRef] = mutable.Map.empty
def packages[A]: mutable.Map[String, A] = _packages.asInstanceOf[mutable.Map[String, A]]
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 698f7e9a9..b8e75664c 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -426,7 +426,7 @@ class Namer { typer: Typer =>
}
def setDocstring(sym: Symbol, tree: Tree)(implicit ctx: Context) = tree match {
- case t: MemberDef => ctx.base.addDocstring(sym, t.rawComment)
+ case t: MemberDef => ctx.docbase.addDocstring(sym, t.rawComment)
case _ => ()
}