summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala2
-rw-r--r--src/compiler/scala/tools/nsc/doc/html/page/Template.scala11
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/Entity.scala3
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala18
4 files changed, 24 insertions, 10 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala
index 30e9f38cbe..3e80f1cdee 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -443,7 +443,9 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// prevents someone from writing a @migration annotation with a calculated
// string. So this needs attention. For now the fact that migration is
// private[scala] ought to provide enough protection.
+ def hasMigrationAnnotation = hasAnnotation(MigrationAnnotationClass)
def migrationMessage = getAnnotation(MigrationAnnotationClass) flatMap { _.stringArg(2) }
+ def migrationVersion = getAnnotation(MigrationAnnotationClass) map { version => version.intArg(0).get + "." + version.intArg(1).get }
def elisionLevel = getAnnotation(ElidableMethodClass) flatMap { _.intArg(0) }
def implicitNotFoundMsg = getAnnotation(ImplicitNotFoundClass) flatMap { _.stringArg(0) }
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
index bc2fc61d0b..2dd597eec8 100644
--- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala
@@ -375,15 +375,12 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage {
<dd class="cmt">{ bodyToHtml(mbr.deprecation.get) }</dd>
}
- val migration: Seq[scala.xml.Node] = {
- mbr.annotations.find(_.qualifiedName == "migration") match {
- case None => NodeSeq.Empty
- case Some(mig) => {
+ val migration: Seq[scala.xml.Node] =
+ if(mbr.migration.isEmpty || isReduced) NodeSeq.Empty
+ else {
<dt>Migration</dt>
- <dd class="cmt"><p>{mig.arguments.view.map(_.value).drop(2).mkString(" ")}</p></dd>
- }
+ <dd class="cmt">{ bodyToHtml(mbr.migration.get) }</dd>
}
- }
val mainComment: Seq[scala.xml.Node] = mbr.comment match {
case Some(comment) if (! isReduced) =>
diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
index a09194c2dd..813d0b2f2e 100644
--- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala
@@ -127,6 +127,9 @@ trait MemberEntity extends Entity {
/** Some deprecation message if this member is deprecated, or none otherwise. */
def deprecation: Option[Body]
+ /** Some migration warning if this member has a migration annotation, or none otherwise. */
+ def migration: Option[Body]
+
@deprecated("Use `inDefinitionTemplates` instead", "2.9.0")
def inheritedFrom: List[TemplateEntity]
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 3c3556fefc..b254cefe3f 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -128,12 +128,24 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
}
def deprecation =
if (sym.isDeprecated)
- Some(sym.deprecationMessage match {
- case Some(msg) => parseWiki(msg, NoPosition)
- case None =>Body(Nil)
+ Some((sym.deprecationMessage, sym.deprecationVersion) match {
+ case (Some(msg), Some(ver)) => parseWiki("''(Since version " + ver + ")'' " + msg, NoPosition)
+ case (Some(msg), None) => parseWiki(msg, NoPosition)
+ case (None, Some(ver)) => parseWiki("''(Since version " + ver + ")''", NoPosition)
+ case (None, None) => Body(Nil)
})
else
comment flatMap { _.deprecated }
+ def migration =
+ if(sym.hasMigrationAnnotation)
+ Some((sym.migrationMessage, sym.migrationVersion) match {
+ case (Some(msg), Some(ver)) => parseWiki("''(Changed in version " + ver + ")'' " + msg, NoPosition)
+ case (Some(msg), None) => parseWiki(msg, NoPosition)
+ case (None, Some(ver)) => parseWiki("''(Changed in version " + ver + ")''", NoPosition)
+ case (None, None) => Body(Nil)
+ })
+ else
+ None
def inheritedFrom =
if (inTemplate.sym == this.sym.owner || inTemplate.sym.isPackage) Nil else
makeTemplate(this.sym.owner) :: (sym.allOverriddenSymbols map { os => makeTemplate(os.owner) })