aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt7
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt10
-rw-r--r--core/testdata/javadoc/deprecated.java28
3 files changed, 42 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index d6e46c50..39a4568a 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -83,7 +83,7 @@ class JavadocParser(
"see" -> result.convertSeeTag(tag)
"deprecated" -> {
deprecatedContent = Content().apply {
- appendAll(convertJavadocElements(tag.contentElements(), element))
+ appendAll(convertJavadocElements(tag.contentElementsOrFirstChild(), element))
}
}
in tagsToInherit -> {}
@@ -122,9 +122,10 @@ class JavadocParser(
recursiveSearch(arrayOf(this))
return output.mapValues { it.value.values }
}
+ private fun PsiDocTag.contentElementsOrFirstChild(): Collection<PsiElement> = contentElements()
+ .takeIf { it.isNotEmpty() } ?: children.take(1)
-
- private fun PsiDocTag.contentElements(): Iterable<PsiElement> {
+ private fun PsiDocTag.contentElements(): Collection<PsiElement> {
val tagValueElements = children
.dropWhile { it.node?.elementType == JavaDocTokenType.DOC_TAG_NAME }
.dropWhile { it is PsiWhiteSpace }
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 9ca668d8..7f1b44da 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -233,6 +233,16 @@ class JavadocTest {
}
}
+ @Test fun shouldHaveAllFunctionMarkedAsDeprecated() {
+ verifyJavadoc("testdata/javadoc/deprecated.java") { doc ->
+ val classDoc = doc.classNamed("bar.Banana")!!
+
+ classDoc.methods().forEach {
+ assertNotNull((it as? DocumentationNodeAdapter)?.node?.deprecation)
+ }
+ }
+ }
+
private fun verifyJavadoc(name: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
diff --git a/core/testdata/javadoc/deprecated.java b/core/testdata/javadoc/deprecated.java
new file mode 100644
index 00000000..5a6cdd77
--- /dev/null
+++ b/core/testdata/javadoc/deprecated.java
@@ -0,0 +1,28 @@
+package bar;
+
+/**
+ * Just a fruit
+ */
+public class Banana {
+ private Double weight;
+
+ /**
+ * Returns weight
+ *
+ * @return weight
+ * @deprecated
+ */
+ public Double getWeight() {
+ return weight;
+ }
+
+ /**
+ * Sets weight
+ *
+ * @param weight in grams
+ * @deprecated with message
+ */
+ public void setWeight(Double weight) {
+ this.weight = weight;
+ }
+} \ No newline at end of file