diff options
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/config/Printers.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 16 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 |
4 files changed, 23 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/config/Printers.scala b/src/dotty/tools/dotc/config/Printers.scala index 21147fe6f..fa36ad12c 100644 --- a/src/dotty/tools/dotc/config/Printers.scala +++ b/src/dotty/tools/dotc/config/Printers.scala @@ -13,6 +13,7 @@ object Printers { } val default: Printer = new Printer + val dottydoc: Printer = noPrinter val core: Printer = noPrinter val typr: Printer = noPrinter val constr: Printer = noPrinter diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index a0bb03e50..ad3a0057d 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -550,6 +550,14 @@ object Contexts { def squashed(p: Phase): Phase = { allPhases.find(_.period.containsPhaseId(p.id)).getOrElse(NoPhase) } + + val _docstrings: mutable.Map[Symbol, String] = + mutable.Map.empty + + def docstring(sym: Symbol): Option[String] = _docstrings.get(sym) + + def addDocstring(sym: Symbol, doc: Option[String]): Unit = + doc.map(d => _docstrings += (sym -> d)) } /** The essential mutable state of a context base, collected into a common class */ diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index de27333d5..82b3b56e9 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -401,19 +401,29 @@ class Namer { typer: Typer => val pkg = createPackageSymbol(pcl.pid) index(pcl.stats)(ctx.fresh.setOwner(pkg.moduleClass)) invalidateCompanions(pkg, Trees.flatten(pcl.stats map expanded)) + setDocstring(pkg, stat) ctx case imp: Import => importContext(createSymbol(imp), imp.selectors) case mdef: DefTree => - enterSymbol(createSymbol(mdef)) + val sym = enterSymbol(createSymbol(mdef)) + setDocstring(sym, stat) ctx case stats: Thicket => - for (tree <- stats.toList) enterSymbol(createSymbol(tree)) + for (tree <- stats.toList) { + val sym = enterSymbol(createSymbol(tree)) + setDocstring(sym, stat) + } ctx case _ => ctx } + def setDocstring(sym: Symbol, tree: Tree)(implicit ctx: Context) = tree match { + case t: MemberDef => ctx.base.addDocstring(sym, t.rawComment) + case _ => () + } + /** Create top-level symbols for statements and enter them into symbol table */ def index(stats: List[Tree])(implicit ctx: Context): Context = { @@ -859,7 +869,7 @@ class Namer { typer: Typer => WildcardType } paramFn(typedAheadType(mdef.tpt, tptProto).tpe) - } + } /** The type signature of a DefDef with given symbol */ def defDefSig(ddef: DefDef, sym: Symbol)(implicit ctx: Context) = { diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 3b8ada2a8..84abf85e0 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -586,7 +586,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case _ => false } - /** The funcion body to be returned in the closure. Can become a TypedSplice + /** The function body to be returned in the closure. Can become a TypedSplice * of a typed expression if this is necessary to infer a parameter type. */ var fnBody = tree.body |