summaryrefslogtreecommitdiff
path: root/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-09-01 10:41:28 +0200
committerGitHub <noreply@github.com>2016-09-01 10:41:28 +0200
commitf90bf565a529d0e95155992a3c243952183f25a5 (patch)
tree151f8d8d79dba64a96d12b1c4a9c4fa38269dcf8 /src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
parent45edf8699f76faa5d1b035fb8f887621bcbb9934 (diff)
parent743f0d2c2a33bc8ab0c1f7bee796865672ba2fcc (diff)
downloadscala-f90bf565a529d0e95155992a3c243952183f25a5.tar.gz
scala-f90bf565a529d0e95155992a3c243952183f25a5.tar.bz2
scala-f90bf565a529d0e95155992a3c243952183f25a5.zip
Merge pull request #5294 from adriaanm/fields-lazies
Fields: expand lazy vals during fields, like modules
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
index 928cb34d30..fb9a5ce7eb 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -106,10 +106,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
// in the doc comment of MyClass
def linkTarget: DocTemplateImpl = inTpl
- lazy val comment = {
- val documented = if (sym.hasAccessorFlag) sym.accessed else sym
- thisFactory.comment(documented, linkTarget, inTpl)
- }
+ // if there is a field symbol, the ValDef will use it, which means docs attached to it will be under the field symbol, not the getter's
+ protected[this] def commentCarryingSymbol(sym: Symbol) =
+ if (sym.hasAccessorFlag && sym.accessed.exists) sym.accessed else sym
+
+ lazy val comment = thisFactory.comment(commentCarryingSymbol(sym), linkTarget, inTpl)
+
def group = comment flatMap (_.group) getOrElse defaultGroup
override def inTemplate = inTpl
override def toRoot: List[MemberImpl] = this :: inTpl.toRoot
@@ -476,17 +478,18 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
override lazy val comment = {
def nonRootTemplate(sym: Symbol): Option[DocTemplateImpl] =
if (sym eq RootPackage) None else findTemplateMaybe(sym)
+
/* Variable precedence order for implicitly added members: Take the variable definitions from ...
* 1. the target of the implicit conversion
* 2. the definition template (owner)
* 3. the current template
*/
- val inRealTpl = conversion.flatMap { conv =>
- nonRootTemplate(conv.toType.typeSymbol)
- } orElse nonRootTemplate(sym.owner) orElse Option(inTpl)
- inRealTpl flatMap { tpl =>
- thisFactory.comment(sym, tpl, tpl)
- }
+ val inRealTpl = (
+ conversion.flatMap(conv => nonRootTemplate(conv.toType.typeSymbol))
+ orElse nonRootTemplate(sym.owner)
+ orElse Option(inTpl))
+
+ inRealTpl flatMap (tpl => thisFactory.comment(commentCarryingSymbol(sym), tpl, tpl))
}
override def inDefinitionTemplates = useCaseOf.fold(super.inDefinitionTemplates)(_.inDefinitionTemplates)