diff options
Diffstat (limited to 'plugins/base/src')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt index 7119ba68..89226821 100644 --- a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt @@ -122,13 +122,16 @@ class JavadocParser( private fun getSeeTagElementContent(tag: PsiDocTag): List<DocTag> = listOfNotNull(tag.referenceElement()?.toDocumentationLink()) - private fun PsiDocComment.getDescription(): Description? = - convertJavadocElements(descriptionElements.dropWhile { - it.text.trim().isEmpty() - }).takeIf { it.isNotEmpty() }?.let { list -> - Description(P(list)) + private fun PsiDocComment.getDescription(): Description? { + val nonEmptyDescriptionElements = descriptionElements.filter { it.text.trim().isNotEmpty() } + val convertedDescriptionElements = convertJavadocElements(nonEmptyDescriptionElements) + if (convertedDescriptionElements.isNotEmpty()) { + return Description(P(convertedDescriptionElements)) } + return null + } + private fun convertJavadocElements(elements: Iterable<PsiElement>): List<DocTag> = elements.mapNotNull { when (it) { @@ -136,7 +139,7 @@ class JavadocParser( is PsiInlineDocTag -> listOfNotNull(convertInlineDocTag(it)) is PsiDocParamRef -> listOfNotNull(it.toDocumentationLink()) is PsiDocTagValue, - is LeafPsiElement -> Jsoup.parse(it.text).body().childNodes().mapNotNull { convertHtmlNode(it) } + is LeafPsiElement -> Jsoup.parse(it.text.trim()).body().childNodes().mapNotNull(::convertHtmlNode) else -> null } }.flatten() |