aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-08-24 00:49:23 +0300
committerGitHub <noreply@github.com>2016-08-24 00:49:23 +0300
commit265ade02e522c89844076b5339267eac08e44c37 (patch)
tree4e1c0f808eb2dbff1a80a7920021874916c9c324 /src/dotty/tools/dotc/core
parent76c3e99e33cf25a6ebccc0785212f629a3cda54e (diff)
parent0b69be68d3100103ebfd636bbc36f9cdcbd6fb28 (diff)
downloaddotty-265ade02e522c89844076b5339267eac08e44c37.tar.gz
dotty-265ade02e522c89844076b5339267eac08e44c37.tar.bz2
dotty-265ade02e522c89844076b5339267eac08e44c37.zip
Merge pull request #1453 from felixmulder/topic/dottydoc
Add dottydoc
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 262443314..cd76fe88b 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -29,6 +29,7 @@ import printing._
import config.{Settings, ScalaSettings, Platform, JavaPlatform, SJSPlatform}
import language.implicitConversions
import DenotTransformers.DenotTransformer
+import parsing.Scanners.Comment
import xsbti.AnalysisCallback
object Contexts {
@@ -531,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 = _
@@ -567,14 +571,32 @@ object Contexts {
def squashed(p: Phase): Phase = {
allPhases.find(_.period.containsPhaseId(p.id)).getOrElse(NoPhase)
}
+ }
- val _docstrings: mutable.Map[Symbol, String] =
+ class DocBase {
+ private[this] val _docstrings: mutable.Map[Symbol, Comment] =
mutable.Map.empty
- def docstring(sym: Symbol): Option[String] = _docstrings.get(sym)
+ def docstring(sym: Symbol): Option[Comment] = _docstrings.get(sym)
- def addDocstring(sym: Symbol, doc: Option[String]): Unit =
+ 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]]
+
+ /** Should perhaps factorize this into caches that get flushed */
+ private var _defs: Map[Symbol, Set[Symbol]] = Map.empty
+ def defs(sym: Symbol): Set[Symbol] = _defs.get(sym).getOrElse(Set.empty)
+
+ def addDef(s: Symbol, d: Symbol): Unit = _defs = (_defs + {
+ s -> _defs.get(s).map(xs => xs + d).getOrElse(Set(d))
+ })
}
/** The essential mutable state of a context base, collected into a common class */