aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-09-21 15:02:30 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-06 17:45:39 +0200
commit92536168e9fda4005a8eff54e5ca72cc70fb32e4 (patch)
tree285d92137cc5c33a0dba3b352b6fa252ed57ce13 /src/dotty/tools/dotc/typer/Typer.scala
parent208232aba52903ae090711589e9c572dc5347651 (diff)
downloaddotty-92536168e9fda4005a8eff54e5ca72cc70fb32e4.tar.gz
dotty-92536168e9fda4005a8eff54e5ca72cc70fb32e4.tar.bz2
dotty-92536168e9fda4005a8eff54e5ca72cc70fb32e4.zip
Separate `ContextDocstrings` from `Context` and make it pluggable
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 3ed6c9228..3e3bb32f5 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -58,7 +58,7 @@ object Typer {
assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
}
-class Typer extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking {
+class Typer extends Namer with TypeAssigner with Applications with Implicits with Dynamic with Checking with Docstrings {
import Typer._
import tpd.{cpy => _, _}
@@ -1247,8 +1247,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val dummy = localDummy(cls, impl)
val body1 = typedStats(impl.body, dummy)(inClassContext(self1.symbol))
- if (ctx.property(DocContext).isDefined)
- typedUsecases(body1.map(_.symbol), self1.symbol)(localContext(cdef, cls).setNewScope)
+ // Expand comments and type usecases
+ cookComments(body1.map(_.symbol), self1.symbol)(localContext(cdef, cls).setNewScope)
checkNoDoubleDefs(cls)
val impl1 = cpy.Template(impl)(constr1, parents1, self1, body1)
@@ -1538,45 +1538,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tpd.cpy.DefDef(mdef)(rhs = Inliner.bodyToInline(mdef.symbol)) ::
Inliner.removeInlineAccessors(mdef.symbol)
- private def typedUsecases(syms: List[Symbol], owner: Symbol)(implicit ctx: Context): Unit =
- ctx.getDocbase.foreach { docbase =>
- val relevantSyms = syms.filter(docbase.docstring(_).isDefined)
- relevantSyms.foreach { sym =>
- expandParentDocs(sym)
- val usecases = docbase.docstring(sym).map(_.usecases).getOrElse(Nil)
-
- usecases.foreach { usecase =>
- enterSymbol(createSymbol(usecase.untpdCode))
-
- typedStats(usecase.untpdCode :: Nil, owner) match {
- case List(df: tpd.DefDef) => usecase.tpdCode = df
- case _ => ctx.error("`@usecase` was not a valid definition", usecase.codePos)
- }
- }
- }
- }
-
- private def expandParentDocs(sym: Symbol)(implicit ctx: Context): Unit =
- ctx.getDocbase.foreach { docbase =>
- docbase.docstring(sym).foreach { cmt =>
- def expandDoc(owner: Symbol): Unit = if (!cmt.isExpanded) {
- val tplExp = docbase.templateExpander
- tplExp.defineVariables(sym)
-
- val newCmt = cmt
- .expand(tplExp.expandedDocComment(sym, owner, _))
- .withUsecases
-
- docbase.addDocstring(sym, Some(newCmt))
- }
-
- if (sym ne NoSymbol) {
- expandParentDocs(sym.owner)
- expandDoc(sym.owner)
- }
- }
- }
-
def typedExpr(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree =
typed(tree, pt)(ctx retractMode Mode.PatternOrType)
def typedType(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = // todo: retract mode between Type and Pattern?