dotty.tools.dotc.transform.CookComments.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala3-compiler_3 Show documentation
Show all versions of scala3-compiler_3 Show documentation
scala3-compiler-bootstrapped
package dotty.tools.dotc.transform
import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.ContextOps.*
import dotty.tools.dotc.typer.Docstrings
class CookComments extends MegaPhase.MiniPhase {
override def phaseName: String = CookComments.name
override def description: String = CookComments.description
override def transformTypeDef(tree: tpd.TypeDef)(using Context): tpd.Tree = {
if (ctx.settings.XcookComments.value && tree.isClassDef) {
val cls = tree.symbol
val cookingCtx = ctx.localContext(tree, cls).setNewScope
val template = tree.rhs.asInstanceOf[tpd.Template]
val owner = template.self.symbol.orElse(cls)
template.body.foreach { stat =>
Docstrings.cookComment(stat.symbol, owner)(using cookingCtx)
}
Docstrings.cookComment(cls, cls)(using cookingCtx)
}
tree
}
}
object CookComments:
val name = "cookComments"
val description: String = "cook the comments: expand variables, doc, etc."
© 2015 - 2025 Weber Informatics LLC | Privacy Policy