diff --git a/src/main/scala/com/typesafe/genjavadoc/AST.scala b/src/main/scala/com/typesafe/genjavadoc/AST.scala index ef46f53..2ab51af 100644 --- a/src/main/scala/com/typesafe/genjavadoc/AST.scala +++ b/src/main/scala/com/typesafe/genjavadoc/AST.scala @@ -96,9 +96,11 @@ trait AST { this: TransformCake => def fabricateParams: Boolean case class DeprecationInfo(msg: String, since: String) { - def maybeDot = if (msg.endsWith(".")) " " else ". " - def maybeSinceDot = if (since.endsWith(".")) " " else ". " - def render = s" * @deprecated ${msg}${maybeDot}Since $since${maybeSinceDot}" + def render = { + val rMsg = if (msg.isEmpty) "" else s" ${msg.stripSuffix(".")}." + val rSince = if (since.isEmpty) "" else s" Since ${since.stripSuffix(".")}." + s" * @deprecated$rMsg$rSince" + } def appendToComment(comment: Seq[String]): Seq[String] = comment.toVector match { case init :+ " */" => diff --git a/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala b/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala index a76865e..079f772 100644 --- a/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala +++ b/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala @@ -160,8 +160,9 @@ trait BasicTransform { this: TransformCake => private def deprecationInfo(d: ImplDef): Option[DeprecationInfo] = deprecationInfo(d.symbol) private def deprecationInfo(symbol: Symbol): Option[DeprecationInfo] = if (symbol.isDeprecated) { - val deprec = symbol.getAnnotation(definitions.DeprecatedAttr).get - Some(DeprecationInfo(deprec.stringArg(0).getOrElse(""), deprec.stringArg(1).getOrElse(""))) + // symbol either has `DeprecatedAttr` or `JavaDeprecatedAttr` + val deprec = symbol.getAnnotation(definitions.DeprecatedAttr) + Some(DeprecationInfo(deprec.flatMap(_.stringArg(0)).getOrElse(""), deprec.flatMap(_.stringArg(1)).getOrElse(""))) } else None } diff --git a/src/test/resources/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java b/src/test/resources/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java index 7e3c5f6..c396e69 100644 --- a/src/test/resources/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +++ b/src/test/resources/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java @@ -10,6 +10,12 @@ public class DontTouchThis { * @deprecated This is already deprecated. Since now. */ public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! + * + * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } /** * Some methods are forever. * diff --git a/src/test/resources/input/basic/test.scala b/src/test/resources/input/basic/test.scala index 464c1d2..04b43e0 100644 --- a/src/test/resources/input/basic/test.scala +++ b/src/test/resources/input/basic/test.scala @@ -275,6 +275,12 @@ private[it] class DontTouchThis { */ @deprecated("This will be ignored", since = "ever") def alreadyDeprecatedInComment = () + + /** + * buh! + */ + @Deprecated + def javaDeprecatedThingie = () } @deprecated("Les Scalac Voyages Extraordinaire", since = "now") diff --git a/src/test/resources/patches/2.12.18.patch b/src/test/resources/patches/2.12.18.patch index e812eb8..0bafb15 100644 --- a/src/test/resources/patches/2.12.18.patch +++ b/src/test/resources/patches/2.12.18.patch @@ -69,3 +69,14 @@ + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ; + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ; } +--- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java ++++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +@@ -12,8 +12,6 @@ + public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! +- * +- * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } + /** diff --git a/src/test/resources/patches/2.12.19.patch b/src/test/resources/patches/2.12.19.patch index e812eb8..0bafb15 100644 --- a/src/test/resources/patches/2.12.19.patch +++ b/src/test/resources/patches/2.12.19.patch @@ -69,3 +69,14 @@ + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ; + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ; } +--- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java ++++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +@@ -12,8 +12,6 @@ + public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! +- * +- * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } + /** diff --git a/src/test/resources/patches/2.12.20.patch b/src/test/resources/patches/2.12.20.patch index e812eb8..0bafb15 100644 --- a/src/test/resources/patches/2.12.20.patch +++ b/src/test/resources/patches/2.12.20.patch @@ -69,3 +69,14 @@ + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ; + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ; } +--- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java ++++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +@@ -12,8 +12,6 @@ + public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! +- * +- * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } + /** diff --git a/src/test/resources/patches/2.13.11.patch b/src/test/resources/patches/2.13.11.patch index df6c303..c303266 100644 --- a/src/test/resources/patches/2.13.11.patch +++ b/src/test/resources/patches/2.13.11.patch @@ -259,3 +259,14 @@ -public interface X extends scala.Serializable, akka.rk.buh.is.it.Y { +public interface X extends java.io.Serializable, akka.rk.buh.is.it.Y { } +--- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java ++++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +@@ -12,8 +12,6 @@ + public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! +- * +- * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } + /** diff --git a/src/test/resources/patches/2.13.12.patch b/src/test/resources/patches/2.13.12.patch index df6c303..c303266 100644 --- a/src/test/resources/patches/2.13.12.patch +++ b/src/test/resources/patches/2.13.12.patch @@ -259,3 +259,14 @@ -public interface X extends scala.Serializable, akka.rk.buh.is.it.Y { +public interface X extends java.io.Serializable, akka.rk.buh.is.it.Y { } +--- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java ++++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java +@@ -12,8 +12,6 @@ + public void alreadyDeprecatedInComment () { throw new RuntimeException(); } + /** + * buh! +- * +- * @deprecated + */ + public void javaDeprecatedThingie () { throw new RuntimeException(); } + /** diff --git a/src/test/scala/com/typesafe/genjavadoc/BasicSpec.scala b/src/test/scala/com/typesafe/genjavadoc/BasicSpec.scala index 782ed12..3e4b13c 100644 --- a/src/test/scala/com/typesafe/genjavadoc/BasicSpec.scala +++ b/src/test/scala/com/typesafe/genjavadoc/BasicSpec.scala @@ -21,7 +21,7 @@ class BasicSpec extends CompilerSpec { if (new java.io.File(patchFile).exists) { // we have a patch to apply to expected output for this scala version "rm -rf target/expected_output".! // cleanup from previous runs "cp -r src/test/resources/expected_output target/".! // copy expected output to a place which is going to be patched - s"patch -p0 -i $patchFile".! // path expected output + s"patch -p0 --no-backup-if-mismatch -i $patchFile".! // path expected output "target/expected_output/basic" } else { "src/test/resources/expected_output/basic"